HSE月报修改

This commit is contained in:
李超 2023-03-20 21:13:22 +08:00
parent c37a207bfe
commit efac95deb3
1 changed files with 33 additions and 28 deletions

View File

@ -69,14 +69,14 @@ namespace FineUIPro.Web.HSSE.Manager
/// </summary> /// </summary>
private void BindGrid() private void BindGrid()
{ {
string strSql = @"SELECT item.* ,ISNULL(0,t.SumProjectTotal) AS SumProjectTotal string strSql = @"SELECT item.* ,ISNULL(t.SumProjectTotal,0) AS SumProjectTotal
FROM dbo.HSSE_MonthReportItem item FROM dbo.HSSE_MonthReportItem item
LEFT JOIN dbo.HSSE_MonthReport r ON r.MonthReportId = item.MonthReportId LEFT JOIN dbo.HSSE_MonthReport r ON r.MonthReportId = item.MonthReportId
LEFT JOIN (SELECT a.MonthReportItemId,ISNULL(0,SUM(ISNULL(0,a.ProjectTotal))) AS SumProjectTotal LEFT JOIN (SELECT a.ReportItem,ISNULL(SUM(ISNULL(a.ProjectTotal,0)),0) AS SumProjectTotal
FROM dbo.HSSE_MonthReportItem a FROM dbo.HSSE_MonthReportItem a
LEFT JOIN dbo.HSSE_MonthReport b ON b.MonthReportId = a.MonthReportId LEFT JOIN dbo.HSSE_MonthReport b ON b.MonthReportId = a.MonthReportId
WHERE b.ProjectId=@ProjectId AND b.Years<>DATENAME(YEAR,GETDATE()) WHERE b.ProjectId=@ProjectId AND b.Years < "+ this.tvControlItem.SelectedNode.Text+ @"
GROUP BY a.MonthReportItemId )t ON t.MonthReportItemId = item.MonthReportItemId GROUP BY a.ReportItem )t ON t.ReportItem = item.ReportItem
WHERE r.ProjectId=@ProjectId AND r.MonthReportId=@MonthReportId WHERE r.ProjectId=@ProjectId AND r.MonthReportId=@MonthReportId
ORDER BY item.Sort"; ORDER BY item.Sort";
List<SqlParameter> listStr = new List<SqlParameter>(); List<SqlParameter> listStr = new List<SqlParameter>();
@ -95,10 +95,15 @@ namespace FineUIPro.Web.HSSE.Manager
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e) protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
{ {
int cm = GetCurMonth(); int editMonth = GetCurMonth();
int cm = 12;
if (DateTime.Now.Year.ToString()== tvControlItem.SelectedNode.Text)
{
cm = DateTime.Now.Month;
}
for (int i = 1; i <= 12; i++) for (int i = 1; i <= 12; i++)
{ {
if (i != cm) if (i != editMonth)
{ {
string monthC = "Month" + i.ToString(); string monthC = "Month" + i.ToString();
RenderField month = Grid1.FindColumn(monthC) as RenderField; RenderField month = Grid1.FindColumn(monthC) as RenderField;
@ -118,7 +123,7 @@ namespace FineUIPro.Web.HSSE.Manager
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
where x.ProjectId == this.CurrUser.LoginProjectId && y.UnitCode == "CHENGDA" where x.ProjectId == this.CurrUser.LoginProjectId && y.UnitCode == "CHENGDA"
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = person.Count(); e.Values[month.ColumnIndex] = person.Count();
} }
@ -131,7 +136,7 @@ namespace FineUIPro.Web.HSSE.Manager
where x.ProjectId == this.CurrUser.LoginProjectId && y.UnitCode == "CHENGDA" where x.ProjectId == this.CurrUser.LoginProjectId && y.UnitCode == "CHENGDA"
&& z.WorkPostName.Contains("安全") && z.WorkPostName.Contains("安全")
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = person.Count(); e.Values[month.ColumnIndex] = person.Count();
} }
@ -142,7 +147,7 @@ namespace FineUIPro.Web.HSSE.Manager
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
where x.ProjectId == this.CurrUser.LoginProjectId && y.UnitCode != "CHENGDA" where x.ProjectId == this.CurrUser.LoginProjectId && y.UnitCode != "CHENGDA"
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = person.Count(); e.Values[month.ColumnIndex] = person.Count();
} }
@ -155,7 +160,7 @@ namespace FineUIPro.Web.HSSE.Manager
where x.ProjectId == this.CurrUser.LoginProjectId && y.UnitCode != "CHENGDA" where x.ProjectId == this.CurrUser.LoginProjectId && y.UnitCode != "CHENGDA"
&& z.WorkPostName.Contains("安全") && z.WorkPostName.Contains("安全")
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = person.Count(); e.Values[month.ColumnIndex] = person.Count();
} }
@ -165,11 +170,11 @@ namespace FineUIPro.Web.HSSE.Manager
{ {
DateTime? sDate = Convert.ToDateTime(tvControlItem.SelectedNode.Text + "-" + i.ToString()); DateTime? sDate = Convert.ToDateTime(tvControlItem.SelectedNode.Text + "-" + i.ToString());
var dayReports = BLL.SitePerson_MonthReportService.getMonthReports(this.CurrUser.LoginProjectId, sDate); var dayReports = BLL.SitePerson_MonthReportService.getMonthReports(this.CurrUser.LoginProjectId, sDate);
if (e.Values[month.ColumnIndex].ToString() == "" && dayReports.Count() > 0) if (i <= cm && e.Values[month.ColumnIndex].ToString() == "" && dayReports.Count() > 0)
{ {
e.Values[month.ColumnIndex] = dayReports.First().DayWorkTime; e.Values[month.ColumnIndex] = dayReports.First().DayWorkTime;
} }
else if (e.Values[month.ColumnIndex].ToString() == "") else if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = 0; e.Values[month.ColumnIndex] = 0;
} }
@ -182,7 +187,7 @@ namespace FineUIPro.Web.HSSE.Manager
where x.ProjectId == this.CurrUser.LoginProjectId where x.ProjectId == this.CurrUser.LoginProjectId
&& x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1) && x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1)
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = accident.Count(); e.Values[month.ColumnIndex] = accident.Count();
} }
@ -195,7 +200,7 @@ namespace FineUIPro.Web.HSSE.Manager
&& x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1) && x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1)
&& x.Injury=="1" && x.Injury=="1"
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = accident.Count(); e.Values[month.ColumnIndex] = accident.Count();
} }
@ -208,7 +213,7 @@ namespace FineUIPro.Web.HSSE.Manager
&& x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1) && x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1)
&& x.Injury == "2" && x.Injury == "2"
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = accident.Count(); e.Values[month.ColumnIndex] = accident.Count();
} }
@ -221,7 +226,7 @@ namespace FineUIPro.Web.HSSE.Manager
&& x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1) && x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1)
&& x.Injury == "3" && x.Injury == "3"
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = accident.Count(); e.Values[month.ColumnIndex] = accident.Count();
} }
@ -233,7 +238,7 @@ namespace FineUIPro.Web.HSSE.Manager
where x.ProjectId == this.CurrUser.LoginProjectId where x.ProjectId == this.CurrUser.LoginProjectId
&& x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1) && x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1)
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = accident.Count(); e.Values[month.ColumnIndex] = accident.Count();
} }
@ -241,14 +246,14 @@ namespace FineUIPro.Web.HSSE.Manager
if (e.RowIndex == 11) // 现场环境事故 if (e.RowIndex == 11) // 现场环境事故
{ {
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = "0"; e.Values[month.ColumnIndex] = "0";
} }
} }
if (e.RowIndex == 12) // 现场发生设备材料盗窃案件 if (e.RowIndex == 12) // 现场发生设备材料盗窃案件
{ {
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = "0"; e.Values[month.ColumnIndex] = "0";
} }
@ -260,7 +265,7 @@ namespace FineUIPro.Web.HSSE.Manager
where x.ProjectId == this.CurrUser.LoginProjectId where x.ProjectId == this.CurrUser.LoginProjectId
&& x.WeekMeetingDate >= startDate && x.WeekMeetingDate < startDate.AddMonths(1) && x.WeekMeetingDate >= startDate && x.WeekMeetingDate < startDate.AddMonths(1)
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = weekMeeting.Count(); e.Values[month.ColumnIndex] = weekMeeting.Count();
} }
@ -272,7 +277,7 @@ namespace FineUIPro.Web.HSSE.Manager
where x.ProjectId == this.CurrUser.LoginProjectId where x.ProjectId == this.CurrUser.LoginProjectId
&& x.AttendMeetingDate >= startDate && x.AttendMeetingDate < startDate.AddMonths(1) && x.AttendMeetingDate >= startDate && x.AttendMeetingDate < startDate.AddMonths(1)
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = weekMeeting.Count(); e.Values[month.ColumnIndex] = weekMeeting.Count();
} }
@ -280,7 +285,7 @@ namespace FineUIPro.Web.HSSE.Manager
if (e.RowIndex == 15) // 施工现场HSE联检 if (e.RowIndex == 15) // 施工现场HSE联检
{ {
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = "0"; e.Values[month.ColumnIndex] = "0";
} }
@ -292,7 +297,7 @@ namespace FineUIPro.Web.HSSE.Manager
where x.ProjectId == this.CurrUser.LoginProjectId where x.ProjectId == this.CurrUser.LoginProjectId
&& x.CheckedDate >= startDate && x.CheckedDate < startDate.AddMonths(1) && x.CheckedDate >= startDate && x.CheckedDate < startDate.AddMonths(1)
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = check.Count(); e.Values[month.ColumnIndex] = check.Count();
} }
@ -304,7 +309,7 @@ namespace FineUIPro.Web.HSSE.Manager
where x.ProjectId == this.CurrUser.LoginProjectId where x.ProjectId == this.CurrUser.LoginProjectId
&& x.CompleteDate >= startDate && x.CompleteDate < startDate.AddMonths(1) && x.CompleteDate >= startDate && x.CompleteDate < startDate.AddMonths(1)
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = check.Count(); e.Values[month.ColumnIndex] = check.Count();
} }
@ -316,7 +321,7 @@ namespace FineUIPro.Web.HSSE.Manager
where x.ProjectId == this.CurrUser.LoginProjectId where x.ProjectId == this.CurrUser.LoginProjectId
&& x.PunishNoticeDate >= startDate && x.PunishNoticeDate < startDate.AddMonths(1) && x.PunishNoticeDate >= startDate && x.PunishNoticeDate < startDate.AddMonths(1)
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = check.Count(); e.Values[month.ColumnIndex] = check.Count();
} }
@ -328,7 +333,7 @@ namespace FineUIPro.Web.HSSE.Manager
where x.ProjectId == this.CurrUser.LoginProjectId where x.ProjectId == this.CurrUser.LoginProjectId
&& x.CompileDate >= startDate && x.CompileDate < startDate.AddMonths(1) && x.CompileDate >= startDate && x.CompileDate < startDate.AddMonths(1)
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
e.Values[month.ColumnIndex] = em.Count(); e.Values[month.ColumnIndex] = em.Count();
} }
@ -340,7 +345,7 @@ namespace FineUIPro.Web.HSSE.Manager
where x.ProjectId == this.CurrUser.LoginProjectId where x.ProjectId == this.CurrUser.LoginProjectId
&& x.TrainStartDate >= startDate && x.TrainStartDate < startDate.AddMonths(1) && x.TrainStartDate >= startDate && x.TrainStartDate < startDate.AddMonths(1)
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
if (edu.Count() > 0) if (edu.Count() > 0)
{ {
@ -359,7 +364,7 @@ namespace FineUIPro.Web.HSSE.Manager
where x.ProjectId == this.CurrUser.LoginProjectId where x.ProjectId == this.CurrUser.LoginProjectId
&& x.CompileDate >= startDate && x.CompileDate < startDate.AddMonths(1) && x.CompileDate >= startDate && x.CompileDate < startDate.AddMonths(1)
select x; select x;
if (e.Values[month.ColumnIndex].ToString() == "") if (i <= cm && e.Values[month.ColumnIndex].ToString() == "")
{ {
if (equ.Count()>0) if (equ.Count()>0)
{ {