735 lines
31 KiB
C#
735 lines
31 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Linq;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
using BLL;
|
||
using Newtonsoft.Json.Linq;
|
||
using System.Threading;
|
||
|
||
namespace FineUIPro.Web.HSSE.Manager
|
||
{
|
||
public partial class ManagerMonthCEdit : PageBase
|
||
{
|
||
#region 定义项
|
||
/// <summary>
|
||
/// 主键
|
||
/// </summary>
|
||
public string MonthReportId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["MonthReportId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["MonthReportId"] = value;
|
||
}
|
||
}
|
||
|
||
public string AddOrUpdate
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["AddOrUpdate"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["AddOrUpdate"] = value;
|
||
}
|
||
}
|
||
|
||
public string ProjectId { get; set; }
|
||
|
||
private static DateTime months;
|
||
|
||
private static DateTime startTime;
|
||
|
||
private static DateTime endTime;
|
||
#endregion
|
||
|
||
#region list集合
|
||
public List<Model.Base_Unit> unitList = new List<Model.Base_Unit>();
|
||
|
||
/// <summary>
|
||
/// 培训情况集合
|
||
/// </summary>
|
||
private static List<Model.Manager_TrainSortC> trainSorts = new List<Model.Manager_TrainSortC>();
|
||
#endregion
|
||
public Model.SGGLDB db = Funs.DB;
|
||
|
||
#region 加载页面
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
ProjectId = CurrUser.LoginProjectId;
|
||
unitList = db.Base_Unit.ToList();
|
||
MonthReportId = Request.Params["MonthReportId"];
|
||
if (!string.IsNullOrEmpty(MonthReportId))
|
||
{
|
||
var model = db.Manager_MonthReportC.FirstOrDefault(x => x.MonthReportId == MonthReportId);
|
||
if (model != null)
|
||
{
|
||
if (model.MonthReportCode != null)
|
||
{
|
||
this.txtPeriod.Text = Convert.ToString(model.MonthReportCode);
|
||
}
|
||
if (model.Months != null)
|
||
{
|
||
txtReportMonths.Text = string.Format("{0:yyyy-MM}", model.Months);
|
||
}
|
||
if (model.StartDate != null)
|
||
{
|
||
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", model.StartDate);
|
||
}
|
||
if (model.EndDate != null)
|
||
{
|
||
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", model.EndDate);
|
||
}
|
||
}
|
||
AddOrUpdate = "update";
|
||
|
||
#region 3.本月项目现场HSE人工日统计
|
||
//本月项目现场HSE人工日统计
|
||
Model.MonthReportCHSEDay hseDay = new Model.MonthReportCHSEDay
|
||
{
|
||
MonthHSEDay = model.MonthHSEDay ?? 0,
|
||
SumHSEDay = model.SumHSEDay ?? 0,
|
||
MonthHSEWorkDay = model.MonthHSEWorkDay ?? 0,
|
||
YearHSEWorkDay = model.YearHSEWorkDay ?? 0,
|
||
SumHSEWorkDay = model.SumHSEWorkDay ?? 0,
|
||
HseManhours = model.HseManhours ?? 0,
|
||
SubcontractManHours = model.SubcontractManHours ?? 0,
|
||
TotalHseManhoursYear = model.TotalHseManhoursYear ?? 0,
|
||
TotalHseManhours = model.TotalHseManhours ?? 0
|
||
};
|
||
List<Model.MonthReportCHSEDay> list = new List<Model.MonthReportCHSEDay>();
|
||
list.Add(hseDay);
|
||
this.gvHSEDay.DataSource = list;
|
||
this.gvHSEDay.DataBind();
|
||
#endregion
|
||
|
||
#region 4.1 培训情况
|
||
//培训情况
|
||
var trainSorts = BLL.TrainSortCService.GetTrainSortsByMonthReportId(MonthReportId);
|
||
if (trainSorts.Count > 0)
|
||
{
|
||
this.gvTrainSort.DataSource = trainSorts;
|
||
this.gvTrainSort.DataBind();
|
||
|
||
if (this.gvTrainSort.Rows.Count > 0)
|
||
{
|
||
JObject summary = new JObject();
|
||
summary.Add("TrainType", "培训人数合计:");
|
||
summary.Add("TotalPersonNum", trainSorts.Sum(x=>x.TotalPersonNum));
|
||
this.gvTrainSort.SummaryData = summary;
|
||
}
|
||
else
|
||
{
|
||
this.gvTrainSort.SummaryData = null;
|
||
}
|
||
}
|
||
#endregion
|
||
//加载所有grid
|
||
lodAllGrid("1");
|
||
}
|
||
else
|
||
{
|
||
MonthReportId = Guid.NewGuid().ToString();
|
||
months = Convert.ToDateTime(Request.Params["months"]);
|
||
this.txtReportMonths.Text = string.Format("{0:yyyy-MM}", months);
|
||
this.txtStartDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddMonths(-1));
|
||
this.txtEndDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
||
this.txtPeriod.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectManagerMonthCMenuId, this.ProjectId, this.CurrUser.UnitId);
|
||
AddOrUpdate = "add";
|
||
startTime = Convert.ToDateTime(txtStartDate.Text);
|
||
endTime = Convert.ToDateTime(txtEndDate.Text);
|
||
//加载所有grid
|
||
lodAllGrid("0");
|
||
}
|
||
|
||
#region 加载1.项目概况
|
||
var project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
|
||
var mainUnit = BLL.UnitService.GetThisUnitDropDownList()[0];
|
||
this.lbProjectName.Text = project.ProjectName;
|
||
if (mainUnit != null)
|
||
{
|
||
this.lblMainUnitName.Text = mainUnit.UnitName;
|
||
}
|
||
this.lblProjectAddress.Text = project.ProjectAddress;
|
||
this.lblProjectCode.Text = project.ProjectCode;
|
||
this.lblContractNo.Text = project.ContractNo; //合同号
|
||
if (!string.IsNullOrEmpty(project.ProjectType))
|
||
{
|
||
var c = BLL.ConstValue.drpConstItemList(BLL.ConstValue.Group_ProjectType).
|
||
FirstOrDefault(x => x.ConstValue == project.ProjectType);
|
||
if (c != null)
|
||
{
|
||
this.lblProjectType.Text = c.ConstText;
|
||
}
|
||
}
|
||
this.lblWorkRange.Text = project.WorkRange;//工程范围
|
||
if (project.Duration != null)
|
||
{
|
||
this.lblDuration.Text = project.Duration.ToString();//工期(月)
|
||
}
|
||
if (project.StartDate != null)
|
||
{
|
||
this.lblStartDate.Text = string.Format("{0:yyyy-MM-dd}", project.StartDate);
|
||
}
|
||
if (project.EndDate != null)
|
||
{
|
||
this.lblEndDate.Text = string.Format("{0:yyyy-MM-dd}", project.EndDate);
|
||
}
|
||
#endregion
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 时间选择事件
|
||
/// <summary>
|
||
/// 开始时间选择事件
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void txtStartDate_TextChanged(object sender, EventArgs e)
|
||
{
|
||
if (!string.IsNullOrEmpty(this.txtStartDate.Text.Trim()))
|
||
{
|
||
string url = Request.Url.ToString();
|
||
if (url.Contains("?"))
|
||
{
|
||
url = Request.Url.ToString().Substring(0, Request.Url.ToString().LastIndexOf('?'));
|
||
}
|
||
Response.Redirect(url + "?startdate=" + txtStartDate.Text + "&enddate=" + txtEndDate.Text);
|
||
}
|
||
}
|
||
|
||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||
{
|
||
if (!string.IsNullOrEmpty(this.txtStartDate.Text.Trim()) && !string.IsNullOrEmpty(this.txtEndDate.Text.Trim()))
|
||
{
|
||
if (Funs.GetNewDateTime(this.txtStartDate.Text.Trim()) > Funs.GetNewDateTime(this.txtEndDate.Text.Trim()))
|
||
{
|
||
Alert.ShowInTop("开始时间不能大于结束时间!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
PageContext.RegisterStartupScript("refresh();");
|
||
}
|
||
}
|
||
|
||
protected void btnLoad_Click(object sender, EventArgs e)
|
||
{
|
||
if (AddOrUpdate == "update")
|
||
{
|
||
lodAllGrid("1");
|
||
PageContext.RegisterStartupScript("rehiden();");
|
||
}
|
||
else
|
||
{
|
||
lodAllGrid("0");
|
||
PageContext.RegisterStartupScript("rehiden();");
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 保存
|
||
protected void btnSave_Click(object sender, EventArgs e)
|
||
{
|
||
#region 保存主表
|
||
string MonthHSEDay = string.Empty, SumHSEDay = string.Empty, MonthHSEWorkDay = string.Empty, YearHSEWorkDay = string.Empty, SumHSEWorkDay = string.Empty,
|
||
HseManhours = string.Empty, SubcontractManHours = string.Empty, TotalHseManhours = string.Empty, TotalYearHseManhours=string.Empty;
|
||
JArray mergedData = gvHSEDay.GetMergedData();
|
||
foreach (JObject mergedRow in mergedData)
|
||
{
|
||
string status = mergedRow.Value<string>("status");
|
||
JObject values = mergedRow.Value<JObject>("values");
|
||
MonthHSEDay = values.Value<string>("MonthHSEDay").ToString();
|
||
SumHSEDay = values.Value<string>("SumHSEDay").ToString();
|
||
MonthHSEWorkDay = values.Value<string>("MonthHSEWorkDay").ToString();
|
||
YearHSEWorkDay = values.Value<string>("YearHSEWorkDay").ToString();
|
||
SumHSEWorkDay = values.Value<string>("SumHSEWorkDay").ToString();
|
||
HseManhours = values.Value<string>("HseManhours").ToString();
|
||
SubcontractManHours = values.Value<string>("SubcontractManHours").ToString();
|
||
TotalYearHseManhours = values.Value<string>("TotalHseManhoursYear").ToString();
|
||
TotalHseManhours = values.Value<string>("TotalHseManhours").ToString();
|
||
}
|
||
|
||
var monthReport = new Model.Manager_MonthReportC();
|
||
monthReport.MonthReportId = MonthReportId;
|
||
monthReport.ProjectId = this.CurrUser.LoginProjectId;
|
||
monthReport.MonthReportCode = txtPeriod.Text;
|
||
monthReport.Months = Funs.GetNewDateTime(Request.Params["months"]);
|
||
monthReport.ReportMan = this.CurrUser.UserId;
|
||
monthReport.MonthReportDate = DateTime.Now;
|
||
|
||
monthReport.StartDate = Funs.GetNewDateTime(txtStartDate.Text);
|
||
monthReport.EndDate = Funs.GetNewDateTime(txtEndDate.Text);
|
||
|
||
monthReport.MonthHSEDay = Funs.GetNewIntOrZero(MonthHSEDay);
|
||
monthReport.SumHSEDay = Funs.GetNewIntOrZero(SumHSEDay);
|
||
monthReport.MonthHSEWorkDay = Funs.GetNewIntOrZero(MonthHSEWorkDay);
|
||
monthReport.YearHSEWorkDay = Funs.GetNewIntOrZero(YearHSEWorkDay);
|
||
monthReport.SumHSEWorkDay = Funs.GetNewIntOrZero(SumHSEWorkDay);
|
||
monthReport.HseManhours = Funs.GetNewIntOrZero(HseManhours);
|
||
monthReport.SubcontractManHours = Funs.GetNewIntOrZero(SubcontractManHours);
|
||
monthReport.TotalHseManhours = Funs.GetNewIntOrZero(TotalHseManhours);
|
||
monthReport.TotalHseManhoursYear= Funs.GetNewIntOrZero(TotalYearHseManhours);
|
||
if (AddOrUpdate == "add")
|
||
{
|
||
|
||
MonthReportCService.AddMonthReport(monthReport);
|
||
}
|
||
else
|
||
{
|
||
MonthReportCService.UpdateMonthReport(monthReport);
|
||
}
|
||
#endregion
|
||
#region 保存所有子表
|
||
//2
|
||
OperatePersonSort();
|
||
|
||
//4.1
|
||
OperateTrainSort();
|
||
#endregion
|
||
|
||
ShowNotify("保存成功!", MessageBoxIcon.Success);
|
||
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
||
}
|
||
#endregion
|
||
|
||
#region 2.保存人力投入情况
|
||
private void OperatePersonSort()
|
||
{
|
||
PersonSortCService.DeletePersonSortsByMonthReportId(MonthReportId);
|
||
JArray mergedData = gvPersonSort.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_PersonSortC personSort = new Model.Manager_PersonSortC
|
||
{
|
||
MonthReportId = MonthReportId,
|
||
UnitId = this.gvPersonSort.Rows[i].DataKeys[1].ToString(),
|
||
SumPersonNum = Funs.GetNewIntOrZero(values.Value<string>("SumPersonNum").ToString()),
|
||
SumOutPersonNum = Funs.GetNewIntOrZero(values.Value<string>("SumOutPersonNum").ToString()),
|
||
HSEPersonNum = Funs.GetNewIntOrZero(values.Value<string>("HSEPersonNum").ToString()),
|
||
ContractRange = values.Value<string>("ContractRange").ToString(),
|
||
Remark = values.Value<string>("Remark").ToString()
|
||
};
|
||
PersonSortCService.AddPersonSort(personSort);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
|
||
#region 4.1保存培训
|
||
private void OperateTrainSort()
|
||
{
|
||
BLL.TrainSortCService.DeleteTrainSortsByMonthReportId(MonthReportId);
|
||
jerqueSaveTrainList();
|
||
foreach (Model.Manager_TrainSortC trainSort in trainSorts)
|
||
{
|
||
trainSort.MonthReportId = MonthReportId;
|
||
BLL.TrainSortCService.AddTrainSort(trainSort);
|
||
}
|
||
}
|
||
|
||
private void jerqueSaveTrainList()
|
||
{
|
||
trainSorts.Clear();
|
||
JArray mergedData = gvTrainSort.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_TrainSortC trainSort = new Model.Manager_TrainSortC
|
||
{
|
||
TrainSortId = this.gvTrainSort.Rows[i].DataKeys[0].ToString(),
|
||
SortIndex = i,
|
||
TrainType = values.Value<string>("TrainType").ToString(),
|
||
//TrainContent = values.Value<string>("TrainContent").ToString(),
|
||
TeachHour = Funs.GetNewDecimalOrZero(values.Value<string>("TeachHour").ToString()),
|
||
//TeachMan = values.Value<string>("TeachMan").ToString(),
|
||
PersonNum = Funs.GetNewIntOrZero(values.Value<string>("PersonNum").ToString()),
|
||
TotalPersonNum = Funs.GetNewIntOrZero(values.Value<string>("TotalPersonNum").ToString())
|
||
};
|
||
trainSorts.Add(trainSort);
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 加载grid
|
||
void lodAllGrid(string objType)
|
||
{
|
||
if (objType == "0")
|
||
{
|
||
//添加的时候加载
|
||
//2.本月项目现场HSE人力投入情况
|
||
GetPersonSort();
|
||
//3.本月项目现场HSE人工日统计
|
||
getMonthReportCHSEDay();
|
||
//4.培训
|
||
GetTrainSort();
|
||
|
||
}
|
||
else
|
||
{
|
||
//2.本月项目现场HSE人力投入情况
|
||
GetPersonSortEdit();
|
||
}
|
||
|
||
}
|
||
#endregion
|
||
|
||
#region 转换字符串
|
||
/// <summary>
|
||
/// 把单位Id转换为单位名称
|
||
/// </summary>
|
||
/// <param name="UnitId"></param>
|
||
/// <returns></returns>
|
||
protected string ConvertUnitName(object UnitId)
|
||
{
|
||
if (UnitId != null)
|
||
{
|
||
var u = unitList.FirstOrDefault(x => x.UnitId == UnitId.ToString());
|
||
if (u != null)
|
||
{
|
||
return u.UnitName;
|
||
}
|
||
}
|
||
return "";
|
||
}
|
||
#endregion
|
||
|
||
#region 2 人力投入情况
|
||
/// <summary>
|
||
/// 显示月报告人员投入情况
|
||
/// </summary>
|
||
private void GetPersonSort()
|
||
{
|
||
List<Model.Manager_PersonSortC> personSorts = new List<Model.Manager_PersonSortC>();
|
||
var units = from x in Funs.DB.Project_ProjectUnit
|
||
where x.ProjectId == this.ProjectId && (x.UnitType == "1" || x.UnitType == "2")
|
||
orderby x.UnitType
|
||
select x; //1为总包,2为施工分包
|
||
int totalSumPersonNum = 0;//总部
|
||
int totalSumOutPersonNum = 0;//外聘
|
||
int totalHSEPersonNum = 0;
|
||
if (units.Count() > 0)
|
||
{
|
||
foreach (Model.Project_ProjectUnit u in units)
|
||
{
|
||
Model.Manager_PersonSortC personSort = new Model.Manager_PersonSortC
|
||
{
|
||
PersonSortId = Guid.NewGuid().ToString(),
|
||
UnitId = u.UnitId,
|
||
SumPersonNum = BLL.PersonService.GetPersonCountByUnitId(u.UnitId, ProjectId, Convert.ToDateTime(txtEndDate.Text), false),//本部
|
||
SumOutPersonNum = BLL.PersonService.GetPersonCountByUnitId(u.UnitId, ProjectId, Convert.ToDateTime(txtEndDate.Text), true),//外聘
|
||
HSEPersonNum = BLL.PersonService.GetHSEPersonCountByUnitId(u.UnitId, ProjectId, Convert.ToDateTime(txtEndDate.Text)),
|
||
ContractRange = u.ContractRange
|
||
};
|
||
personSorts.Add(personSort);
|
||
totalSumPersonNum += Convert.ToInt32(personSort.SumPersonNum);
|
||
totalSumOutPersonNum += Convert.ToInt32(personSort.SumOutPersonNum);
|
||
totalHSEPersonNum += Convert.ToInt32(personSort.HSEPersonNum);
|
||
}
|
||
}
|
||
this.gvPersonSort.DataSource = personSorts;
|
||
this.gvPersonSort.DataBind();
|
||
if (this.gvPersonSort.Rows.Count > 0)
|
||
{
|
||
JObject summary = new JObject();
|
||
summary.Add("UnitId", "合计:");
|
||
summary.Add("SumPersonNum", totalSumPersonNum);
|
||
summary.Add("SumOutPersonNum", totalSumOutPersonNum);
|
||
summary.Add("HSEPersonNum", totalHSEPersonNum);
|
||
this.gvPersonSort.SummaryData = summary;
|
||
}
|
||
else
|
||
{
|
||
this.gvPersonSort.SummaryData = null;
|
||
}
|
||
}
|
||
|
||
//修改的时候
|
||
void GetPersonSortEdit()
|
||
{
|
||
var q = from x in db.Manager_PersonSortC
|
||
where x.MonthReportId == MonthReportId
|
||
select x;
|
||
if (q.Count() > 0) //保存过数据
|
||
{
|
||
//人力投入情况
|
||
List<Model.Manager_PersonSortC> sorts = (from x in db.Manager_PersonSortC
|
||
join y in db.Project_ProjectUnit
|
||
on x.UnitId equals y.UnitId
|
||
where x.MonthReportId == MonthReportId && y.ProjectId == this.ProjectId
|
||
orderby y.UnitType
|
||
select x).Distinct().ToList();
|
||
List<Model.Manager_PersonSortC> personSorts = new List<Model.Manager_PersonSortC>();
|
||
var units = from x in db.Project_ProjectUnit
|
||
where x.ProjectId == this.ProjectId && (x.UnitType == "1" || x.UnitType == "2")
|
||
orderby x.UnitType
|
||
select x; //1为总包,2为施工分包
|
||
foreach (var unit in units)
|
||
{
|
||
Model.Manager_PersonSortC personSort = sorts.FirstOrDefault(x => x.UnitId == unit.UnitId);
|
||
if (personSort != null)
|
||
{
|
||
personSorts.Add(personSort);
|
||
}
|
||
}
|
||
this.gvPersonSort.DataSource = personSorts;
|
||
this.gvPersonSort.DataBind();
|
||
if (this.gvPersonSort.Rows.Count > 0)
|
||
{
|
||
JObject summary = new JObject();
|
||
summary.Add("UnitId", "合计:");
|
||
summary.Add("SumPersonNum", (from x in personSorts select x.SumPersonNum ?? 0).Sum());
|
||
summary.Add("SumOutPersonNum", (from x in personSorts select x.SumOutPersonNum ?? 0).Sum());
|
||
summary.Add("HSEPersonNum", (from x in personSorts select x.HSEPersonNum ?? 0).Sum());
|
||
this.gvPersonSort.SummaryData = summary;
|
||
}
|
||
else
|
||
{
|
||
this.gvPersonSort.SummaryData = null;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GetPersonSort();
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 3.本月项目现场HSE人工日统计
|
||
private void getMonthReportCHSEDay()
|
||
{
|
||
|
||
//本月项目现场HSE人工日统计
|
||
Model.MonthReportCHSEDay hseDay = new Model.MonthReportCHSEDay
|
||
{
|
||
MonthHSEDay = (endTime - startTime).Days + 1
|
||
};
|
||
Model.Manager_MonthReportC mr = BLL.MonthReportCService.GetLastMonthReportByDate(endTime, this.ProjectId);
|
||
if (mr != null)
|
||
{
|
||
if (mr.SumHSEDay != 0)
|
||
{
|
||
hseDay.SumHSEDay = (mr.SumHSEDay ?? 0) + hseDay.MonthHSEDay;
|
||
}
|
||
else
|
||
{
|
||
hseDay.SumHSEDay = hseDay.MonthHSEDay;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
hseDay.SumHSEDay = hseDay.MonthHSEDay;
|
||
}
|
||
|
||
int? monthHSEWorkDay = 0;
|
||
int? yearHSEWorkDay = 0;
|
||
int? sumHSEWorkDay = 0;
|
||
decimal? hSEManhours = 0;
|
||
decimal? sumHseManhours = 0;
|
||
decimal? SubcontractManHours = 0;
|
||
|
||
decimal? YearHSEWorkDay = 0;
|
||
//年度安全人工时
|
||
var getProjectMonthReport = from x in db.SitePerson_MonthReport where x.ProjectId == ProjectId select x;
|
||
if (getProjectMonthReport.Count() > 0)
|
||
{
|
||
////人工时月报明细
|
||
var getMonthReportDetail = from x in db.SitePerson_MonthReportDetail
|
||
join y in getProjectMonthReport on x.MonthReportId equals y.MonthReportId
|
||
select x;
|
||
var yearMonthReport = from x in getProjectMonthReport
|
||
where x.CompileDate.Value.Year == months.Year
|
||
select x;
|
||
if (yearMonthReport.Count() > 0)
|
||
{
|
||
foreach (var item in yearMonthReport)
|
||
{
|
||
////年度累计安全人工时
|
||
YearHSEWorkDay += getMonthReportDetail.Where(x => x.MonthReportId ==
|
||
item.MonthReportId).Sum(x => x.PersonWorkTime) ?? 0;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
YearHSEWorkDay = 0;
|
||
}
|
||
hseDay.YearHSEWorkDay = Convert.ToInt32(YearHSEWorkDay);
|
||
var monthReport = BLL.Funs.DB.SitePerson_MonthReport.FirstOrDefault(x => x.CompileDate == months && x.ProjectId == ProjectId); //当月人工时月报
|
||
if (monthReport != null)
|
||
{
|
||
monthHSEWorkDay = Convert.ToInt32((from x in Funs.DB.SitePerson_MonthReportDetail
|
||
where x.MonthReportId == monthReport.MonthReportId
|
||
select x.RealPersonNum ?? 0).Sum());
|
||
hSEManhours = (from x in Funs.DB.SitePerson_MonthReportDetail
|
||
join z in Funs.DB.Project_ProjectUnit
|
||
on x.UnitId equals z.UnitId
|
||
where z.UnitType == "1" && z.ProjectId == this.CurrUser.LoginProjectId && x.MonthReportId == monthReport.MonthReportId //总包
|
||
select x.PersonWorkTime ?? 0).Sum();
|
||
var q = (from x in Funs.DB.SitePerson_MonthReportDetail
|
||
join z in Funs.DB.Project_ProjectUnit
|
||
on x.UnitId equals z.UnitId
|
||
where z.UnitType == "2" && z.ProjectId == this.CurrUser.LoginProjectId && x.MonthReportId == monthReport.MonthReportId //分包
|
||
select x);
|
||
foreach (var item in q)
|
||
{
|
||
SubcontractManHours += item.PersonWorkTime ?? 0;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
monthHSEWorkDay = 0;
|
||
hSEManhours = 0;
|
||
SubcontractManHours = 0;
|
||
}
|
||
//年度人工日
|
||
if (months.Month == 1)
|
||
{
|
||
yearHSEWorkDay = monthHSEWorkDay;
|
||
}
|
||
else
|
||
{
|
||
if (mr != null)
|
||
{
|
||
if (mr.YearHSEWorkDay != null)
|
||
{
|
||
yearHSEWorkDay = (mr.YearHSEWorkDay ?? 0) + monthHSEWorkDay;
|
||
}
|
||
else
|
||
{
|
||
yearHSEWorkDay = monthHSEWorkDay;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
yearHSEWorkDay = monthHSEWorkDay;
|
||
}
|
||
}
|
||
if (mr != null)
|
||
{
|
||
if (mr.SumHSEWorkDay != 0)
|
||
{
|
||
sumHSEWorkDay = (mr.SumHSEWorkDay ?? 0) + monthHSEWorkDay;
|
||
}
|
||
else
|
||
{
|
||
sumHSEWorkDay = monthHSEWorkDay;
|
||
}
|
||
if (mr.TotalHseManhours != 0)
|
||
{
|
||
sumHseManhours = (mr.TotalHseManhours ?? 0) + hSEManhours + SubcontractManHours;
|
||
}
|
||
else
|
||
{
|
||
sumHseManhours = hSEManhours + SubcontractManHours;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
sumHSEWorkDay = monthHSEWorkDay;
|
||
sumHseManhours = hSEManhours + SubcontractManHours;
|
||
}
|
||
hseDay.MonthHSEWorkDay = monthHSEWorkDay ?? 0;
|
||
hseDay.YearHSEWorkDay = yearHSEWorkDay ?? 0;
|
||
hseDay.SumHSEWorkDay = sumHSEWorkDay ?? 0;
|
||
if (hSEManhours.ToString().Contains("."))
|
||
{
|
||
hseDay.HseManhours = int.Parse(hSEManhours.ToString().Substring(0, hSEManhours.ToString().LastIndexOf(".")));
|
||
}
|
||
else
|
||
{
|
||
hseDay.HseManhours = int.Parse(hSEManhours.ToString());
|
||
}
|
||
if (SubcontractManHours.ToString().Contains("."))
|
||
{
|
||
hseDay.SubcontractManHours = int.Parse(SubcontractManHours.ToString().Substring(0, SubcontractManHours.ToString().LastIndexOf(".")));
|
||
}
|
||
else
|
||
{
|
||
hseDay.SubcontractManHours = int.Parse(SubcontractManHours.ToString());
|
||
}
|
||
if (sumHseManhours.ToString().Contains("."))
|
||
{
|
||
hseDay.TotalHseManhours = int.Parse(sumHseManhours.ToString().Substring(0, sumHseManhours.ToString().LastIndexOf(".")));
|
||
}
|
||
else
|
||
{
|
||
hseDay.TotalHseManhours = int.Parse(sumHseManhours.ToString());
|
||
}
|
||
List<Model.MonthReportCHSEDay> list = new List<Model.MonthReportCHSEDay>();
|
||
list.Add(hseDay);
|
||
this.gvHSEDay.DataSource = list;
|
||
this.gvHSEDay.DataBind();
|
||
}
|
||
#endregion
|
||
|
||
#region HSE培训
|
||
/// <summary>
|
||
/// 显示月报告HSE培训情况
|
||
/// </summary>
|
||
private void GetTrainSort()
|
||
{
|
||
trainSorts.Clear();
|
||
var TotalPersonNum = 0;
|
||
var list = db.Base_TrainType.ToList();
|
||
var listTrain = BLL.EduTrain_TrainRecordService.GetTrainingsByTrainDate(startTime, endTime, this.ProjectId);
|
||
var listAllTrain= BLL.EduTrain_TrainRecordService.GetTrainingsByTrainDate(endTime, this.ProjectId);
|
||
foreach (var item in list)
|
||
{
|
||
int i = 0;
|
||
var trainSort = new Model.Manager_TrainSortC
|
||
{
|
||
TrainSortId = SQLHelper.GetNewID(typeof(Model.Manager_TrainSortC)),
|
||
SortIndex = i
|
||
};
|
||
trainSort.TrainType = item.TrainTypeName;
|
||
if (listTrain.Count > 0)
|
||
{
|
||
trainSort.TeachHour = listTrain.Where(x => x.TrainTypeId == item.TrainTypeId).Sum(x => x.TeachHour);
|
||
trainSort.PersonNum = listTrain.Where(x => x.TrainTypeId == item.TrainTypeId).Sum(x => x.TrainPersonNum);
|
||
}
|
||
else {
|
||
trainSort.TeachHour = 0;
|
||
trainSort.PersonNum = 0;
|
||
}
|
||
if (listAllTrain.Count > 0)
|
||
{
|
||
trainSort.TotalPersonNum = listAllTrain.Where(x => x.TrainTypeId == item.TrainTypeId).Sum(x => x.TrainPersonNum);
|
||
TotalPersonNum += Convert.ToInt32(trainSort.TotalPersonNum);
|
||
}
|
||
else {
|
||
trainSort.TotalPersonNum = 0;
|
||
}
|
||
i++;
|
||
trainSorts.Add(trainSort);
|
||
}
|
||
this.gvTrainSort.DataSource = trainSorts;
|
||
this.gvTrainSort.DataBind();
|
||
if (this.gvTrainSort.Rows.Count > 0)
|
||
{
|
||
JObject summary = new JObject();
|
||
summary.Add("TrainType", "培训人数合计:");
|
||
summary.Add("TotalPersonNum", TotalPersonNum);
|
||
this.gvTrainSort.SummaryData = summary;
|
||
}
|
||
else
|
||
{
|
||
this.gvTrainSort.SummaryData = null;
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
} |