/// <summary> /// 增加月报告事故分类信息 /// </summary> /// <param name="accidentSort">月报告事故分类实体</param> public static void AddAccidentSort(Model.Manager_AccidentSortB accidentSort) { Model.SUBHSSEDB db = Funs.DB; string newKeyID = SQLHelper.GetNewID(typeof(Model.Manager_AccidentSortB)); Model.Manager_AccidentSortB newAccidentSort = new Model.Manager_AccidentSortB { AccidentSortId = newKeyID, MonthReportId = accidentSort.MonthReportId, AccidentType = accidentSort.AccidentType, TypeFlag = accidentSort.TypeFlag, Number = accidentSort.Number, TotalNum = accidentSort.TotalNum, PersonNum = accidentSort.PersonNum, TotalPersonNum = accidentSort.TotalPersonNum, LoseHours = accidentSort.LoseHours, TotalLoseHours = accidentSort.TotalLoseHours, LoseMoney = accidentSort.LoseMoney, TotalLoseMoney = accidentSort.TotalLoseMoney }; db.Manager_AccidentSortB.InsertOnSubmit(newAccidentSort); db.SubmitChanges(); }
/// <summary> /// 数据保存 /// </summary> /// <param name="type"></param> private void SaveData(string type) { if (this.drpAccidentTypeId.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择事故类型!", MessageBoxIcon.Warning); return; } if (this.rbIsNotConfirm.SelectedValue == "True") { if (this.drpUnitId2.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择事故责任单位!", MessageBoxIcon.Warning); return; } } else { if (this.drpUnitId.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择事故责任单位!", MessageBoxIcon.Warning); return; } } Model.Accident_AccidentReport accidentReport = new Model.Accident_AccidentReport { ProjectId = this.ProjectId, AccidentReportCode = this.txtAccidentReportCode.Text.Trim(), //accidentReport.AccidentReportType = this.drpAccidentReportType.SelectedValue; FileContent = HttpUtility.HtmlEncode(this.txtFileContents.Text) }; if (this.drpCompileMan.SelectedValue != BLL.Const._Null) { accidentReport.CompileMan = this.drpCompileMan.SelectedValue; } accidentReport.CompileDate = Funs.GetNewDateTime(this.txtCompileDate.Text.Trim()); accidentReport.States = BLL.Const.State_0; accidentReport.AccidentReportName = this.txtAccidentReportName.Text.Trim(); if (this.drpAccidentTypeId.SelectedValue != BLL.Const._Null) { accidentReport.AccidentTypeId = this.drpAccidentTypeId.SelectedValue; if (this.rbIsNotConfirm.Hidden == false) { accidentReport.IsNotConfirm = Convert.ToBoolean(this.rbIsNotConfirm.SelectedValue); } } accidentReport.Abstract = this.txtAbstract.Text.Trim(); accidentReport.AccidentDate = Funs.GetNewDateTime(this.txtAccidentDate.Text.Trim()); accidentReport.WorkArea = this.txtWorkArea.Text; accidentReport.PeopleNum = Funs.GetNewIntOrZero(this.txtPeopleNum.Text.Trim()); if (accidentReport.IsNotConfirm == true) //待定事故 { accidentReport.UnitId = this.drpUnitId2.SelectedValue; accidentReport.NotConfirmWorkingHoursLoss = this.txtNotConfirmWorkingHoursLoss.Text.Trim(); accidentReport.NotConfirmEconomicLoss = this.txtNotConfirmEconomicLoss.Text.Trim(); accidentReport.NotConfirmEconomicOtherLoss = this.txtNotConfirmEconomicOtherLoss.Text.Trim(); } else { accidentReport.UnitId = this.drpUnitId.SelectedValue; accidentReport.WorkingHoursLoss = Funs.GetNewDecimalOrZero(this.txtWorkingHoursLoss.Text.Trim()); accidentReport.EconomicLoss = Funs.GetNewDecimalOrZero(this.txtEconomicLoss.Text.Trim()); accidentReport.EconomicOtherLoss = Funs.GetNewDecimalOrZero(this.txtEconomicOtherLoss.Text.Trim()); } accidentReport.ReportMan = this.txtReportMan.Text.Trim(); accidentReport.ReporterUnit = this.txtReporterUnit.Text.Trim(); accidentReport.ReportDate = Funs.GetNewDateTime(this.txtReportDate.Text.Trim()); accidentReport.ProcessDescription = this.txtProcessDescription.Text.Trim(); accidentReport.EmergencyMeasures = this.txtEmergencyMeasures.Text.Trim(); if (type == BLL.Const.BtnSubmit) { accidentReport.States = this.ctlAuditFlow.NextStep; } if (!string.IsNullOrEmpty(this.AccidentReportId)) { accidentReport.AccidentReportId = this.AccidentReportId; BLL.AccidentReport2Service.UpdateAccidentReport(accidentReport); BLL.LogService.AddSys_Log(this.CurrUser, this.txtAccidentReportCode.Text, this.AccidentReportId, BLL.Const.ProjectAccidentReportMenuId, Const.BtnModify); Model.Accident_AccidentReport a = BLL.AccidentReport2Service.GetAccidentReportById(this.AccidentReportId); if (type == BLL.Const.BtnSubmit && accidentReport.States == BLL.Const.State_2 && a.NotConfirmed == true) { //更新待定事故之前月报 DateTime startMonth = Convert.ToDateTime(a.AccidentDate.Value.Year + "-" + a.AccidentDate.Value.Month + "-01"); Model.Manager_MonthReportB startMonthReport = BLL.MonthReportBService.GetMonthReportByMonth(startMonth, this.ProjectId); if (startMonthReport != null) //事故当月月报 { Model.Manager_AccidentSortB sort = new Model.Manager_AccidentSortB(); if (a.AccidentTypeId == "1") { sort = (from x in Funs.DB.Manager_AccidentSortB where x.AccidentType == "死 亡 事 故" && x.MonthReportId == startMonthReport.MonthReportId select x).FirstOrDefault(); } else if (a.AccidentTypeId == "2") { sort = (from x in Funs.DB.Manager_AccidentSortB where x.AccidentType == "重 伤 事 故" && x.MonthReportId == startMonthReport.MonthReportId select x).FirstOrDefault(); } else if (a.AccidentTypeId == "3") { sort = (from x in Funs.DB.Manager_AccidentSortB where x.AccidentType == "轻 伤 事 故" && x.MonthReportId == startMonthReport.MonthReportId select x).FirstOrDefault(); } if (sort != null) { sort.Number += 1; sort.TotalNum += 1; sort.PersonNum += a.PeopleNum ?? 0; sort.TotalPersonNum += a.PeopleNum ?? 0; sort.LoseHours += Funs.GetNewIntOrZero((a.WorkingHoursLoss ?? 0).ToString()); sort.TotalLoseHours += Funs.GetNewIntOrZero((a.WorkingHoursLoss ?? 0).ToString()); sort.LoseMoney += (a.EconomicLoss ?? 0) + (a.EconomicOtherLoss ?? 0); sort.TotalLoseMoney += (a.EconomicLoss ?? 0) + (a.EconomicOtherLoss ?? 0); Funs.DB.SubmitChanges(); } List <Model.Manager_MonthReportB> monthReports = (from x in Funs.DB.Manager_MonthReportB where x.Months > startMonth && x.ProjectId == this.ProjectId select x).ToList(); foreach (var monthReport in monthReports) { if (monthReport != null) { Model.Manager_AccidentSortB sort1 = new Model.Manager_AccidentSortB(); if (a.AccidentTypeId == "1") { sort1 = (from x in Funs.DB.Manager_AccidentSortB where x.AccidentType == "死 亡 事 故" && x.MonthReportId == monthReport.MonthReportId select x).FirstOrDefault(); } else if (a.AccidentTypeId == "2") { sort1 = (from x in Funs.DB.Manager_AccidentSortB where x.AccidentType == "重 伤 事 故" && x.MonthReportId == monthReport.MonthReportId select x).FirstOrDefault(); } else if (a.AccidentTypeId == "3") { sort1 = (from x in Funs.DB.Manager_AccidentSortB where x.AccidentType == "轻 伤 事 故" && x.MonthReportId == monthReport.MonthReportId select x).FirstOrDefault(); } if (sort1 != null) { sort1.TotalNum += 1; sort1.TotalPersonNum += a.PeopleNum ?? 0; sort1.TotalLoseHours += Funs.GetNewIntOrZero((a.WorkingHoursLoss ?? 0).ToString()); sort1.TotalLoseMoney += (a.EconomicLoss ?? 0) + (a.EconomicOtherLoss ?? 0); Funs.DB.SubmitChanges(); } } } } } } else { this.AccidentReportId = SQLHelper.GetNewID(typeof(Model.Accident_AccidentReport)); accidentReport.AccidentReportId = this.AccidentReportId; if (accidentReport.IsNotConfirm == true) //待定事故 { accidentReport.NotConfirmed = true; } BLL.AccidentReport2Service.AddAccidentReport(accidentReport); BLL.LogService.AddSys_Log(this.CurrUser, this.txtAccidentReportCode.Text, this.AccidentReportId, BLL.Const.ProjectAccidentReportMenuId, Const.BtnAdd); } //保存流程审核数据 this.ctlAuditFlow.btnSaveData(this.ProjectId, BLL.Const.ProjectAccidentReportMenuId, this.AccidentReportId, (type == BLL.Const.BtnSubmit ? true : false), accidentReport.AccidentReportCode, "../Accident/AccidentReportView.aspx?AccidentReportId={0}"); }