using BLL; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web.Customization.CNCEC4.ZHGL.Report { public partial class HazardousEngineeringEdit : PageBase { #region 定义变量 /// /// 主键 /// public string ReportId { get { return (string)ViewState["ReportId"]; } set { ViewState["ReportId"] = value; } } /// /// 单位id /// public string UnitId { get { return (string)ViewState["UnitId"]; } set { ViewState["UnitId"] = value; } } /// /// 项目id /// 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.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.ReportId = Request.Params["reportId"]; if (!string.IsNullOrEmpty(this.ReportId)) { var report = BLL.HazardousEngineeringService.GetReportById(this.ReportId); if (report != null) { var project = BLL.ProjectService.GetProjectByProjectId(report.ProjectId); if (project != null) { this.ProjectId = report.ProjectId; this.UnitId = project.UnitId; this.txtProjectName.Text = project.ProjectName; this.txtUnitName.Text = BLL.UnitService.GetUnitNameByUnitId(project.UnitId); } 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; } } } } #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.ProjectId; newReport.UnitId = this.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); ShowNotify("保存成功"); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } } #endregion } }