/// <summary> /// /// </summary> private void InitTextValue() { string unitId = this.drpUnitId.SelectedValue; int year = Funs.GetNewIntOrZero(this.drpYear.SelectedValue); int month = Funs.GetNewIntOrZero(this.drpMonths.SelectedValue); DateTime?Months = Funs.GetNewDateTime(this.drpYear.SelectedValue + "-" + this.drpMonths.SelectedValue); this.HSSECostManageId = string.Empty; this.HSSECostUnitManageId = string.Empty; decimal pMainIncome = 0, pConstructionIncome = 0, pSafetyCosts = 0; var sumHsseCostMange = BLL.HSSECostManageService.GetListHSSECostManageByProjectIdMonth(this.ProjectId, Months); if (sumHsseCostMange.Count() > 0) { pMainIncome = sumHsseCostMange.Sum(x => x.MainIncome) ?? 0; pConstructionIncome = sumHsseCostMange.Sum(x => x.ConstructionIncome) ?? 0; pSafetyCosts = sumHsseCostMange.Sum(x => x.SafetyCosts) ?? 0; } Model.CostGoods_HSSECostUnitManage hsseCostUnitManage = new Model.CostGoods_HSSECostUnitManage(); var hsseCostManage = BLL.HSSECostManageService.GetHSSECostManageByProjectIdMonth(ProjectId, year, month); if (hsseCostManage != null) { this.HSSECostManageId = hsseCostManage.HSSECostManageId; this.txtCode.Text = BLL.CodeRecordsService.ReturnCodeByDataId(hsseCostManage.HSSECostManageId); this.txtReportDate.Text = string.Format("{0:yyyy-MM-dd}", hsseCostManage.ReportDate); this.txtMainIncome.Text = hsseCostManage.MainIncome.ToString(); this.txtProjectMainIncome.Text = (pMainIncome + (hsseCostManage.MainIncome ?? 0)).ToString(); this.txtRemark1.Text = hsseCostManage.Remark1; this.txtConstructionIncome.Text = hsseCostManage.ConstructionIncome.ToString(); this.txtProjectConstructionIncome.Text = (pConstructionIncome + (hsseCostManage.ConstructionIncome ?? 0)).ToString(); this.txtRemark2.Text = hsseCostManage.Remark2; this.txtSafetyCosts.Text = hsseCostManage.SafetyCosts.ToString(); this.txtProjectSafetyCosts.Text = (pSafetyCosts + (hsseCostManage.SafetyCosts ?? 0)).ToString(); this.txtRemark3.Text = hsseCostManage.Remark3; hsseCostUnitManage = BLL.HSSECostUnitManageService.GetHSSECostUnitManageByHSSECostManageIdUnitId(this.HSSECostManageId, this.drpUnitId.SelectedValue); if (hsseCostManage.States == BLL.Const.State_2) { this.btnSave.Hidden = true; this.btnSubmit.Hidden = true; } } else { this.txtReportDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); this.txtCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectHSSECostManageMenuId, this.ProjectId, string.Empty); this.txtMainIncome.Text = "0"; this.txtConstructionIncome.Text = "0"; this.txtSafetyCosts.Text = "0"; this.txtProjectMainIncome.Text = pMainIncome.ToString(); this.txtProjectConstructionIncome.Text = pConstructionIncome.ToString(); this.txtProjectSafetyCosts.Text = pSafetyCosts.ToString(); hsseCostUnitManage = BLL.HSSECostUnitManageService.GetHSSECostUnitManageByProjectIdUnitIdYearMonth(this.ProjectId, this.drpUnitId.SelectedValue, year, month); } this.InitTextUnitValue(hsseCostUnitManage); }
/// <summary> /// 修改费用管理 /// </summary> /// <param name="hsseCostUnitManage"></param> public static void UpdateHSSECostUnitManage(Model.CostGoods_HSSECostUnitManage hsseCostUnitManage) { Model.SUBHSSEDB db = Funs.DB; Model.CostGoods_HSSECostUnitManage newHSSECostUnitManage = db.CostGoods_HSSECostUnitManage.FirstOrDefault(e => e.HSSECostUnitManageId == hsseCostUnitManage.HSSECostUnitManageId); if (newHSSECostUnitManage != null) { newHSSECostUnitManage.EngineeringCost = hsseCostUnitManage.EngineeringCost; newHSSECostUnitManage.Remark1 = hsseCostUnitManage.Remark1; newHSSECostUnitManage.SubUnitCost = hsseCostUnitManage.SubUnitCost; newHSSECostUnitManage.Remark2 = hsseCostUnitManage.Remark2; newHSSECostUnitManage.AuditedSubUnitCost = hsseCostUnitManage.AuditedSubUnitCost; newHSSECostUnitManage.Remark3 = hsseCostUnitManage.Remark3; newHSSECostUnitManage.CostRatio = hsseCostUnitManage.CostRatio; newHSSECostUnitManage.Remark4 = hsseCostUnitManage.Remark4; newHSSECostUnitManage.CostA1 = hsseCostUnitManage.CostA1; newHSSECostUnitManage.CostA2 = hsseCostUnitManage.CostA2; newHSSECostUnitManage.CostA3 = hsseCostUnitManage.CostA3; newHSSECostUnitManage.CostA4 = hsseCostUnitManage.CostA4; newHSSECostUnitManage.CostA5 = hsseCostUnitManage.CostA5; newHSSECostUnitManage.CostA6 = hsseCostUnitManage.CostA6; newHSSECostUnitManage.CostA7 = hsseCostUnitManage.CostA7; newHSSECostUnitManage.CostA8 = hsseCostUnitManage.CostA8; newHSSECostUnitManage.CostB1 = hsseCostUnitManage.CostB1; newHSSECostUnitManage.CostB2 = hsseCostUnitManage.CostB2; newHSSECostUnitManage.CostC1 = hsseCostUnitManage.CostC1; newHSSECostUnitManage.CostD1 = hsseCostUnitManage.CostD1; newHSSECostUnitManage.CostD2 = hsseCostUnitManage.CostD2; newHSSECostUnitManage.CostD3 = hsseCostUnitManage.CostD3; newHSSECostUnitManage.States = hsseCostUnitManage.States; newHSSECostUnitManage.StateType = hsseCostUnitManage.StateType; newHSSECostUnitManage.AuditCostA1 = hsseCostUnitManage.AuditCostA1; newHSSECostUnitManage.AuditCostA2 = hsseCostUnitManage.AuditCostA2; newHSSECostUnitManage.AuditCostA3 = hsseCostUnitManage.AuditCostA3; newHSSECostUnitManage.AuditCostA4 = hsseCostUnitManage.AuditCostA4; newHSSECostUnitManage.AuditCostA5 = hsseCostUnitManage.AuditCostA5; newHSSECostUnitManage.AuditCostA6 = hsseCostUnitManage.AuditCostA6; newHSSECostUnitManage.AuditCostA7 = hsseCostUnitManage.AuditCostA7; newHSSECostUnitManage.AuditCostA8 = hsseCostUnitManage.AuditCostA8; newHSSECostUnitManage.RatifiedCostA1 = hsseCostUnitManage.RatifiedCostA1; newHSSECostUnitManage.RatifiedCostA2 = hsseCostUnitManage.RatifiedCostA2; newHSSECostUnitManage.RatifiedCostA3 = hsseCostUnitManage.RatifiedCostA3; newHSSECostUnitManage.RatifiedCostA4 = hsseCostUnitManage.RatifiedCostA4; newHSSECostUnitManage.RatifiedCostA5 = hsseCostUnitManage.RatifiedCostA5; newHSSECostUnitManage.RatifiedCostA6 = hsseCostUnitManage.RatifiedCostA6; newHSSECostUnitManage.RatifiedCostA7 = hsseCostUnitManage.RatifiedCostA7; newHSSECostUnitManage.RatifiedCostA8 = hsseCostUnitManage.RatifiedCostA8; newHSSECostUnitManage.AuditManId = hsseCostUnitManage.AuditManId; newHSSECostUnitManage.RatifiedManId = hsseCostUnitManage.RatifiedManId; db.SubmitChanges(); } }
/// <summary> /// 添加安全费用管理 /// </summary> /// <param name="hsseCostUnitManage"></param> public static void AddHSSECostUnitManage(Model.CostGoods_HSSECostUnitManage hsseCostUnitManage) { Model.SUBHSSEDB db = Funs.DB; Model.CostGoods_HSSECostUnitManage newHSSECostUnitManage = new Model.CostGoods_HSSECostUnitManage { HSSECostUnitManageId = hsseCostUnitManage.HSSECostUnitManageId, HSSECostManageId = hsseCostUnitManage.HSSECostManageId, UnitId = hsseCostUnitManage.UnitId, EngineeringCost = hsseCostUnitManage.EngineeringCost, Remark1 = hsseCostUnitManage.Remark1, SubUnitCost = hsseCostUnitManage.SubUnitCost, Remark2 = hsseCostUnitManage.Remark2, AuditedSubUnitCost = hsseCostUnitManage.AuditedSubUnitCost, Remark3 = hsseCostUnitManage.Remark3, CostRatio = hsseCostUnitManage.CostRatio, Remark4 = hsseCostUnitManage.Remark4, CostA1 = hsseCostUnitManage.CostA1, CostA2 = hsseCostUnitManage.CostA2, CostA3 = hsseCostUnitManage.CostA3, CostA4 = hsseCostUnitManage.CostA4, CostA5 = hsseCostUnitManage.CostA5, CostA6 = hsseCostUnitManage.CostA6, CostA7 = hsseCostUnitManage.CostA7, CostA8 = hsseCostUnitManage.CostA8, CostB1 = hsseCostUnitManage.CostB1, CostB2 = hsseCostUnitManage.CostB2, CostC1 = hsseCostUnitManage.CostC1, CostD1 = hsseCostUnitManage.CostD1, CostD2 = hsseCostUnitManage.CostD2, CostD3 = hsseCostUnitManage.CostD3, CompileDate = hsseCostUnitManage.CompileDate, CompileManId = hsseCostUnitManage.CompileManId, States = hsseCostUnitManage.States, StateType = hsseCostUnitManage.StateType, AuditManId = hsseCostUnitManage.AuditManId, RatifiedManId = hsseCostUnitManage.RatifiedManId, }; db.CostGoods_HSSECostUnitManage.InsertOnSubmit(newHSSECostUnitManage); db.SubmitChanges(); }
/// <summary> /// 根据施工单位费用主键删除施工单位费用管理 /// </summary> /// <param name="hsseCostUnitManageId"></param> public static void DeleteHSSECostUnitManageById(string hsseCostUnitManageId) { Model.SUBHSSEDB db = Funs.DB; Model.CostGoods_HSSECostUnitManage HSSECostUnitManage = db.CostGoods_HSSECostUnitManage.FirstOrDefault(e => e.HSSECostUnitManageId == hsseCostUnitManageId); if (HSSECostUnitManage != null) { ///删除编码表记录 BLL.CodeRecordsService.DeleteCodeRecordsByDataId(hsseCostUnitManageId); ////删除附件表 BLL.CommonService.DeleteAttachFileById(hsseCostUnitManageId); ////删除流程表 BLL.CommonService.DeleteFlowOperateByID(hsseCostUnitManageId); ////删除流程表 BLL.CommonService.DeleteFlowOperateByID(hsseCostUnitManageId + "#2"); ////删除流程表 BLL.CommonService.DeleteFlowOperateByID(hsseCostUnitManageId + "#3"); HSSECostUnitManageItemService.DeleteHSSECostUnitManageItemByHSSECostUnitManageId(HSSECostUnitManage.HSSECostUnitManageId); db.CostGoods_HSSECostUnitManage.DeleteOnSubmit(HSSECostUnitManage); db.SubmitChanges(); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BtnNew_Click(object sender, EventArgs e) { if (this.drpYear.SelectedValue != BLL.Const._Null && this.drpMonths.SelectedValue != BLL.Const._Null && this.drpUnitId.SelectedValue != BLL.Const._Null && this.drpUnitId.SelectedValue != BLL.Const._Null) { DateTime?Months = Funs.GetNewDateTime(this.drpYear.SelectedValue + "-" + this.drpMonths.SelectedValue); string hsseCostManageId = string.Empty; string unitId = this.drpUnitId.SelectedValue; var hsseCost = BLL.HSSECostManageService.GetHSSECostManageByProjectIdMonth(this.ProjectId, Funs.GetNewIntOrZero(this.drpYear.SelectedValue), Funs.GetNewIntOrZero(this.drpMonths.SelectedValue)); if (hsseCost != null) { hsseCostManageId = hsseCost.HSSECostManageId; } else { hsseCostManageId = SQLHelper.GetNewID(typeof(Model.CostGoods_HSSECostManage)); Model.CostGoods_HSSECostManage newHSSECostManage = new Model.CostGoods_HSSECostManage { HSSECostManageId = hsseCostManageId, ProjectId = this.ProjectId, Month = Months, Code = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectHSSECostManageMenuId, this.ProjectId, string.Empty), ReportDate = System.DateTime.Now, CompileDate = System.DateTime.Now, }; BLL.HSSECostManageService.AddHSSECostManage(newHSSECostManage); } var unitCost = BLL.HSSECostUnitManageService.GetHSSECostUnitManageByHSSECostManageIdUnitId(hsseCostManageId, unitId); if (unitCost == null) { string HSSECostUnitManageId = SQLHelper.GetNewID(typeof(Model.CostGoods_HSSECostUnitManage)); Model.CostGoods_HSSECostUnitManage newHSSECostUnit = new Model.CostGoods_HSSECostUnitManage { HSSECostUnitManageId = HSSECostUnitManageId, HSSECostManageId = hsseCostManageId, UnitId = unitId, StateType = "1", States = "0", CompileManId = this.CurrUser.UserId, CompileDate = DateTime.Now, CostA1 = 0, CostA2 = 0, CostA3 = 0, CostA4 = 0, CostA5 = 0, CostA6 = 0, CostA7 = 0, CostA8 = 0, CostB1 = 0, CostB2 = 0, CostC1 = 0, CostD1 = 0, CostD2 = 0, CostD3 = 0, }; BLL.HSSECostUnitManageService.AddHSSECostUnitManage(newHSSECostUnit); PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("HSSECostUnitManageEdit.aspx?HSSECostUnitManageId={0}", HSSECostUnitManageId, "编辑 - "))); } else { Alert.ShowInTop("当月已存在费用表!", MessageBoxIcon.Warning); } } else { Alert.ShowInTop("请选择月份、单位!", MessageBoxIcon.Warning); } }
/// <summary> /// /// </summary> private void SaveData(string type) { ///添加安全费用 DateTime?Months = Funs.GetNewDateTime(this.drpYear.SelectedValue + "-" + this.drpMonths.SelectedValue); Model.CostGoods_HSSECostManage newHSSECostManage = new Model.CostGoods_HSSECostManage { ProjectId = this.ProjectId, Month = Months, Code = this.txtCode.Text, ReportDate = Funs.GetNewDateTime(this.txtReportDate.Text), MainIncome = Funs.GetNewDecimal(this.txtMainIncome.Text), Remark1 = this.txtRemark1.Text, ConstructionIncome = Funs.GetNewDecimal(this.txtConstructionIncome.Text), Remark2 = this.txtRemark2.Text, SafetyCosts = Funs.GetNewDecimal(this.txtSafetyCosts.Text), Remark3 = this.txtRemark3.Text, }; ////单据状态 newHSSECostManage.States = BLL.Const.State_0; if (type == BLL.Const.BtnSubmit) { newHSSECostManage.States = this.ctlAuditFlow.NextStep; } if (!string.IsNullOrEmpty(this.HSSECostManageId)) { newHSSECostManage.HSSECostManageId = this.HSSECostManageId; BLL.HSSECostManageService.UpdateHSSECostManage(newHSSECostManage); BLL.LogService.AddSys_Log(this.CurrUser, newHSSECostManage.Code, newHSSECostManage.HSSECostManageId, BLL.Const.ProjectHSSECostManageMenuId, BLL.Const.BtnModify); } else { this.HSSECostManageId = SQLHelper.GetNewID(typeof(Model.CostGoods_HSSECostManage)); newHSSECostManage.HSSECostManageId = this.HSSECostManageId; newHSSECostManage.CompileDate = System.DateTime.Now; newHSSECostManage.CompileManId = this.CurrUser.UserId; BLL.HSSECostManageService.AddHSSECostManage(newHSSECostManage); BLL.LogService.AddSys_Log(this.CurrUser, newHSSECostManage.Code, newHSSECostManage.HSSECostManageId, BLL.Const.ProjectHSSECostManageMenuId, BLL.Const.BtnAdd); } if (!string.IsNullOrEmpty(this.drpUnitId.SelectedValue) && this.drpUnitId.SelectedValue != BLL.Const._Null) { var updateItem = BLL.HSSECostUnitManageService.GetHSSECostUnitManageByHSSECostUnitManageId(this.HSSECostUnitManageId); if (updateItem != null) { updateItem.HSSECostManageId = this.HSSECostManageId; updateItem.UnitId = this.drpUnitId.SelectedValue; updateItem.EngineeringCost = Funs.GetNewDecimal(this.txtEngineeringCost.Text); updateItem.Remark1 = this.txtRemark1.Text; updateItem.SubUnitCost = Funs.GetNewDecimal(this.txtSubUnitCost.Text); updateItem.Remark2 = this.txtRemark2.Text; updateItem.AuditedSubUnitCost = Funs.GetNewDecimal(this.txtAuditedSubUnitCost.Text); updateItem.Remark3 = this.txtRemark1.Text; updateItem.CostRatio = Funs.GetNewDecimal(this.txtCostRatio.Text); updateItem.Remark4 = this.txtRemark1.Text; BLL.HSSECostUnitManageService.UpdateHSSECostUnitManage(updateItem); } else { ///添加施工单位安全费用 Model.CostGoods_HSSECostUnitManage newHSSECostUnitManage = new Model.CostGoods_HSSECostUnitManage { HSSECostManageId = this.HSSECostManageId, UnitId = this.drpUnitId.SelectedValue, EngineeringCost = Funs.GetNewDecimal(this.txtEngineeringCost.Text), Remark1 = this.txtRemark1.Text, SubUnitCost = Funs.GetNewDecimal(this.txtSubUnitCost.Text), Remark2 = this.txtRemark2.Text, AuditedSubUnitCost = Funs.GetNewDecimal(this.txtAuditedSubUnitCost.Text), Remark3 = this.txtRemark1.Text, CostRatio = Funs.GetNewDecimal(this.txtCostRatio.Text), Remark4 = this.txtRemark1.Text, }; this.HSSECostUnitManageId = SQLHelper.GetNewID(typeof(Model.CostGoods_HSSECostUnitManage)); newHSSECostUnitManage.HSSECostUnitManageId = this.HSSECostUnitManageId; BLL.HSSECostUnitManageService.AddHSSECostUnitManage(newHSSECostUnitManage); } this.ctlAuditFlow.btnSaveData(this.ProjectId, BLL.Const.ProjectHSSECostManageMenuId, this.HSSECostManageId, (type == BLL.Const.BtnSubmit ? true : false), this.drpYear.SelectedText + "年" + this.drpMonths.SelectedText + "月安全费用", "../CostGoods/HSSECostManageView.aspx?HSSECostManageId={0}"); ////判断单据是否 加入到企业管理资料 string menuId = BLL.Const.ProjectHSSECostManageMenuId; var safeData = Funs.DB.SafetyData_SafetyData.FirstOrDefault(x => x.MenuId == menuId); if (safeData != null) { BLL.SafetyDataService.AddSafetyData(menuId, this.HSSECostManageId, this.drpYear.SelectedText + "-" + this.drpMonths.SelectedText + "安全费用", "../CostGoods/HSSECostManageView.aspx?HSSECostManageId={0}", this.ProjectId); } } }
/// <summary> /// 初始化菜单输入框信息 /// </summary> private void InitTextUnitValue(Model.CostGoods_HSSECostUnitManage hsseCostUnitManage) { decimal? a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0, a7 = 0, a8 = 0, aall = 0; decimal? pa1 = 0, pa2 = 0, pa3 = 0, pa4 = 0, pa5 = 0, pa6 = 0, pa7 = 0, pa8 = 0, paall = 0; decimal? EngineeringCost = 0, SubUnitCost = 0, AuditedSubUnitCost = 0; decimal? pEngineeringCost = 0, pSubUnitCost = 0, pAuditedSubUnitCost = 0; string remark1 = string.Empty, remark2 = string.Empty, remark3 = string.Empty, remark4 = string.Empty; DateTime?Months = Funs.GetNewDateTime(this.drpYear.SelectedValue + "-" + this.drpMonths.SelectedValue); var sumUnit = BLL.HSSECostUnitManageService.GetHSSECostUnitManageListByProjectIdUnitIdMonth(this.ProjectId, this.drpUnitId.SelectedValue, Months); if (sumUnit.Count() > 0) { pa1 = sumUnit.Sum(x => x.RatifiedCostA1); pa2 = sumUnit.Sum(x => x.RatifiedCostA2); pa3 = sumUnit.Sum(x => x.RatifiedCostA3); pa4 = sumUnit.Sum(x => x.RatifiedCostA4); pa5 = sumUnit.Sum(x => x.RatifiedCostA5); pa6 = sumUnit.Sum(x => x.RatifiedCostA6); pa7 = sumUnit.Sum(x => x.RatifiedCostA7); pa8 = sumUnit.Sum(x => x.RatifiedCostA8); paall = pa1 + pa2 + pa3 + pa4 + pa5 + pa6 + pa7 + pa8; pEngineeringCost = sumUnit.Sum(x => EngineeringCost ?? 0); pSubUnitCost = sumUnit.Sum(x => SubUnitCost ?? 0); pAuditedSubUnitCost = sumUnit.Sum(x => AuditedSubUnitCost ?? 0); } if (hsseCostUnitManage != null) { this.HSSECostUnitManageId = hsseCostUnitManage.HSSECostUnitManageId; a1 = hsseCostUnitManage.RatifiedCostA1; pa1 += a1; aall += a1; a2 = hsseCostUnitManage.RatifiedCostA2; pa2 += a2; aall += a2; a3 = hsseCostUnitManage.RatifiedCostA3; pa3 += a3; aall += a3; a4 = hsseCostUnitManage.RatifiedCostA4; pa4 += a4; aall += a4; a5 = hsseCostUnitManage.RatifiedCostA5; pa5 += a5; aall += a5; a6 = hsseCostUnitManage.RatifiedCostA6; pa6 += a6; aall += a6; a7 = hsseCostUnitManage.RatifiedCostA7; pa7 += a7; aall += a7; a8 = hsseCostUnitManage.RatifiedCostA8; pa8 += a8; aall += a8; paall += aall; EngineeringCost = hsseCostUnitManage.EngineeringCost; pEngineeringCost += EngineeringCost; SubUnitCost = hsseCostUnitManage.SubUnitCost; pSubUnitCost += SubUnitCost; AuditedSubUnitCost = hsseCostUnitManage.AuditedSubUnitCost; pAuditedSubUnitCost += AuditedSubUnitCost; remark1 = hsseCostUnitManage.Remark1; remark2 = hsseCostUnitManage.Remark2; remark3 = hsseCostUnitManage.Remark3; remark4 = hsseCostUnitManage.Remark4; } this.txtA1.Text = a1.ToString(); this.txtA2.Text = a2.ToString(); this.txtA3.Text = a3.ToString(); this.txtA4.Text = a4.ToString(); this.txtA5.Text = a5.ToString(); this.txtA6.Text = a6.ToString(); this.txtA7.Text = a7.ToString(); this.txtA8.Text = a8.ToString(); this.txtAAll.Text = aall.ToString(); this.txtProjectA1.Text = pa1.ToString(); this.txtProjectA2.Text = pa2.ToString(); this.txtProjectA3.Text = pa3.ToString(); this.txtProjectA4.Text = pa4.ToString(); this.txtProjectA5.Text = pa5.ToString(); this.txtProjectA6.Text = pa6.ToString(); this.txtProjectA7.Text = pa7.ToString(); this.txtProjectA8.Text = pa8.ToString(); this.txtProjectAAll.Text = paall.ToString(); this.txtEngineeringCost.Text = EngineeringCost.ToString(); this.txtSubUnitCost.Text = SubUnitCost.ToString(); this.txtAuditedSubUnitCost.Text = AuditedSubUnitCost.ToString(); this.txtUnitRemark1.Text = remark1; this.txtUnitRemark2.Text = remark2; this.txtUnitRemark3.Text = remark3; this.txtUnitRemark4.Text = remark4; this.txtProjectEngineeringCost.Text = pEngineeringCost.ToString(); this.txtProjectSubUnitCost.Text = pSubUnitCost.ToString(); this.txtProjectAuditedSubUnitCost.Text = pAuditedSubUnitCost.ToString(); if (EngineeringCost.HasValue && EngineeringCost != 0 && AuditedSubUnitCost.HasValue) { this.txtCostRatio.Text = Math.Round((AuditedSubUnitCost / EngineeringCost * 100).Value, 2).ToString() + "%"; } else { this.txtCostRatio.Text = "0%"; } if (pEngineeringCost.HasValue && pEngineeringCost != 0 && pAuditedSubUnitCost.HasValue) { this.txtProjectCostRatio.Text = Math.Round((pAuditedSubUnitCost / pEngineeringCost * 100).Value, 2).ToString() + "%"; } else { this.txtProjectCostRatio.Text = "0%"; } }
/// <summary> /// /// </summary> private void InitTextValue() { string unitId = this.drpUnitId.SelectedValue; DateTime?Months = Funs.GetNewDateTime(this.txtMonth.Text); this.HSSECostManageId = string.Empty; this.HSSECostUnitManageId = string.Empty; decimal pMainIncome = 0, pConstructionIncome = 0, pSafetyCosts = 0; var sumHsseCostMange = from x in Funs.DB.CostGoods_HSSECostManage where x.ProjectId == this.ProjectId && x.Month < Months select x; if (sumHsseCostMange.Count() > 0) { pMainIncome = sumHsseCostMange.Sum(x => x.MainIncome) ?? 0; pConstructionIncome = sumHsseCostMange.Sum(x => x.ConstructionIncome) ?? 0; pSafetyCosts = sumHsseCostMange.Sum(x => x.SafetyCosts) ?? 0; } Model.CostGoods_HSSECostUnitManage hsseCostUnitManage = new Model.CostGoods_HSSECostUnitManage(); var hsseCostManage = Funs.DB.CostGoods_HSSECostManage.FirstOrDefault(x => x.ProjectId == this.ProjectId && x.Month.Value.Year == Months.Value.Year && x.Month.Value.Month == Months.Value.Month); if (hsseCostManage != null) { this.HSSECostManageId = hsseCostManage.HSSECostManageId; this.txtCode.Text = BLL.CodeRecordsService.ReturnCodeByDataId(hsseCostManage.HSSECostManageId); this.txtReportDate.Text = string.Format("{0:yyyy-MM-dd}", hsseCostManage.ReportDate); this.txtMainIncome.Text = hsseCostManage.MainIncome.ToString(); this.txtProjectMainIncome.Text = (pMainIncome + hsseCostManage.MainIncome ?? 0).ToString(); this.txtRemark1.Text = hsseCostManage.Remark1; this.txtConstructionIncome.Text = hsseCostManage.ConstructionIncome.ToString(); this.txtProjectConstructionIncome.Text = (pConstructionIncome + hsseCostManage.ConstructionIncome ?? 0).ToString(); this.txtRemark2.Text = hsseCostManage.Remark2; this.txtSafetyCosts.Text = hsseCostManage.SafetyCosts.ToString(); this.txtProjectSafetyCosts.Text = (pSafetyCosts + hsseCostManage.SafetyCosts ?? 0).ToString(); this.txtRemark3.Text = hsseCostManage.Remark3; hsseCostUnitManage = (from x in Funs.DB.CostGoods_HSSECostUnitManage join y in Funs.DB.CostGoods_HSSECostManage on x.HSSECostManageId equals y.HSSECostManageId where x.UnitId == this.drpUnitId.SelectedValue && y.HSSECostManageId == this.HSSECostManageId select x).FirstOrDefault(); } else { this.txtReportDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); this.txtCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectHSSECostManageMenuId, this.ProjectId, string.Empty); this.txtMainIncome.Text = "0"; this.txtConstructionIncome.Text = "0"; this.txtSafetyCosts.Text = "0"; this.txtProjectMainIncome.Text = pMainIncome.ToString(); this.txtProjectConstructionIncome.Text = pConstructionIncome.ToString(); this.txtProjectSafetyCosts.Text = pSafetyCosts.ToString(); hsseCostUnitManage = (from x in Funs.DB.CostGoods_HSSECostUnitManage join y in Funs.DB.CostGoods_HSSECostManage on x.HSSECostManageId equals y.HSSECostManageId where x.UnitId == this.drpUnitId.SelectedValue && y.ProjectId == this.ProjectId && y.Month.Value.Year == Months.Value.Year && y.Month.Value.Month == Months.Value.Month select x).FirstOrDefault(); } this.InitTextUnitValue(hsseCostUnitManage); }