/// <summary> /// 单位变化事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void drpUnitId_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpUnitId.SelectedValue != BLL.Const._Null) { Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(this.ProjectId); DateTime? date = Funs.GetNewDateTime(this.drpYear.SelectedValue + "-" + this.drpMonths.SelectedValue + "-01"); if (project != null && date.HasValue) { List <Model.CostGoods_CostSmallDetailItem> projectDetails = BLL.CostSmallDetailItemService.GetCostDetailsByUnitId(this.CurrUser.LoginProjectId, this.drpUnitId.SelectedValue, project != null ? project.StartDate : null, date); this.hdProjectA1.Text = (from x in projectDetails where x.CostType == "A1" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectA2.Text = (from x in projectDetails where x.CostType == "A2" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectA3.Text = (from x in projectDetails where x.CostType == "A3" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectA4.Text = (from x in projectDetails where x.CostType == "A4" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectA5.Text = (from x in projectDetails where x.CostType == "A5" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectA6.Text = (from x in projectDetails where x.CostType == "A6" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectB1.Text = (from x in projectDetails where x.CostType == "B1" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectB2.Text = (from x in projectDetails where x.CostType == "B2" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectB3.Text = (from x in projectDetails where x.CostType == "B3" select x.CostMoney ?? 0).Sum().ToString(); } } else { this.hdProjectA1.Text = "0"; this.hdProjectA2.Text = "0"; this.hdProjectA3.Text = "0"; this.hdProjectA4.Text = "0"; this.hdProjectA5.Text = "0"; this.hdProjectA6.Text = "0"; this.hdProjectB1.Text = "0"; this.hdProjectB2.Text = "0"; this.hdProjectB3.Text = "0"; } }
/// <summary> /// 单位变化事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void drpUnitId_SelectedIndexChanged(object sender, EventArgs e) { if (this.drpUnitId.SelectedValue != BLL.Const._Null) { Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(this.ProjectId); List <Model.CostGoods_ExpenseDetail> projectDetails = BLL.ExpenseDetailService.GetCostDetailsByUnitId(this.drpUnitId.SelectedValue, project != null ? Convert.ToDateTime(project.StartDate) : Convert.ToDateTime("2000-01-01"), Convert.ToDateTime(this.drpYear.SelectedValue + "-" + this.drpMonths.SelectedValue + "-01")); this.hdProjectA1.Text = (from x in projectDetails where x.CostType == "A1" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectA2.Text = (from x in projectDetails where x.CostType == "A2" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectA3.Text = (from x in projectDetails where x.CostType == "A3" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectA4.Text = (from x in projectDetails where x.CostType == "A4" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectA5.Text = (from x in projectDetails where x.CostType == "A5" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectA6.Text = (from x in projectDetails where x.CostType == "A6" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectB1.Text = (from x in projectDetails where x.CostType == "B1" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectB2.Text = (from x in projectDetails where x.CostType == "B2" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectB3.Text = (from x in projectDetails where x.CostType == "B3" select x.CostMoney ?? 0).Sum().ToString(); } else { this.hdProjectA1.Text = "0"; this.hdProjectA2.Text = "0"; this.hdProjectA3.Text = "0"; this.hdProjectA4.Text = "0"; this.hdProjectA5.Text = "0"; this.hdProjectA6.Text = "0"; this.hdProjectB1.Text = "0"; this.hdProjectB2.Text = "0"; this.hdProjectB3.Text = "0"; } }
/// <summary> /// 根据项目和安全资料项生成企业安全管理资料计划总表 /// </summary> /// <param name="safetyDataPlanId"></param> public static void GetSafetyDataPlanByProjectInfo(string projectId, string safetyDataId, DateTime?startTime, DateTime?endTime) { Model.SUBHSSEDB db = Funs.DB; List <Model.SafetyData_SafetyData> safetyDataEnd = new List <Model.SafetyData_SafetyData>(); ///是否更新某一个安全资料项 先删除 再重新生成 DeleteSafetyDataPlanBySafetyDataId(safetyDataId); //if (!isDelete(projectId, safetyDataId)) //{ if (!string.IsNullOrEmpty(safetyDataId)) { safetyDataEnd = (from x in db.SafetyData_SafetyData where x.IsEndLever == true && x.SafetyDataId == safetyDataId && x.IsCheck == true orderby x.Code select x).ToList(); } else { safetyDataEnd = (from x in db.SafetyData_SafetyData where x.IsEndLever == true && x.IsCheck == true orderby x.Code select x).ToList(); } ///是否存在安全资料项 if (safetyDataEnd.Count() > 0) { Model.Base_Project project = new Model.Base_Project(); if (!string.IsNullOrEmpty(projectId)) { project = BLL.ProjectService.GetProjectByProjectId(projectId); if (project != null) { GetSafetyDataPlanMethod(project, safetyDataEnd, startTime, endTime); } } else { ///取竣工时间大于当前时间 项目 var projects = from x in db.Base_Project where x.EndDate >= System.DateTime.Now && x.ProjectType != "5" select x; if (projects.Count() > 0) { foreach (var item in projects) { GetSafetyDataPlanMethod(item, safetyDataEnd, startTime, endTime); } } } } //} }
/// <summary> /// 根据项目Id返回对应的所属单位及上级UnitIdLists /// </summary> /// <returns></returns> public static List <string> GetUnitIdListsByProject(Model.Base_Project project) { List <string> unitIdList = new List <string>(); if (project != null) { if (!string.IsNullOrEmpty(project.UnitId)) { unitIdList.Add(project.UnitId); List <string> supUnitId = GetSupUnitId(project.UnitId); if (supUnitId.Count > 0) { unitIdList.AddRange(supUnitId); } } } return(unitIdList); }
/// <summary> /// 加载页面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ProjectId = this.CurrUser.LoginProjectId; this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.hdProjectA1.Text = "0"; this.hdProjectA2.Text = "0"; this.hdProjectA3.Text = "0"; this.hdProjectA4.Text = "0"; this.hdProjectA5.Text = "0"; this.hdProjectA6.Text = "0"; this.hdProjectB1.Text = "0"; this.hdProjectB2.Text = "0"; this.hdProjectB3.Text = "0"; this.InitDropDownList(); this.CostSmallDetailId = Request.Params["CostSmallDetailId"]; if (!string.IsNullOrEmpty(this.CostSmallDetailId)) { Model.CostGoods_CostSmallDetail costSmallDetail = BLL.CostSmallDetailService.GetCostSmallDetailById(this.CostSmallDetailId); if (costSmallDetail != null) { this.ProjectId = costSmallDetail.ProjectId; if (this.ProjectId != this.CurrUser.LoginProjectId) { this.InitDropDownList(); } if (costSmallDetail.Months != null) { //this.txtMonths.Text = string.Format("{0:yyyy-MM}", costSmallDetail.Months); this.drpYear.SelectedValue = Convert.ToString(costSmallDetail.Months.Value.Year); this.drpMonths.SelectedValue = Convert.ToString(costSmallDetail.Months.Value.Month); } this.txtCostSmallDetailCode.Text = CodeRecordsService.ReturnCodeByDataId(this.CostSmallDetailId); if (!string.IsNullOrEmpty(costSmallDetail.UnitId)) { this.drpUnitId.SelectedValue = costSmallDetail.UnitId; } if (costSmallDetail.ReportDate != null) { this.txtReportDate.Text = string.Format("{0:yyyy-MM-dd}", costSmallDetail.ReportDate); } //this.txtCompileMan.Text = costSmallDetail.CompileMan; //if (costSmallDetail.CompileDate != null) //{ // this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", costSmallDetail.CompileDate); //} //this.txtCheckMan.Text = costSmallDetail.CheckMan; //if (costSmallDetail.CheckDate != null) //{ // this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", costSmallDetail.CheckDate); //} //this.txtApproveMan.Text = costSmallDetail.ApproveMan; //if (costSmallDetail.ApproveDate != null) //{ // this.txtApproveDate.Text = string.Format("{0:yyyy-MM-dd}", costSmallDetail.ApproveDate); //} decimal totalA = 0, totalB = 0, totalProjectA = 0, totalProjectB = 0; Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(this.ProjectId); if (project != null && costSmallDetail.Months.HasValue) { List <Model.CostGoods_CostSmallDetailItem> projectDetails = BLL.CostSmallDetailItemService.GetCostDetailsByUnitId(this.CurrUser.LoginProjectId, costSmallDetail.UnitId, project != null ? project.StartDate : null, Convert.ToDateTime(costSmallDetail.Months)); List <Model.CostGoods_CostSmallDetailItem> details = BLL.CostSmallDetailItemService.GetCostSmallDetailItemByCostSmallDetailId(this.CostSmallDetailId); Model.CostGoods_CostSmallDetailItem a1 = details.FirstOrDefault(x => x.CostType == "A1"); this.hdProjectA1.Text = (from x in projectDetails where x.CostType == "A1" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectA2.Text = (from x in projectDetails where x.CostType == "A2" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectA3.Text = (from x in projectDetails where x.CostType == "A3" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectA4.Text = (from x in projectDetails where x.CostType == "A4" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectA5.Text = (from x in projectDetails where x.CostType == "A5" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectA6.Text = (from x in projectDetails where x.CostType == "A6" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectB1.Text = (from x in projectDetails where x.CostType == "B1" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectB2.Text = (from x in projectDetails where x.CostType == "B2" select x.CostMoney ?? 0).Sum().ToString(); this.hdProjectB3.Text = (from x in projectDetails where x.CostType == "B3" select x.CostMoney ?? 0).Sum().ToString(); if (a1 != null) { this.nbA1.Text = (a1.CostMoney ?? 0).ToString(); totalA += Funs.GetNewDecimalOrZero(this.nbA1.Text); this.nbProjectA1.Text = ((from x in projectDetails where x.CostType == "A1" select x.CostMoney ?? 0).Sum() + a1.CostMoney ?? 0).ToString(); totalProjectA += Funs.GetNewDecimalOrZero(this.nbProjectA1.Text); this.txtDefA1.Text = a1.CostDef; } Model.CostGoods_CostSmallDetailItem a2 = details.FirstOrDefault(x => x.CostType == "A2"); if (a2 != null) { this.nbA2.Text = (a2.CostMoney ?? 0).ToString(); totalA += Funs.GetNewDecimalOrZero(this.nbA2.Text); this.nbProjectA2.Text = ((from x in projectDetails where x.CostType == "A2" select x.CostMoney ?? 0).Sum() + a2.CostMoney ?? 0).ToString(); totalProjectA += Funs.GetNewDecimalOrZero(this.nbProjectA2.Text); this.txtDefA2.Text = a2.CostDef; } Model.CostGoods_CostSmallDetailItem a3 = details.FirstOrDefault(x => x.CostType == "A3"); if (a3 != null) { this.nbA3.Text = (a3.CostMoney ?? 0).ToString(); totalA += Funs.GetNewDecimalOrZero(this.nbA3.Text); this.nbProjectA3.Text = ((from x in projectDetails where x.CostType == "A3" select x.CostMoney ?? 0).Sum() + a3.CostMoney ?? 0).ToString(); totalProjectA += Funs.GetNewDecimalOrZero(this.nbProjectA3.Text); this.txtDefA3.Text = a3.CostDef; } Model.CostGoods_CostSmallDetailItem a4 = details.FirstOrDefault(x => x.CostType == "A4"); if (a4 != null) { this.nbA4.Text = (a4.CostMoney ?? 0).ToString(); totalA += Funs.GetNewDecimalOrZero(this.nbA4.Text); this.nbProjectA4.Text = ((from x in projectDetails where x.CostType == "A4" select x.CostMoney ?? 0).Sum() + a4.CostMoney ?? 0).ToString(); totalProjectA += Funs.GetNewDecimalOrZero(this.nbProjectA4.Text); this.txtDefA4.Text = a4.CostDef; } Model.CostGoods_CostSmallDetailItem a5 = details.FirstOrDefault(x => x.CostType == "A5"); if (a5 != null) { this.nbA5.Text = (a5.CostMoney ?? 0).ToString(); totalA += Funs.GetNewDecimalOrZero(this.nbA5.Text); this.nbProjectA5.Text = ((from x in projectDetails where x.CostType == "A5" select x.CostMoney ?? 0).Sum() + a5.CostMoney ?? 0).ToString(); totalProjectA += Funs.GetNewDecimalOrZero(this.nbProjectA5.Text); this.txtDefA5.Text = a5.CostDef; } Model.CostGoods_CostSmallDetailItem a6 = details.FirstOrDefault(x => x.CostType == "A6"); if (a6 != null) { this.nbA6.Text = (a6.CostMoney ?? 0).ToString(); totalA += Funs.GetNewDecimalOrZero(this.nbA6.Text); this.nbProjectA6.Text = ((from x in projectDetails where x.CostType == "A6" select x.CostMoney ?? 0).Sum() + a6.CostMoney ?? 0).ToString(); totalProjectA += Funs.GetNewDecimalOrZero(this.nbProjectA6.Text); this.txtDefA6.Text = a6.CostDef; } this.nbA.Text = totalA.ToString(); this.nbProjectA.Text = totalProjectA.ToString(); Model.CostGoods_CostSmallDetailItem b1 = details.FirstOrDefault(x => x.CostType == "B1"); if (b1 != null) { this.nbB1.Text = (b1.CostMoney ?? 0).ToString(); totalB += Funs.GetNewDecimalOrZero(this.nbB1.Text); this.nbProjectB1.Text = ((from x in projectDetails where x.CostType == "B1" select x.CostMoney ?? 0).Sum() + b1.CostMoney ?? 0).ToString(); totalProjectB += Funs.GetNewDecimalOrZero(this.nbProjectB1.Text); this.txtDefB1.Text = b1.CostDef; } Model.CostGoods_CostSmallDetailItem b2 = details.FirstOrDefault(x => x.CostType == "B2"); if (b2 != null) { this.nbB2.Text = (b2.CostMoney ?? 0).ToString(); totalB += Funs.GetNewDecimalOrZero(this.nbB2.Text); this.nbProjectB2.Text = ((from x in projectDetails where x.CostType == "B2" select x.CostMoney ?? 0).Sum() + b2.CostMoney ?? 0).ToString(); totalProjectB += Funs.GetNewDecimalOrZero(this.nbProjectB2.Text); this.txtDefB2.Text = b2.CostDef; } Model.CostGoods_CostSmallDetailItem b3 = details.FirstOrDefault(x => x.CostType == "B3"); if (b3 != null) { this.nbB3.Text = (b3.CostMoney ?? 0).ToString(); totalB += Funs.GetNewDecimalOrZero(this.nbB3.Text); this.nbProjectB3.Text = ((from x in projectDetails where x.CostType == "B3" select x.CostMoney ?? 0).Sum() + b3.CostMoney ?? 0).ToString(); totalProjectB += Funs.GetNewDecimalOrZero(this.nbProjectB3.Text); this.txtDefB3.Text = b3.CostDef; } this.nbB.Text = totalB.ToString(); this.nbProjectB.Text = totalProjectB.ToString(); this.nbAB.Text = (totalA + totalB).ToString(); this.nbProjectAB.Text = (totalProjectA + totalProjectB).ToString(); } } } else { this.drpYear.SelectedValue = Convert.ToString(DateTime.Now.Year); this.drpMonths.SelectedValue = Convert.ToString(DateTime.Now.Month); //this.txtMonths.Text = DateTime.Now.ToString("yyyy-MM"); //this.txtCompileMan.Text = this.CurrUser.UserName; this.txtReportDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); //this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); this.txtCostSmallDetailCode.Text = CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectCostSmallDetailMenuId, this.ProjectId, this.CurrUser.UnitId); } ///初始化审核菜单 this.ctlAuditFlow.MenuId = BLL.Const.ProjectCostSmallDetailMenuId; this.ctlAuditFlow.DataId = this.CostSmallDetailId; this.ctlAuditFlow.ProjectId = this.ProjectId; this.ctlAuditFlow.UnitId = this.CurrUser.UnitId; } }
/// <summary> /// 加载页面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.ExpenseId = Request.Params["ExpenseId"]; if (!string.IsNullOrEmpty(this.ExpenseId)) { Model.CostGoods_Expense expense = BLL.ExpenseService.GetExpenseById(this.ExpenseId); if (expense != null) { this.txtExpenseCode.Text = CodeRecordsService.ReturnCodeByDataId(this.ExpenseId); if (expense.Months != null) { this.txtMonths.Text = string.Format("{0:yyyy-MM}", expense.Months); } if (!string.IsNullOrEmpty(expense.UnitId)) { Model.Base_Unit unit = BLL.UnitService.GetUnitByUnitId(expense.UnitId); if (unit != null) { this.drpUnitId.Text = unit.UnitName; } } if (expense.ReportDate != null) { this.txtReportDate.Text = string.Format("{0:yyyy-MM-dd}", expense.ReportDate); } //this.txtCompileMan.Text = expense.CompileMan; //if (expense.CompileDate != null) //{ // this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", expense.CompileDate); //} //this.txtCheckMan.Text = expense.CheckMan; //if (expense.CheckDate != null) //{ // this.txtCheckDate.Text = string.Format("{0:yyyy-MM-dd}", expense.CheckDate); //} //this.txtApproveMan.Text = expense.ApproveMan; //if (expense.ApproveDate != null) //{ // this.txtApproveDate.Text = string.Format("{0:yyyy-MM-dd}", expense.ApproveDate); //} decimal totalA = 0, totalB = 0, totalProjectA = 0, totalProjectB = 0; Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(expense.ProjectId); List <Model.CostGoods_ExpenseDetail> projectDetails = BLL.ExpenseDetailService.GetCostDetailsByUnitId(expense.UnitId, project != null ? Convert.ToDateTime(project.StartDate) : Convert.ToDateTime("2000-01-01"), Convert.ToDateTime(expense.Months)); List <Model.CostGoods_ExpenseDetail> details = BLL.ExpenseDetailService.GetExpenseDetailsByExpenseId(this.ExpenseId); Model.CostGoods_ExpenseDetail a1 = details.FirstOrDefault(x => x.CostType == "A1"); if (a1 != null) { this.nbA1.Text = (a1.CostMoney ?? 0).ToString(); totalA += Funs.GetNewDecimalOrZero(this.nbA1.Text); this.nbProjectA1.Text = ((from x in projectDetails where x.CostType == "A1" select x.CostMoney ?? 0).Sum() + a1.CostMoney ?? 0).ToString(); totalProjectA += Funs.GetNewDecimalOrZero(this.nbProjectA1.Text); this.txtDefA1.Text = a1.CostDef; } Model.CostGoods_ExpenseDetail a2 = details.FirstOrDefault(x => x.CostType == "A2"); if (a2 != null) { this.nbA2.Text = (a2.CostMoney ?? 0).ToString(); totalA += Funs.GetNewDecimalOrZero(this.nbA2.Text); this.nbProjectA2.Text = ((from x in projectDetails where x.CostType == "A2" select x.CostMoney ?? 0).Sum() + a2.CostMoney ?? 0).ToString(); totalProjectA += Funs.GetNewDecimalOrZero(this.nbProjectA2.Text); this.txtDefA2.Text = a2.CostDef; } Model.CostGoods_ExpenseDetail a3 = details.FirstOrDefault(x => x.CostType == "A3"); if (a3 != null) { this.nbA3.Text = (a3.CostMoney ?? 0).ToString(); totalA += Funs.GetNewDecimalOrZero(this.nbA3.Text); this.nbProjectA3.Text = ((from x in projectDetails where x.CostType == "A3" select x.CostMoney ?? 0).Sum() + a3.CostMoney ?? 0).ToString(); totalProjectA += Funs.GetNewDecimalOrZero(this.nbProjectA3.Text); this.txtDefA3.Text = a3.CostDef; } Model.CostGoods_ExpenseDetail a4 = details.FirstOrDefault(x => x.CostType == "A4"); if (a4 != null) { this.nbA4.Text = (a4.CostMoney ?? 0).ToString(); totalA += Funs.GetNewDecimalOrZero(this.nbA4.Text); this.nbProjectA4.Text = ((from x in projectDetails where x.CostType == "A4" select x.CostMoney ?? 0).Sum() + a4.CostMoney ?? 0).ToString(); totalProjectA += Funs.GetNewDecimalOrZero(this.nbProjectA4.Text); this.txtDefA4.Text = a4.CostDef; } Model.CostGoods_ExpenseDetail a5 = details.FirstOrDefault(x => x.CostType == "A5"); if (a5 != null) { this.nbA5.Text = (a5.CostMoney ?? 0).ToString(); totalA += Funs.GetNewDecimalOrZero(this.nbA5.Text); this.nbProjectA5.Text = ((from x in projectDetails where x.CostType == "A5" select x.CostMoney ?? 0).Sum() + a5.CostMoney ?? 0).ToString(); totalProjectA += Funs.GetNewDecimalOrZero(this.nbProjectA5.Text); this.txtDefA5.Text = a5.CostDef; } Model.CostGoods_ExpenseDetail a6 = details.FirstOrDefault(x => x.CostType == "A6"); if (a6 != null) { this.nbA6.Text = (a6.CostMoney ?? 0).ToString(); totalA += Funs.GetNewDecimalOrZero(this.nbA6.Text); this.nbProjectA6.Text = ((from x in projectDetails where x.CostType == "A6" select x.CostMoney ?? 0).Sum() + a6.CostMoney ?? 0).ToString(); totalProjectA += Funs.GetNewDecimalOrZero(this.nbProjectA6.Text); this.txtDefA6.Text = a6.CostDef; } this.nbA.Text = totalA.ToString(); this.nbProjectA.Text = totalProjectA.ToString(); Model.CostGoods_ExpenseDetail b1 = details.FirstOrDefault(x => x.CostType == "B1"); if (b1 != null) { this.nbB1.Text = (b1.CostMoney ?? 0).ToString(); totalB += Funs.GetNewDecimalOrZero(this.nbB1.Text); this.nbProjectB1.Text = ((from x in projectDetails where x.CostType == "B1" select x.CostMoney ?? 0).Sum() + b1.CostMoney ?? 0).ToString(); totalProjectB += Funs.GetNewDecimalOrZero(this.nbProjectB1.Text); this.txtDefB1.Text = b1.CostDef; } Model.CostGoods_ExpenseDetail b2 = details.FirstOrDefault(x => x.CostType == "B2"); if (b2 != null) { this.nbB2.Text = (b2.CostMoney ?? 0).ToString(); totalB += Funs.GetNewDecimalOrZero(this.nbB2.Text); this.nbProjectB2.Text = ((from x in projectDetails where x.CostType == "B2" select x.CostMoney ?? 0).Sum() + b2.CostMoney ?? 0).ToString(); totalProjectB += Funs.GetNewDecimalOrZero(this.nbProjectB2.Text); this.txtDefB2.Text = b2.CostDef; } Model.CostGoods_ExpenseDetail b3 = details.FirstOrDefault(x => x.CostType == "B3"); if (b3 != null) { this.nbB3.Text = (b3.CostMoney ?? 0).ToString(); totalB += Funs.GetNewDecimalOrZero(this.nbB3.Text); this.nbProjectB3.Text = ((from x in projectDetails where x.CostType == "B3" select x.CostMoney ?? 0).Sum() + b3.CostMoney ?? 0).ToString(); totalProjectB += Funs.GetNewDecimalOrZero(this.nbProjectB3.Text); this.txtDefB3.Text = b3.CostDef; } this.nbB.Text = totalB.ToString(); this.nbProjectB.Text = totalProjectB.ToString(); this.nbAB.Text = (totalA + totalB).ToString(); this.nbProjectAB.Text = (totalProjectA + totalProjectB).ToString(); } } ///初始化审核菜单 this.ctlAuditFlow.MenuId = BLL.Const.ProjectExpenseMenuId; this.ctlAuditFlow.DataId = this.ExpenseId; } }
/// <summary> /// 加载页面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var thisunit = BLL.CommonService.GetIsThisUnit(); if (thisunit != null && !string.IsNullOrEmpty(thisunit.UnitCode)) { string url = "../Images/SUBimages/" + thisunit.UnitCode + ".gif"; if (url.Contains('*')) { url = url.Replace('*', '-'); } this.image.Src = url; } this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.AccidentReportOtherId = Request.Params["AccidentReportOtherId"]; if (!string.IsNullOrEmpty(this.AccidentReportOtherId)) { Model.Accident_AccidentReportOther accidentReportOther = BLL.AccidentReportOtherService.GetAccidentReportOtherById(this.AccidentReportOtherId); if (accidentReportOther != null) { Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(accidentReportOther.ProjectId); if (project != null) { this.lblProjectName.Text = project.ProjectName; this.lblProjectCode.Text = project.ProjectCode; } this.txtAccidentReportOtherCode.Text = accidentReportOther.AccidentReportOtherCode; if (!string.IsNullOrEmpty(accidentReportOther.AccidentTypeId)) { Model.Sys_Const c = BLL.ConstValue.drpConstItemList(BLL.ConstValue.Group_AccidentInvestigationProcessingReport).FirstOrDefault(x => x.ConstValue == accidentReportOther.AccidentTypeId); if (c != null) { this.txtAccidentTypeName.Text = c.ConstText; } } this.txtAbstract.Text = accidentReportOther.Abstract; if (accidentReportOther.AccidentDate != null) { this.txtAccidentDate.Text = string.Format("{0:yyyy-MM-dd}", accidentReportOther.AccidentDate); } this.txtWorkAreaName.Text = accidentReportOther.WorkArea; } if (accidentReportOther.PeopleNum != null) { this.txtPeopleNum.Text = Convert.ToString(accidentReportOther.PeopleNum); } if (!string.IsNullOrEmpty(accidentReportOther.UnitId)) { var unit = BLL.UnitService.GetUnitByUnitId(accidentReportOther.UnitId); if (unit != null) { this.txtUnitName.Text = unit.UnitName; } } if (accidentReportOther.EconomicLoss != null) { this.txtEconomicLoss.Text = Convert.ToString(accidentReportOther.EconomicLoss); } if (accidentReportOther.EconomicOtherLoss != null) { this.txtEconomicOtherLoss.Text = Convert.ToString(accidentReportOther.EconomicOtherLoss); } this.txtReportMan.Text = accidentReportOther.ReportMan; this.txtReporterUnit.Text = accidentReportOther.ReporterUnit; if (accidentReportOther.ReportDate != null) { this.txtReportDate.Text = string.Format("{0:yyyy-MM-dd}", accidentReportOther.ReportDate); } this.txtProcessDescription.Text = accidentReportOther.ProcessDescription; this.txtEmergencyMeasures.Text = accidentReportOther.EmergencyMeasures; this.txtImmediateCause.Text = accidentReportOther.ImmediateCause; this.txtIndirectReason.Text = accidentReportOther.IndirectReason; this.txtCorrectivePreventive.Text = accidentReportOther.CorrectivePreventive; if (!string.IsNullOrEmpty(accidentReportOther.CompileMan)) { var user = BLL.UserService.GetUserByUserId(accidentReportOther.CompileMan); if (user != null) { this.txtCompileManName.Text = user.UserName; } } if (accidentReportOther.CompileDate != null) { this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", accidentReportOther.CompileDate); } } BindGrid(); } }
/// <summary> /// 加载页面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { var unit = BLL.CommonService.GetIsThisUnit(); if (unit != null && !string.IsNullOrEmpty(unit.UnitCode)) { string url = "../Images/SUBimages/" + unit.UnitCode + ".gif"; if (url.Contains('*')) { url = url.Replace('*', '-'); } this.image.Src = url; } this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.AccidentReportId = Request.Params["AccidentReportId"]; if (!string.IsNullOrEmpty(this.AccidentReportId)) { Model.Accident_AccidentReport accidentReport = BLL.AccidentReport2Service.GetAccidentReportById(this.AccidentReportId); if (accidentReport != null) { this.txtAccidentReportCode.Text = BLL.CodeRecordsService.ReturnCodeByDataId(this.AccidentReportId); this.txtUnitName.Text = BLL.UnitService.GetUnitNameByUnitId(accidentReport.UnitId); this.txtCompileManName.Text = BLL.UserService.GetUserNameByUserId(accidentReport.CompileMan); Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(accidentReport.ProjectId); if (project != null) { this.lblProjectName.Text = project.ProjectName; this.lblProjectCode.Text = project.ProjectCode; } if (accidentReport.CompileDate != null) { this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", accidentReport.CompileDate); } if (!string.IsNullOrEmpty(accidentReport.AccidentTypeId)) { Model.Sys_Const c = BLL.ConstValue.drpConstItemList(BLL.ConstValue.Group_AccidentReportRegistration).FirstOrDefault(x => x.ConstValue == accidentReport.AccidentTypeId); if (c != null) { this.txtAccidentTypeName.Text = c.ConstText; } if (accidentReport.IsNotConfirm != null) { this.txtIsNotConfirm.Visible = false; this.txtIsNotConfirm.Text = accidentReport.IsNotConfirm == true ? "是" : "否"; } } this.txtAbstract.Text = accidentReport.Abstract; if (accidentReport.AccidentDate != null) { this.txtAccidentDate.Text = string.Format("{0:yyyy-MM-dd}", accidentReport.AccidentDate); } this.txtWorkAreaName.Text = accidentReport.WorkArea; if (accidentReport.PeopleNum != null) { this.txtPeopleNum.Text = Convert.ToString(accidentReport.PeopleNum); } if (accidentReport.IsNotConfirm == true) //待定 { this.txtWorkingHoursLoss.Text = accidentReport.NotConfirmWorkingHoursLoss; this.txtEconomicLoss.Text = accidentReport.NotConfirmEconomicLoss; this.txtEconomicOtherLoss.Text = accidentReport.NotConfirmEconomicOtherLoss; } else { if (accidentReport.WorkingHoursLoss != null) { this.txtWorkingHoursLoss.Text = Convert.ToString(accidentReport.WorkingHoursLoss); } if (accidentReport.EconomicLoss != null) { this.txtEconomicLoss.Text = Convert.ToString(accidentReport.EconomicLoss); } if (accidentReport.EconomicOtherLoss != null) { this.txtEconomicOtherLoss.Text = Convert.ToString(accidentReport.EconomicOtherLoss); } } this.txtReportMan.Text = accidentReport.ReportMan; this.txtReporterUnit.Text = accidentReport.ReporterUnit; if (accidentReport.ReportDate != null) { this.txtReportDate.Text = string.Format("{0:yyyy-MM-dd}", accidentReport.ReportDate); } this.txtProcessDescription.Text = accidentReport.ProcessDescription; this.txtEmergencyMeasures.Text = accidentReport.EmergencyMeasures; } } } }
/// <summary> /// 生成安全资料计划总表 方法 /// </summary> /// <param name="project"></param> /// <param name="safetyDataEnd"></param> public static void GetSafetyDataPlanMethod(Model.Base_Project project, List <Model.SafetyData_SafetyData> safetyDataEnd, DateTime?startTime, DateTime?endTime) { ////第一步 判断是否存在此项目的计划表 ////第二步 不存在增加这个项目时间范围内的 存在取不存在时间段 ////第三步 项目时间 是否为空? 现在默认都不能为空 Model.SUBHSSEDB db = Funs.DB; string projectId = project.ProjectId; DateTime startDatep = project.StartDate.HasValue ? project.StartDate.Value : System.DateTime.Now; if (startTime.HasValue) { startDatep = startTime.Value; } DateTime startDate = startDatep; DateTime endDate = project.EndDate.HasValue ? project.EndDate.Value : System.DateTime.Now.AddMonths(6); if (endTime.HasValue) { endDate = endTime.Value; } DeleteSafetyDataPlanByProjectDateId(projectId, endDate); ///删除竣工后的考核计划 foreach (var item in safetyDataEnd) { var safetyDataPlan = db.SafetyData_SafetyDataPlan.FirstOrDefault(x => x.ProjectId == project.ProjectId && x.SafetyDataId == item.SafetyDataId && (x.IsManual == null || x.IsManual == false)); if (safetyDataPlan != null) { ///取结束时间 最大值作为开始时间 DateTime maxEndDate = Funs.DB.SafetyData_SafetyDataPlan.Where(x => x.ProjectId == projectId && x.RealEndDate.HasValue && x.SafetyDataId == item.SafetyDataId).Select(x => x.RealEndDate.Value).Max(); if (endDate > maxEndDate) ////如果计划单最大时间小于项目结束时间 则追加时间 否则删去 { startDate = maxEndDate; } else { ///项目提前结束 则删除计划时间 var delSafetyDataPlan = from x in db.SafetyData_SafetyDataPlan where x.RealEndDate > endDate && x.SafetyDataId == item.SafetyDataId select x; if (delSafetyDataPlan.Count() > 0) { db.SafetyData_SafetyDataPlan.DeleteAllOnSubmit(delSafetyDataPlan); } } } ////算出 开始、结束时间跨度 然后循环增加一个月 并把在此时间段的 考核项写入计划表 for (int i = 0; startDate.AddMonths(i) <= endDate; i++) { Model.SafetyData_SafetyDataPlan newSafetyDataPlan = new Model.SafetyData_SafetyDataPlan { SafetyDataPlanId = SQLHelper.GetNewID(typeof(Model.SafetyData_SafetyDataPlan)), ProjectId = projectId, SafetyDataId = item.SafetyDataId, Score = item.Score, ShouldScore = item.Score, Remark = item.Remark, }; int monthValue = 0; ///设置月数 if (item.CheckTypeValue1.HasValue) { monthValue = item.CheckTypeValue1.Value; } int dateValue = 1; ///设置天 if (item.CheckTypeValue2.HasValue) { dateValue = item.CheckTypeValue2.Value; if (dateValue > 30) { dateValue = 30; } } ////TODO:通过判断是月报、季报、定时报等情况 是否落在 当前时间范围内 写入到计划总表 if (item.CheckType == BLL.Const.SafetyDataCheckType_1) /// 月报 { if (startDate.AddMonths(i + monthValue).Month == 2 && dateValue > 28) { dateValue = 28; } DateTime?checkDate = Funs.GetNewDateTime(startDate.AddMonths(i + monthValue).Year + "-" + startDate.AddMonths(i + monthValue).Month + "-" + dateValue); if (checkDate.HasValue && checkDate <= endDate && checkDate >= startDatep) { newSafetyDataPlan.CheckDate = checkDate; newSafetyDataPlan.RealStartDate = checkDate.Value.AddMonths(-1); ///月报开始日期 newSafetyDataPlan.RealStartDate = new DateTime(newSafetyDataPlan.RealStartDate.Value.Year, newSafetyDataPlan.RealStartDate.Value.Month, 1); newSafetyDataPlan.RealEndDate = newSafetyDataPlan.RealStartDate.Value.AddMonths(1).AddDays(-1); } } else if (item.CheckType == BLL.Const.SafetyDataCheckType_2) /// 季报 { int month = startDate.AddMonths(i).Month; ///当前月份 if ((month == 3 + monthValue) || (month == 6 + monthValue) || (month == 9 + monthValue) || (month == monthValue) || (month == 12 && monthValue == 0)) ///考核季度时间 { if (startDate.AddMonths(i + monthValue).Month == 2 && dateValue > 28) { dateValue = 28; } DateTime?checkDate = Funs.GetNewDateTime(startDate.AddMonths(i).Year + "-" + startDate.AddMonths(i).Month + "-" + dateValue); if ((month == monthValue) && monthValue != 0) { checkDate = checkDate.Value.AddYears(1); } if (checkDate.HasValue && checkDate <= endDate && checkDate >= startDatep) { newSafetyDataPlan.CheckDate = checkDate; newSafetyDataPlan.RealStartDate = checkDate.Value.AddMonths(-3); ///开始日期 newSafetyDataPlan.RealStartDate = new DateTime(newSafetyDataPlan.RealStartDate.Value.Year, newSafetyDataPlan.RealStartDate.Value.Month, 1); newSafetyDataPlan.RealEndDate = newSafetyDataPlan.RealStartDate.Value.AddMonths(3).AddDays(-1); } } } else if (item.CheckType == BLL.Const.SafetyDataCheckType_3) /// 定时 { if (startDate.AddMonths(i).Month == monthValue) ///定时月份 { if (startDate.AddMonths(i + monthValue).Month == 2 && dateValue > 28) { dateValue = 28; } DateTime?checkDate = Funs.GetNewDateTime(startDate.AddMonths(i).Year + "-" + startDate.AddMonths(i).Month + "-" + dateValue); if (checkDate.HasValue && checkDate <= endDate && checkDate >= startDatep) { newSafetyDataPlan.CheckDate = checkDate; newSafetyDataPlan.RealStartDate = checkDate.Value.AddMonths(-12); ///开始日期 newSafetyDataPlan.RealStartDate = new DateTime(newSafetyDataPlan.RealStartDate.Value.Year, newSafetyDataPlan.RealStartDate.Value.Month, 1); newSafetyDataPlan.RealEndDate = checkDate.Value; } } } else if (item.CheckType == BLL.Const.SafetyDataCheckType_4) /// 开工后报 { DateTime?checkDate = startDate.AddMonths(i); if (checkDate.HasValue && checkDate <= endDate && BLL.Funs.CompareMonths(startDatep, checkDate.Value) == monthValue && checkDate >= startDatep) { newSafetyDataPlan.CheckDate = checkDate; newSafetyDataPlan.RealStartDate = startDate; ///开始日期 newSafetyDataPlan.RealEndDate = checkDate.Value; } } else if (item.CheckType == BLL.Const.SafetyDataCheckType_5) /// 半年报 { if (startDate.AddMonths(i).Month == monthValue || startDate.AddMonths(i).Month == monthValue + 6) { if (startDate.AddMonths(i + monthValue).Month == 2 && dateValue > 28) { dateValue = 28; } DateTime?checkDate = Funs.GetNewDateTime(startDate.AddMonths(i).Year + "-" + startDate.AddMonths(i).Month + "-" + dateValue); if (checkDate.HasValue && checkDate <= endDate && checkDate >= startDatep) { newSafetyDataPlan.CheckDate = checkDate; newSafetyDataPlan.RealStartDate = checkDate.Value.AddMonths(-6); ///开始日期 newSafetyDataPlan.RealStartDate = new DateTime(newSafetyDataPlan.RealStartDate.Value.Year, newSafetyDataPlan.RealStartDate.Value.Month, 1); newSafetyDataPlan.RealEndDate = newSafetyDataPlan.RealStartDate.Value.AddMonths(6).AddDays(-1); } } } else /// 其他 { if (monthValue > 0 && startDate.AddMonths(i).Year == System.DateTime.Now.Year && startDate.AddMonths(i).Month == monthValue) { if (startDate.AddMonths(i + monthValue).Month == 2 && dateValue > 28) { dateValue = 28; } DateTime?checkDate = Funs.GetNewDateTime(startDate.AddMonths(i).Year + "-" + startDate.AddMonths(i).Month + "-" + dateValue); if (checkDate.HasValue && checkDate <= endDate && checkDate >= startDatep) { newSafetyDataPlan.CheckDate = checkDate; newSafetyDataPlan.RealStartDate = startDate; ///开始日期 newSafetyDataPlan.RealStartDate = new DateTime(newSafetyDataPlan.RealStartDate.Value.Year, newSafetyDataPlan.RealStartDate.Value.Month, 1); newSafetyDataPlan.RealEndDate = checkDate.Value; } } } if (newSafetyDataPlan.RealEndDate.HasValue) { newSafetyDataPlan.ReminderDate = newSafetyDataPlan.CheckDate.Value.AddDays(-7); AddSafetyDataPlan(newSafetyDataPlan); } } } }
/// <summary> /// 加载页面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ProjectId = this.CurrUser.LoginProjectId; if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId) { this.ProjectId = Request.Params["projectId"]; } Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(this.ProjectId); if (project.StartDate == null || project.EndDate == null) { Alert.ShowInTop("请先设置项目的开始时间和结束时间!", MessageBoxIcon.Warning); return; } else { headerStr = string.Empty; DateTime startTime; DateTime endTime; DateTime monthStartTime; DateTime monthEndTime; int sortIndex = 1; List <Model.Project_ProjectUnit> subUnits = BLL.ProjectUnitService.GetProjectUnitListByProjectIdUnitType(this.ProjectId, BLL.Const.ProjectUnitType_2); DataTable dt = new DataTable(); dt.Columns.Add("R0"); //序号 dt.Columns.Add("R1"); //施工分包商 dt.Columns.Add("R2"); //HSE费用(元) dt.Columns.Add("R3"); //审批支付、剩余 startTime = Convert.ToDateTime(Convert.ToDateTime(project.StartDate).ToString("yyyy-MM")); endTime = Convert.ToDateTime(Convert.ToDateTime(project.EndDate).ToString("yyyy-MM")); string monthStr = string.Empty; while (endTime >= startTime) { monthStr += startTime.ToString("yyyy-MM") + "|"; startTime = startTime.AddMonths(1); } if (!string.IsNullOrEmpty(monthStr)) { monthStr = monthStr.Substring(0, monthStr.LastIndexOf("|")); } string[] months = monthStr.Split('|'); //如果超过15个月,需要加宽GridView以保证样式 if (months.Length > 15) { int addNum = months.Length - 15; this.gvCostLedger.Width = 1100 + addNum * 60; } string monthTitle = string.Empty; for (int i = 0; i < months.Length; i++) { monthTitle += months[i] + ","; dt.Columns.Add("M" + i); } if (!string.IsNullOrEmpty(monthTitle)) { monthTitle = monthTitle.Substring(0, monthTitle.LastIndexOf(",")); } dt.Columns.Add("合计"); headerStr += "序号#施工分包商#HSE费用(元)#步骤#审批金额"; headerStr += " " + monthTitle + "#合计"; foreach (Model.Project_ProjectUnit proUnit in subUnits) { var unit = BLL.UnitService.GetUnitByUnitId(proUnit.UnitId); decimal?planCost = proUnit.PlanCostA + proUnit.PlanCostB ?? 0; decimal planAmount = planCost ?? 0; decimal lastCost = planAmount; decimal totalCost = 0; DataRow row1 = dt.NewRow(); DataRow row2 = dt.NewRow(); row1[0] = sortIndex; row1[1] = unit.UnitName; row1[2] = planAmount.ToString("0.00"); row1[3] = "审批支付"; row2[0] = sortIndex; row2[1] = unit.UnitName; row2[2] = planAmount.ToString("0.00"); row2[3] = "剩余"; int r = 4; for (int i = 0; i < months.Length; i++) { DateTime month = Convert.ToDateTime(months[i] + "-01"); monthStartTime = month.AddMonths(-1).AddDays(25); monthEndTime = month.AddDays(24); decimal?costitem = BLL.CostManageItemService.GetCostsByUnitId(unit.UnitId, monthStartTime, monthEndTime); //分包商HSE费用申请总价 decimal?subPay = BLL.SubPayRegistrationService.GetSubPayRegistrationByUnitId(unit.UnitId, monthStartTime, monthEndTime); //分包商HSE费用投入登记 decimal?cost = null; if (costitem != null && subPay != null) { cost = Convert.ToDecimal(costitem) + Convert.ToDecimal(subPay); } else { if (costitem != null) { cost = Convert.ToDecimal(costitem); } else if (subPay != null) { cost = Convert.ToDecimal(subPay); } } if (cost != null) { decimal c = Convert.ToDecimal(cost); row1[r + i] = c.ToString("0.00");; totalCost += c; if (lastCost == planAmount) { lastCost = planAmount - c; } else { lastCost = lastCost - c; } row2[r + i] = lastCost.ToString("0.00"); } } row1[r + months.Length] = totalCost.ToString("0.00");; dt.Rows.Add(row1); dt.Rows.Add(row2); sortIndex++; } this.gvCostLedger.DataSource = dt; this.gvCostLedger.DataBind(); } } }