259 lines
12 KiB
C#
259 lines
12 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.HSSE.Check
|
|
{
|
|
public partial class HiddenTroubleManager : PageBase
|
|
{
|
|
#region 项目主键
|
|
/// <summary>
|
|
/// 项目主键
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack) {
|
|
|
|
}
|
|
}
|
|
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"select newid() as Id,Content,CheckDate,HiddendangersTypes,HiddendangersLevel,UnitName,Person,Term
|
|
,Rectification,ReviewResults,ReviewDate,ReviewMan,StatesStr,Projectid from(
|
|
--安全巡检
|
|
select RegisterDef as Content,CheckTime as CheckDate,HiddenType as HiddendangersTypes,
|
|
Risk_Level as HiddendangersLevel,Unit.UnitName as UnitName, User4.UserName as Person,RectificationPeriod as Term
|
|
,(Rectification+';'+Requirements) as Rectification,
|
|
(CASE WHEN Registration.states='1' and (Registration.SafeSupervisionIsOK is null OR Registration.SafeSupervisionIsOK=0) THEN '待整改'
|
|
WHEN Registration.states='1' and Registration.SafeSupervisionIsOK=1 THEN '合格'
|
|
WHEN Registration.states='2' THEN '已整改-待复查验收'
|
|
WHEN Registration.states='3' THEN '已闭环'
|
|
ELSE '已作废' END ) as ReviewResults,
|
|
RectificationTime as ReviewDate,User2.UserName as ReviewMan,
|
|
(CASE WHEN Registration.states='1' and (Registration.SafeSupervisionIsOK is null OR Registration.SafeSupervisionIsOK=0) THEN '开放'
|
|
WHEN Registration.states='1' and Registration.SafeSupervisionIsOK=1 THEN '关闭'
|
|
WHEN Registration.states='2' THEN '开放'
|
|
WHEN Registration.states='3' THEN '关闭'
|
|
ELSE '已作废' END )as StatesStr,Registration.ProjectId
|
|
|
|
from HSSE_Hazard_HazardRegister Registration
|
|
LEFT JOIN Base_Unit AS Unit ON Unit.UnitId = Registration.ResponsibleUnit
|
|
LEFT JOIN dbo.Sys_User AS User4 ON User4.UserId = Registration.ResponsibleMan2
|
|
LEFT JOIN dbo.Sys_User AS User2 ON User2.UserId = Registration.CheckManId
|
|
|
|
union all
|
|
--专项检查
|
|
select CheckItemSetContent as Content,cc.CheckTime as CheckDate,f.HiddenType as HiddendangersTypes,
|
|
(CASE WHEN f.HiddenHazardType = '3' THEN '重大' WHEN f.HiddenHazardType = '2' THEN '较大' WHEN f.HiddenHazardType
|
|
= '1' THEN '一般' ELSE '' END) as HiddendangersLevel,
|
|
unit1.UnitName as UnitName,cc.PartInPersonIds as Person,f.Rectification_Date as Term
|
|
,sc.ConstText as Rectification,
|
|
(CASE WHEN cc.States='2' THEN '待确认' WHEN cc.States='3' THEN '已关闭' WHEN cc.States='1' THEN '待整改' ELSE '待提交' END)
|
|
as ReviewResults,f.CompletedDate as ReviewDate,su.UserName as ReviewMan,
|
|
(CASE WHEN cc.States='2' THEN '开放' WHEN cc.States='3' THEN '关闭' WHEN cc.States='1' THEN '开放' ELSE '开放' END) as StatesStr ,cc.ProjectId
|
|
from Check_CheckSpecialDetail f
|
|
left join Check_CheckSpecial cc on f.CheckSpecialId=cc.CheckSpecialId
|
|
left join base_unit unit1 on cc.ResponsibleUnit=unit1.UnitId
|
|
left join sys_const sc on f.HandleStep=sc.ConstValue
|
|
left join sys_user su on cc.ResponsibleMan=su.UserId
|
|
where CompleteStatus=0
|
|
|
|
union all
|
|
|
|
--综合检查
|
|
select f.Unqualified as Content,ccc.CheckTime as CheckDate, f.HiddenType as HiddendangersTypes,
|
|
f.HiddenHazardType as HiddendangersLevel,unit1.UnitName as UnitName,'' as Person, f.LimitedDate as Term
|
|
,sc.ConstText as Rectification,(CASE WHEN f.CompleteStatus =1 THEN '是'
|
|
WHEN f.CompleteStatus =0 THEN '否' ELSE '' END) as ReviewResults,
|
|
f.CompletedDate as ReviewDate,su.UserName as ReviewMan,(CASE WHEN f.CompleteStatus =1 THEN '关闭'
|
|
WHEN f.CompleteStatus =0 THEN '开放' ELSE '' END) as StatesStr,ccc.ProjectId
|
|
from Check_CheckColligationDetail f
|
|
left join Check_CheckColligation ccc on f.CheckColligationId=ccc.CheckColligationId
|
|
left join base_unit unit1 on f.UnitId=unit1.UnitId
|
|
left join sys_const sc on f.HandleStep=sc.ConstValue
|
|
left join sys_user su on su.userid=ccc.CheckPerson
|
|
|
|
union all
|
|
|
|
--隐患整改单
|
|
select f.WrongContent as Content,cr.CheckedDate as CheckDate,f.HiddenType as HiddendangersTypes,
|
|
f.HiddenHazardType as HiddendangersLevel,bu.UnitName as UnitName,cr.DutyPerson as Person,LimitTime as Term
|
|
,Requirement as Rectification,
|
|
(CASE WHEN States = 0 THEN '待提交'
|
|
WHEN States = 1 THEN '待签发'
|
|
WHEN States = 2 THEN '待整改'
|
|
WHEN States = 3 THEN '待审核'
|
|
WHEN States = 4 THEN '待复查'
|
|
WHEN States = 5 THEN '已完成' ELSE '' END) as ReviewResults,
|
|
cr.CompleteDate as ReviewDate,CheckPerson.UserName as ReviewMan,
|
|
(CASE WHEN States = 0 THEN '开放'
|
|
WHEN States = 1 THEN '开放'
|
|
WHEN States = 2 THEN '开放'
|
|
WHEN States = 3 THEN '开放'
|
|
WHEN States = 4 THEN '开放'
|
|
WHEN States = 5 THEN '关闭' ELSE '' END) as StatesStr,cr.ProjectId
|
|
from Check_RectifyNoticesItem f
|
|
left join Check_RectifyNotices cr on f.RectifyNoticesId=cr.RectifyNoticesId
|
|
left join base_unit bu on cr.UnitId=bu.UnitId
|
|
LEFT JOIN Sys_User AS CheckPerson ON CheckPerson.UserId = cr.CheckPerson
|
|
)f where 1=1 ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
strSql += " AND ProjectId = @ProjectId";
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
|
|
if (!string.IsNullOrEmpty(this.txtStartTime.Text.Trim()))
|
|
{
|
|
strSql += " AND CheckDate >= @StartDate";
|
|
listStr.Add(new SqlParameter("@StartDate", this.txtStartTime.Text.Trim()));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtEndTime.Text.Trim()))
|
|
{
|
|
strSql += " AND CheckDate <= @EndDate";
|
|
listStr.Add(new SqlParameter("@EndDate", this.txtEndTime.Text.Trim()));
|
|
}
|
|
|
|
strSql += " order by CheckDate desc ";
|
|
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
#region 分页 排序
|
|
/// <summary>
|
|
/// 改变索引事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页下拉选择事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.txtStartTime.Text.Trim()) && !string.IsNullOrEmpty(this.txtEndTime.Text.Trim()))
|
|
{
|
|
if (Convert.ToDateTime(this.txtStartTime.Text.Trim()) > Convert.ToDateTime(this.txtEndTime.Text.Trim()))
|
|
{
|
|
Alert.ShowInTop("开始时间不能大于结束时间", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
this.BindGrid();
|
|
}
|
|
#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 = this.Grid1.RecordCount;
|
|
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)
|
|
{
|
|
if (column.ColumnID != "ckbIsSelected" && column.ColumnID != "Punish" && column.ColumnID != "Del")
|
|
{
|
|
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)
|
|
{
|
|
if (column.ColumnID != "ckbIsSelected" && column.ColumnID != "Punish" && column.ColumnID != "Del")
|
|
{
|
|
string html = row.Values[column.ColumnIndex].ToString();
|
|
if (column.ColumnID == "tfPageIndex")
|
|
{
|
|
html = (row.FindControl("lblPageIndex") as AspNet.Label).Text;
|
|
}
|
|
|
|
sb.AppendFormat("<td>{0}</td>", html);
|
|
}
|
|
}
|
|
sb.Append("</tr>");
|
|
}
|
|
sb.Append("</table>");
|
|
|
|
return sb.ToString();
|
|
}
|
|
#endregion
|
|
}
|
|
} |