using System; using System.Collections.Generic; using System.Linq; namespace FineUIPro.Web.HSSE.HazardousMG { /// /// 编辑安全技术交底页面 /// public partial class SafetyDisclosureEdit : PageBase { #region 定义项 /// /// 主键 /// private string DisclosureId { get { return (string)ViewState["DisclosureId"]; } set { ViewState["DisclosureId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.DisclosureId = Request.Params["DisclosureId"]; if (!string.IsNullOrEmpty(this.DisclosureId)) { ////编辑:回填数据 Model.HSSE_SafetyDisclosure info = BLL.SafetyDisclosureService.GetById(this.DisclosureId); if (info != null) { this.txtHazardProjectName.Text = info.HazardProjectName; this.txtDisclosureName.Text = info.DisclosureName; this.txtDisclosureMan.Text = info.DisclosureMan; if (info.DisclosureDate.HasValue) { this.dpDisclosureDate.SelectedDate = info.DisclosureDate.Value; } this.txtRemark.Text = info.Remark; } } } } #endregion #region 保存 /// /// 保存按钮事件 /// protected void btnSave_Click(object sender, EventArgs e) { if (this.CurrUser == null || string.IsNullOrEmpty(this.CurrUser.LoginProjectId)) { Alert.ShowInTop("请先选择项目!", MessageBoxIcon.Warning); return; } ////新增时先生成主键,保证附件能挂到同一记录 if (string.IsNullOrEmpty(this.DisclosureId)) { this.DisclosureId = Guid.NewGuid().ToString(); } ////校验附件是否已上传 Model.AttachFile attach = BLL.Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.DisclosureId); if (attach == null || string.IsNullOrEmpty(attach.AttachUrl)) { Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning); return; } Model.HSSE_SafetyDisclosure info = new Model.HSSE_SafetyDisclosure { DisclosureId = this.DisclosureId, ProjectId = this.CurrUser.LoginProjectId, HazardProjectName = this.txtHazardProjectName.Text.Trim(), DisclosureName = this.txtDisclosureName.Text.Trim(), DisclosureMan = this.txtDisclosureMan.Text.Trim(), DisclosureDate = this.dpDisclosureDate.SelectedDate, Remark = this.txtRemark.Text.Trim() }; ////存在则更新,不存在则新增(服务层已处理) BLL.SafetyDisclosureService.Update(info); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } /// /// 上传附件(参考专项施工方案) /// protected void btnAttach_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.DisclosureId)) { this.DisclosureId = Guid.NewGuid().ToString(); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/SafetyDisclosure&menuId={1}", this.DisclosureId, BLL.Const.ProjectHSETechnicalMenuId))); } #endregion } }