465 lines
		
	
	
		
			25 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			465 lines
		
	
	
		
			25 KiB
		
	
	
	
		
			C#
		
	
	
	
| using BLL;
 | |
| using Newtonsoft.Json.Linq;
 | |
| using System;
 | |
| 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;
 | |
|                 ColumnNum = 9 + months.Count * 2 + 1;
 | |
|             }
 | |
|         }
 | |
|         #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;
 | |
|                 string Id = Request.Params["Id"];
 | |
|                 DataTable table = BLL.WorkloadStatisticsService.GetAllTreeDataTable(this.CurrUser.LoginProjectId, string.Empty, Id);
 | |
|                 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()))
 | |
|                     {
 | |
|                         foreach (GridColumn column in Grid1.Columns)
 | |
|                         {
 | |
|                             if (column.ColumnIndex != 0)
 | |
|                             {
 | |
|                                 this.Grid1.Rows[i].CellCssClasses[column.ColumnIndex] = "f-grid-cell-uneditable";
 | |
|                             }
 | |
|                         }
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         #endregion
 | |
| 
 | |
|         #region 保存
 | |
|         /// <summary>
 | |
|         /// 保存按钮
 | |
|         /// </summary>
 | |
|         /// <param name="sender"></param>
 | |
|         /// <param name="e"></param>
 | |
|         protected void btnSave_Click(object sender, EventArgs e)
 | |
|         {
 | |
|             Save();
 | |
|             ShowNotify("保存成功!", MessageBoxIcon.Success);
 | |
|             //PageContext.RegisterStartupScript(ActiveWindow.GetHideReference());
 | |
|         }
 | |
| 
 | |
|         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;
 | |
|             Model.SGGLDB db = Funs.DB;
 | |
|             string[] ids = this.hdId.Text.Split(',');
 | |
|             if (ids.Length > 0)
 | |
|             {
 | |
|                 foreach (JObject mergedRow in Grid1.GetMergedData())
 | |
|                 {
 | |
|                     JObject values = mergedRow.Value<JObject>("values");
 | |
|                     int i = mergedRow.Value<int>("index");
 | |
|                     if (this.Grid1.Rows[i].DataKeys[2] != null && ids.Contains(this.Grid1.Rows[i].DataKeys[2].ToString()))
 | |
|                     {
 | |
|                         Model.WBS_CostControl costControl = oldViewInfos.FirstOrDefault(x => x.CostControlId == this.Grid1.Rows[i].DataKeys[2].ToString());
 | |
|                         if (costControl != null)
 | |
|                         {
 | |
|                             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++)
 | |
|                             {
 | |
|                                 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;
 | |
|                                 //更新工作包、工作项
 | |
|                                 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)
 | |
|                                 {
 | |
|                                     unitProjectDetail.ThisPlanValue += changeThisPlanValue;
 | |
|                                     unitProjectDetail.ThisRealCost += changeThisRealCost;
 | |
|                                     unitProjectDetail.ThisPlanCost += changeThisPlanCost;
 | |
|                                     //BLL.CostControlParentDetailService.UpdateCostControlParentDetail(unitProjectDetail);
 | |
|                                 }
 | |
|                                 else
 | |
|                                 {
 | |
|                                     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);
 | |
|                                 }
 | |
|                                 //更新专业
 | |
|                                 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();
 | |
|                             }
 | |
|                         }
 | |
|                     }
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         #region  更新工作包、工作项
 | |
|         /// <summary>
 | |
|         /// 更新月工作包、工作项
 | |
|         /// </summary>
 | |
|         /// <param name="years"></param>
 | |
|         /// <param name="months"></param>
 | |
|         /// <param name="planValue"></param>
 | |
|         /// <param name="parentId"></param>
 | |
|         private void UpdateWbsSetDetail(Model.SGGLDB db, string wbsSetId, DateTime months, decimal changeThisPlanValue, decimal changeThisRealCost, decimal changeThisPlanCost)
 | |
|         {
 | |
|             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;
 | |
|                     //BLL.CostControlParentDetailService.UpdateCostControlParentDetail(parentDetail);
 | |
|                 }
 | |
|                 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;
 | |
|                     //BLL.CostControlParentDetailService.AddCostControlParentDetail(parentDetail);
 | |
|                     db.WBS_CostControlParentDetail.InsertOnSubmit(parentDetail);
 | |
|                 }
 | |
|                 if (wbsSet.SuperWbsSetId != null)   //还存在上级节点,需要继续循环
 | |
|                 {
 | |
|                     UpdateWbsSetDetail(db, wbsSet.SuperWbsSetId, months, changeThisPlanValue, changeThisRealCost, changeThisPlanCost);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <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>
 | |
|         private void UpdateInstallationDetail(Model.SGGLDB db, string installationId, DateTime months, 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.ThisPlanValue = changeThisPlanValue;
 | |
|                     parentDetail.ThisRealCost = changeThisRealCost;
 | |
|                     parentDetail.ThisPlanCost = changeThisPlanCost;
 | |
|                     //BLL.CostControlParentDetailService.AddCostControlParentDetail(parentDetail);
 | |
|                     db.WBS_CostControlParentDetail.InsertOnSubmit(parentDetail);
 | |
|                 }
 | |
|                 if (installation.SuperInstallationId != null)   //还存在上级节点,需要继续循环
 | |
|                 {
 | |
|                     UpdateInstallationDetail(db, installation.SuperInstallationId, months, changeThisPlanValue, changeThisRealCost, changeThisPlanCost);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
| 
 | |
|         /// <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
 | |
|     }
 | |
| } |