| 
									
										
										
										
											2023-05-06 15:27:27 +08:00
										 |  |  |  | using BLL; | 
					
						
							|  |  |  |  | using Newtonsoft.Json.Linq; | 
					
						
							|  |  |  |  | using System; | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Data; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Web.UI.WebControls; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace FineUIPro.Web.JDGL.WBS | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public partial class WorkloadInputEditAll : PageBase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         #region 定义变量 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 列数量 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public int ColumnNum | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return (int)ViewState["ColumnNum"]; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             set | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 ViewState["ColumnNum"] = value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 上传预设的虚拟路径 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private string initPath = Const.ExcelUrl; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 错误集合 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public static string errorInfos = string.Empty; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 月份集合 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public static List<DateTime> months = new List<DateTime>(); | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 加载表头 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         protected void Page_Init(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             InitGrid(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 表头 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 表头 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         private void InitGrid() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             ColumnNum = 0; | 
					
						
							|  |  |  |  |             months.Clear(); | 
					
						
							|  |  |  |  |             var installation = Funs.DB.Project_Installation.FirstOrDefault(x => x.SuperInstallationId == "0" && x.ProjectId == this.CurrUser.LoginProjectId); | 
					
						
							|  |  |  |  |             if (installation != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 DateTime startDate, endDate, startMonth, endMonth; | 
					
						
							|  |  |  |  |                 if (installation.StartDate != null && installation.EndDate != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     startDate = Convert.ToDateTime(installation.StartDate); | 
					
						
							|  |  |  |  |                     endDate = Convert.ToDateTime(installation.EndDate); | 
					
						
							|  |  |  |  |                     startMonth = Convert.ToDateTime(startDate.Year + "-" + startDate.Month + "-01"); | 
					
						
							|  |  |  |  |                     endMonth = Convert.ToDateTime(endDate.Year + "-" + endDate.Month + "-01"); | 
					
						
							|  |  |  |  |                     do | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         months.Add(startMonth); | 
					
						
							|  |  |  |  |                         startMonth = startMonth.AddMonths(1); | 
					
						
							|  |  |  |  |                     } while (startMonth <= endMonth); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 for (int i = 0; i < months.Count; i++) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     RenderField rdPlan = new RenderField(); | 
					
						
							|  |  |  |  |                     rdPlan.ColumnID = string.Format("{0:yyyy-MM}", months[i]) + "Plan"; | 
					
						
							|  |  |  |  |                     rdPlan.Width = Unit.Pixel(100); | 
					
						
							|  |  |  |  |                     rdPlan.DataField = "PlanNum" + (i + 1).ToString(); | 
					
						
							|  |  |  |  |                     rdPlan.FieldType = FieldType.Double; | 
					
						
							|  |  |  |  |                     rdPlan.HeaderText = string.Format("{0:yyyy年MM月}", months[i]) + "<br/>计划量"; | 
					
						
							|  |  |  |  |                     rdPlan.HeaderTextAlign = TextAlign.Center; | 
					
						
							|  |  |  |  |                     NumberBox numPlan = new NumberBox(); | 
					
						
							|  |  |  |  |                     numPlan.NoNegative = true; | 
					
						
							|  |  |  |  |                     numPlan.NoDecimal = false; | 
					
						
							|  |  |  |  |                     rdPlan.Editor.Add(numPlan); | 
					
						
							|  |  |  |  |                     Grid1.Columns.Add(rdPlan); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     RenderField rdThis = new RenderField(); | 
					
						
							|  |  |  |  |                     rdThis.ColumnID = string.Format("{0:yyyy-MM}", months[i]) + "This"; | 
					
						
							|  |  |  |  |                     rdThis.Width = Unit.Pixel(100); | 
					
						
							|  |  |  |  |                     rdThis.DataField = "ThisNum" + (i + 1).ToString(); | 
					
						
							|  |  |  |  |                     rdThis.FieldType = FieldType.Double; | 
					
						
							|  |  |  |  |                     rdThis.HeaderText = string.Format("{0:yyyy年MM月}", months[i]) + "<br/>完成量"; | 
					
						
							|  |  |  |  |                     rdThis.HeaderTextAlign = TextAlign.Center; | 
					
						
							|  |  |  |  |                     NumberBox numReal = new NumberBox(); | 
					
						
							|  |  |  |  |                     numReal.NoNegative = true; | 
					
						
							|  |  |  |  |                     numReal.NoDecimal = false; | 
					
						
							|  |  |  |  |                     rdThis.Editor.Add(numReal); | 
					
						
							|  |  |  |  |                     Grid1.Columns.Add(rdThis); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 RenderField rdId = new RenderField(); | 
					
						
							|  |  |  |  |                 rdId.ColumnID = "ShowId"; | 
					
						
							|  |  |  |  |                 rdId.Width = Unit.Pixel(350); | 
					
						
							|  |  |  |  |                 rdId.DataField = "ShowId"; | 
					
						
							|  |  |  |  |                 rdId.FieldType = FieldType.String; | 
					
						
							|  |  |  |  |                 rdId.HeaderText = "ShowId"; | 
					
						
							|  |  |  |  |                 rdId.HeaderTextAlign = TextAlign.Center; | 
					
						
							|  |  |  |  |                 Grid1.Columns.Add(rdId); | 
					
						
							|  |  |  |  |                 rdId.Hidden = true; | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  |                 ColumnNum = 9 + months.Count * 2 + 1; | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 加载 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 加载页面 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void Page_Load(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (!IsPostBack) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 errorInfos = string.Empty; | 
					
						
							| 
									
										
										
										
											2023-07-25 17:32:36 +08:00
										 |  |  |  |                 string Id = Request.Params["Id"]; | 
					
						
							|  |  |  |  |                 DataTable table = BLL.WorkloadStatisticsService.GetAllTreeDataTable(this.CurrUser.LoginProjectId, string.Empty, Id); | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |                 Grid1.DataSource = table; | 
					
						
							|  |  |  |  |                 Grid1.DataBind(); | 
					
						
							|  |  |  |  |                 for (int i = 0; i < this.Grid1.Rows.Count; i++) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     if (string.IsNullOrEmpty(this.Grid1.Rows[i].DataKeys[2].ToString())) | 
					
						
							|  |  |  |  |                     { | 
					
						
							| 
									
										
										
										
											2022-06-14 18:21:58 +08:00
										 |  |  |  |                         foreach (GridColumn column in Grid1.Columns) | 
					
						
							|  |  |  |  |                         { | 
					
						
							|  |  |  |  |                             if (column.ColumnIndex != 0) | 
					
						
							|  |  |  |  |                             { | 
					
						
							|  |  |  |  |                                 this.Grid1.Rows[i].CellCssClasses[column.ColumnIndex] = "f-grid-cell-uneditable"; | 
					
						
							|  |  |  |  |                             } | 
					
						
							|  |  |  |  |                         } | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region 保存 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 保存按钮 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="sender"></param> | 
					
						
							|  |  |  |  |         /// <param name="e"></param> | 
					
						
							|  |  |  |  |         protected void btnSave_Click(object sender, EventArgs e) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Save(); | 
					
						
							|  |  |  |  |             ShowNotify("保存成功!", MessageBoxIcon.Success); | 
					
						
							| 
									
										
										
										
											2023-07-24 19:40:26 +08:00
										 |  |  |  |             //PageContext.RegisterStartupScript(ActiveWindow.GetHideReference()); | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private void Save() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             decimal changeThisPlanValue = 0, changeThisRealCost = 0, changeThisPlanCost = 0,  //当月总变化完成成本、完成预算 | 
					
						
							|  |  |  |  |                         oldThisPlanValue = 0, oldThisRealCost = 0, oldThisPlanCost = 0, | 
					
						
							|  |  |  |  |                         thisPlanValue = 0, thisRealCost = 0, thisPlanCost = 0; | 
					
						
							|  |  |  |  |             var oldViewInfos = from x in Funs.DB.WBS_CostControl | 
					
						
							|  |  |  |  |                                where x.ProjectId == this.CurrUser.LoginProjectId | 
					
						
							|  |  |  |  |                                select x; | 
					
						
							| 
									
										
										
										
											2023-07-04 18:53:13 +08:00
										 |  |  |  |             Model.SGGLDB db = Funs.DB; | 
					
						
							| 
									
										
										
										
											2023-07-05 17:20:04 +08:00
										 |  |  |  |             string[] ids = this.hdId.Text.Split(','); | 
					
						
							|  |  |  |  |             if (ids.Length > 0) | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2023-07-05 17:20:04 +08:00
										 |  |  |  |                 foreach (JObject mergedRow in Grid1.GetMergedData()) | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2023-07-05 17:20:04 +08:00
										 |  |  |  |                     JObject values = mergedRow.Value<JObject>("values"); | 
					
						
							|  |  |  |  |                     int i = mergedRow.Value<int>("index"); | 
					
						
							| 
									
										
										
										
											2023-08-24 10:00:59 +08:00
										 |  |  |  |                     if (this.Grid1.Rows[i].DataKeys[2] != null && ids.Contains(this.Grid1.Rows[i].DataKeys[2].ToString())) | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |                     { | 
					
						
							| 
									
										
										
										
											2023-07-05 17:20:04 +08:00
										 |  |  |  |                         Model.WBS_CostControl costControl = oldViewInfos.FirstOrDefault(x => x.CostControlId == this.Grid1.Rows[i].DataKeys[2].ToString()); | 
					
						
							| 
									
										
										
										
											2023-08-24 10:00:59 +08:00
										 |  |  |  |                         if (costControl != null) | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |                         { | 
					
						
							| 
									
										
										
										
											2023-07-05 17:20:04 +08:00
										 |  |  |  |                             decimal oldPlanPrice = costControl.PlanPrice ?? 0; | 
					
						
							|  |  |  |  |                             decimal oldRealPrice = costControl.RealPrice ?? 0; | 
					
						
							|  |  |  |  |                             string costControlId = costControl.CostControlId; | 
					
						
							|  |  |  |  |                             string totalNum = values.Value<string>("TotalNum"); | 
					
						
							|  |  |  |  |                             string planPrice = values.Value<string>("PlanPrice"); | 
					
						
							|  |  |  |  |                             string realPrice = values.Value<string>("RealPrice"); | 
					
						
							|  |  |  |  |                             string planStartDate = values.Value<string>("PlanStartDate"); | 
					
						
							|  |  |  |  |                             string planEndDate = values.Value<string>("PlanEndDate"); | 
					
						
							|  |  |  |  |                             string realStartDate = values.Value<string>("RealStartDate"); | 
					
						
							|  |  |  |  |                             string realEndDate = values.Value<string>("RealEndDate"); | 
					
						
							|  |  |  |  |                             costControl.TotalNum = Funs.GetNewDecimal(totalNum); | 
					
						
							|  |  |  |  |                             costControl.PlanPrice = Funs.GetNewDecimal(planPrice); | 
					
						
							|  |  |  |  |                             costControl.RealPrice = Funs.GetNewDecimal(realPrice); | 
					
						
							|  |  |  |  |                             costControl.PlanStartDate = Funs.GetNewDateTime(planStartDate); | 
					
						
							|  |  |  |  |                             costControl.PlanEndDate = Funs.GetNewDateTime(planEndDate); | 
					
						
							|  |  |  |  |                             costControl.RealStartDate = Funs.GetNewDateTime(realStartDate); | 
					
						
							|  |  |  |  |                             costControl.RealEndDate = Funs.GetNewDateTime(realEndDate); | 
					
						
							|  |  |  |  |                             BLL.CostControlService.UpdateCostControl(costControl); | 
					
						
							|  |  |  |  |                             for (int j = 0; j < months.Count; j++) | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |                             { | 
					
						
							| 
									
										
										
										
											2023-07-05 17:20:04 +08:00
										 |  |  |  |                                 oldThisPlanValue = 0; | 
					
						
							|  |  |  |  |                                 oldThisRealCost = 0; | 
					
						
							|  |  |  |  |                                 oldThisPlanCost = 0; | 
					
						
							|  |  |  |  |                                 changeThisPlanValue = 0; | 
					
						
							|  |  |  |  |                                 changeThisRealCost = 0; | 
					
						
							|  |  |  |  |                                 changeThisPlanCost = 0; | 
					
						
							|  |  |  |  |                                 string planNum = values.Value<string>(string.Format("{0:yyyy-MM}", months[j]) + "Plan"); | 
					
						
							|  |  |  |  |                                 string thisNum = values.Value<string>(string.Format("{0:yyyy-MM}", months[j]) + "This"); | 
					
						
							|  |  |  |  |                                 Model.WBS_CostControlDetail costControlDetail = BLL.CostControlDetailService.GetCostControlDetailByCostControlIdAndMonths(costControlId, months[j]); | 
					
						
							|  |  |  |  |                                 if (costControlDetail != null) | 
					
						
							|  |  |  |  |                                 { | 
					
						
							|  |  |  |  |                                     oldThisPlanValue = (costControlDetail.PlanNum ?? 0) * oldPlanPrice; | 
					
						
							|  |  |  |  |                                     oldThisRealCost = (costControlDetail.ThisNum ?? 0) * oldRealPrice; | 
					
						
							|  |  |  |  |                                     oldThisPlanCost = (costControlDetail.ThisNum ?? 0) * oldPlanPrice; | 
					
						
							|  |  |  |  |                                     costControlDetail.PlanNum = Funs.GetNewDecimalOrZero(planNum); | 
					
						
							|  |  |  |  |                                     costControlDetail.ThisNum = Funs.GetNewDecimalOrZero(thisNum); | 
					
						
							|  |  |  |  |                                     thisPlanValue = (costControlDetail.PlanNum ?? 0) * (costControl.PlanPrice ?? 0); | 
					
						
							|  |  |  |  |                                     thisRealCost = (costControlDetail.ThisNum ?? 0) * (costControl.RealPrice ?? 0); | 
					
						
							|  |  |  |  |                                     thisPlanCost = (costControlDetail.ThisNum ?? 0) * (costControl.PlanPrice ?? 0); | 
					
						
							|  |  |  |  |                                     //BLL.CostControlDetailService.UpdateCostControlDetail(costControlDetail); | 
					
						
							|  |  |  |  |                                 } | 
					
						
							|  |  |  |  |                                 else | 
					
						
							|  |  |  |  |                                 { | 
					
						
							|  |  |  |  |                                     costControlDetail = new Model.WBS_CostControlDetail(); | 
					
						
							|  |  |  |  |                                     costControlDetail.CostControlDetailId = SQLHelper.GetNewID(); | 
					
						
							|  |  |  |  |                                     costControlDetail.CostControlId = costControlId; | 
					
						
							|  |  |  |  |                                     costControlDetail.Months = months[j]; | 
					
						
							|  |  |  |  |                                     costControlDetail.PlanNum = Funs.GetNewDecimalOrZero(planNum); | 
					
						
							|  |  |  |  |                                     costControlDetail.ThisNum = Funs.GetNewDecimalOrZero(thisNum); | 
					
						
							|  |  |  |  |                                     thisPlanValue = (costControlDetail.PlanNum ?? 0) * (costControl.PlanPrice ?? 0); | 
					
						
							|  |  |  |  |                                     thisRealCost = (costControlDetail.ThisNum ?? 0) * (costControl.RealPrice ?? 0); | 
					
						
							|  |  |  |  |                                     thisPlanCost = (costControlDetail.ThisNum ?? 0) * (costControl.PlanPrice ?? 0); | 
					
						
							|  |  |  |  |                                     //BLL.CostControlDetailService.AddCostControlDetail(costControlDetail); | 
					
						
							|  |  |  |  |                                     db.WBS_CostControlDetail.InsertOnSubmit(costControlDetail); | 
					
						
							|  |  |  |  |                                 } | 
					
						
							|  |  |  |  |                                 //累加变化值,计算总的变化值 | 
					
						
							|  |  |  |  |                                 changeThisPlanValue += thisPlanValue - oldThisPlanValue; | 
					
						
							|  |  |  |  |                                 changeThisRealCost += thisRealCost - oldThisRealCost; | 
					
						
							|  |  |  |  |                                 changeThisPlanCost += thisPlanCost - oldThisPlanCost; | 
					
						
							| 
									
										
										
										
											2023-07-04 18:53:13 +08:00
										 |  |  |  |                                 //更新工作包、工作项 | 
					
						
							|  |  |  |  |                                 Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(costControl.WbsSetId); | 
					
						
							|  |  |  |  |                                 UpdateWbsSetDetail(db, costControl.WbsSetId, months[j], changeThisPlanValue, changeThisRealCost, changeThisPlanCost); | 
					
						
							|  |  |  |  |                                 //更新分部 | 
					
						
							|  |  |  |  |                                 Model.WBS_CostControlParentDetail unitProjectDetail = BLL.CostControlParentDetailService.GetCostControlParentDetailByParentIdAndMonths(wbsSet.UnitProjectId, months[j]); | 
					
						
							|  |  |  |  |                                 if (unitProjectDetail != null) | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |                                 { | 
					
						
							| 
									
										
										
										
											2023-07-04 18:53:13 +08:00
										 |  |  |  |                                     unitProjectDetail.ThisPlanValue += changeThisPlanValue; | 
					
						
							|  |  |  |  |                                     unitProjectDetail.ThisRealCost += changeThisRealCost; | 
					
						
							|  |  |  |  |                                     unitProjectDetail.ThisPlanCost += changeThisPlanCost; | 
					
						
							|  |  |  |  |                                     //BLL.CostControlParentDetailService.UpdateCostControlParentDetail(unitProjectDetail); | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |                                 } | 
					
						
							|  |  |  |  |                                 else | 
					
						
							|  |  |  |  |                                 { | 
					
						
							| 
									
										
										
										
											2023-07-04 18:53:13 +08:00
										 |  |  |  |                                     unitProjectDetail = new Model.WBS_CostControlParentDetail(); | 
					
						
							|  |  |  |  |                                     unitProjectDetail.CostControlParentDetailId = SQLHelper.GetNewID(); | 
					
						
							|  |  |  |  |                                     unitProjectDetail.ParentId = wbsSet.UnitProjectId; | 
					
						
							|  |  |  |  |                                     unitProjectDetail.Months = months[j]; | 
					
						
							|  |  |  |  |                                     unitProjectDetail.ThisPlanValue = changeThisPlanValue; | 
					
						
							|  |  |  |  |                                     unitProjectDetail.ThisRealCost = changeThisRealCost; | 
					
						
							|  |  |  |  |                                     unitProjectDetail.ThisPlanCost = changeThisPlanCost; | 
					
						
							|  |  |  |  |                                     //BLL.CostControlParentDetailService.AddCostControlParentDetail(unitProjectDetail); | 
					
						
							|  |  |  |  |                                     db.WBS_CostControlParentDetail.InsertOnSubmit(unitProjectDetail); | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |                                 } | 
					
						
							| 
									
										
										
										
											2023-07-04 18:53:13 +08:00
										 |  |  |  |                                 //更新专业 | 
					
						
							|  |  |  |  |                                 if (!string.IsNullOrEmpty(wbsSet.CnProfessionId)) | 
					
						
							|  |  |  |  |                                 { | 
					
						
							|  |  |  |  |                                     Model.WBS_CostControlParentDetail cnProfessionDetail = BLL.CostControlParentDetailService.GetCostControlParentDetailByParentIdAndMonths(wbsSet.CnProfessionId, months[j]); | 
					
						
							|  |  |  |  |                                     if (cnProfessionDetail != null) | 
					
						
							|  |  |  |  |                                     { | 
					
						
							|  |  |  |  |                                         cnProfessionDetail.ThisPlanValue += changeThisPlanValue; | 
					
						
							|  |  |  |  |                                         cnProfessionDetail.ThisRealCost += changeThisRealCost; | 
					
						
							|  |  |  |  |                                         cnProfessionDetail.ThisPlanCost += changeThisPlanCost; | 
					
						
							|  |  |  |  |                                         //BLL.CostControlParentDetailService.UpdateCostControlParentDetail(cnProfessionDetail); | 
					
						
							|  |  |  |  |                                     } | 
					
						
							|  |  |  |  |                                     else | 
					
						
							|  |  |  |  |                                     { | 
					
						
							|  |  |  |  |                                         cnProfessionDetail = new Model.WBS_CostControlParentDetail(); | 
					
						
							|  |  |  |  |                                         cnProfessionDetail.CostControlParentDetailId = SQLHelper.GetNewID(); | 
					
						
							|  |  |  |  |                                         cnProfessionDetail.ParentId = wbsSet.CnProfessionId; | 
					
						
							|  |  |  |  |                                         cnProfessionDetail.Months = months[j]; | 
					
						
							|  |  |  |  |                                         cnProfessionDetail.ThisPlanValue = changeThisPlanValue; | 
					
						
							|  |  |  |  |                                         cnProfessionDetail.ThisRealCost = changeThisRealCost; | 
					
						
							|  |  |  |  |                                         cnProfessionDetail.ThisPlanCost = changeThisPlanCost; | 
					
						
							|  |  |  |  |                                         //BLL.CostControlParentDetailService.AddCostControlParentDetail(cnProfessionDetail); | 
					
						
							|  |  |  |  |                                         db.WBS_CostControlParentDetail.InsertOnSubmit(cnProfessionDetail); | 
					
						
							|  |  |  |  |                                     } | 
					
						
							|  |  |  |  |                                 } | 
					
						
							|  |  |  |  |                                 //更新装置 | 
					
						
							|  |  |  |  |                                 UpdateInstallationDetail(db, wbsSet.InstallationId, months[j], changeThisPlanValue, changeThisRealCost, changeThisPlanCost); | 
					
						
							|  |  |  |  |                                 db.SubmitChanges(); | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |                             } | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region  更新工作包、工作项 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 更新月工作包、工作项 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="years"></param> | 
					
						
							|  |  |  |  |         /// <param name="months"></param> | 
					
						
							|  |  |  |  |         /// <param name="planValue"></param> | 
					
						
							|  |  |  |  |         /// <param name="parentId"></param> | 
					
						
							| 
									
										
										
										
											2023-07-04 18:53:13 +08:00
										 |  |  |  |         private void UpdateWbsSetDetail(Model.SGGLDB db, string wbsSetId, DateTime months, decimal changeThisPlanValue, decimal changeThisRealCost, decimal changeThisPlanCost) | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(wbsSetId); | 
					
						
							|  |  |  |  |             if (wbsSet != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Model.WBS_CostControlParentDetail parentDetail = BLL.CostControlParentDetailService.GetCostControlParentDetailByParentIdAndMonths(wbsSetId, months); | 
					
						
							|  |  |  |  |                 if (parentDetail != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanValue += changeThisPlanValue; | 
					
						
							|  |  |  |  |                     parentDetail.ThisRealCost += changeThisRealCost; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanCost += changeThisPlanCost; | 
					
						
							| 
									
										
										
										
											2023-07-04 18:53:13 +08:00
										 |  |  |  |                     //BLL.CostControlParentDetailService.UpdateCostControlParentDetail(parentDetail); | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     parentDetail = new Model.WBS_CostControlParentDetail(); | 
					
						
							|  |  |  |  |                     parentDetail.CostControlParentDetailId = SQLHelper.GetNewID(); | 
					
						
							|  |  |  |  |                     parentDetail.ParentId = wbsSetId; | 
					
						
							|  |  |  |  |                     parentDetail.Months = months; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanValue = changeThisPlanValue; | 
					
						
							|  |  |  |  |                     parentDetail.ThisRealCost = changeThisRealCost; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanCost = changeThisPlanCost; | 
					
						
							| 
									
										
										
										
											2023-07-04 18:53:13 +08:00
										 |  |  |  |                     //BLL.CostControlParentDetailService.AddCostControlParentDetail(parentDetail); | 
					
						
							|  |  |  |  |                     db.WBS_CostControlParentDetail.InsertOnSubmit(parentDetail); | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |                 if (wbsSet.SuperWbsSetId != null)   //还存在上级节点,需要继续循环 | 
					
						
							|  |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2023-07-04 18:53:13 +08:00
										 |  |  |  |                     UpdateWbsSetDetail(db, wbsSet.SuperWbsSetId, months, changeThisPlanValue, changeThisRealCost, changeThisPlanCost); | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 更新周工作包、工作项 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="years"></param> | 
					
						
							|  |  |  |  |         /// <param name="months"></param> | 
					
						
							|  |  |  |  |         /// <param name="planValue"></param> | 
					
						
							|  |  |  |  |         /// <param name="parentId"></param> | 
					
						
							|  |  |  |  |         private void UpdateWeekWbsSetDetail(string wbsSetId, DateTime months, DateTime startDate, DateTime endDate, decimal changeThisPlanValue, decimal changeThisRealCost, decimal changeThisPlanCost) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(wbsSetId); | 
					
						
							|  |  |  |  |             if (wbsSet != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Model.WBS_CostControlParentDetail parentDetail = BLL.CostControlParentDetailService.GetCostControlParentDetailByParentIdAndMonthsWeek(wbsSetId, months, startDate); | 
					
						
							|  |  |  |  |                 if (parentDetail != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanValue += changeThisPlanValue; | 
					
						
							|  |  |  |  |                     parentDetail.ThisRealCost += changeThisRealCost; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanCost += changeThisPlanCost; | 
					
						
							|  |  |  |  |                     BLL.CostControlParentDetailService.UpdateCostControlParentDetail(parentDetail); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     parentDetail = new Model.WBS_CostControlParentDetail(); | 
					
						
							|  |  |  |  |                     parentDetail.CostControlParentDetailId = SQLHelper.GetNewID(); | 
					
						
							|  |  |  |  |                     parentDetail.ParentId = wbsSetId; | 
					
						
							|  |  |  |  |                     parentDetail.Months = months; | 
					
						
							|  |  |  |  |                     parentDetail.StartDate = startDate; | 
					
						
							|  |  |  |  |                     parentDetail.EndDate = endDate; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanValue = changeThisPlanValue; | 
					
						
							|  |  |  |  |                     parentDetail.ThisRealCost = changeThisRealCost; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanCost = changeThisPlanCost; | 
					
						
							|  |  |  |  |                     BLL.CostControlParentDetailService.AddCostControlParentDetail(parentDetail); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 if (wbsSet.SuperWbsSetId != null)   //还存在上级节点,需要继续循环 | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     UpdateWeekWbsSetDetail(wbsSet.SuperWbsSetId, months, startDate, endDate, changeThisPlanValue, changeThisRealCost, changeThisPlanCost); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         #region  更新装置 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 更新月装置 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="years"></param> | 
					
						
							|  |  |  |  |         /// <param name="months"></param> | 
					
						
							|  |  |  |  |         /// <param name="planValue"></param> | 
					
						
							|  |  |  |  |         /// <param name="parentId"></param> | 
					
						
							| 
									
										
										
										
											2023-07-04 18:53:13 +08:00
										 |  |  |  |         private void UpdateInstallationDetail(Model.SGGLDB db, string installationId, DateTime months, decimal changeThisPlanValue, decimal changeThisRealCost, decimal changeThisPlanCost) | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.Project_Installation installation = BLL.Project_InstallationService.GetInstallationByInstallationId(installationId); | 
					
						
							|  |  |  |  |             if (installation != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Model.WBS_CostControlParentDetail parentDetail = BLL.CostControlParentDetailService.GetCostControlParentDetailByParentIdAndMonths(installationId, months); | 
					
						
							|  |  |  |  |                 if (parentDetail != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanValue += changeThisPlanValue; | 
					
						
							|  |  |  |  |                     parentDetail.ThisRealCost += changeThisRealCost; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanCost += changeThisPlanCost; | 
					
						
							| 
									
										
										
										
											2023-07-04 18:53:13 +08:00
										 |  |  |  |                     //BLL.CostControlParentDetailService.UpdateCostControlParentDetail(parentDetail); | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     parentDetail = new Model.WBS_CostControlParentDetail(); | 
					
						
							|  |  |  |  |                     parentDetail.CostControlParentDetailId = SQLHelper.GetNewID(); | 
					
						
							|  |  |  |  |                     parentDetail.ParentId = installationId; | 
					
						
							|  |  |  |  |                     parentDetail.Months = months; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanValue = changeThisPlanValue; | 
					
						
							|  |  |  |  |                     parentDetail.ThisRealCost = changeThisRealCost; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanCost = changeThisPlanCost; | 
					
						
							| 
									
										
										
										
											2023-07-04 18:53:13 +08:00
										 |  |  |  |                     //BLL.CostControlParentDetailService.AddCostControlParentDetail(parentDetail); | 
					
						
							|  |  |  |  |                     db.WBS_CostControlParentDetail.InsertOnSubmit(parentDetail); | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |                 if (installation.SuperInstallationId != null)   //还存在上级节点,需要继续循环 | 
					
						
							|  |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2023-07-04 18:53:13 +08:00
										 |  |  |  |                     UpdateInstallationDetail(db, installation.SuperInstallationId, months, changeThisPlanValue, changeThisRealCost, changeThisPlanCost); | 
					
						
							| 
									
										
										
										
											2022-06-06 11:23:24 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// 更新周装置 | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <param name="years"></param> | 
					
						
							|  |  |  |  |         /// <param name="months"></param> | 
					
						
							|  |  |  |  |         /// <param name="planValue"></param> | 
					
						
							|  |  |  |  |         /// <param name="parentId"></param> | 
					
						
							|  |  |  |  |         private void UpdateWeekInstallationDetail(string installationId, DateTime months, DateTime startDate, DateTime endDate, decimal changeThisPlanValue, decimal changeThisRealCost, decimal changeThisPlanCost) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Model.Project_Installation installation = BLL.Project_InstallationService.GetInstallationByInstallationId(installationId); | 
					
						
							|  |  |  |  |             if (installation != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Model.WBS_CostControlParentDetail parentDetail = BLL.CostControlParentDetailService.GetCostControlParentDetailByParentIdAndMonths(installationId, months); | 
					
						
							|  |  |  |  |                 if (parentDetail != null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanValue += changeThisPlanValue; | 
					
						
							|  |  |  |  |                     parentDetail.ThisRealCost += changeThisRealCost; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanCost += changeThisPlanCost; | 
					
						
							|  |  |  |  |                     BLL.CostControlParentDetailService.UpdateCostControlParentDetail(parentDetail); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     parentDetail = new Model.WBS_CostControlParentDetail(); | 
					
						
							|  |  |  |  |                     parentDetail.CostControlParentDetailId = SQLHelper.GetNewID(); | 
					
						
							|  |  |  |  |                     parentDetail.ParentId = installationId; | 
					
						
							|  |  |  |  |                     parentDetail.Months = months; | 
					
						
							|  |  |  |  |                     parentDetail.StartDate = startDate; | 
					
						
							|  |  |  |  |                     parentDetail.EndDate = endDate; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanValue = changeThisPlanValue; | 
					
						
							|  |  |  |  |                     parentDetail.ThisRealCost = changeThisRealCost; | 
					
						
							|  |  |  |  |                     parentDetail.ThisPlanCost = changeThisPlanCost; | 
					
						
							|  |  |  |  |                     BLL.CostControlParentDetailService.AddCostControlParentDetail(parentDetail); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 if (installation.SuperInstallationId != null)   //还存在上级节点,需要继续循环 | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     UpdateWeekInstallationDetail(installation.SuperInstallationId, months, startDate, endDate, changeThisPlanValue, changeThisRealCost, changeThisPlanCost); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  |         #endregion | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |