528 lines
30 KiB
C#
528 lines
30 KiB
C#
using BLL;
|
||
using Newtonsoft.Json.Linq;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Linq;
|
||
|
||
namespace FineUIPro.Web.HSSE.Manager
|
||
{
|
||
public partial class MonthReportCEdit5 : PageBase
|
||
{
|
||
#region 定义项
|
||
/// <summary>
|
||
/// 月报告查主键
|
||
/// </summary>
|
||
public string newKeyID
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["MonthReportId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["MonthReportId"] = value;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 项目主键
|
||
/// </summary>
|
||
public string ProjectId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["ProjectId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["ProjectId"] = value;
|
||
}
|
||
}
|
||
|
||
private static DateTime startTime;
|
||
|
||
private static DateTime endTime;
|
||
|
||
private static DateTime yearStartTime;
|
||
|
||
private static DateTime projectStartTime;
|
||
|
||
#region 定义集合
|
||
/// <summary>
|
||
/// 6.1 五环HSE费用投入集合
|
||
/// </summary>
|
||
private static List<Model.Manager_Month_FiveExpenseC> fiveExpenses = new List<Model.Manager_Month_FiveExpenseC>();
|
||
|
||
/// <summary>
|
||
/// 6.2 分包商HSE费用投入集合
|
||
/// </summary>
|
||
private static List<Model.Manager_Month_SubExpenseC> subExpenses = new List<Model.Manager_Month_SubExpenseC>();
|
||
|
||
#endregion
|
||
|
||
#endregion
|
||
|
||
#region 加载
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
fiveExpenses.Clear();
|
||
subExpenses.Clear();
|
||
this.newKeyID = Request.Params["monthReportId"];
|
||
this.ProjectId = this.CurrUser.LoginProjectId;
|
||
DateTime months = Convert.ToDateTime(Request.Params["months"]);
|
||
startTime = Convert.ToDateTime(Request.Params["startTime"]);
|
||
endTime = Convert.ToDateTime(Request.Params["endTime"]);
|
||
yearStartTime = Convert.ToDateTime(Request.Params["yearStartTime"]);
|
||
Model.Manager_MonthReportC monthReport = BLL.MonthReportCService.GetMonthReportByMonths(months, this.CurrUser.LoginProjectId);
|
||
Model.Manager_MonthReportC mr = BLL.MonthReportCService.GetLastMonthReportByDate(endTime, this.ProjectId);
|
||
Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(ProjectId);
|
||
if (project.StartDate != null)
|
||
{
|
||
projectStartTime = Convert.ToDateTime(project.StartDate);
|
||
}
|
||
if (monthReport != null)
|
||
{
|
||
this.newKeyID = monthReport.MonthReportId;
|
||
this.ProjectId = monthReport.ProjectId;
|
||
months = Convert.ToDateTime(monthReport.Months);
|
||
|
||
fiveExpenses = BLL.FiveExpenseCService.GetFiveExpenseByMonthReportId(this.newKeyID);
|
||
if (fiveExpenses.Count > 0)
|
||
{
|
||
this.gvFiveExpenseC.DataSource = fiveExpenses;
|
||
this.gvFiveExpenseC.DataBind();
|
||
OutputSummaryData();
|
||
}
|
||
else
|
||
{
|
||
GetFiveExpenseList();
|
||
}
|
||
|
||
subExpenses = BLL.SubExpenseCService.GetSubExpenseByMonthReportId(this.newKeyID);
|
||
if (subExpenses.Count>0)
|
||
{
|
||
this.gvSubExpenseC.DataSource = subExpenses;
|
||
this.gvSubExpenseC.DataBind();
|
||
OutputSubSummaryData();
|
||
}
|
||
else
|
||
{
|
||
GetSubExpenseList();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GetFiveExpenseList(); //费用投入
|
||
GetSubExpenseList(); //本月项目分包商HSE费用支付统计
|
||
}
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 本月项目分包商HSE费用支付统计
|
||
/// <summary>
|
||
/// 费用投入
|
||
/// </summary>
|
||
private void GetFiveExpenseList()
|
||
{
|
||
#region 五环(本月)
|
||
decimal? sMonthType1 = 0, sMonthType2 = 0, sMonthType3 = 0, sMonthType4 = 0, sMonthType5 = 0, sMonthType6 = 0;
|
||
decimal? tMonthType1 = 0;
|
||
List<Model.CostGoods_PayRegistration> payRegistrations = BLL.PayRegistrationService.GetPayRegistrationByPayDate(startTime, endTime, this.ProjectId, BLL.Const.UnitId_CWCEC);
|
||
if (payRegistrations != null)
|
||
{
|
||
foreach (var item in payRegistrations)
|
||
{
|
||
sMonthType1 += item.SMonthType1_1 + item.SMonthType1_2 + item.SMonthType1_3 + item.SMonthType1_4 + item.SMonthType1_5 + item.SMonthType1_6 + item.SMonthType1_7 + item.SMonthType1_8 + item.SMonthType1_9 + item.SMonthType1_10 + item.SMonthType1_11 + item.SMonthType1_12 + item.SMonthType1_13 + item.SMonthType1_14 + item.SMonthType1_15 + item.SMonthType1_16;
|
||
sMonthType2 += item.SMonthType2_1 + item.SMonthType2_2 + item.SMonthType2_3 + item.SMonthType2_4;
|
||
sMonthType3 += item.SMonthType3_1 + item.SMonthType3_2 + item.SMonthType3_3 + item.SMonthType3_4 + item.SMonthType3_5 + item.SMonthType3_6;
|
||
sMonthType4 += item.SMonthType4_1 + item.SMonthType4_2 + item.SMonthType4_3 + item.SMonthType4_4 + item.SMonthType4_5 + item.SMonthType4_6 + item.SMonthType4_7 + item.SMonthType4_8 + item.SMonthType4_9 + item.SMonthType4_10 + item.SMonthType4_11 + item.SMonthType4_12 + item.SMonthType4_13 + item.SMonthType4_14 + item.SMonthType4_15 + item.SMonthType4_16 + item.SMonthType4_17 + item.SMonthType4_18 + item.SMonthType4_19 + item.SMonthType4_20 + item.SMonthType4_21 + item.SMonthType4_22 + item.SMonthType4_23 + item.SMonthType4_24 + item.SMonthType4_25 + item.SMonthType4_26 + item.SMonthType4_27 + item.SMonthType4_28 + item.SMonthType4_29 + item.SMonthType4_30 + item.SMonthType4_31 + item.SMonthType4_32 + item.SMonthType4_33 + item.SMonthType4_34 + item.SMonthType4_35 + item.SMonthType4_35 + item.SMonthType4_36 + item.SMonthType4_37 + item.SMonthType4_38 + item.SMonthType4_39 + item.SMonthType4_40;
|
||
sMonthType5 += item.SMonthType5_1 + item.SMonthType5_2 + item.SMonthType5_3 + item.SMonthType5_4 + item.SMonthType5_5 + item.SMonthType5_6;
|
||
sMonthType6 += item.SMonthType6_1 + item.SMonthType6_2 + item.SMonthType6_3;
|
||
tMonthType1 += item.TMonthType1_1 + item.TMonthType1_2 + item.TMonthType1_3 + item.TMonthType1_4 + item.TMonthType1_5 + item.TMonthType1_6 + item.TMonthType1_7 + item.TMonthType1_8 + item.TMonthType1_9 + item.TMonthType1_10 + item.TMonthType1_11;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 五环(项目)
|
||
decimal? sProjectType1 = 0, sProjectType2 = 0, sProjectType3 = 0, sProjectType4 = 0, sProjectType5 = 0, sProjectType6 = 0;
|
||
decimal? tProjectType1 = 0;
|
||
List<Model.CostGoods_PayRegistration> payRegistrationsPro = BLL.PayRegistrationService.GetPayRegistrationByPayDate(projectStartTime, endTime, this.ProjectId, BLL.Const.UnitId_CWCEC);
|
||
if (payRegistrationsPro != null)
|
||
{
|
||
foreach (var item in payRegistrationsPro)
|
||
{
|
||
sProjectType1 += item.SMonthType1_1 + item.SMonthType1_2 + item.SMonthType1_3 + item.SMonthType1_4 + item.SMonthType1_5 + item.SMonthType1_6 + item.SMonthType1_7 + item.SMonthType1_8 + item.SMonthType1_9 + item.SMonthType1_10 + item.SMonthType1_11 + item.SMonthType1_12 + item.SMonthType1_13 + item.SMonthType1_14 + item.SMonthType1_15 + item.SMonthType1_16;
|
||
sProjectType2 += item.SMonthType2_1 + item.SMonthType2_2 + item.SMonthType2_3 + item.SMonthType2_4;
|
||
sProjectType3 += item.SMonthType3_1 + item.SMonthType3_2 + item.SMonthType3_3 + item.SMonthType3_4 + item.SMonthType3_5 + item.SMonthType3_6;
|
||
sProjectType4 += item.SMonthType4_1 + item.SMonthType4_2 + item.SMonthType4_3 + item.SMonthType4_4 + item.SMonthType4_5 + item.SMonthType4_6 + item.SMonthType4_7 + item.SMonthType4_8 + item.SMonthType4_9 + item.SMonthType4_10 + item.SMonthType4_11 + item.SMonthType4_12 + item.SMonthType4_13 + item.SMonthType4_14 + item.SMonthType4_15 + item.SMonthType4_16 + item.SMonthType4_17 + item.SMonthType4_18 + item.SMonthType4_19 + item.SMonthType4_20 + item.SMonthType4_21 + item.SMonthType4_22 + item.SMonthType4_23 + item.SMonthType4_24 + item.SMonthType4_25 + item.SMonthType4_26 + item.SMonthType4_27 + item.SMonthType4_28 + item.SMonthType4_29 + item.SMonthType4_30 + item.SMonthType4_31 + item.SMonthType4_32 + item.SMonthType4_33 + item.SMonthType4_34 + item.SMonthType4_35 + item.SMonthType4_35 + item.SMonthType4_36 + item.SMonthType4_37 + item.SMonthType4_38 + item.SMonthType4_39 + item.SMonthType4_40;
|
||
sProjectType5 += item.SMonthType5_1 + item.SMonthType5_2 + item.SMonthType5_3 + item.SMonthType5_4 + item.SMonthType5_5 + item.SMonthType5_6;
|
||
sProjectType6 += item.SMonthType6_1 + item.SMonthType6_2 + item.SMonthType6_3;
|
||
tProjectType1 += item.TMonthType1_1 + item.TMonthType1_2 + item.TMonthType1_3 + item.TMonthType1_4 + item.TMonthType1_5 + item.TMonthType1_6 + item.TMonthType1_7 + item.TMonthType1_8 + item.TMonthType1_9 + item.TMonthType1_10 + item.TMonthType1_11;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 施工分包(本月)
|
||
decimal? sConMonthType1 = 0, sConMonthType2 = 0, sConMonthType3 = 0, sConMonthType4 = 0, sConMonthType5 = 0, sConMonthType6 = 0;
|
||
decimal? tConMonthType1 = 0;
|
||
List<Model.CostGoods_PayRegistration> payRegistrationsConMonth = BLL.PayRegistrationService.GetConPayRegistrationByPayDate(startTime, endTime, this.ProjectId);
|
||
if (payRegistrationsConMonth != null)
|
||
{
|
||
foreach (var item in payRegistrationsConMonth)
|
||
{
|
||
sConMonthType1 += item.SMonthType1_1 + item.SMonthType1_2 + item.SMonthType1_3 + item.SMonthType1_4 + item.SMonthType1_5 + item.SMonthType1_6 + item.SMonthType1_7 + item.SMonthType1_8 + item.SMonthType1_9 + item.SMonthType1_10 + item.SMonthType1_11 + item.SMonthType1_12 + item.SMonthType1_13 + item.SMonthType1_14 + item.SMonthType1_15 + item.SMonthType1_16;
|
||
sConMonthType2 += item.SMonthType2_1 + item.SMonthType2_2 + item.SMonthType2_3 + item.SMonthType2_4;
|
||
sConMonthType3 += item.SMonthType3_1 + item.SMonthType3_2 + item.SMonthType3_3 + item.SMonthType3_4 + item.SMonthType3_5 + item.SMonthType3_6;
|
||
sConMonthType4 += item.SMonthType4_1 + item.SMonthType4_2 + item.SMonthType4_3 + item.SMonthType4_4 + item.SMonthType4_5 + item.SMonthType4_6 + item.SMonthType4_7 + item.SMonthType4_8 + item.SMonthType4_9 + item.SMonthType4_10 + item.SMonthType4_11 + item.SMonthType4_12 + item.SMonthType4_13 + item.SMonthType4_14 + item.SMonthType4_15 + item.SMonthType4_16 + item.SMonthType4_17 + item.SMonthType4_18 + item.SMonthType4_19 + item.SMonthType4_20 + item.SMonthType4_21 + item.SMonthType4_22 + item.SMonthType4_23 + item.SMonthType4_24 + item.SMonthType4_25 + item.SMonthType4_26 + item.SMonthType4_27 + item.SMonthType4_28 + item.SMonthType4_29 + item.SMonthType4_30 + item.SMonthType4_31 + item.SMonthType4_32 + item.SMonthType4_33 + item.SMonthType4_34 + item.SMonthType4_35 + item.SMonthType4_35 + item.SMonthType4_36 + item.SMonthType4_37 + item.SMonthType4_38 + item.SMonthType4_39 + item.SMonthType4_40;
|
||
sConMonthType5 += item.SMonthType5_1 + item.SMonthType5_2 + item.SMonthType5_3 + item.SMonthType5_4 + item.SMonthType5_5 + item.SMonthType5_6;
|
||
sConMonthType6 += item.SMonthType6_1 + item.SMonthType6_2 + item.SMonthType6_3;
|
||
tConMonthType1 += item.TMonthType1_1 + item.TMonthType1_2 + item.TMonthType1_3 + item.TMonthType1_4 + item.TMonthType1_5 + item.TMonthType1_6 + item.TMonthType1_7 + item.TMonthType1_8 + item.TMonthType1_9 + item.TMonthType1_10 + item.TMonthType1_11;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 施工分包(项目)
|
||
decimal? sConProjectType1 = 0, sConProjectType2 = 0, sConProjectType3 = 0, sConProjectType4 = 0, sConProjectType5 = 0, sConProjectType6 = 0;
|
||
decimal? tConProjectType1 = 0;
|
||
List<Model.CostGoods_PayRegistration> payRegistrationsConPro = BLL.PayRegistrationService.GetConPayRegistrationByPayDate(projectStartTime, endTime, this.ProjectId);
|
||
if (payRegistrationsConPro != null)
|
||
{
|
||
foreach (var item in payRegistrationsConPro)
|
||
{
|
||
sConProjectType1 += item.SMonthType1_1 + item.SMonthType1_2 + item.SMonthType1_3 + item.SMonthType1_4 + item.SMonthType1_5 + item.SMonthType1_6 + item.SMonthType1_7 + item.SMonthType1_8 + item.SMonthType1_9 + item.SMonthType1_10 + item.SMonthType1_11 + item.SMonthType1_12 + item.SMonthType1_13 + item.SMonthType1_14 + item.SMonthType1_15 + item.SMonthType1_16;
|
||
sConProjectType2 += item.SMonthType2_1 + item.SMonthType2_2 + item.SMonthType2_3 + item.SMonthType2_4;
|
||
sConProjectType3 += item.SMonthType3_1 + item.SMonthType3_2 + item.SMonthType3_3 + item.SMonthType3_4 + item.SMonthType3_5 + item.SMonthType3_6;
|
||
sConProjectType4 += item.SMonthType4_1 + item.SMonthType4_2 + item.SMonthType4_3 + item.SMonthType4_4 + item.SMonthType4_5 + item.SMonthType4_6 + item.SMonthType4_7 + item.SMonthType4_8 + item.SMonthType4_9 + item.SMonthType4_10 + item.SMonthType4_11 + item.SMonthType4_12 + item.SMonthType4_13 + item.SMonthType4_14 + item.SMonthType4_15 + item.SMonthType4_16 + item.SMonthType4_17 + item.SMonthType4_18 + item.SMonthType4_19 + item.SMonthType4_20 + item.SMonthType4_21 + item.SMonthType4_22 + item.SMonthType4_23 + item.SMonthType4_24 + item.SMonthType4_25 + item.SMonthType4_26 + item.SMonthType4_27 + item.SMonthType4_28 + item.SMonthType4_29 + item.SMonthType4_30 + item.SMonthType4_31 + item.SMonthType4_32 + item.SMonthType4_33 + item.SMonthType4_34 + item.SMonthType4_35 + item.SMonthType4_35 + item.SMonthType4_36 + item.SMonthType4_37 + item.SMonthType4_38 + item.SMonthType4_39 + item.SMonthType4_40;
|
||
sConProjectType5 += item.SMonthType5_1 + item.SMonthType5_2 + item.SMonthType5_3 + item.SMonthType5_4 + item.SMonthType5_5 + item.SMonthType5_6;
|
||
sConProjectType6 += item.SMonthType6_1 + item.SMonthType6_2 + item.SMonthType6_3;
|
||
tConProjectType1 += item.TMonthType1_1 + item.TMonthType1_2 + item.TMonthType1_3 + item.TMonthType1_4 + item.TMonthType1_5 + item.TMonthType1_6 + item.TMonthType1_7 + item.TMonthType1_8 + item.TMonthType1_9 + item.TMonthType1_10 + item.TMonthType1_11;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
int i = 0;
|
||
Model.Manager_Month_FiveExpenseC fiveExpense1 = new Model.Manager_Month_FiveExpenseC
|
||
{
|
||
FiveExpenseId = SQLHelper.GetNewID(typeof(Model.Manager_Month_FiveExpenseC)),
|
||
SortIndex = i,
|
||
InvestmentProject = "基础管理",
|
||
PlanCostMonth = sMonthType1,//五环工程(本月)
|
||
PlanCostYear = sProjectType1, //五环工程(项目累计)
|
||
ActualCostMonth = sConMonthType1,//施工分包商(本月)
|
||
ActualCostYear = sConProjectType1//施工分包商(项目累计)
|
||
};
|
||
fiveExpenses.Add(fiveExpense1);
|
||
i++;
|
||
|
||
Model.Manager_Month_FiveExpenseC fiveExpense2 = new Model.Manager_Month_FiveExpenseC
|
||
{
|
||
FiveExpenseId = SQLHelper.GetNewID(typeof(Model.Manager_Month_FiveExpenseC)),
|
||
SortIndex = i,
|
||
InvestmentProject = "安全技术",
|
||
PlanCostMonth = sMonthType2,//五环工程(本月)
|
||
PlanCostYear = sProjectType2, //五环工程(项目累计)
|
||
ActualCostMonth = sConMonthType2,//施工分包商(本月)
|
||
ActualCostYear = sConProjectType2//施工分包商(项目累计)
|
||
};
|
||
fiveExpenses.Add(fiveExpense2);
|
||
i++;
|
||
|
||
Model.Manager_Month_FiveExpenseC fiveExpense3 = new Model.Manager_Month_FiveExpenseC
|
||
{
|
||
FiveExpenseId = SQLHelper.GetNewID(typeof(Model.Manager_Month_FiveExpenseC)),
|
||
SortIndex = i,
|
||
InvestmentProject = "职业健康",
|
||
PlanCostMonth = sMonthType3,//五环工程(本月)
|
||
PlanCostYear = sProjectType3, //五环工程(项目累计)
|
||
ActualCostMonth = sConMonthType3,//施工分包商(本月)
|
||
ActualCostYear = sConProjectType3//施工分包商(项目累计)
|
||
};
|
||
fiveExpenses.Add(fiveExpense3);
|
||
i++;
|
||
|
||
Model.Manager_Month_FiveExpenseC fiveExpense4 = new Model.Manager_Month_FiveExpenseC
|
||
{
|
||
FiveExpenseId = SQLHelper.GetNewID(typeof(Model.Manager_Month_FiveExpenseC)),
|
||
SortIndex = i,
|
||
InvestmentProject = "安全防护",
|
||
PlanCostMonth = sMonthType4,//五环工程(本月)
|
||
PlanCostYear = sProjectType4, //五环工程(项目累计)
|
||
ActualCostMonth = sConMonthType4,//施工分包商(本月)
|
||
ActualCostYear = sConProjectType4//施工分包商(项目累计)
|
||
};
|
||
fiveExpenses.Add(fiveExpense4);
|
||
i++;
|
||
|
||
Model.Manager_Month_FiveExpenseC fiveExpense5 = new Model.Manager_Month_FiveExpenseC
|
||
{
|
||
FiveExpenseId = SQLHelper.GetNewID(typeof(Model.Manager_Month_FiveExpenseC)),
|
||
SortIndex = i,
|
||
InvestmentProject = "化工试车",
|
||
PlanCostMonth = sMonthType5,//五环工程(本月)
|
||
PlanCostYear = sProjectType5, //五环工程(项目累计)
|
||
ActualCostMonth = sConMonthType5,//施工分包商(本月)
|
||
ActualCostYear = sConProjectType5//施工分包商(项目累计)
|
||
};
|
||
fiveExpenses.Add(fiveExpense5);
|
||
i++;
|
||
|
||
Model.Manager_Month_FiveExpenseC fiveExpense6 = new Model.Manager_Month_FiveExpenseC
|
||
{
|
||
FiveExpenseId = SQLHelper.GetNewID(typeof(Model.Manager_Month_FiveExpenseC)),
|
||
SortIndex = i,
|
||
InvestmentProject = "教育培训",
|
||
PlanCostMonth = sMonthType6,//五环工程(本月)
|
||
PlanCostYear = sProjectType6, //五环工程(项目累计)
|
||
ActualCostMonth = sConMonthType6,//施工分包商(本月)
|
||
ActualCostYear = sConProjectType6//施工分包商(项目累计)
|
||
};
|
||
fiveExpenses.Add(fiveExpense6);
|
||
i++;
|
||
|
||
Model.Manager_Month_FiveExpenseC fiveExpense7 = new Model.Manager_Month_FiveExpenseC
|
||
{
|
||
FiveExpenseId = SQLHelper.GetNewID(typeof(Model.Manager_Month_FiveExpenseC)),
|
||
SortIndex = i,
|
||
InvestmentProject = "文明施工环境保护",
|
||
PlanCostMonth = tMonthType1,//五环工程(本月)
|
||
PlanCostYear = tMonthType1, //五环工程(项目累计)
|
||
ActualCostMonth = tConMonthType1,//施工分包商(本月)
|
||
ActualCostYear = tConProjectType1//施工分包商(项目累计)
|
||
};
|
||
fiveExpenses.Add(fiveExpense7);
|
||
|
||
this.gvFiveExpenseC.DataSource = fiveExpenses;
|
||
this.gvFiveExpenseC.DataBind();
|
||
|
||
OutputSummaryData();
|
||
}
|
||
/// <summary>
|
||
/// 求和
|
||
/// </summary>
|
||
private void OutputSummaryData()
|
||
{
|
||
JObject summary = new JObject();
|
||
|
||
decimal TotalPlanCostMonth = 0, TotalPlanCostYear = 0, TotalActualCostMonth = 0, TotalActualCostYear = 0;
|
||
foreach (JObject mergedRow in gvFiveExpenseC.GetMergedData())
|
||
{
|
||
JObject values = mergedRow.Value<JObject>("values");
|
||
if (!string.IsNullOrEmpty(values["PlanCostMonth"].ToString()))
|
||
{
|
||
TotalPlanCostMonth += values.Value<decimal>("PlanCostMonth");
|
||
}
|
||
if (!string.IsNullOrEmpty(values["PlanCostYear"].ToString()))
|
||
{
|
||
TotalPlanCostYear += values.Value<decimal>("PlanCostYear");
|
||
}
|
||
if (!string.IsNullOrEmpty(values["ActualCostMonth"].ToString()))
|
||
{
|
||
TotalActualCostMonth += values.Value<decimal>("ActualCostMonth");
|
||
}
|
||
if (!string.IsNullOrEmpty(values["ActualCostYear"].ToString()))
|
||
{
|
||
TotalActualCostYear += values.Value<decimal>("ActualCostYear");
|
||
}
|
||
}
|
||
summary.Add("InvestmentProject", "合计");
|
||
summary.Add("PlanCostMonth", TotalPlanCostMonth.ToString("F2"));
|
||
summary.Add("PlanCostYear", TotalPlanCostYear.ToString("F2"));
|
||
summary.Add("ActualCostMonth", TotalActualCostMonth.ToString("F2"));
|
||
summary.Add("ActualCostYear", TotalActualCostYear.ToString("F2"));
|
||
|
||
gvFiveExpenseC.SummaryData = summary;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 本月项目分包商HSE费用支付统计
|
||
/// <summary>
|
||
/// 绑定数据
|
||
/// </summary>
|
||
private void GetSubExpenseList()
|
||
{
|
||
var units = from x in Funs.DB.Project_ProjectUnit
|
||
where x.ProjectId == this.ProjectId && x.UnitType == "2"
|
||
orderby x.UnitType
|
||
select x;
|
||
if (units.Count() > 0)
|
||
{
|
||
foreach (Model.Project_ProjectUnit u in units)
|
||
{
|
||
Model.Manager_Month_SubExpenseC subExpense = new Model.Manager_Month_SubExpenseC
|
||
{
|
||
SubExpenseId = SQLHelper.GetNewID(typeof(Model.Manager_Month_SubExpenseC)),
|
||
SubUnit =BLL.UnitService.GetUnitNameByUnitId(u.UnitId),
|
||
ContractAmount = BLL.SubPayRegistrationService.GetSubPaySMonthTypeByUnitId(u.UnitId, startTime,endTime),
|
||
MonthApprovalAmount = BLL.SubPayRegistrationService.GetSubPayRegistrationByUnitId(u.UnitId, startTime, endTime),
|
||
ProjectApprovalAmount = BLL.SubPayRegistrationService.GetSubPayRegistrationByUnitId(u.UnitId, projectStartTime, endTime),
|
||
};
|
||
|
||
subExpenses.Add(subExpense);
|
||
}
|
||
}
|
||
this.gvSubExpenseC.DataSource = subExpenses;
|
||
this.gvSubExpenseC.DataBind();
|
||
OutputSubSummaryData();
|
||
}
|
||
/// <summary>
|
||
/// 求和
|
||
/// </summary>
|
||
private void OutputSubSummaryData()
|
||
{
|
||
JObject summary = new JObject();
|
||
|
||
decimal TotalContractAmount = 0, TotalMonthApprovalAmount = 0, TotalProjectApprovalAmount = 0;
|
||
foreach (JObject mergedRow in gvSubExpenseC.GetMergedData())
|
||
{
|
||
JObject values = mergedRow.Value<JObject>("values");
|
||
if (!string.IsNullOrEmpty(values["ContractAmount"].ToString()))
|
||
{
|
||
TotalContractAmount += values.Value<decimal>("ContractAmount");
|
||
}
|
||
if (!string.IsNullOrEmpty(values["MonthApprovalAmount"].ToString()))
|
||
{
|
||
TotalMonthApprovalAmount += values.Value<decimal>("MonthApprovalAmount");
|
||
}
|
||
if (!string.IsNullOrEmpty(values["ProjectApprovalAmount"].ToString()))
|
||
{
|
||
TotalProjectApprovalAmount += values.Value<decimal>("ProjectApprovalAmount");
|
||
}
|
||
}
|
||
summary.Add("SubUnit", "合计");
|
||
summary.Add("ContractAmount", TotalContractAmount.ToString("F2"));
|
||
summary.Add("MonthApprovalAmount", TotalMonthApprovalAmount.ToString("F2"));
|
||
summary.Add("ProjectApprovalAmount", TotalProjectApprovalAmount.ToString("F2"));
|
||
|
||
gvSubExpenseC.SummaryData = summary;
|
||
}
|
||
#endregion
|
||
|
||
#region 保存按钮
|
||
/// <summary>
|
||
/// 保存按钮
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
Model.Manager_MonthReportC oldMonthReport = BLL.MonthReportCService.GetMonthReportByMonths(Convert.ToDateTime(Request.Params["months"]), this.CurrUser.LoginProjectId);
|
||
if (oldMonthReport != null)
|
||
{
|
||
BLL.MonthReportCService.UpdateMonthReport(oldMonthReport);
|
||
OperateFiveExpenseSort(oldMonthReport.MonthReportId);
|
||
OperateSubExpenseSort(oldMonthReport.MonthReportId);
|
||
BLL.LogService.AddSys_Log(this.CurrUser, oldMonthReport.MonthReportCode, oldMonthReport.MonthReportId, BLL.Const.ProjectManagerMonthCMenuId, BLL.Const.BtnModify);
|
||
}
|
||
else
|
||
{
|
||
Model.Manager_MonthReportC monthReport = new Model.Manager_MonthReportC();
|
||
string newKeyID = SQLHelper.GetNewID(typeof(Model.Manager_MonthReportC));
|
||
monthReport.MonthReportId = newKeyID;
|
||
monthReport.ProjectId = this.CurrUser.LoginProjectId;
|
||
this.newKeyID = newKeyID;
|
||
monthReport.MonthReportCode = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectManagerMonthCMenuId, this.ProjectId, this.CurrUser.UnitId);
|
||
monthReport.Months = Funs.GetNewDateTime(Request.Params["months"]);
|
||
monthReport.ReportMan = this.CurrUser.UserId;
|
||
monthReport.MonthReportDate = DateTime.Now;
|
||
BLL.MonthReportCService.AddMonthReport(monthReport);
|
||
OperateFiveExpenseSort(newKeyID);
|
||
OperateSubExpenseSort(newKeyID);
|
||
BLL.LogService.AddSys_Log(this.CurrUser, monthReport.MonthReportCode, monthReport.MonthReportId, BLL.Const.ProjectManagerMonthCMenuId, BLL.Const.BtnAdd);
|
||
}
|
||
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
||
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
||
}
|
||
|
||
#region 保存本月项目HSE费用投入统计
|
||
/// <summary>
|
||
/// 本月项目HSE费用投入统计
|
||
/// </summary>
|
||
/// <param name="monthReportId"></param>
|
||
private void OperateFiveExpenseSort(string monthReportId)
|
||
{
|
||
BLL.FiveExpenseCService.DeleteFiveExpenseByMonthReportId(monthReportId);
|
||
jerqueSaveFiveExpenseList();
|
||
foreach (Model.Manager_Month_FiveExpenseC fiveExpendse in fiveExpenses)
|
||
{
|
||
fiveExpendse.MonthReportId = monthReportId;
|
||
BLL.FiveExpenseCService.AddFiveExpense(fiveExpendse);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 保存本月项目HSE费用投入统计数据
|
||
/// </summary>
|
||
private void jerqueSaveFiveExpenseList()
|
||
{
|
||
fiveExpenses.Clear();
|
||
JArray mergedData = gvFiveExpenseC.GetMergedData();
|
||
foreach (JObject mergedRow in mergedData)
|
||
{
|
||
string status = mergedRow.Value<string>("status");
|
||
JObject values = mergedRow.Value<JObject>("values");
|
||
int i = mergedRow.Value<int>("index");
|
||
Model.Manager_Month_FiveExpenseC trainSort = new Model.Manager_Month_FiveExpenseC
|
||
{
|
||
FiveExpenseId = this.gvFiveExpenseC.Rows[i].DataKeys[0].ToString(),
|
||
SortIndex = i,
|
||
InvestmentProject = values.Value<string>("InvestmentProject").ToString(),
|
||
PlanCostMonth = Funs.GetNewDecimal(values.Value<string>("PlanCostMonth").ToString()),
|
||
PlanCostYear = Funs.GetNewDecimal(values.Value<string>("PlanCostYear").ToString()),
|
||
ActualCostMonth = Funs.GetNewDecimal(values.Value<string>("ActualCostMonth").ToString()),
|
||
ActualCostYear = Funs.GetNewDecimal(values.Value<string>("ActualCostYear").ToString())
|
||
};
|
||
fiveExpenses.Add(trainSort);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 保存本月项目分包商HSE费用支付统计
|
||
/// <summary>
|
||
/// 本月项目分包商HSE费用支付统计
|
||
/// </summary>
|
||
/// <param name="monthReportId"></param>
|
||
private void OperateSubExpenseSort(string monthReportId)
|
||
{
|
||
BLL.SubExpenseCService.DeleteSubExpenseByMonthReportId(monthReportId);
|
||
jerqueSaveSubExpenseList();
|
||
foreach (Model.Manager_Month_SubExpenseC subExpendse in subExpenses)
|
||
{
|
||
subExpendse.MonthReportId = monthReportId;
|
||
BLL.SubExpenseCService.AddSubExpense(subExpendse);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 保存本月项目分包商HSE费用支付统计数据
|
||
/// </summary>
|
||
private void jerqueSaveSubExpenseList()
|
||
{
|
||
subExpenses.Clear();
|
||
JArray mergedData = gvSubExpenseC.GetMergedData();
|
||
foreach (JObject mergedRow in mergedData)
|
||
{
|
||
string status = mergedRow.Value<string>("status");
|
||
JObject values = mergedRow.Value<JObject>("values");
|
||
int i = mergedRow.Value<int>("index");
|
||
Model.Manager_Month_SubExpenseC trainSort = new Model.Manager_Month_SubExpenseC
|
||
{
|
||
SubExpenseId = this.gvSubExpenseC.Rows[i].DataKeys[0].ToString(),
|
||
SortIndex = i,
|
||
SubUnit = values.Value<string>("SubUnit").ToString(),
|
||
ContractAmount = Funs.GetNewDecimal(values.Value<string>("ContractAmount").ToString()),
|
||
MonthApprovalAmount = Funs.GetNewDecimal(values.Value<string>("MonthApprovalAmount").ToString()),
|
||
ProjectApprovalAmount = Funs.GetNewDecimal(values.Value<string>("ProjectApprovalAmount").ToString())
|
||
};
|
||
subExpenses.Add(trainSort);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#endregion
|
||
}
|
||
} |