815 lines
38 KiB
C#
815 lines
38 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Data;
|
|||
|
using System.Data.SqlClient;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using BLL;
|
|||
|
using AspNet = System.Web.UI.WebControls;
|
|||
|
using Newtonsoft.Json.Linq;
|
|||
|
|
|||
|
namespace FineUIPro.Web.CQMS.ManageReport
|
|||
|
{
|
|||
|
public partial class ManagerMonthC : PageBase
|
|||
|
{
|
|||
|
|
|||
|
#region 加载页面
|
|||
|
/// <summary>
|
|||
|
/// 加载页面
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
////权限按钮方法
|
|||
|
this.GetButtonPower();
|
|||
|
|
|||
|
this.txtReportYear.Text = string.Format("{0:yyyy}", DateTime.Now);
|
|||
|
// 绑定表格
|
|||
|
//BindGrid();
|
|||
|
InitTreeMenu();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private void InitTreeMenu()
|
|||
|
{
|
|||
|
this.tvControlItem.Nodes.Clear();
|
|||
|
TreeNode rootNode = new TreeNode();
|
|||
|
rootNode.Text = "年份";
|
|||
|
rootNode.NodeID = "0";
|
|||
|
rootNode.Expanded = true;
|
|||
|
this.tvControlItem.Nodes.Add(rootNode);
|
|||
|
|
|||
|
var report = from x in Funs.DB.CQMS_MonthReport
|
|||
|
where x.ProjectId == CurrUser.LoginProjectId
|
|||
|
orderby x.Years
|
|||
|
select x;
|
|||
|
if (report.Count() > 0)
|
|||
|
{
|
|||
|
foreach (var y in report)
|
|||
|
{
|
|||
|
TreeNode tnYear = new TreeNode();//年节点
|
|||
|
tnYear.Text = y.Years.HasValue ? y.Years.Value.ToString() : "";
|
|||
|
tnYear.NodeID = y.MonthReportId;
|
|||
|
tnYear.EnableClickEvent = true;
|
|||
|
rootNode.Nodes.Add(tnYear);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
protected void tvControlItem_NodeCommand(object sender, TreeCommandEventArgs e)
|
|||
|
{
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 绑定数据
|
|||
|
/// </summary>
|
|||
|
private void BindGrid()
|
|||
|
{
|
|||
|
string strSql = @"SELECT item.* ,ISNULL(t.SumProjectTotal,0) AS SumProjectTotal
|
|||
|
FROM dbo.CQMS_MonthReportItem item
|
|||
|
LEFT JOIN dbo.CQMS_MonthReport r ON r.MonthReportId = item.MonthReportId
|
|||
|
LEFT JOIN (SELECT a.ReportItem,ISNULL(SUM(ISNULL(a.ProjectTotal,0)),0) AS SumProjectTotal
|
|||
|
FROM dbo.CQMS_MonthReportItem a
|
|||
|
LEFT JOIN dbo.CQMS_MonthReport b ON b.MonthReportId = a.MonthReportId
|
|||
|
WHERE b.ProjectId=@ProjectId AND b.Years < " + this.tvControlItem.SelectedNode.Text + @"
|
|||
|
GROUP BY a.ReportItem )t ON t.ReportItem = item.ReportItem
|
|||
|
WHERE r.ProjectId=@ProjectId AND r.MonthReportId=@MonthReportId
|
|||
|
ORDER BY item.Sort";
|
|||
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|||
|
listStr.Add(new SqlParameter("@ProjectId", CurrUser.LoginProjectId));
|
|||
|
listStr.Add(new SqlParameter("@MonthReportId", tvControlItem.SelectedNodeID));
|
|||
|
|
|||
|
SqlParameter[] parameter = listStr.ToArray();
|
|||
|
DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|||
|
// 2.获取当前分页数据
|
|||
|
//var table = this.GetPagedDataTable(Grid1, tb1);
|
|||
|
|
|||
|
Grid1.DataSource = dt;
|
|||
|
Grid1.DataBind();
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
|
|||
|
{
|
|||
|
int cm = GetCurMonth();
|
|||
|
|
|||
|
for (int i = 1; i <= 12; i++)
|
|||
|
{
|
|||
|
if (i != cm)
|
|||
|
{
|
|||
|
//string monthC = "Month" + i.ToString();
|
|||
|
//RenderField month = Grid1.FindColumn(monthC) as RenderField;
|
|||
|
//e.CellCssClasses[month.ColumnIndex] = "f-grid-cell-uneditable";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
string monthC = "Month" + i.ToString();
|
|||
|
RenderField month = Grid1.FindColumn(monthC) as RenderField;
|
|||
|
RenderField yearTotal = Grid1.FindColumn("YearTotal") as RenderField;
|
|||
|
RenderField projectTotal = Grid1.FindColumn("ProjectTotal") as RenderField;
|
|||
|
RenderField sumProjectTotal = Grid1.FindColumn("SumProjectTotal") as RenderField;
|
|||
|
|
|||
|
if (e.RowIndex == 0) // 成达公司现场人数
|
|||
|
{
|
|||
|
var person = from x in Funs.DB.SitePerson_Person
|
|||
|
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId && y.UnitCode == "CHENGDA"
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = person.Count();
|
|||
|
}
|
|||
|
}
|
|||
|
if (e.RowIndex == 1) // 成达公司HSE管理人数
|
|||
|
{
|
|||
|
var person = from x in Funs.DB.SitePerson_Person
|
|||
|
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
|
|||
|
join z in Funs.DB.Base_WorkPost on x.WorkPostId equals z.WorkPostId
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId && y.UnitCode == "CHENGDA"
|
|||
|
&& z.WorkPostName.Contains("安全")
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = person.Count();
|
|||
|
}
|
|||
|
}
|
|||
|
if (e.RowIndex == 2) // 分包商现场人数
|
|||
|
{
|
|||
|
var person = from x in Funs.DB.SitePerson_Person
|
|||
|
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId && y.UnitCode != "CHENGDA"
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = person.Count();
|
|||
|
}
|
|||
|
}
|
|||
|
if (e.RowIndex == 3) // 分包商HSE管理人数
|
|||
|
{
|
|||
|
var person = from x in Funs.DB.SitePerson_Person
|
|||
|
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
|
|||
|
join z in Funs.DB.Base_WorkPost on x.WorkPostId equals z.WorkPostId
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId && y.UnitCode != "CHENGDA"
|
|||
|
&& z.WorkPostName.Contains("安全")
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = person.Count();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (e.RowIndex == 4 || e.RowIndex == 5) // 人工时数,安全生产人工时数
|
|||
|
{
|
|||
|
DateTime? sDate = Convert.ToDateTime(tvControlItem.SelectedNode.Text + "-" + i.ToString());
|
|||
|
var dayReports = BLL.SitePerson_MonthReportService.getMonthReports(this.CurrUser.LoginProjectId, sDate);
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "" && dayReports.Count() > 0)
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = dayReports.First().DayWorkTime;
|
|||
|
}
|
|||
|
else if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
DateTime startDate = Convert.ToDateTime(tvControlItem.SelectedNode.Text + "-" + i.ToString() + "-01");
|
|||
|
if (e.RowIndex == 6) // HSE记录事故数量
|
|||
|
{
|
|||
|
var accident = from x in Funs.DB.Accident_AccidentPersonRecord
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|||
|
&& x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1)
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = accident.Count();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (e.RowIndex == 7) // 死亡
|
|||
|
{
|
|||
|
var accident = from x in Funs.DB.Accident_AccidentPersonRecord
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|||
|
&& x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1)
|
|||
|
&& x.Injury == "1"
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = accident.Count();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (e.RowIndex == 8) // 重伤
|
|||
|
{
|
|||
|
var accident = from x in Funs.DB.Accident_AccidentPersonRecord
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|||
|
&& x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1)
|
|||
|
&& x.Injury == "2"
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = accident.Count();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (e.RowIndex == 9) // 轻伤
|
|||
|
{
|
|||
|
var accident = from x in Funs.DB.Accident_AccidentPersonRecord
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|||
|
&& x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1)
|
|||
|
&& x.Injury == "3"
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = accident.Count();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (e.RowIndex == 10) // 未遂事故
|
|||
|
{
|
|||
|
var accident = from x in Funs.DB.Accident_AccidentHandle
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|||
|
&& x.AccidentDate >= startDate && x.AccidentDate < startDate.AddMonths(1)
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = accident.Count();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (e.RowIndex == 11) // 现场环境事故
|
|||
|
{
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = "0";
|
|||
|
}
|
|||
|
}
|
|||
|
if (e.RowIndex == 12) // 现场发生设备材料盗窃案件
|
|||
|
{
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = "0";
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (e.RowIndex == 13) // HSE周会
|
|||
|
{
|
|||
|
var weekMeeting = from x in Funs.DB.Meeting_WeekMeeting
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|||
|
&& x.WeekMeetingDate >= startDate && x.WeekMeetingDate < startDate.AddMonths(1)
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = weekMeeting.Count();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (e.RowIndex == 14) // HSE委员会会议
|
|||
|
{
|
|||
|
var weekMeeting = from x in Funs.DB.Meeting_AttendMeeting
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|||
|
&& x.AttendMeetingDate >= startDate && x.AttendMeetingDate < startDate.AddMonths(1)
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = weekMeeting.Count();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (e.RowIndex == 15) // 施工现场HSE联检
|
|||
|
{
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = "0";
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (e.RowIndex == 16) // 发布HSE整改通知书
|
|||
|
{
|
|||
|
var check = from x in Funs.DB.Check_RectifyNotices
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|||
|
&& x.CheckedDate >= startDate && x.CheckedDate < startDate.AddMonths(1)
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = check.Count();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (e.RowIndex == 17) // 关闭HSE整改通知书
|
|||
|
{
|
|||
|
var check = from x in Funs.DB.Check_RectifyNotices
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|||
|
&& x.CompleteDate >= startDate && x.CompleteDate < startDate.AddMonths(1)
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = check.Count();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (e.RowIndex == 18) // 发布HSE处罚书
|
|||
|
{
|
|||
|
var check = from x in Funs.DB.Check_PunishNotice
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|||
|
&& x.PunishNoticeDate >= startDate && x.PunishNoticeDate < startDate.AddMonths(1)
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = check.Count();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (e.RowIndex == 19) // 发布应急预案
|
|||
|
{
|
|||
|
var em = from x in Funs.DB.Emergency_EmergencyList
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|||
|
&& x.CompileDate >= startDate && x.CompileDate < startDate.AddMonths(1)
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = em.Count();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (e.RowIndex == 20) // 人员培训
|
|||
|
{
|
|||
|
var edu = from x in Funs.DB.EduTrain_TrainRecord
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|||
|
&& x.TrainStartDate >= startDate && x.TrainStartDate < startDate.AddMonths(1)
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
if (edu.Count() > 0)
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = edu.Sum(x => x.TrainPersonNum);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (e.RowIndex == 21) // 设备HSE检验
|
|||
|
{
|
|||
|
var equ = from x in Funs.DB.License_EquipmentSafetyList
|
|||
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|||
|
&& x.CompileDate >= startDate && x.CompileDate < startDate.AddMonths(1)
|
|||
|
select x;
|
|||
|
if (e.Values[month.ColumnIndex].ToString() == "")
|
|||
|
{
|
|||
|
if (equ.Count() > 0)
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = equ.Sum(x => x.EquipmentSafetyListCount);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
e.Values[month.ColumnIndex] = 0;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
RenderField month1 = Grid1.FindColumn("Month1") as RenderField;
|
|||
|
RenderField month2 = Grid1.FindColumn("Month2") as RenderField;
|
|||
|
RenderField month3 = Grid1.FindColumn("Month3") as RenderField;
|
|||
|
RenderField month4 = Grid1.FindColumn("Month4") as RenderField;
|
|||
|
RenderField month5 = Grid1.FindColumn("Month5") as RenderField;
|
|||
|
RenderField month6 = Grid1.FindColumn("Month6") as RenderField;
|
|||
|
RenderField month7 = Grid1.FindColumn("Month7") as RenderField;
|
|||
|
RenderField month8 = Grid1.FindColumn("Month8") as RenderField;
|
|||
|
RenderField month9 = Grid1.FindColumn("Month9") as RenderField;
|
|||
|
RenderField month10 = Grid1.FindColumn("Month10") as RenderField;
|
|||
|
RenderField month11 = Grid1.FindColumn("Month11") as RenderField;
|
|||
|
RenderField month12 = Grid1.FindColumn("Month12") as RenderField;
|
|||
|
// 年度总计
|
|||
|
e.Values[yearTotal.ColumnIndex] = Convert.ToInt32(e.Values[month1.ColumnIndex].ToString() != "" ? e.Values[month1.ColumnIndex] : 0)
|
|||
|
+ Convert.ToInt32(e.Values[month2.ColumnIndex].ToString() != "" ? e.Values[month2.ColumnIndex] : 0)
|
|||
|
+ Convert.ToInt32(e.Values[month3.ColumnIndex].ToString() != "" ? e.Values[month3.ColumnIndex] : 0)
|
|||
|
+ Convert.ToInt32(e.Values[month4.ColumnIndex].ToString() != "" ? e.Values[month4.ColumnIndex] : 0)
|
|||
|
+ Convert.ToInt32(e.Values[month5.ColumnIndex].ToString() != "" ? e.Values[month5.ColumnIndex] : 0)
|
|||
|
+ Convert.ToInt32(e.Values[month6.ColumnIndex].ToString() != "" ? e.Values[month6.ColumnIndex] : 0)
|
|||
|
+ Convert.ToInt32(e.Values[month7.ColumnIndex].ToString() != "" ? e.Values[month7.ColumnIndex] : 0)
|
|||
|
+ Convert.ToInt32(e.Values[month8.ColumnIndex].ToString() != "" ? e.Values[month8.ColumnIndex] : 0)
|
|||
|
+ Convert.ToInt32(e.Values[month9.ColumnIndex].ToString() != "" ? e.Values[month9.ColumnIndex] : 0)
|
|||
|
+ Convert.ToInt32(e.Values[month10.ColumnIndex].ToString() != "" ? e.Values[month10.ColumnIndex] : 0)
|
|||
|
+ Convert.ToInt32(e.Values[month11.ColumnIndex].ToString() != "" ? e.Values[month11.ColumnIndex] : 0)
|
|||
|
+ Convert.ToInt32(e.Values[month12.ColumnIndex].ToString() != "" ? e.Values[month12.ColumnIndex] : 0);
|
|||
|
// 项目总计
|
|||
|
e.Values[projectTotal.ColumnIndex] = Convert.ToInt32(e.Values[yearTotal.ColumnIndex]) + Convert.ToInt32(e.Values[sumProjectTotal.ColumnIndex]);
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 查询
|
|||
|
/// <summary>
|
|||
|
/// 查询
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
this.BindGrid();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 新建报表
|
|||
|
/// <summary>
|
|||
|
/// 新增
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnNew_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
|
|||
|
if (project.StartDate != null)
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(this.txtReportYear.Text.Trim()))
|
|||
|
{
|
|||
|
if (this.txtReportYear.Text.Trim() == DateTime.Now.Year.ToString())
|
|||
|
{
|
|||
|
int? years = Convert.ToInt32(this.txtReportYear.Text.Trim());
|
|||
|
var report = Funs.DB.CQMS_MonthReport.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.Years == years);
|
|||
|
|
|||
|
if (report == null)
|
|||
|
{
|
|||
|
Model.CQMS_MonthReport newReport = new Model.CQMS_MonthReport();
|
|||
|
newReport.MonthReportId = SQLHelper.GetNewID(typeof(Model.CQMS_MonthReport));
|
|||
|
newReport.ProjectId = this.CurrUser.LoginProjectId;
|
|||
|
newReport.Years = years;
|
|||
|
Funs.DB.CQMS_MonthReport.InsertOnSubmit(newReport);
|
|||
|
Funs.DB.SubmitChanges();
|
|||
|
|
|||
|
List<Model.CQMS_MonthReportItem> ItemList = new List<Model.CQMS_MonthReportItem>();
|
|||
|
for (int i = 0; i < 22; i++)
|
|||
|
{
|
|||
|
Model.CQMS_MonthReportItem item = new Model.CQMS_MonthReportItem();
|
|||
|
item.MonthReportItemId = SQLHelper.GetNewID(typeof(Model.CQMS_MonthReportItem));
|
|||
|
item.MonthReportId = newReport.MonthReportId;
|
|||
|
if (i == 0)
|
|||
|
{
|
|||
|
item.ReportItem = "发布施工质量管理文件";
|
|||
|
item.Unit = "份";
|
|||
|
}
|
|||
|
if (i == 1)
|
|||
|
{
|
|||
|
item.ReportItem = "组织设计交底与图纸会审";
|
|||
|
item.Unit = "次";
|
|||
|
}
|
|||
|
if (i == 2)
|
|||
|
{
|
|||
|
item.ReportItem = "审批施工组织设计或施工方案";
|
|||
|
item.Unit = "份";
|
|||
|
}
|
|||
|
if (i == 3)
|
|||
|
{
|
|||
|
item.ReportItem = "施工质量联合检查(例行检测+专项检测)";
|
|||
|
item.Unit = "次";
|
|||
|
}
|
|||
|
if (i == 4)
|
|||
|
{
|
|||
|
item.ReportItem = "施工质量专题会议";
|
|||
|
item.Unit = "次";
|
|||
|
}
|
|||
|
if (i == 5)
|
|||
|
{
|
|||
|
item.ReportItem = "不符合项报告(NCR)";
|
|||
|
item.Unit = "";
|
|||
|
}
|
|||
|
if (i == 6)
|
|||
|
{
|
|||
|
item.ReportItem = "发布";
|
|||
|
item.Unit = "份";
|
|||
|
}
|
|||
|
if (i == 7)
|
|||
|
{
|
|||
|
item.ReportItem = "关闭";
|
|||
|
item.Unit = "份";
|
|||
|
}
|
|||
|
|
|||
|
if (i == 8)
|
|||
|
{
|
|||
|
item.ReportItem = "质量整改与处罚";
|
|||
|
item.Unit = "";
|
|||
|
}
|
|||
|
if (i == 9)
|
|||
|
{
|
|||
|
item.ReportItem = "发出质量整改通知单";
|
|||
|
item.Unit = "份";
|
|||
|
}
|
|||
|
if (i == 10)
|
|||
|
{
|
|||
|
item.ReportItem = "发出质量处罚通知单";
|
|||
|
item.Unit = "份";
|
|||
|
}
|
|||
|
if (i == 11)
|
|||
|
{
|
|||
|
item.ReportItem = "检验批及合格率";
|
|||
|
item.Unit = "";
|
|||
|
}
|
|||
|
if (i == 12)
|
|||
|
{
|
|||
|
item.ReportItem = "检验批次数";
|
|||
|
item.Unit = "次";
|
|||
|
}
|
|||
|
if (i == 13)
|
|||
|
{
|
|||
|
item.ReportItem = "合格率";
|
|||
|
item.Unit = "%";
|
|||
|
}
|
|||
|
if (i == 14)
|
|||
|
{
|
|||
|
item.ReportItem = "无损检测(RT)";
|
|||
|
item.Unit = "";
|
|||
|
}
|
|||
|
if (i == 15)
|
|||
|
{
|
|||
|
item.ReportItem = "一次拍片数";
|
|||
|
item.Unit = "张";
|
|||
|
}
|
|||
|
if (i == 16)
|
|||
|
{
|
|||
|
item.ReportItem = "一次合格数";
|
|||
|
item.Unit = "张";
|
|||
|
}
|
|||
|
if (i == 17)
|
|||
|
{
|
|||
|
item.ReportItem = "一次合格率";
|
|||
|
item.Unit = "%";
|
|||
|
}
|
|||
|
if (i == 18)
|
|||
|
{
|
|||
|
item.ReportItem = "质量事故";
|
|||
|
item.Unit = "";
|
|||
|
}
|
|||
|
if (i == 19)
|
|||
|
{
|
|||
|
item.ReportItem = "重大质量事故";
|
|||
|
item.Unit = "次";
|
|||
|
}
|
|||
|
if (i == 20)
|
|||
|
{
|
|||
|
item.ReportItem = "较大质量事故";
|
|||
|
item.Unit = "次";
|
|||
|
}
|
|||
|
if (i == 21)
|
|||
|
{
|
|||
|
item.ReportItem = "一般质量事故";
|
|||
|
item.Unit = "次";
|
|||
|
}
|
|||
|
if (i == 22)
|
|||
|
{
|
|||
|
item.ReportItem = "监理单位下发质量问题通知单";
|
|||
|
item.Unit = "";
|
|||
|
}
|
|||
|
if (i == 23)
|
|||
|
{
|
|||
|
item.ReportItem = "收到";
|
|||
|
item.Unit = "份";
|
|||
|
}
|
|||
|
if (i == 24)
|
|||
|
{
|
|||
|
item.ReportItem = "关闭";
|
|||
|
item.Unit = "份";
|
|||
|
}
|
|||
|
if (i == 25)
|
|||
|
{
|
|||
|
item.ReportItem = "业主方/业主管理公司下发质量问题通知单";
|
|||
|
item.Unit = "";
|
|||
|
}
|
|||
|
if (i == 26)
|
|||
|
{
|
|||
|
item.ReportItem = "收到";
|
|||
|
item.Unit = "份";
|
|||
|
}
|
|||
|
if (i == 27)
|
|||
|
{
|
|||
|
item.ReportItem = "关闭";
|
|||
|
item.Unit = "份";
|
|||
|
}
|
|||
|
item.Sort = i + 1;
|
|||
|
ItemList.Add(item);
|
|||
|
}
|
|||
|
|
|||
|
Funs.DB.CQMS_MonthReportItem.InsertAllOnSubmit(ItemList);
|
|||
|
Funs.DB.SubmitChanges();
|
|||
|
this.InitTreeMenu();
|
|||
|
Alert.ShowInTop("月报创建成功!", MessageBoxIcon.Success);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Alert.ShowInTop("月报已创建,请选择左边树的年进行编辑!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Alert.ShowInTop("只能新建当年的月报!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Alert.ShowInTop("请选择年度!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Alert.ShowInTop("请先设置项目开工时间!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
protected void btnSave_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
int cm = GetCurMonth();
|
|||
|
JArray editReport = Grid1.GetMergedData();
|
|||
|
if (editReport.Count > 0)
|
|||
|
{
|
|||
|
if (true || cm != 0)
|
|||
|
{
|
|||
|
for (int i = 0; i < editReport.Count; i++)
|
|||
|
{
|
|||
|
JObject objects = (JObject)editReport[i];
|
|||
|
string monthReportItemId = objects["values"]["MonthReportItemId"].ToString();
|
|||
|
Model.CQMS_MonthReportItem item = Funs.DB.CQMS_MonthReportItem.FirstOrDefault(x => x.MonthReportItemId == monthReportItemId);
|
|||
|
// if (cm == 1)
|
|||
|
{
|
|||
|
item.Month1 = Funs.GetNewInt(objects["values"]["Month1"].ToString());
|
|||
|
}
|
|||
|
// if (cm == 2)
|
|||
|
{
|
|||
|
item.Month2 = Funs.GetNewInt(objects["values"]["Month2"].ToString());
|
|||
|
}
|
|||
|
// if (cm == 3)
|
|||
|
{
|
|||
|
item.Month3 = Funs.GetNewInt(objects["values"]["Month3"].ToString());
|
|||
|
}
|
|||
|
// if (cm == 4)
|
|||
|
{
|
|||
|
item.Month4 = Funs.GetNewInt(objects["values"]["Month4"].ToString());
|
|||
|
}
|
|||
|
// if (cm == 5)
|
|||
|
{
|
|||
|
item.Month5 = Funs.GetNewInt(objects["values"]["Month5"].ToString());
|
|||
|
}
|
|||
|
// if (cm == 6)
|
|||
|
{
|
|||
|
item.Month6 = Funs.GetNewInt(objects["values"]["Month6"].ToString());
|
|||
|
}
|
|||
|
//if (cm == 7)
|
|||
|
{
|
|||
|
item.Month7 = Funs.GetNewInt(objects["values"]["Month7"].ToString());
|
|||
|
}
|
|||
|
// if (cm == 8)
|
|||
|
{
|
|||
|
item.Month8 = Funs.GetNewInt(objects["values"]["Month8"].ToString());
|
|||
|
}
|
|||
|
//if (cm == 9)
|
|||
|
{
|
|||
|
item.Month9 = Funs.GetNewInt(objects["values"]["Month9"].ToString());
|
|||
|
}
|
|||
|
// if (cm == 10)
|
|||
|
{
|
|||
|
item.Month10 = Funs.GetNewInt(objects["values"]["Month10"].ToString());
|
|||
|
}
|
|||
|
//if (cm == 11)
|
|||
|
{
|
|||
|
item.Month11 = Funs.GetNewInt(objects["values"]["Month11"].ToString());
|
|||
|
}
|
|||
|
//if (cm == 12)
|
|||
|
{
|
|||
|
item.Month12 = Funs.GetNewInt(objects["values"]["Month12"].ToString());
|
|||
|
}
|
|||
|
item.YearTotal = Funs.GetNewInt(objects["values"]["YearTotal"].ToString());
|
|||
|
item.ProjectTotal = Funs.GetNewInt(objects["values"]["ProjectTotal"].ToString());
|
|||
|
Funs.DB.SubmitChanges();
|
|||
|
this.ShowNotify("保存成功");
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Alert.ShowInTop("月报的填报日期为每月的26号开始到下月的4号截止!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取可编辑的月份
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
private int GetCurMonth()
|
|||
|
{
|
|||
|
DateTime nowDate = DateTime.Now;
|
|||
|
// 本月
|
|||
|
int m = nowDate.Month;
|
|||
|
// 上月
|
|||
|
int lm = nowDate.AddMonths(-1).Month;
|
|||
|
// 当月第几天
|
|||
|
int cd = nowDate.Day;
|
|||
|
// 下月的第几天
|
|||
|
int nd = nowDate.AddMonths(1).Day;
|
|||
|
|
|||
|
int cm = 0;
|
|||
|
if (cd >= 26)
|
|||
|
{
|
|||
|
cm = m;
|
|||
|
}
|
|||
|
if (nd <= 20)
|
|||
|
{
|
|||
|
cm = lm;
|
|||
|
}
|
|||
|
return cm;
|
|||
|
}
|
|||
|
|
|||
|
#region 获取按钮权限
|
|||
|
/// <summary>
|
|||
|
/// 获取按钮权限
|
|||
|
/// </summary>
|
|||
|
/// <param name="button"></param>
|
|||
|
/// <returns></returns>
|
|||
|
private void GetButtonPower()
|
|||
|
{
|
|||
|
if (Request.Params["value"] == "0")
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.WeekReportMenuId);
|
|||
|
if (buttonList.Count() > 0)
|
|||
|
{
|
|||
|
if (buttonList.Contains(BLL.Const.BtnAdd))
|
|||
|
{
|
|||
|
this.btnNew.Hidden = false;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 导出按钮
|
|||
|
/// 导出按钮
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnOut_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
Response.ClearContent();
|
|||
|
string filename = Funs.GetNewFileName();
|
|||
|
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("施工质量月报" + filename, System.Text.Encoding.UTF8) + ".xls");
|
|||
|
Response.ContentType = "application/excel";
|
|||
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|||
|
this.Grid1.PageSize = 500;
|
|||
|
this.BindGrid();
|
|||
|
Response.Write(GetGridTableHtml(Grid1));
|
|||
|
Response.End();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 导出方法
|
|||
|
/// </summary>
|
|||
|
/// <param name="grid"></param>
|
|||
|
/// <returns></returns>
|
|||
|
private string GetGridTableHtml(Grid grid)
|
|||
|
{
|
|||
|
StringBuilder sb = new StringBuilder();
|
|||
|
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
|
|||
|
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
|
|||
|
sb.Append("<tr>");
|
|||
|
foreach (GridColumn column in grid.Columns)
|
|||
|
{
|
|||
|
sb.AppendFormat("<td>{0}</td>", column.HeaderText);
|
|||
|
}
|
|||
|
sb.Append("</tr>");
|
|||
|
foreach (GridRow row in grid.Rows)
|
|||
|
{
|
|||
|
sb.Append("<tr>");
|
|||
|
foreach (GridColumn column in grid.Columns)
|
|||
|
{
|
|||
|
string html = row.Values[column.ColumnIndex].ToString();
|
|||
|
if (column.ColumnID == "tfNumber")
|
|||
|
{
|
|||
|
html = (row.FindControl("lblNumber") as AspNet.Label).Text;
|
|||
|
}
|
|||
|
sb.AppendFormat("<td>{0}</td>", html);
|
|||
|
}
|
|||
|
|
|||
|
sb.Append("</tr>");
|
|||
|
}
|
|||
|
|
|||
|
sb.Append("</table>");
|
|||
|
|
|||
|
return sb.ToString();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|