using BLL; using System; using System.Web; namespace FineUIPro.Web.SHIYE.Work { public partial class LimitedSpaceEdit : PageBase { #region 定义项 /// /// 主键 /// public string LicenseId { get { return (string)ViewState["LicenseId"]; } set { ViewState["LicenseId"] = value; } } /// /// 项目主键 /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ProjectId = this.CurrUser.LoginProjectId; this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.InitDropDownList(); this.LicenseId = Request.Params["LicenseId"]; if (!string.IsNullOrEmpty(this.LicenseId)) { Model.SY_License_LimitedSpace License = BLL.SYLicensePublicService.GetLimitedSpaceByIds(this.LicenseId); if (License != null) { this.ProjectId = License.ProjectId; if (this.ProjectId != this.CurrUser.LoginProjectId) { this.InitDropDownList(); } this.txtLicenseCode.Text = License.LicenseCode; if (!string.IsNullOrEmpty(License.ApplyUnitId)) { this.drpUnitId.SelectedValue = License.ApplyUnitId; } this.txtWorkPlace.Text = License.WorkPalce; this.txtApplicantMan.Text =License.ApplyManId; this.txtApplyDate.Text = string.Format("{0:yyyy-MM-dd}", License.ApplyDate); this.txtWorkMeasures.Text = HttpUtility.HtmlDecode(License.WorkMeasures); this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", License.ValidityStartTime); this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", License.ValidityEndTime); this.drpStates.SelectedValue = License.States; } } else { this.txtApplicantMan.Text = this.CurrUser.UserName; this.drpUnitId.SelectedValue = this.CurrUser.UnitId; this.txtApplyDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(1)); ////自动生成编码 this.txtLicenseCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectLicenseManagerMenuId, this.ProjectId, this.CurrUser.UnitId); } } } #endregion /// /// 初始化下拉框 /// private void InitDropDownList() { UnitService.InitUnitDropDownList(this.drpUnitId, this.ProjectId, true); } #region 保存 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { this.SaveData(BLL.Const.BtnSave); PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); } /// /// 保存数据 /// /// private void SaveData(string type) { if (this.drpUnitId.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择申请单位!", MessageBoxIcon.Warning); return; } Model.SY_License_LimitedSpace License = new Model.SY_License_LimitedSpace { ProjectId = this.ProjectId, LicenseCode = this.txtLicenseCode.Text.Trim() }; if (this.drpUnitId.SelectedValue != BLL.Const._Null) { License.ApplyUnitId = this.drpUnitId.SelectedValue; } License.ApplyManId = this.CurrUser.UserId; License.WorkPalce = this.txtWorkPlace.Text; License.ValidityStartTime = Funs.GetNewDateTime(this.txtStartDate.Text); License.ValidityEndTime = Funs.GetNewDateTime(this.txtEndDate.Text); License.ApplyDate = Funs.GetNewDateTime(this.txtApplyDate.Text.Trim()); License.WorkMeasures = HttpUtility.HtmlEncode(this.txtWorkMeasures.Text); License.States = BLL.Const.State_0; if (!string.IsNullOrEmpty(this.drpStates.SelectedValue)) { License.States = this.drpStates.SelectedValue; } else { License.States =null; } if (!string.IsNullOrEmpty(this.LicenseId)) { License.OldLicenseId = this.LicenseId; BLL.SYLicensePublicService.UpdateLimitedSpace(License); BLL.LogService.AddSys_Log(this.CurrUser, License.LicenseCode, License.OldLicenseId, BLL.Const.ProjectLicenseManagerMenuId, BLL.Const.BtnModify); } else { License.ApplyManId = this.CurrUser.UserName; this.LicenseId = SQLHelper.GetNewID(typeof(Model.SY_License_LimitedSpace)); License.OldLicenseId = this.LicenseId; BLL.SYLicensePublicService.AddLimitedSpace(License); BLL.LogService.AddSys_Log(this.CurrUser, License.LicenseCode, License.OldLicenseId, BLL.Const.ProjectLicenseManagerMenuId, BLL.Const.BtnAdd); } } #endregion #region 附件上传 /// /// 上传附件 /// /// /// protected void btnAttachUrl_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.LicenseId)) { this.SaveData(BLL.Const.BtnSave); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/LicenseAttachUrl&menuId={1}", LicenseId, BLL.Const.ProjectLicenseManagerMenuId))); } #endregion } }