using BLL; using System; namespace FineUIPro.Web.Customization.CNCEC4.HSSE.Report { public partial class HazardousEngineeringEdit : PageBase { #region 定义变量 /// /// 主键 /// public string ReportId { get { return (string)ViewState["ReportId"]; } set { ViewState["ReportId"] = value; } } #endregion #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.ReportId = Request.Params["reportId"]; if (!string.IsNullOrEmpty(this.ReportId)) { var report = BLL.HazardousEngineeringService.GetReportById(this.ReportId); if (report != null) { this.txtMonths.Text = string.Format("{0:yyyy-MM}", report.Months); this.txtSubProjectName.Text = report.SubProjectName; this.txtWorksCategory.Text = report.WorksCategory; this.rblIsSuperDangerous.SelectedValue = report.IsSuperDangerous.ToString(); this.txtAddress.Text = report.Address; this.txtConStartDate.Text = report.ConStartDate.HasValue ? string.Format("{0:yyyy-MM-dd}", report.ConStartDate) : ""; this.txtConEndDate.Text = report.ConEndDate.HasValue ? string.Format("{0:yyyy-MM-dd}", report.ConEndDate) : ""; this.txtPlanSubmissionDate.Text = report.PlanSubmissionDate.HasValue ? string.Format("{0:yyyy-MM-dd}", report.PlanSubmissionDate) : ""; this.txtPlanApprovalDate.Text = report.PlanApprovalDate.HasValue ? string.Format("{0:yyyy-MM-dd}", report.PlanApprovalDate) : ""; this.txtCompletionDate.Text = report.CompletionDate.HasValue ? string.Format("{0:yyyy-MM-dd}", report.CompletionDate) : ""; this.txtSpecializedClass.Text = report.SpecializedClass; } } else { this.txtMonths.Text = string.Format("{0:yyyy-MM}", DateTime.Now); } var project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId); if (project != null) { this.txtProjectName.Text = project.ProjectName; this.txtUnitName.Text = BLL.UnitService.GetUnitNameByUnitId(project.UnitId); } } } #endregion #region 保存、提交 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { SaveData(BLL.Const.BtnSave); } /// /// 保存方法 /// /// private void SaveData(string type) { Model.Report_HazardousEngineering newReport = new Model.Report_HazardousEngineering(); newReport.Months = Convert.ToDateTime(this.txtMonths.Text); newReport.ProjectId = this.CurrUser.LoginProjectId; newReport.UnitId = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId).UnitId; newReport.SubProjectName = this.txtSubProjectName.Text.Trim(); newReport.WorksCategory = this.txtWorksCategory.Text.Trim(); if (this.rblIsSuperDangerous.SelectedValue == "True") { newReport.IsSuperDangerous = true; } else { newReport.IsSuperDangerous = false; } newReport.Address = this.txtAddress.Text.Trim(); newReport.ConStartDate = Funs.GetNewDateTime(this.txtConStartDate.Text.Trim()); newReport.ConEndDate = Funs.GetNewDateTime(this.txtConEndDate.Text.Trim()); newReport.PlanSubmissionDate = Funs.GetNewDateTime(this.txtPlanSubmissionDate.Text.Trim()); newReport.PlanApprovalDate = Funs.GetNewDateTime(this.txtPlanApprovalDate.Text.Trim()); newReport.CompletionDate = Funs.GetNewDateTime(this.txtCompletionDate.Text.Trim()); newReport.SpecializedClass = this.txtSpecializedClass.Text.Trim(); if (!string.IsNullOrEmpty(this.ReportId)) { newReport.ReportId = this.ReportId; BLL.HazardousEngineeringService.UpdateHazardousEngineering(newReport); } else { newReport.ReportId = SQLHelper.GetNewID(typeof(Model.Report_HazardousEngineering)); BLL.HazardousEngineeringService.AddHazardousEngineering(newReport); } ShowNotify("保存成功"); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } #endregion } }