using BLL; using FineUIPro.Web.BaseInfo; using FineUIPro.Web.InformationProject; using Model; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Web.UI.WebControls; namespace FineUIPro.Web.ZHGL.Information { public partial class MillionsMonthlyReportSave : PageBase { #region 定义变量 /// /// 报表主键Id /// public string MillionsMonthlyReportId { get { return (string)ViewState["MillionsMonthlyReportId"]; } set { ViewState["MillionsMonthlyReportId"] = value; } } /// /// 定义集合 /// private static List items = new List(); #endregion #region 加载页面 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.GetButtonPower(); items.Clear(); BLL.ConstValue.InitConstValueDropDownList(this.drpMonth, ConstValue.Group_0009, false); BLL.ConstValue.InitConstValueDropDownList(this.drpYear, ConstValue.Group_0008, false); this.drpUnit.DataTextField = "UnitName"; drpUnit.DataValueField = "UnitId"; drpUnit.DataSource = BLL.UnitService.GetThisUnitDropDownList(); drpUnit.DataBind(); this.drpUnit.Readonly = true; string unitId = Request.QueryString["UnitId"]; string year = Request.QueryString["Year"]; string months = Request.QueryString["Months"]; MillionsMonthlyReportId = Request.QueryString["MillionsMonthlyReportId"]; if (!String.IsNullOrEmpty(MillionsMonthlyReportId)) { var report = BLL.MillionsMonthlyReportService.GetMillionsMonthlyReportByMillionsMonthlyReportId(MillionsMonthlyReportId); if (report != null) { setPageInfo(report); } } else { this.btnCopy.Hidden = false; drpMonth.SelectedValue = months; drpYear.SelectedValue = year; txtFillingDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); txtDutyPerson.Text = this.CurrUser.PersonName; //增加明细集合 GetNewItems(year, months); this.txtRecordableIncidentRate.Text = "0"; this.txtLostTimeRate.Text = "0"; this.txtLostTimeInjuryRate.Text = "0"; this.txtDeathAccidentFrequency.Text = "0"; this.txtAccidentMortality.Text = "0"; } } } #region 初始化页面信息 /// /// /// /// private void setPageInfo(Model.Information_MillionsMonthlyReport report) { this.btnSave.Hidden = true; this.btnSubmit.Hidden = true; this.btnCopy.Hidden = true; if (report.HandleState == BLL.Const.HandleState_4) { this.btnUpdata.Hidden = false; } else { if (report.HandleMan == this.CurrUser.PersonId || this.CurrUser.PersonId == BLL.Const.sysglyId) { this.btnSave.Hidden = false; this.btnSubmit.Hidden = false; } } if (report.UpState == BLL.Const.UpState_3) { this.btnSave.Hidden = true; this.btnUpdata.Hidden = true; } drpMonth.SelectedValue = report.Month.ToString(); drpYear.SelectedValue = report.Year.ToString(); drpUnit.SelectedValue = report.UnitId; if (report.FillingDate != null) { txtFillingDate.Text = string.Format("{0:yyyy-MM-dd}", report.FillingDate); } txtDutyPerson.Text = report.DutyPerson; if (report.RecordableIncidentRate != null) { txtRecordableIncidentRate.Text = report.RecordableIncidentRate.ToString(); } if (report.LostTimeRate != null) { txtLostTimeRate.Text = report.LostTimeRate.ToString(); } if (report.LostTimeInjuryRate != null) { txtLostTimeInjuryRate.Text = report.LostTimeInjuryRate.ToString(); } if (report.DeathAccidentFrequency != null) { txtDeathAccidentFrequency.Text = report.DeathAccidentFrequency.ToString(); } if (report.AccidentMortality != null) { txtAccidentMortality.Text = report.AccidentMortality.ToString(); } if (report.InputCosts != null) { this.txtInputCosts.Text = Convert.ToString(report.InputCosts); } if (report.TrainNum != null) { this.txtTrainNum.Text = Convert.ToString(report.TrainNum); } if (report.GeneralHazardNum != null) { this.txtGeneralHazardNum.Text = Convert.ToString(report.GeneralHazardNum); } if (report.MajorHazardNum != null) { this.txtMajorHazardNum.Text = Convert.ToString(report.MajorHazardNum); } if (report.NotProofLargeProjectNum != null) { this.txtNotProofLargeProjectNum.Text = Convert.ToString(report.NotProofLargeProjectNum); } if (report.ProofLargeProjectNum != null) { this.txtProofLargeProjectNum.Text = Convert.ToString(report.ProofLargeProjectNum); } if (report.FireLicenseNum != null) { this.txtFireLicenseNum.Text = Convert.ToString(report.FireLicenseNum); } if (report.LimitLicenseNum != null) { this.txtLimitLicenseNum.Text = Convert.ToString(report.LimitLicenseNum); } if (report.HighLicenseNum != null) { this.txtHighLicenseNum.Text = Convert.ToString(report.HighLicenseNum); } if (report.HoistingLicenseNum != null) { this.txtHoistingLicenseNum.Text = Convert.ToString(report.HoistingLicenseNum); } if (report.BreakGroundLicenseNum != null) { this.txtBreakGroundLicenseNum.Text = Convert.ToString(report.BreakGroundLicenseNum); } if (report.ElectricityLicenseNum != null) { this.txtElectricityLicenseNum.Text = Convert.ToString(report.ElectricityLicenseNum); } if (report.RTLicenseNum != null) { this.txtRTLicenseNum.Text = Convert.ToString(report.RTLicenseNum); } if (report.NightLicenseNum != null) { this.txtNightLicenseNum.Text = Convert.ToString(report.NightLicenseNum); } if (report.CommissionerNum != null) { this.txtCommissionerNum.Text = Convert.ToString(report.CommissionerNum); } if (report.SoleDutyNum != null) { this.txtSoleDutyNum.Text = Convert.ToString(report.SoleDutyNum); } items = BLL.MillionsMonthlyReportItemService.GetItemsNoSum(MillionsMonthlyReportId); this.Grid1.DataSource = items; this.Grid1.DataBind(); } #endregion #endregion #region 关闭窗口 /// /// 关闭窗口 /// /// /// protected void Window1_Close(object sender, WindowCloseEventArgs e) { Model.Information_MillionsMonthlyReport report = BLL.MillionsMonthlyReportService.GetMillionsMonthlyReportByMillionsMonthlyReportId(MillionsMonthlyReportId); if (report.HandleMan == this.CurrUser.PersonId) { this.btnSave.Hidden = false; this.btnSubmit.Hidden = false; } else { this.btnSave.Hidden = true; this.btnSubmit.Hidden = true; } } #endregion #region 保存、提交、上报 /// /// 保存数据 /// /// private void Save(string type) { //string millionsMonthlyReportId = Request.QueryString["MillionsMonthlyReportId"]; Model.Information_MillionsMonthlyReport report = new Information_MillionsMonthlyReport { UnitId = drpUnit.SelectedValue, Year = Funs.GetNewIntOrZero(drpYear.SelectedValue), Month = Funs.GetNewIntOrZero(drpMonth.SelectedValue) }; if (!string.IsNullOrEmpty(txtFillingDate.Text.Trim())) { report.FillingDate = Convert.ToDateTime(txtFillingDate.Text.Trim()); } report.DutyPerson = txtDutyPerson.Text.Trim(); if (!string.IsNullOrEmpty(txtRecordableIncidentRate.Text.Trim())) { report.RecordableIncidentRate = Convert.ToDecimal(txtRecordableIncidentRate.Text.Trim()); } if (!string.IsNullOrEmpty(txtLostTimeRate.Text.Trim())) { report.LostTimeRate = Convert.ToDecimal(txtLostTimeRate.Text.Trim()); } if (!string.IsNullOrEmpty(txtLostTimeInjuryRate.Text.Trim())) { report.LostTimeInjuryRate = Convert.ToDecimal(txtLostTimeInjuryRate.Text.Trim()); } if (!string.IsNullOrEmpty(txtDeathAccidentFrequency.Text.Trim())) { report.DeathAccidentFrequency = Convert.ToDecimal(txtDeathAccidentFrequency.Text.Trim()); } if (!string.IsNullOrEmpty(txtAccidentMortality.Text.Trim())) { report.AccidentMortality = Convert.ToDecimal(txtAccidentMortality.Text.Trim()); } report.InputCosts = Funs.GetNewDecimalOrZero(this.txtInputCosts.Text.Trim()); report.TrainNum = Funs.GetNewInt(this.txtTrainNum.Text.Trim()); report.GeneralHazardNum = Funs.GetNewInt(this.txtGeneralHazardNum.Text.Trim()); report.MajorHazardNum = Funs.GetNewInt(this.txtMajorHazardNum.Text.Trim()); report.NotProofLargeProjectNum = Funs.GetNewInt(this.txtNotProofLargeProjectNum.Text.Trim()); report.ProofLargeProjectNum = Funs.GetNewInt(this.txtProofLargeProjectNum.Text.Trim()); report.FireLicenseNum = Funs.GetNewInt(this.txtFireLicenseNum.Text.Trim()); report.LimitLicenseNum = Funs.GetNewInt(this.txtLimitLicenseNum.Text.Trim()); report.HighLicenseNum = Funs.GetNewInt(this.txtHighLicenseNum.Text.Trim()); report.HoistingLicenseNum = Funs.GetNewInt(this.txtHoistingLicenseNum.Text.Trim()); report.BreakGroundLicenseNum = Funs.GetNewInt(this.txtBreakGroundLicenseNum.Text.Trim()); report.ElectricityLicenseNum = Funs.GetNewInt(this.txtElectricityLicenseNum.Text.Trim()); report.RTLicenseNum = Funs.GetNewInt(this.txtRTLicenseNum.Text.Trim()); report.NightLicenseNum = Funs.GetNewInt(this.txtNightLicenseNum.Text.Trim()); report.CommissionerNum = Funs.GetNewInt(this.txtCommissionerNum.Text.Trim()); report.SoleDutyNum = Funs.GetNewInt(this.txtSoleDutyNum.Text.Trim()); if (String.IsNullOrEmpty(MillionsMonthlyReportId)) { Information_MillionsMonthlyReport old = MillionsMonthlyReportService.GetMillionsMonthlyReportByUnitIdDate(drpUnit.SelectedValue, Funs.GetNewIntOrZero(drpYear.SelectedValue), Funs.GetNewIntOrZero(drpMonth.SelectedValue)); if (old == null) { report.MillionsMonthlyReportId = SQLHelper.GetNewID(typeof(Model.Information_MillionsMonthlyReport)); report.UpState = BLL.Const.UpState_2; report.FillingMan = this.CurrUser.PersonName; report.HandleState = BLL.Const.HandleState_1; report.HandleMan = this.CurrUser.PersonId; BLL.MillionsMonthlyReportService.AddMillionsMonthlyReport(report); BLL.LogService.AddSys_Log(this.CurrUser, report.Year.ToString() + "-" + report.Month.ToString(), report.MillionsMonthlyReportId, BLL.Const.MillionsMonthlyReportMenuId, BLL.Const.BtnAdd); } else { ShowNotify("该月份记录已存在!", MessageBoxIcon.Warning); return; } } else { Model.Information_MillionsMonthlyReport oldReport = BLL.MillionsMonthlyReportService.GetMillionsMonthlyReportByMillionsMonthlyReportId(MillionsMonthlyReportId); if (oldReport != null) { report.HandleMan = oldReport.HandleMan; report.HandleState = oldReport.HandleState; } report.MillionsMonthlyReportId = MillionsMonthlyReportId; report.UpState = BLL.Const.UpState_2; BLL.MillionsMonthlyReportService.UpdateMillionsMonthlyReport(report); BLL.LogService.AddSys_Log(this.CurrUser, report.Year.ToString() + "-" + report.Month.ToString(), report.MillionsMonthlyReportId, BLL.Const.MillionsMonthlyReportMenuId, BLL.Const.BtnModify); } MillionsMonthlyReportId = report.MillionsMonthlyReportId; BLL.MillionsMonthlyReportItemService.DeleteMillionsMonthlyReportItemByMillionsMonthlyReportId(report.MillionsMonthlyReportId); List mReportItemList = new List(); GetItems(report.MillionsMonthlyReportId); foreach (var item in items) { if (!string.IsNullOrEmpty(item.Name)) { item.Affiliation = System.Web.HttpUtility.HtmlDecode(item.Affiliation); item.Name = System.Web.HttpUtility.HtmlDecode(item.Name); MillionsMonthlyReportItemService.AddMillionsMonthlyReportItem(item); mReportItemList.Add(item); } } if (type == "updata") //数据同步 { if (report.UpState == BLL.Const.UpState_2) { string code = CNCECHSSEWebService.UpMillionsMonthlyReport(report.MillionsMonthlyReportId, this.CurrUser); if (code == "1") { ShowNotify("同步成功!", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); return; } else { Alert.ShowInParent("同步异常,请退出后重试!", MessageBoxIcon.Error); } } else { ShowNotify("当前单据状态不能同步!", MessageBoxIcon.Warning); return; } } if (type == "submit") { PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ReportSubmit.aspx?Type=MillionsMonthlyReport&Id={0}", report.MillionsMonthlyReportId, "编辑 - "))); } } protected void btnSave_Click(object sender, EventArgs e) { Save("add"); } protected void btnUpdata_Click(object sender, EventArgs e) { Save("updata"); } protected void btnSubmit_Click(object sender, EventArgs e) { Save("submit"); } #endregion #region 增加本月明细 private void GetItems(string millionsMonthlyReportId) { decimal TotalWorkNumSum = 0; int PostPersonNumSum = 0, SnapPersonNumSum = 0, ContractorNumSum = 0, SumPersonNumSum = 0, SeriousInjuriesNumSum = 0, SeriousInjuriesPersonNumSum = 0, SeriousInjuriesLossHourSum = 0, MinorAccidentNumSum = 0, MinorAccidentPersonNumSum = 0, MinorAccidentLossHourSum = 0, DeathAccidentNumSum = 0, DeathAccidentPersonNumSum = 0, DeathAccidentLossHourSum = 0, RestrictedWorkPersonNumSum = 0, RestrictedWorkLossHourSum = 0, MedicalTreatmentPersonNumSum = 0, MedicalTreatmentLossHourSum = 0, FireNumSum = 0, EnvironmenNumSum = 0, TrafficNumSum = 0, EquipmentNumSum = 0, QualityNumSum = 0, OtherNumSum = 0, FirstAidDressingsNumSum = 0, AttemptedEventNumSum = 0, LossDayNumSum = 0; items.Clear(); int i = 10; foreach (JObject mergedRow in Grid1.GetMergedData()) { JObject values = mergedRow.Value("values"); int SumPersonNum = 0; Model.Information_MillionsMonthlyReportItem item = new Information_MillionsMonthlyReportItem(); if (values["MillionsMonthlyReportItemId"].ToString() != "") { item.MillionsMonthlyReportItemId = values.Value("MillionsMonthlyReportItemId"); } item.MillionsMonthlyReportId = millionsMonthlyReportId; item.SortIndex = i; if (!string.IsNullOrEmpty(values["Affiliation"].ToString())) { item.Affiliation = values.Value("Affiliation"); } if (!string.IsNullOrEmpty(values["Name"].ToString())) { item.Name = values.Value("Name"); } if (!string.IsNullOrEmpty(values["PostPersonNum"].ToString())) { item.PostPersonNum = values.Value("PostPersonNum"); SumPersonNum += values.Value("PostPersonNum"); PostPersonNumSum += values.Value("PostPersonNum"); SumPersonNumSum += values.Value("PostPersonNum"); } else { item.PostPersonNum = 0; } if (!string.IsNullOrEmpty(values["SnapPersonNum"].ToString())) { item.SnapPersonNum = values.Value("SnapPersonNum"); SumPersonNum += values.Value("SnapPersonNum"); SnapPersonNumSum += values.Value("SnapPersonNum"); SumPersonNumSum += values.Value("SnapPersonNum"); } else { item.SnapPersonNum = 0; } if (!string.IsNullOrEmpty(values["ContractorNum"].ToString())) { item.ContractorNum = values.Value("ContractorNum"); SumPersonNum += values.Value("ContractorNum"); ContractorNumSum += values.Value("ContractorNum"); SumPersonNumSum += values.Value("ContractorNum"); } else { item.ContractorNum = 0; } if (SumPersonNum != 0) { item.SumPersonNum = SumPersonNum; //获取每条明细记录员工总数合计值 } if (!string.IsNullOrEmpty(values["TotalWorkNum"].ToString())) { item.TotalWorkNum = values.Value("TotalWorkNum"); TotalWorkNumSum += values.Value("TotalWorkNum"); } else { item.TotalWorkNum = 0; } if (!string.IsNullOrEmpty(values["SeriousInjuriesNum"].ToString())) { item.SeriousInjuriesNum = values.Value("SeriousInjuriesNum"); SeriousInjuriesNumSum += values.Value("SeriousInjuriesNum"); } else { item.SeriousInjuriesNum = 0; } if (!string.IsNullOrEmpty(values["SeriousInjuriesPersonNum"].ToString())) { item.SeriousInjuriesPersonNum = values.Value("SeriousInjuriesPersonNum"); SeriousInjuriesPersonNumSum += values.Value("SeriousInjuriesPersonNum"); } else { item.SeriousInjuriesPersonNum = 0; } if (values["SeriousInjuriesLossHour"].ToString() != "") { item.SeriousInjuriesLossHour = values.Value("SeriousInjuriesLossHour"); SeriousInjuriesLossHourSum += values.Value("SeriousInjuriesLossHour"); } else { item.SeriousInjuriesLossHour = 0; } if (values["MinorAccidentNum"].ToString() != "") { item.MinorAccidentNum = values.Value("MinorAccidentNum"); MinorAccidentNumSum += values.Value("MinorAccidentNum"); } else { item.MinorAccidentNum = 0; } if (values["MinorAccidentPersonNum"].ToString() != "") { item.MinorAccidentPersonNum = values.Value("MinorAccidentPersonNum"); MinorAccidentPersonNumSum += values.Value("MinorAccidentPersonNum"); } if (values["MinorAccidentLossHour"].ToString() != "") { item.MinorAccidentLossHour = values.Value("MinorAccidentLossHour"); MinorAccidentLossHourSum += values.Value("MinorAccidentLossHour"); } else { item.MinorAccidentLossHour = 0; } if (values["DeathAccidentNum"].ToString() != "") { item.DeathAccidentNum = values.Value("DeathAccidentNum"); DeathAccidentNumSum += values.Value("DeathAccidentNum"); } if (values["DeathAccidentPersonNum"].ToString() != "") { item.DeathAccidentPersonNum = values.Value("DeathAccidentPersonNum"); DeathAccidentPersonNumSum += values.Value("DeathAccidentPersonNum"); } else { item.DeathAccidentPersonNum = 0; } if (values["DeathAccidentLossHour"].ToString() != "") { item.DeathAccidentLossHour = values.Value("DeathAccidentLossHour"); DeathAccidentLossHourSum += values.Value("DeathAccidentLossHour"); } else { item.DeathAccidentLossHour = 0; } if (values["RestrictedWorkPersonNum"].ToString() != "") { item.RestrictedWorkPersonNum = values.Value("RestrictedWorkPersonNum"); RestrictedWorkPersonNumSum += values.Value("RestrictedWorkPersonNum"); } else { item.RestrictedWorkPersonNum = 0; } if (values["RestrictedWorkLossHour"].ToString() != "") { item.RestrictedWorkLossHour = values.Value("RestrictedWorkLossHour"); RestrictedWorkLossHourSum += values.Value("RestrictedWorkLossHour"); } else { item.RestrictedWorkLossHour = 0; } if (values["MedicalTreatmentPersonNum"].ToString() != "") { item.MedicalTreatmentPersonNum = values.Value("MedicalTreatmentPersonNum"); MedicalTreatmentPersonNumSum += values.Value("MedicalTreatmentPersonNum"); } else { item.MedicalTreatmentPersonNum = 0; } if (values["MedicalTreatmentLossHour"].ToString() != "") { item.MedicalTreatmentLossHour = values.Value("MedicalTreatmentLossHour"); MedicalTreatmentLossHourSum += values.Value("MedicalTreatmentLossHour"); } else { item.MedicalTreatmentLossHour = 0; } if (values["FireNum"].ToString() != "") { item.FireNum = values.Value("FireNum"); FireNumSum += values.Value("FireNum"); } else { item.FireNum = 0; } if (values["EnvironmenNum"].ToString() != "") { item.EnvironmenNum = values.Value("EnvironmenNum"); EnvironmenNumSum += values.Value("EnvironmenNum"); } else { item.EnvironmenNum = 0; } if (values["TrafficNum"].ToString() != "") { item.TrafficNum = values.Value("TrafficNum"); TrafficNumSum += values.Value("TrafficNum"); } else { item.TrafficNum = 0; } if (values["EquipmentNum"].ToString() != "") { item.EquipmentNum = values.Value("EquipmentNum"); EquipmentNumSum += values.Value("EquipmentNum"); } else { item.EquipmentNum = 0; } if (values["QualityNum"].ToString() != "") { item.QualityNum = values.Value("QualityNum"); QualityNumSum += values.Value("QualityNum"); } else { item.QualityNum = 0; } if (values["OtherNum"].ToString() != "") { item.OtherNum = values.Value("OtherNum"); OtherNumSum += values.Value("OtherNum"); } else { item.OtherNum = 0; } if (values["FirstAidDressingsNum"].ToString() != "") { item.FirstAidDressingsNum = values.Value("FirstAidDressingsNum"); FirstAidDressingsNumSum += values.Value("FirstAidDressingsNum"); } else { item.FirstAidDressingsNum = 0; } if (values["AttemptedEventNum"].ToString() != "") { item.AttemptedEventNum = values.Value("AttemptedEventNum"); AttemptedEventNumSum += values.Value("AttemptedEventNum"); } else { item.AttemptedEventNum = 0; } if (values["LossDayNum"].ToString() != "") { item.LossDayNum = values.Value("LossDayNum"); LossDayNumSum += values.Value("LossDayNum"); } else { item.LossDayNum = 0; } items.Add(item); i += 10; } Information_MillionsMonthlyReportItem totalItem = new Information_MillionsMonthlyReportItem { MillionsMonthlyReportItemId = SQLHelper.GetNewID(typeof(Model.Information_MillionsMonthlyReportItem)), MillionsMonthlyReportId = millionsMonthlyReportId, SortIndex = i + 10, Affiliation = "本月合计", Name = "本月合计", PostPersonNum = PostPersonNumSum, SnapPersonNum = SnapPersonNumSum, ContractorNum = ContractorNumSum, SumPersonNum = SumPersonNumSum, TotalWorkNum = TotalWorkNumSum, SeriousInjuriesNum = SeriousInjuriesNumSum, SeriousInjuriesPersonNum = SeriousInjuriesPersonNumSum, SeriousInjuriesLossHour = SeriousInjuriesLossHourSum, MinorAccidentNum = MinorAccidentNumSum, MinorAccidentPersonNum = MinorAccidentPersonNumSum, MinorAccidentLossHour = MinorAccidentLossHourSum, DeathAccidentNum = DeathAccidentNumSum, DeathAccidentPersonNum = DeathAccidentPersonNumSum, DeathAccidentLossHour = DeathAccidentLossHourSum, RestrictedWorkPersonNum = RestrictedWorkPersonNumSum, RestrictedWorkLossHour = RestrictedWorkLossHourSum, MedicalTreatmentPersonNum = MedicalTreatmentPersonNumSum, MedicalTreatmentLossHour = MedicalTreatmentLossHourSum, FireNum = FireNumSum, EnvironmenNum = EnvironmenNumSum, TrafficNum = TrafficNumSum, EquipmentNum = EquipmentNumSum, QualityNum = QualityNumSum, OtherNum = OtherNumSum, FirstAidDressingsNum = FirstAidDressingsNumSum, AttemptedEventNum = AttemptedEventNumSum, LossDayNum = LossDayNumSum }; items.Add(totalItem); } #endregion #region Grid行点击事件 protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) { string rowID = Grid1.DataKeys[e.RowIndex][0].ToString(); GetItems(string.Empty); Model.Information_MillionsMonthlyReportItem totalItem = items.FirstOrDefault(x => x.Affiliation == "本月合计"); items.Remove(totalItem); if (e.CommandName == "Add") { Model.Information_MillionsMonthlyReportItem oldItem = items.FirstOrDefault(x => x.MillionsMonthlyReportItemId == rowID); Model.Information_MillionsMonthlyReportItem newItem = new Information_MillionsMonthlyReportItem { MillionsMonthlyReportItemId = SQLHelper.GetNewID(typeof(Model.Information_MillionsMonthlyReportItem)) }; if (oldItem != null) { newItem.SortIndex = oldItem.SortIndex + 1; newItem.Affiliation = oldItem.Affiliation; } else { newItem.SortIndex = 0; } items.Add(newItem); items = items.OrderBy(x => x.SortIndex).ToList(); Grid1.DataSource = items; Grid1.DataBind(); } if (e.CommandName == "Delete") { foreach (var item in items) { if (item.MillionsMonthlyReportItemId == rowID) { items.Remove(item); break; } } Grid1.DataSource = items; Grid1.DataBind(); ShowNotify("删除数据成功!", MessageBoxIcon.Success); } } #endregion #region 获取明细 private void GetNewItems(string year, string months) { var getCosts = from x in Funs.DB.CostGoods_CostManageItem join y in Funs.DB.CostGoods_CostManage on x.CostManageId equals y.CostManageId where y.CostManageDate.Value.Year.ToString() == year && y.CostManageDate.Value.Month.ToString() == months select x; if (getCosts.Count() > 0) { this.txtInputCosts.Text = getCosts.Sum(x => x.PriceMoney ?? 0).ToString(); } this.txtTrainNum.Text = Funs.DB.EduTrain_TrainRecord.Where(x => x.TrainStartDate.Value.Year.ToString() == year && x.TrainStartDate.Value.Month.ToString() == months).Count().ToString(); int HazardAll = 0, RectifyAll = 0; int HazardMajor = 0, RectifyMajor = 0; var getHazardRegister = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.RegisterDate.Value.Year.ToString() == year && x.RegisterDate.Value.Month.ToString() == months && x.States == Const.State_3); HazardAll = getHazardRegister.Count(); if (HazardAll > 0) { HazardMajor = getHazardRegister.Where(x => x.HazardValue == "2").Count(); } var getRectifyNotices = Funs.DB.Check_RectifyNotices.Where(x => x.CheckedDate.Value.Year.ToString() == year && x.CheckedDate.Value.Month.ToString() == months && x.States == Const.State_5); RectifyAll = getRectifyNotices.Count(); if (RectifyAll > 0) { RectifyMajor = getRectifyNotices.Where(x => x.HiddenHazardType == "3").Count(); } this.txtGeneralHazardNum.Text = ((HazardAll - HazardMajor) + (RectifyAll - RectifyMajor)).ToString(); this.txtMajorHazardNum.Text = (HazardMajor + RectifyMajor).ToString(); var getLarger = from x in Funs.DB.Solution_LargerHazardListItem join y in Funs.DB.Solution_LargerHazardList on x.LargerHazardListId equals y.LargerHazardListId where y.States == Const.State_1 && y.RecordTime.Value.Year.ToString() == year && y.RecordTime.Value.Month.ToString() == months select x; if (getLarger.Count() > 0) { this.txtNotProofLargeProjectNum.Text = Convert.ToString(getLarger.Where(x => x.IsArgument == false).Count()); this.txtProofLargeProjectNum.Text = Convert.ToString(getLarger.Where(x => x.IsArgument == true).Count()); } var getLicense = from x in Funs.DB.License_LicenseManager join y in Funs.DB.Base_LicenseType on x.LicenseTypeId equals y.LicenseTypeId where x.States != Const.State_R && x.StartDate.Value.Year.ToString() == year && x.StartDate.Value.Month.ToString() == months select new { x.LicenseManagerId,x.StartDate,x.EndDate,x.States,y.LicenseTypeId,y.LicenseTypeCode,y.LicenseTypeName}; int fire1 = Funs.DB.License_FireWork.Where(x => x.ApplyDate.Value.Year.ToString() == year && x.ApplyDate.Value.Month.ToString() == months && (x.States == Const.State_2 || x.States == Const.State_3)).Count(); int fire2 = getLicense.Where(x => x.LicenseTypeName.Contains("动火")).Count(); this.txtFireLicenseNum.Text =(fire1+ fire2) .ToString(); int limit1 = Funs.DB.License_LimitedSpace.Where(x => x.ApplyDate.Value.Year.ToString() == year && x.ApplyDate.Value.Month.ToString() == months && (x.States == Const.State_2 || x.States == Const.State_3)).Count(); int limit2 = getLicense.Where(x => x.LicenseTypeName.Contains("受限空间")).Count(); this.txtLimitLicenseNum.Text = (limit1+ limit2).ToString(); int High1 = Funs.DB.License_HeightWork.Where(x => x.ApplyDate.Value.Year.ToString() == year && x.ApplyDate.Value.Month.ToString() == months && (x.States == Const.State_2 || x.States == Const.State_3)).Count(); int High2 = getLicense.Where(x => x.LicenseTypeName.Contains("登高")).Count(); this.txtHighLicenseNum.Text =(High1+ High2).ToString(); int Hoisting1 = Funs.DB.License_LiftingWork.Where(x => x.ApplyDate.Value.Year.ToString() == year && x.ApplyDate.Value.Month.ToString() == months && (x.States == Const.State_2 || x.States == Const.State_3)).Count(); int Hoisting2 = getLicense.Where(x => x.LicenseTypeName.Contains("吊装")).Count(); this.txtHoistingLicenseNum.Text =(Hoisting1+ Hoisting2).ToString(); int Break1 = Funs.DB.License_BreakGround.Where(x => x.ApplyDate.Value.Year.ToString() == year && x.ApplyDate.Value.Month.ToString() == months && (x.States == Const.State_2 || x.States == Const.State_3)).Count(); int Break2 = getLicense.Where(x => x.LicenseTypeName.Contains("动土")).Count(); this.txtBreakGroundLicenseNum.Text = (Break1+ Break2).ToString(); this.txtElectricityLicenseNum.Text = getLicense.Where(x=>x.LicenseTypeName.Contains("临电")).Count().ToString(); int rt1 = Funs.DB.License_RadialWork.Where(x => x.ApplyDate.Value.Year.ToString() == year && x.ApplyDate.Value.Month.ToString() == months && (x.States == Const.State_2 || x.States == Const.State_3)).Count(); int rt2 = getLicense.Where(x => x.LicenseTypeName.Contains("射线")).Count(); this.txtRTLicenseNum.Text =(rt1+ rt2).ToString(); int night1 = Funs.DB.License_NightWork.Where(x => x.ApplyDate.Value.Year.ToString() == year && x.ApplyDate.Value.Month.ToString() == months && (x.States == Const.State_2 || x.States == Const.State_3)).Count(); int night2 = getLicense.Where(x => x.LicenseTypeName.Contains("夜间")).Count(); this.txtNightLicenseNum.Text =(night1+ night2).ToString(); var getPersons = from x in Funs.DB.SitePerson_Person join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId where x.States == Const.ProjectPersonStates_1 && y.IsHsse == true select new { x.ProjectId,y.WorkPostName} ; int isHsse = getPersons.Count(); if (isHsse > 0) { this.txtCommissionerNum.Text = Convert.ToString(getPersons.Where(x => x.WorkPostName.Contains("安全总监")).Count()); } this.txtSoleDutyNum.Text = isHsse.ToString(); //增加明细集合 Model.Information_MillionsMonthlyReportItem item1 = new Information_MillionsMonthlyReportItem { MillionsMonthlyReportItemId = SQLHelper.GetNewID(), Affiliation = "机关后勤服务", Name = "总部", SortIndex = 10, PostPersonNum = 0, SnapPersonNum = 0, ContractorNum = 0, SumPersonNum = 0, TotalWorkNum = 0, SeriousInjuriesNum = 0, SeriousInjuriesPersonNum = 0, SeriousInjuriesLossHour = 0, MinorAccidentNum = 0, MinorAccidentPersonNum = 0, MinorAccidentLossHour = 0, DeathAccidentNum = 0, DeathAccidentPersonNum = 0, DeathAccidentLossHour = 0, RestrictedWorkPersonNum = 0, RestrictedWorkLossHour = 0, MedicalTreatmentPersonNum = 0, MedicalTreatmentLossHour = 0, FireNum = 0, EnvironmenNum = 0, TrafficNum = 0, EquipmentNum = 0, QualityNum = 0, OtherNum = 0, FirstAidDressingsNum = 0, AttemptedEventNum = 0, LossDayNum = 0, }; items.Add(item1); Model.Information_MillionsMonthlyReportItem item2 = new Information_MillionsMonthlyReportItem { MillionsMonthlyReportItemId = SQLHelper.GetNewID(), Affiliation = "机关后勤服务", Name = "二级单位", SortIndex = 20, PostPersonNum = 0, SnapPersonNum = 0, ContractorNum = 0, SumPersonNum = 0, TotalWorkNum = 0, SeriousInjuriesNum = 0, SeriousInjuriesPersonNum = 0, SeriousInjuriesLossHour = 0, MinorAccidentNum = 0, MinorAccidentPersonNum = 0, MinorAccidentLossHour = 0, DeathAccidentNum = 0, DeathAccidentPersonNum = 0, DeathAccidentLossHour = 0, RestrictedWorkPersonNum = 0, RestrictedWorkLossHour = 0, MedicalTreatmentPersonNum = 0, MedicalTreatmentLossHour = 0, FireNum = 0, EnvironmenNum = 0, TrafficNum = 0, EquipmentNum = 0, QualityNum = 0, OtherNum = 0, FirstAidDressingsNum = 0, AttemptedEventNum = 0, LossDayNum = 0, }; items.Add(item2); var projects = BLL.ProjectService.GetProjectWorkList(); int i = 20; foreach (var p in projects) { i += 10; Model.Information_MillionsMonthlyReportItem item = new Information_MillionsMonthlyReportItem { MillionsMonthlyReportItemId = SQLHelper.GetNewID(), Affiliation = "项目现场", Name = p.ProjectName, SortIndex = i }; if (!string.IsNullOrEmpty(p.UnitId)) { var name = BLL.UnitService.GetUnitNameByUnitId(p.UnitId); if (!string.IsNullOrEmpty(name)) { item.Affiliation = name; item.Name = "[" + p.ProjectCode + "]" + p.ProjectName; } } var getSitePersons = Funs.DB.SitePerson_Person.Where(x => x.ProjectId == p.ProjectId && x.States == Const.ProjectPersonStates_1); //var getZSOerson = from x in getSitePersons // join y in Funs.DB.Person_Persons on x.PersonId equals y.PersonId // where y.PersonType == "1" && x.UnitId == Const.UnitId_SEDIN // select x; var getAllSedinPerson= getSitePersons.Where(x => x.UnitId == Const.UnitId_SEDIN).Count(); item.PostPersonNum = getAllSedinPerson; item.SnapPersonNum = 0; item.ContractorNum = getSitePersons.Where(x => x.UnitId != Const.UnitId_SEDIN).Count(); item.SumPersonNum = getSitePersons.Count(); item.TotalWorkNum = 0; item.SeriousInjuriesNum = 0; item.SeriousInjuriesPersonNum = 0; item.SeriousInjuriesLossHour = 0; item.MinorAccidentNum = 0; item.MinorAccidentPersonNum = 0; item.MinorAccidentLossHour = 0; item.DeathAccidentNum = 0; item.DeathAccidentPersonNum = 0; item.DeathAccidentLossHour = 0; item.RestrictedWorkPersonNum = 0; item.RestrictedWorkLossHour = 0; item.MedicalTreatmentPersonNum = 0; item.MedicalTreatmentLossHour = 0; item.FireNum = 0; item.EnvironmenNum = 0; item.TrafficNum = 0; item.EquipmentNum = 0; item.QualityNum = 0; item.OtherNum = 0; item.FirstAidDressingsNum = 0; item.AttemptedEventNum = 0; item.LossDayNum = 0; items.Add(item); } this.Grid1.DataSource = items; this.Grid1.DataBind(); } #endregion #region 单位下拉选择事件 /// /// 单位下拉选择事件 /// /// /// protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e) { items.Clear(); if (drpUnit.SelectedValue != BLL.Const._Null) { //GetNewItems(); } Grid1.DataSource = items; Grid1.DataBind(); } #endregion #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, BLL.Const.MillionsMonthlyReportMenuId); if (buttonList.Count() > 0) { if (buttonList.Contains(BLL.Const.BtnSave)) { this.btnSave.Hidden = false; this.btnCopy.Hidden = false; } //if (buttonList.Contains(BLL.Const.BtnSaveUp)) //{ // this.btnUpdata.Hidden = false; //} if (buttonList.Contains(BLL.Const.BtnSubmit)) { this.btnSubmit.Hidden = false; //this.btnCopy.Hidden = false; } } } #endregion #region 复制上个月数据 /// /// 复制上个月的数据 /// /// /// protected void btnCopy_Click(object sender, EventArgs e) { DateTime? nowDate = Funs.GetNewDateTime(this.drpYear.SelectedValue + "-" + this.drpMonth.SelectedValue); if (nowDate.HasValue) { DateTime showDate = new DateTime(); showDate = nowDate.Value.AddMonths(-1); Model.Information_MillionsMonthlyReport millionsMonthlyReport = BLL.MillionsMonthlyReportService.GetMillionsMonthlyReportByUnitIdAndYearAndMonth(this.drpUnit.SelectedValue, showDate.Year, showDate.Month); if (millionsMonthlyReport != null) { Model.Information_MillionsMonthlyReport newMillionsMonthlyReport = new Information_MillionsMonthlyReport(); this.MillionsMonthlyReportId = SQLHelper.GetNewID(typeof(Model.Information_MillionsMonthlyReport)); newMillionsMonthlyReport.MillionsMonthlyReportId = this.MillionsMonthlyReportId; newMillionsMonthlyReport.UnitId = this.drpUnit.SelectedValue; newMillionsMonthlyReport.Year = Convert.ToInt32(this.drpYear.SelectedValue); newMillionsMonthlyReport.Month = Convert.ToInt32(this.drpMonth.SelectedValue); newMillionsMonthlyReport.FillingMan = this.CurrUser.PersonName; newMillionsMonthlyReport.FillingDate = DateTime.Now; newMillionsMonthlyReport.DutyPerson = this.CurrUser.PersonName; newMillionsMonthlyReport.RecordableIncidentRate = millionsMonthlyReport.RecordableIncidentRate; newMillionsMonthlyReport.LostTimeRate = millionsMonthlyReport.LostTimeRate; newMillionsMonthlyReport.LostTimeInjuryRate = millionsMonthlyReport.LostTimeInjuryRate; newMillionsMonthlyReport.DeathAccidentFrequency = millionsMonthlyReport.DeathAccidentFrequency; newMillionsMonthlyReport.AccidentMortality = millionsMonthlyReport.AccidentMortality; newMillionsMonthlyReport.UpState = BLL.Const.UpState_2; newMillionsMonthlyReport.HandleState = BLL.Const.HandleState_1; newMillionsMonthlyReport.HandleMan = this.CurrUser.PersonId; newMillionsMonthlyReport.InputCosts = millionsMonthlyReport.InputCosts; newMillionsMonthlyReport.TrainNum = millionsMonthlyReport.TrainNum; newMillionsMonthlyReport.GeneralHazardNum = millionsMonthlyReport.GeneralHazardNum; newMillionsMonthlyReport.MajorHazardNum = millionsMonthlyReport.MajorHazardNum; newMillionsMonthlyReport.NotProofLargeProjectNum = millionsMonthlyReport.NotProofLargeProjectNum; newMillionsMonthlyReport.ProofLargeProjectNum = millionsMonthlyReport.ProofLargeProjectNum; newMillionsMonthlyReport.FireLicenseNum = millionsMonthlyReport.FireLicenseNum; newMillionsMonthlyReport.LimitLicenseNum = millionsMonthlyReport.LimitLicenseNum; newMillionsMonthlyReport.HighLicenseNum = millionsMonthlyReport.HighLicenseNum; newMillionsMonthlyReport.HoistingLicenseNum = millionsMonthlyReport.HoistingLicenseNum; newMillionsMonthlyReport.BreakGroundLicenseNum = millionsMonthlyReport.BreakGroundLicenseNum; newMillionsMonthlyReport.ElectricityLicenseNum = millionsMonthlyReport.ElectricityLicenseNum; newMillionsMonthlyReport.RTLicenseNum = millionsMonthlyReport.RTLicenseNum; newMillionsMonthlyReport.NightLicenseNum = millionsMonthlyReport.NightLicenseNum; newMillionsMonthlyReport.CommissionerNum = millionsMonthlyReport.CommissionerNum; newMillionsMonthlyReport.SoleDutyNum = millionsMonthlyReport.SoleDutyNum; BLL.MillionsMonthlyReportService.AddMillionsMonthlyReport(newMillionsMonthlyReport); items = BLL.MillionsMonthlyReportItemService.GetItems(millionsMonthlyReport.MillionsMonthlyReportId); if (items.Count > 0) { foreach (var item in items) { if (item.Affiliation != "本月合计" || item.Name != "本月合计") { Model.Information_MillionsMonthlyReportItem newItem = new Information_MillionsMonthlyReportItem { MillionsMonthlyReportItemId = SQLHelper.GetNewID(typeof(Model.Information_MillionsMonthlyReportItem)), MillionsMonthlyReportId = this.MillionsMonthlyReportId, SortIndex = item.SortIndex, Affiliation = item.Affiliation, Name = item.Name, PostPersonNum = item.PostPersonNum, SnapPersonNum = item.SnapPersonNum, ContractorNum = item.ContractorNum, SumPersonNum = item.SumPersonNum, TotalWorkNum = item.TotalWorkNum, SeriousInjuriesNum = item.SeriousInjuriesNum, SeriousInjuriesPersonNum = item.SeriousInjuriesPersonNum, SeriousInjuriesLossHour = item.SeriousInjuriesLossHour, MinorAccidentNum = item.MinorAccidentNum, MinorAccidentPersonNum = item.MinorAccidentPersonNum, MinorAccidentLossHour = item.MinorAccidentLossHour, DeathAccidentNum = item.DeathAccidentNum, DeathAccidentPersonNum = item.DeathAccidentPersonNum, DeathAccidentLossHour = item.DeathAccidentLossHour, RestrictedWorkPersonNum = item.RestrictedWorkPersonNum, RestrictedWorkLossHour = item.RestrictedWorkLossHour, MedicalTreatmentPersonNum = item.MedicalTreatmentPersonNum, MedicalTreatmentLossHour = item.MedicalTreatmentLossHour, FireNum = item.FireNum, EnvironmenNum = item.EnvironmenNum, TrafficNum = item.TrafficNum, EquipmentNum = item.EquipmentNum, QualityNum = item.QualityNum, OtherNum = item.OtherNum, FirstAidDressingsNum = item.FirstAidDressingsNum, AttemptedEventNum = item.AttemptedEventNum, LossDayNum = item.LossDayNum }; BLL.MillionsMonthlyReportItemService.AddMillionsMonthlyReportItem(newItem); } } } GetValues(newMillionsMonthlyReport.MillionsMonthlyReportId); } } } /// /// 获取复制的值绑定到文本中 /// private void GetValues(string millionsMonthlyReportId) { var report = BLL.MillionsMonthlyReportService.GetMillionsMonthlyReportByMillionsMonthlyReportId(millionsMonthlyReportId); if (report != null) { drpMonth.SelectedValue = report.Month.ToString(); drpYear.SelectedValue = report.Year.ToString(); drpUnit.SelectedValue = report.UnitId; if (report.FillingDate != null) { txtFillingDate.Text = string.Format("{0:yyyy-MM-dd}", report.FillingDate); } txtDutyPerson.Text = report.DutyPerson; if (report.RecordableIncidentRate != null) { txtRecordableIncidentRate.Text = report.RecordableIncidentRate.ToString(); } if (report.LostTimeRate != null) { txtLostTimeRate.Text = report.LostTimeRate.ToString(); } if (report.LostTimeInjuryRate != null) { txtLostTimeInjuryRate.Text = report.LostTimeInjuryRate.ToString(); } if (report.DeathAccidentFrequency != null) { txtDeathAccidentFrequency.Text = report.DeathAccidentFrequency.ToString(); } if (report.AccidentMortality != null) { txtAccidentMortality.Text = report.AccidentMortality.ToString(); } if (report.InputCosts != null) { this.txtInputCosts.Text = Convert.ToString(report.InputCosts); } if (report.TrainNum != null) { this.txtTrainNum.Text = Convert.ToString(report.TrainNum); } if (report.GeneralHazardNum != null) { this.txtGeneralHazardNum.Text = Convert.ToString(report.GeneralHazardNum); } if (report.MajorHazardNum != null) { this.txtMajorHazardNum.Text = Convert.ToString(report.MajorHazardNum); } if (report.NotProofLargeProjectNum != null) { this.txtNotProofLargeProjectNum.Text = Convert.ToString(report.NotProofLargeProjectNum); } if (report.ProofLargeProjectNum != null) { this.txtProofLargeProjectNum.Text = Convert.ToString(report.ProofLargeProjectNum); } if (report.FireLicenseNum != null) { this.txtFireLicenseNum.Text = Convert.ToString(report.FireLicenseNum); } if (report.LimitLicenseNum != null) { this.txtLimitLicenseNum.Text = Convert.ToString(report.LimitLicenseNum); } if (report.HighLicenseNum != null) { this.txtHighLicenseNum.Text = Convert.ToString(report.HighLicenseNum); } if (report.HoistingLicenseNum != null) { this.txtHoistingLicenseNum.Text = Convert.ToString(report.HoistingLicenseNum); } if (report.BreakGroundLicenseNum != null) { this.txtBreakGroundLicenseNum.Text = Convert.ToString(report.BreakGroundLicenseNum); } if (report.ElectricityLicenseNum != null) { this.txtElectricityLicenseNum.Text = Convert.ToString(report.ElectricityLicenseNum); } if (report.RTLicenseNum != null) { this.txtRTLicenseNum.Text = Convert.ToString(report.RTLicenseNum); } if (report.NightLicenseNum != null) { this.txtNightLicenseNum.Text = Convert.ToString(report.NightLicenseNum); } if (report.CommissionerNum != null) { this.txtCommissionerNum.Text = Convert.ToString(report.CommissionerNum); } if (report.SoleDutyNum != null) { this.txtSoleDutyNum.Text = Convert.ToString(report.SoleDutyNum); } items = BLL.MillionsMonthlyReportItemService.GetItems(millionsMonthlyReportId); this.Grid1.DataSource = items; this.Grid1.DataBind(); } } #endregion } }