817 lines
42 KiB
C#
817 lines
42 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Data.OleDb;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Web;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
using BLL;
|
||
|
||
namespace FineUIPro.Web.JDGL.WBS
|
||
{
|
||
public partial class WorkloadInputIn : PageBase
|
||
{
|
||
/// <summary>
|
||
/// 控制项主键
|
||
/// </summary>
|
||
public string Id
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["Id"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["Id"] = value;
|
||
}
|
||
}
|
||
|
||
#region 定义变量
|
||
/// <summary>
|
||
/// 上传预设的虚拟路径
|
||
/// </summary>
|
||
private string initPath = Const.ExcelUrl;
|
||
|
||
/// <summary>
|
||
/// 安装组件集合
|
||
/// </summary>
|
||
public static List<Model.View_HJGL_Pipeline> PipelineList = new List<Model.View_HJGL_Pipeline>();
|
||
|
||
/// <summary>
|
||
/// 错误集合
|
||
/// </summary>
|
||
public static string errorInfos = string.Empty;
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 加载表头
|
||
/// </summary>
|
||
protected void Page_Init(object sender, EventArgs e)
|
||
{
|
||
InitGrid();
|
||
}
|
||
|
||
#region 表头
|
||
/// <summary>
|
||
/// 表头
|
||
/// </summary>
|
||
private void InitGrid()
|
||
{
|
||
this.Id = Request.Params["Id"];
|
||
Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(Id);
|
||
DateTime startDate, endDate, startMonth, endMonth;
|
||
List<DateTime> months = new List<DateTime>();
|
||
if (wbsSet != null && wbsSet.StartDate != null && wbsSet.EndDate != null)
|
||
{
|
||
startDate = Convert.ToDateTime(wbsSet.StartDate);
|
||
endDate = Convert.ToDateTime(wbsSet.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++)
|
||
{
|
||
//GroupField gd = new GroupField();
|
||
//gd.HeaderText = string.Format("{0:yyyy-MM}", months[i]);
|
||
//gd.HeaderTextAlign = TextAlign.Center;
|
||
|
||
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;
|
||
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;
|
||
Grid1.Columns.Add(rdThis);
|
||
|
||
//Grid1.Columns.Add(gd);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 加载
|
||
/// <summary>
|
||
/// 加载页面
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
this.hdFileName.Text = string.Empty;
|
||
this.Id = Request.Params["Id"];
|
||
if (PipelineList != null)
|
||
{
|
||
PipelineList.Clear();
|
||
}
|
||
errorInfos = string.Empty;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 导入
|
||
/// <summary>
|
||
/// 导入
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnAudit_Click(object sender, EventArgs e)
|
||
{
|
||
try
|
||
{
|
||
if (this.fuAttachUrl.HasFile == false)
|
||
{
|
||
ShowNotify("请您选择Excel文件!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
string IsXls = Path.GetExtension(this.fuAttachUrl.FileName).ToString().Trim().ToLower();
|
||
if (IsXls != ".xls")
|
||
{
|
||
ShowNotify("只可以选择Excel文件!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
if (PipelineList != null)
|
||
{
|
||
PipelineList.Clear();
|
||
}
|
||
if (!string.IsNullOrEmpty(errorInfos))
|
||
{
|
||
errorInfos = string.Empty;
|
||
}
|
||
string rootPath = Server.MapPath("~/");
|
||
string initFullPath = rootPath + initPath;
|
||
if (!Directory.Exists(initFullPath))
|
||
{
|
||
Directory.CreateDirectory(initFullPath);
|
||
}
|
||
|
||
this.hdFileName.Text = BLL.Funs.GetNewFileName() + IsXls;
|
||
string filePath = initFullPath + this.hdFileName.Text;
|
||
this.fuAttachUrl.PostedFile.SaveAs(filePath);
|
||
ImportXlsToData(rootPath + initPath + this.hdFileName.Text);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
ShowNotify("'" + ex.Message + "'", MessageBoxIcon.Warning);
|
||
}
|
||
}
|
||
|
||
#region 读Excel提取数据
|
||
/// <summary>
|
||
/// 从Excel提取数据--》Dataset
|
||
/// </summary>
|
||
/// <param name="filename">Excel文件路径名</param>
|
||
private void ImportXlsToData(string fileName)
|
||
{
|
||
try
|
||
{
|
||
string oleDBConnString = String.Empty;
|
||
oleDBConnString = "Provider=Microsoft.Jet.OLEDB.4.0;";
|
||
oleDBConnString += "Data Source=";
|
||
oleDBConnString += fileName;
|
||
oleDBConnString += ";Extended Properties=Excel 8.0;";
|
||
OleDbConnection oleDBConn = null;
|
||
OleDbDataAdapter oleAdMaster = null;
|
||
DataTable m_tableName = new DataTable();
|
||
DataSet ds = new DataSet();
|
||
|
||
oleDBConn = new OleDbConnection(oleDBConnString);
|
||
oleDBConn.Open();
|
||
m_tableName = oleDBConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
|
||
|
||
if (m_tableName != null && m_tableName.Rows.Count > 0)
|
||
{
|
||
|
||
m_tableName.TableName = m_tableName.Rows[0]["TABLE_NAME"].ToString().Trim();
|
||
|
||
}
|
||
string sqlMaster;
|
||
sqlMaster = " SELECT * FROM [" + m_tableName.TableName + "]";
|
||
oleAdMaster = new OleDbDataAdapter(sqlMaster, oleDBConn);
|
||
oleAdMaster.Fill(ds, "m_tableName");
|
||
oleAdMaster.Dispose();
|
||
oleDBConn.Close();
|
||
oleDBConn.Dispose();
|
||
Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(Id);
|
||
DateTime startDate, endDate, startMonth, endMonth;
|
||
List<DateTime> months = new List<DateTime>();
|
||
if (wbsSet != null && wbsSet.StartDate != null && wbsSet.EndDate != null)
|
||
{
|
||
startDate = Convert.ToDateTime(wbsSet.StartDate);
|
||
endDate = Convert.ToDateTime(wbsSet.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);
|
||
}
|
||
AddDatasetToSQL(ds.Tables[0], 7 + months.Count * 2);
|
||
}
|
||
catch (Exception exc)
|
||
{
|
||
Response.Write(exc);
|
||
//return null;
|
||
// return dt;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 将Dataset的数据导入数据库
|
||
/// <summary>
|
||
/// 将Dataset的数据导入数据库
|
||
/// </summary>
|
||
/// <param name="pds">数据集</param>
|
||
/// <param name="Cols">数据集行数</param>
|
||
/// <returns></returns>
|
||
private bool AddDatasetToSQL(DataTable pds, int Cols)
|
||
{
|
||
string result = string.Empty;
|
||
int ic, ir;
|
||
ic = pds.Columns.Count;
|
||
ir = pds.Rows.Count;
|
||
if (ic < Cols)
|
||
{
|
||
ShowNotify("导入Excel格式错误!Excel只有" + ic.ToString().Trim() + "列", MessageBoxIcon.Warning);
|
||
return false;
|
||
}
|
||
if (pds != null && ir > 0)
|
||
{
|
||
Model.Wbs_WbsSet wbsSet1 = BLL.WbsSetService.GetWbsSetByWbsSetId(Id);
|
||
DateTime startDate, endDate, startMonth, endMonth;
|
||
List<DateTime> months = new List<DateTime>();
|
||
if (wbsSet1 != null && wbsSet1.StartDate != null && wbsSet1.EndDate != null)
|
||
{
|
||
startDate = Convert.ToDateTime(wbsSet1.StartDate);
|
||
endDate = Convert.ToDateTime(wbsSet1.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);
|
||
}
|
||
Dictionary<int, string> editRows = new Dictionary<int, string>();
|
||
int a = 0;
|
||
var childWbsSets = BLL.WbsSetService.GetApproveWbsSetsBySuperWbsSetId(Id);
|
||
foreach (var childWbsSet in childWbsSets)
|
||
{
|
||
a++;
|
||
var costControls = BLL.CostControlService.GetSelectedCostControlsByWbsSetId(childWbsSet.WbsSetId);
|
||
foreach (var costControl in costControls)
|
||
{
|
||
a++;
|
||
editRows.Add(a, costControl.CostControlId);
|
||
}
|
||
}
|
||
for (int i = 0; i < ir; i++)
|
||
{
|
||
if (editRows.ContainsKey(i))
|
||
{
|
||
string totalNum = pds.Rows[i][4].ToString();
|
||
string planPrice = pds.Rows[i][5].ToString();
|
||
string realPrice = pds.Rows[i][6].ToString();
|
||
if (!string.IsNullOrEmpty(totalNum))
|
||
{
|
||
try
|
||
{
|
||
decimal d = Convert.ToDecimal(totalNum);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "合同工作量格式输入有误" + "|";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "合同工作量" + "," + "此项为必填项!" + "|";
|
||
}
|
||
if (!string.IsNullOrEmpty(planPrice))
|
||
{
|
||
try
|
||
{
|
||
decimal d = Convert.ToDecimal(planPrice);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "预算单价格式输入有误" + "|";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "预算单价" + "," + "此项为必填项!" + "|";
|
||
}
|
||
if (!string.IsNullOrEmpty(realPrice))
|
||
{
|
||
try
|
||
{
|
||
decimal d = Convert.ToDecimal(realPrice);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "实际单价格式输入有误" + "|";
|
||
}
|
||
}
|
||
else
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + "实际单价" + "," + "此项为必填项!" + "|";
|
||
}
|
||
for (int j = 0; j < months.Count; j++)
|
||
{
|
||
string planNum = pds.Rows[i][7 + j * 2].ToString();
|
||
string thisNum = pds.Rows[i][8 + j * 2].ToString();
|
||
if (!string.IsNullOrEmpty(planNum))
|
||
{
|
||
try
|
||
{
|
||
decimal d = Convert.ToDecimal(planNum);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + string.Format("{0:yyyy年MM月}", months[j]) + "计划量格式输入有误" + "|";
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(thisNum))
|
||
{
|
||
try
|
||
{
|
||
decimal d = Convert.ToDecimal(thisNum);
|
||
}
|
||
catch (Exception)
|
||
{
|
||
result += "第" + (i + 2).ToString() + "行," + string.Format("{0:yyyy年MM月}", months[j]) + "完成量格式输入有误" + "|";
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
decimal changeThisPlanValue = 0, changeThisRealCost = 0, changeThisPlanCost = 0, //当月总变化完成成本、完成预算
|
||
oldThisPlanValue = 0, oldThisRealCost = 0, oldThisPlanCost = 0,
|
||
thisPlanValue = 0, thisRealCost = 0, thisPlanCost = 0;
|
||
if (string.IsNullOrEmpty(result))
|
||
{
|
||
for (int i = 0; i < ir; i++)
|
||
{
|
||
if (editRows.ContainsKey(i))
|
||
{
|
||
string costControlId = editRows.First(x => x.Key == i).Value;
|
||
Model.WBS_CostControl costControl = BLL.CostControlService.GetCostControlByCostControlId(costControlId);
|
||
if (costControl != null)
|
||
{
|
||
string totalNum = pds.Rows[i][4].ToString();
|
||
string planPrice = pds.Rows[i][5].ToString();
|
||
string realPrice = pds.Rows[i][6].ToString();
|
||
costControl.TotalNum = Funs.GetNewDecimal(totalNum);
|
||
costControl.PlanPrice = Funs.GetNewDecimal(planPrice);
|
||
costControl.RealPrice = Funs.GetNewDecimal(realPrice);
|
||
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 = pds.Rows[i][7 + j * 2].ToString();
|
||
string thisNum = pds.Rows[i][8 + j * 2].ToString();
|
||
Model.WBS_CostControlDetail costControlDetail = BLL.CostControlDetailService.GetCostControlDetailByCostControlIdAndMonths(costControlId, months[j]);
|
||
if (costControlDetail != null)
|
||
{
|
||
oldThisPlanValue = (costControlDetail.PlanNum ?? 0) * (costControl.PlanPrice ?? 0);
|
||
oldThisRealCost = (costControlDetail.ThisNum ?? 0) * (costControl.RealPrice ?? 0);
|
||
oldThisPlanCost = (costControlDetail.ThisNum ?? 0) * (costControl.PlanPrice ?? 0);
|
||
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);
|
||
}
|
||
//累加变化值,计算总的变化值
|
||
changeThisPlanValue += thisPlanValue - oldThisPlanValue;
|
||
changeThisRealCost += thisRealCost - oldThisRealCost;
|
||
changeThisPlanCost += thisPlanCost - oldThisPlanCost;
|
||
//更新工作包、工作项
|
||
Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(costControl.WbsSetId);
|
||
UpdateWbsSetDetail(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);
|
||
}
|
||
//更新专业
|
||
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);
|
||
}
|
||
}
|
||
//更新装置
|
||
UpdateInstallationDetail(wbsSet.InstallationId, months[j], changeThisPlanValue, changeThisRealCost, changeThisPlanCost);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(result))
|
||
{
|
||
PipelineList.Clear();
|
||
result = result.Substring(0, result.LastIndexOf("|"));
|
||
errorInfos = result;
|
||
Alert alert = new Alert();
|
||
alert.Message = result;
|
||
alert.Target = Target.Self;
|
||
alert.Show();
|
||
}
|
||
else
|
||
{
|
||
errorInfos = string.Empty;
|
||
ShowNotify("导入成功!", MessageBoxIcon.Success);
|
||
List<Model.CostControlDetailItem> itemList = new List<Model.CostControlDetailItem>();
|
||
Model.CostControlDetailItem item1 = new Model.CostControlDetailItem();
|
||
item1.Id = Id;
|
||
item1.Name1 = wbsSet1.WbsSetName;
|
||
itemList.Add(item1);
|
||
var childWbsSets1 = BLL.WbsSetService.GetApproveWbsSetsBySuperWbsSetId(Id);
|
||
foreach (var childWbsSet in childWbsSets1)
|
||
{
|
||
Model.CostControlDetailItem item2 = new Model.CostControlDetailItem();
|
||
item2.Id = childWbsSet.WbsSetId;
|
||
item2.Name2 = childWbsSet.WbsSetName;
|
||
itemList.Add(item2);
|
||
var costControls = BLL.CostControlService.GetSelectedCostControlsByWbsSetId(childWbsSet.WbsSetId);
|
||
foreach (var costControl in costControls)
|
||
{
|
||
Model.CostControlDetailItem item3 = new Model.CostControlDetailItem();
|
||
item3.Id = costControl.CostControlId;
|
||
item3.Name3 = costControl.CostControlName;
|
||
item3.TotalNum = costControl.TotalNum;
|
||
item3.PlanPrice = costControl.PlanPrice;
|
||
item3.RealPrice = costControl.RealPrice;
|
||
for (int j = 0; j < months.Count; j++)
|
||
{
|
||
Model.WBS_CostControlDetail costControlDetail = BLL.CostControlDetailService.GetCostControlDetailByCostControlIdAndMonths(costControl.CostControlId, months[j]);
|
||
if (costControlDetail != null)
|
||
{
|
||
if (j == 0)
|
||
{
|
||
item3.PlanNum1 = costControlDetail.PlanNum;
|
||
item3.ThisNum1 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 1)
|
||
{
|
||
item3.PlanNum2 = costControlDetail.PlanNum;
|
||
item3.ThisNum2 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 2)
|
||
{
|
||
item3.PlanNum3 = costControlDetail.PlanNum;
|
||
item3.ThisNum3 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 3)
|
||
{
|
||
item3.PlanNum4 = costControlDetail.PlanNum;
|
||
item3.ThisNum4 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 4)
|
||
{
|
||
item3.PlanNum5 = costControlDetail.PlanNum;
|
||
item3.ThisNum5 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 5)
|
||
{
|
||
item3.PlanNum6 = costControlDetail.PlanNum;
|
||
item3.ThisNum6 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 6)
|
||
{
|
||
item3.PlanNum7 = costControlDetail.PlanNum;
|
||
item3.ThisNum7 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 7)
|
||
{
|
||
item3.PlanNum8 = costControlDetail.PlanNum;
|
||
item3.ThisNum8 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 8)
|
||
{
|
||
item3.PlanNum9 = costControlDetail.PlanNum;
|
||
item3.ThisNum9 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 9)
|
||
{
|
||
item3.PlanNum10 = costControlDetail.PlanNum;
|
||
item3.ThisNum10 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 10)
|
||
{
|
||
item3.PlanNum11 = costControlDetail.PlanNum;
|
||
item3.ThisNum11 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 11)
|
||
{
|
||
item3.PlanNum12 = costControlDetail.PlanNum;
|
||
item3.ThisNum12 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 12)
|
||
{
|
||
item3.PlanNum13 = costControlDetail.PlanNum;
|
||
item3.ThisNum13 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 13)
|
||
{
|
||
item3.PlanNum14 = costControlDetail.PlanNum;
|
||
item3.ThisNum14 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 14)
|
||
{
|
||
item3.PlanNum15 = costControlDetail.PlanNum;
|
||
item3.ThisNum15 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 15)
|
||
{
|
||
item3.PlanNum16 = costControlDetail.PlanNum;
|
||
item3.ThisNum16 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 16)
|
||
{
|
||
item3.PlanNum17 = costControlDetail.PlanNum;
|
||
item3.ThisNum17 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 17)
|
||
{
|
||
item3.PlanNum18 = costControlDetail.PlanNum;
|
||
item3.ThisNum18 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 18)
|
||
{
|
||
item3.PlanNum19 = costControlDetail.PlanNum;
|
||
item3.ThisNum19 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 19)
|
||
{
|
||
item3.PlanNum20 = costControlDetail.PlanNum;
|
||
item3.ThisNum20 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 20)
|
||
{
|
||
item3.PlanNum21 = costControlDetail.PlanNum;
|
||
item3.ThisNum21 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 21)
|
||
{
|
||
item3.PlanNum22 = costControlDetail.PlanNum;
|
||
item3.ThisNum22 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 22)
|
||
{
|
||
item3.PlanNum23 = costControlDetail.PlanNum;
|
||
item3.ThisNum23 = costControlDetail.ThisNum;
|
||
}
|
||
else if (j == 23)
|
||
{
|
||
item3.PlanNum24 = costControlDetail.PlanNum;
|
||
item3.ThisNum24 = costControlDetail.ThisNum;
|
||
}
|
||
}
|
||
}
|
||
itemList.Add(item3);
|
||
}
|
||
}
|
||
this.Grid1.DataSource = itemList;
|
||
this.Grid1.DataBind();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ShowNotify("导入数据为空!", MessageBoxIcon.Warning);
|
||
}
|
||
return true;
|
||
}
|
||
|
||
#region 更新工作包、工作项
|
||
/// <summary>
|
||
/// 更新月工作包、工作项
|
||
/// </summary>
|
||
/// <param name="years"></param>
|
||
/// <param name="months"></param>
|
||
/// <param name="planValue"></param>
|
||
/// <param name="parentId"></param>
|
||
private void UpdateWbsSetDetail(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);
|
||
}
|
||
if (wbsSet.SuperWbsSetId != null) //还存在上级节点,需要继续循环
|
||
{
|
||
UpdateWbsSetDetail(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(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);
|
||
}
|
||
if (installation.SuperInstallationId != null) //还存在上级节点,需要继续循环
|
||
{
|
||
UpdateInstallationDetail(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
|
||
#endregion
|
||
}
|
||
} |