using System; using System.Collections.Generic; using System.IO; using System.Linq; namespace FineUIPro.Web.HSSE.HazardousMG { /// /// 编辑专项施工方案页面 /// public partial class SpecialPlanEdit : PageBase { #region 定义项 /// /// 主键 /// private string PlanId { get { return (string)ViewState["PlanId"]; } set { ViewState["PlanId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.PlanId = Request.Params["PlanId"]; if (!string.IsNullOrEmpty(this.PlanId)) { ////编辑:回填数据 Model.HSSE_SpecialPlan info = BLL.SpecialPlanService.GetById(this.PlanId); if (info != null) { this.txtHazardProjectName.Text = info.HazardProjectName; this.txtPlanName.Text = info.PlanName; this.txtCompileMan.Text = info.CompileMan; if (info.CompileDate.HasValue) { this.dpCompileDate.SelectedDate = info.CompileDate.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.PlanId)) { this.PlanId = Guid.NewGuid().ToString(); } ////校验附件是否已上传 Model.AttachFile attach = BLL.Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.PlanId); if (attach == null || string.IsNullOrEmpty(attach.AttachUrl)) { Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning); return; } Model.HSSE_SpecialPlan info = new Model.HSSE_SpecialPlan { PlanId = this.PlanId, ProjectId = this.CurrUser.LoginProjectId, HazardProjectName = this.txtHazardProjectName.Text.Trim(), PlanName = this.txtPlanName.Text.Trim(), CompileMan = this.txtCompileMan.Text.Trim(), CompileDate = this.dpCompileDate.SelectedDate, Remark = this.txtRemark.Text.Trim() }; ////存在则更新,不存在则新增(服务层已处理) BLL.SpecialPlanService.Update(info); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } /// /// 上传附件 /// protected void btnAttach_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.PlanId)) { this.PlanId = Guid.NewGuid().ToString(); } PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/SpecialPlan&menuId={1}", this.PlanId, BLL.Const.SpecialSchemeMenuId))); } #endregion } }