using System; using System.Collections.Generic; using System.Linq; namespace FineUIPro.Web.HSSE.HazardousMG { /// /// 编辑危大、超危工程页面 /// public partial class HazardProjectEdit : PageBase { #region 定义项 /// /// 主键 /// private string HazardProjectId { get { return (string)ViewState["HazardProjectId"]; } set { ViewState["HazardProjectId"] = value; } } #endregion #region 加载 /// /// 加载页面 /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.HazardProjectId = Request.Params["HazardProjectId"]; if (!string.IsNullOrEmpty(this.HazardProjectId)) { ////编辑:回填数据 Model.HSSE_HazardProject info = BLL.HazardProjectService.GetById(this.HazardProjectId); if (info != null) { this.txtProjectName.Text = info.ProjectName; this.txtWorkContent.Text = info.WorkContent; this.ddlRiskLevel.SelectedValue = info.RiskLevel; if (info.StartDate.HasValue) { this.dpStartDate.SelectedDate = info.StartDate.Value; } if (info.EndDate.HasValue) { this.dpEndDate.SelectedDate = info.EndDate.Value; } this.txtManagerMan.Text = info.ManagerMan; 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.HazardProjectId)) { ////编辑:更新原记录(仅更新表单字段,保留编号等内部字段) Model.HSSE_HazardProject info = BLL.HazardProjectService.GetById(this.HazardProjectId); if (info != null) { info.ProjectName = this.txtProjectName.Text.Trim(); info.WorkContent = this.txtWorkContent.Text.Trim(); info.RiskLevel = this.ddlRiskLevel.SelectedValue; info.StartDate = this.dpStartDate.SelectedDate; info.EndDate = this.dpEndDate.SelectedDate; info.ManagerMan = this.txtManagerMan.Text.Trim(); info.Remark = this.txtRemark.Text.Trim(); BLL.HazardProjectService.Update(info); } } else { ////新增:插入记录,编号自动生成 Model.HSSE_HazardProject info = new Model.HSSE_HazardProject { HazardProjectId = Guid.NewGuid().ToString(), ProjectId = this.CurrUser.LoginProjectId, ProjectCode = BLL.HazardProjectService.GetNewCode(), ProjectName = this.txtProjectName.Text.Trim(), WorkContent = this.txtWorkContent.Text.Trim(), RiskLevel = this.ddlRiskLevel.SelectedValue, StartDate = this.dpStartDate.SelectedDate, EndDate = this.dpEndDate.SelectedDate, ManagerMan = this.txtManagerMan.Text.Trim(), Remark = this.txtRemark.Text.Trim() }; BLL.HazardProjectService.Add(info); } PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); } #endregion } }