using BLL; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Web.UI.WebControls; namespace FineUIPro.Web.HSSE.Manager { public partial class MonthReportCEdit8 : PageBase { #region 定义项 /// /// 月报告查主键 /// public string MonthReportId { get { return (string)ViewState["MonthReportId"]; } set { ViewState["MonthReportId"] = value; } } /// /// 项目主键 /// public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } #region 定义集合 /// /// HSE合规义务识别与评价表 /// private static List complianceObligationsCs = new List(); #endregion #endregion #region 加载 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { complianceObligationsCs.Clear(); this.MonthReportId = Request.Params["monthReportId"]; this.ProjectId = this.CurrUser.LoginProjectId; DateTime months = Convert.ToDateTime(Request.Params["months"]); Model.Manager_MonthReportC monthReport = BLL.MonthReportCService.GetMonthReportByMonths(months, this.CurrUser.LoginProjectId); if (monthReport != null) { this.MonthReportId = monthReport.MonthReportId; this.ProjectId = monthReport.ProjectId; months = Convert.ToDateTime(monthReport.Months); complianceObligationsCs = (from x in Funs.DB.Manager_Month_ComplianceObligationsC where x.MonthReportId == this.MonthReportId select x).ToList(); if (complianceObligationsCs.Count>0) { this.Grid1.DataSource = complianceObligationsCs; this.Grid1.DataBind(); } } } } #endregion #region HSE合规义务识别与评价 ///// ///// 增加HSE合规义务识别与评价 ///// ///// ///// protected void btnNew_Click(object sender, EventArgs e) { jerqueSaveComplianceObligationsCList(); Model.Manager_Month_ComplianceObligationsC complianceObligationsC = new Model.Manager_Month_ComplianceObligationsC { ComplianceObligationsId = SQLHelper.GetNewID(typeof(Model.Manager_Month_ComplianceObligationsC)) }; complianceObligationsCs.Add(complianceObligationsC); this.Grid1.DataSource = complianceObligationsCs; this.Grid1.DataBind(); } ///// ///// 检查并保存危险源动态识别及控制集合 ///// private void jerqueSaveComplianceObligationsCList() { complianceObligationsCs.Clear(); JArray mergedData = Grid1.GetMergedData(); foreach (JObject mergedRow in mergedData) { string status = mergedRow.Value("status"); JObject values = mergedRow.Value("values"); int i = mergedRow.Value("index"); Model.Manager_Month_ComplianceObligationsC hazardSort = new Model.Manager_Month_ComplianceObligationsC { ComplianceObligationsId = this.Grid1.Rows[i].DataKeys[0].ToString(), InformationContent = values.Value("InformationContent").ToString(), ResponseMeasures = values.Value("ResponseMeasures").ToString(), ImplementationStatus = values.Value("ImplementationStatus").ToString(), EvaluationConclusion = values.Value("EvaluationConclusion").ToString() }; complianceObligationsCs.Add(hazardSort); } } protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) { jerqueSaveComplianceObligationsCList(); string rowID = this.Grid1.DataKeys[e.RowIndex][0].ToString(); if (e.CommandName == "Delete") { foreach (var item in complianceObligationsCs) { if (item.ComplianceObligationsId == rowID) { complianceObligationsCs.Remove(item); break; } } Grid1.DataSource = complianceObligationsCs; Grid1.DataBind(); ShowNotify("删除数据成功!", MessageBoxIcon.Success); } } #endregion #region 保存按钮 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { Model.Manager_MonthReportC oldMonthReport = BLL.MonthReportCService.GetMonthReportByMonths(Convert.ToDateTime(Request.Params["months"]), this.CurrUser.LoginProjectId); if (oldMonthReport != null) { BLL.MonthReportCService.UpdateMonthReport(oldMonthReport); OperateComplianceObligationsCSort(MonthReportId); BLL.LogService.AddSys_Log(this.CurrUser, oldMonthReport.MonthReportCode, oldMonthReport.MonthReportId, BLL.Const.ProjectManagerMonthCMenuId, BLL.Const.BtnModify); } else { Model.Manager_MonthReportC monthReport = new Model.Manager_MonthReportC(); string newKeyID = SQLHelper.GetNewID(typeof(Model.Manager_MonthReportC)); monthReport.MonthReportId = newKeyID; monthReport.ProjectId = this.CurrUser.LoginProjectId; this.MonthReportId = newKeyID; monthReport.MonthReportCode = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectManagerMonthCMenuId, this.ProjectId, this.CurrUser.UnitId); monthReport.Months = Funs.GetNewDateTime(Request.Params["months"]); monthReport.ReportMan = this.CurrUser.UserId; monthReport.MonthReportDate = DateTime.Now; BLL.MonthReportCService.AddMonthReport(monthReport); OperateComplianceObligationsCSort(MonthReportId); BLL.LogService.AddSys_Log(this.CurrUser, monthReport.MonthReportCode, monthReport.MonthReportId, BLL.Const.ProjectManagerMonthCMenuId, BLL.Const.BtnAdd); } ShowNotify("保存成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); } /// /// HSE合规义务识别与评价 /// /// private void OperateComplianceObligationsCSort(string monthReportId) { BLL.ComplianceObligationsCService.DeleteComplianceObligationsCByMonthReportId(monthReportId); jerqueSaveComplianceObligationsCList(); foreach (Model.Manager_Month_ComplianceObligationsC coc in complianceObligationsCs) { coc.MonthReportId = monthReportId; BLL.ComplianceObligationsCService.AddComplianceObligationsC(coc); } } #endregion } }