423 lines
16 KiB
C#
423 lines
16 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.Hazard
|
|||
|
{
|
|||
|
public partial class RoutingInspection : PageBase
|
|||
|
{
|
|||
|
#region 定义项
|
|||
|
/// <summary>
|
|||
|
/// 清单主键
|
|||
|
/// </summary>
|
|||
|
public string RoutingInspectionId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["RoutingInspectionId"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["RoutingInspectionId"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// 项目id
|
|||
|
/// </summary>
|
|||
|
public string ProjectId
|
|||
|
{
|
|||
|
get
|
|||
|
{
|
|||
|
return (string)ViewState["ProjectId"];
|
|||
|
}
|
|||
|
set
|
|||
|
{
|
|||
|
ViewState["ProjectId"] = value;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 加载页面
|
|||
|
/// <summary>
|
|||
|
/// 加载页面
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|||
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|||
|
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.ProjectId)
|
|||
|
{
|
|||
|
this.ProjectId = Request.Params["projectId"];
|
|||
|
}
|
|||
|
////权限按钮方法
|
|||
|
this.GetButtonPower();
|
|||
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|||
|
BLL.RiskLevelService.InitRiskLevelDropDownList(this.drpHazardLevel, true);
|
|||
|
Funs.FineUIPleaseSelect(this.drpState);
|
|||
|
// 绑定表格
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 绑定数据
|
|||
|
/// </summary>
|
|||
|
private void BindGrid()
|
|||
|
{
|
|||
|
string strSql = "select r.*,HazardListItem.WorkStage,HazardListItem.HazardListTypeId,HazardListItem.HazardId,HazardListItem.HazardItems,HazardListItem.Position,ControllingPersonUsers.UserName AS ControllingPersonName,Users.UserName as PatrolManName,HazardList.WorkAreaName,HazardList.CompileDate,case r.PatrolResult when 0 then '原状态' when 1 then '二次评估' when 2 then '下整改单' else '消除' end as PatrolResultStr,"
|
|||
|
+ @" (select RiskLevelName from Base_RiskLevel where RiskLevelId=r.OldRiskLevel) as OldRiskLevelName,"
|
|||
|
+ @" (select RiskLevelName from Base_RiskLevel where RiskLevelId=(select HazardLevel from Hazard_HazardSelectedItem where HazardSelectedItemId=r.HazardSelectedItemId)) as RiskLevelName"
|
|||
|
+ @" from Hazard_RoutingInspection AS r "
|
|||
|
+ @" LEFT JOIN Hazard_HazardSelectedItem AS HazardListItem on HazardListItem.HazardSelectedItemId=r.HazardSelectedItemId"
|
|||
|
+ @" LEFT JOIN Hazard_HazardList AS HazardList on HazardList.HazardListId=HazardListItem.HazardListId "
|
|||
|
+ @" LEFT JOIN Sys_User AS Users ON r.PatrolManId=Users.UserId "
|
|||
|
+ @" LEFT JOIN Sys_User AS ControllingPersonUsers ON HazardList.ControllingPerson=ControllingPersonUsers.UserId WHERE HazardList.States = " + BLL.Const.State_2;
|
|||
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|||
|
strSql += " AND HazardList.ProjectId = @ProjectId";
|
|||
|
if (!string.IsNullOrEmpty(Request.Params["projectId"])) ///是否文件柜查看页面传项目值
|
|||
|
{
|
|||
|
listStr.Add(new SqlParameter("@ProjectId", Request.Params["projectId"]));
|
|||
|
strSql += " AND HazardList.States = @States"; ///状态为已完成
|
|||
|
listStr.Add(new SqlParameter("@States", BLL.Const.State_2));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
listStr.Add(new SqlParameter("@ProjectId", this.ProjectId));
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(this.txtWorkAreaName.Text.Trim()))
|
|||
|
{
|
|||
|
strSql += " AND HazardList.WorkAreaName LIKE @WorkAreaName";
|
|||
|
listStr.Add(new SqlParameter("@WorkAreaName", "%" + this.txtWorkAreaName.Text.Trim() + "%"));
|
|||
|
}
|
|||
|
if (this.drpHazardLevel.SelectedValue != BLL.Const._Null)
|
|||
|
{
|
|||
|
strSql += " AND HazardListItem.HazardLevel = @HazardLevel";
|
|||
|
listStr.Add(new SqlParameter("@HazardLevel", this.drpHazardLevel.SelectedValue));
|
|||
|
}
|
|||
|
if (this.drpState.SelectedValue != BLL.Const._Null)
|
|||
|
{
|
|||
|
strSql += " AND r.PatrolResult = @PatrolResult";
|
|||
|
listStr.Add(new SqlParameter("@PatrolResult", this.drpState.SelectedValue));
|
|||
|
}
|
|||
|
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();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取危险源编号
|
|||
|
/// </summary>
|
|||
|
/// <param name="WorkStage"></param>
|
|||
|
/// <returns></returns>
|
|||
|
protected string ConvertHazardCode(object HazardId)
|
|||
|
{
|
|||
|
string hazardCode = string.Empty;
|
|||
|
if (HazardId != null)
|
|||
|
{
|
|||
|
Model.Technique_HazardList hazardList = BLL.HazardListService.GetHazardListById(HazardId.ToString());
|
|||
|
if (hazardList != null)
|
|||
|
{
|
|||
|
hazardCode = hazardList.HazardCode;
|
|||
|
}
|
|||
|
}
|
|||
|
return hazardCode;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取危险源类别
|
|||
|
/// </summary>
|
|||
|
/// <param name="hazardListTypeId"></param>
|
|||
|
/// <returns></returns>
|
|||
|
protected string ConvertSupHazardListTypeId(object hazardListTypeId)
|
|||
|
{
|
|||
|
if (hazardListTypeId != null)
|
|||
|
{
|
|||
|
Model.Technique_HazardListType hazardListType = BLL.HazardListTypeService.GetHazardListTypeById(hazardListTypeId.ToString());
|
|||
|
if (hazardListType != null)
|
|||
|
{
|
|||
|
var hazard = BLL.HazardListTypeService.GetHazardListTypeById(hazardListType.SupHazardListTypeId);
|
|||
|
if (hazard != null)
|
|||
|
{
|
|||
|
return hazard.HazardListTypeName;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 获取危险源项
|
|||
|
/// </summary>
|
|||
|
/// <param name="hazardListTypeId"></param>
|
|||
|
/// <returns></returns>
|
|||
|
protected string ConvertHazardListTypeId(object hazardListTypeId)
|
|||
|
{
|
|||
|
if (hazardListTypeId != null)
|
|||
|
{
|
|||
|
Model.Technique_HazardListType hazardListType = BLL.HazardListTypeService.GetHazardListTypeById(hazardListTypeId.ToString());
|
|||
|
if (hazardListType != null)
|
|||
|
{
|
|||
|
return hazardListType.HazardListTypeName;
|
|||
|
}
|
|||
|
}
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
#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 Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|||
|
{
|
|||
|
Grid1.PageIndex = e.NewPageIndex;
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 排序
|
|||
|
/// <summary>
|
|||
|
/// 排序
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|||
|
{
|
|||
|
Grid1.SortDirection = e.SortDirection;
|
|||
|
Grid1.SortField = e.SortField;
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 分页选择下拉改变事件
|
|||
|
/// <summary>
|
|||
|
/// 分页选择下拉改变事件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 弹出编辑窗口关闭事件
|
|||
|
/// <summary>
|
|||
|
/// 弹出编辑窗体关闭事件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|||
|
{
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Grid双击事件
|
|||
|
/// <summary>
|
|||
|
/// Grid行双击事件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|||
|
{
|
|||
|
btnMenuView_Click(null, null);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 编辑
|
|||
|
/// <summary>
|
|||
|
/// 编辑按钮
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnMenuView_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|||
|
{
|
|||
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
string RoutingInspectionId = Grid1.SelectedRowID;
|
|||
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("RoutingInspectionView.aspx?RoutingInspectionId={0}", RoutingInspectionId, "查看 - ")));
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 删除
|
|||
|
/// <summary>
|
|||
|
/// 右键删除事件
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|||
|
{
|
|||
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|||
|
{
|
|||
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|||
|
Model.Hazard_RoutingInspection routingInspection = BLL.Hazard_RoutingInspectionService.GetRoutingInspectionByRoutingInspectionId(rowID);
|
|||
|
BLL.LogService.AddSys_Log(this.CurrUser, routingInspection.PatrolResult.ToString(), routingInspection.RoutingInspectionId, BLL.Const.ProjectRoutingInspectionMenuId, BLL.Const.BtnDelete);
|
|||
|
BLL.Hazard_RoutingInspectionService.DeleteRoutingInspection(rowID);
|
|||
|
Model.Hazard_PatrolPlan plan = BLL.Hazard_PatrolPlanService.GetPatrolPlanByPatrolPlanId(routingInspection.PatrolPlanId);
|
|||
|
if (plan != null)
|
|||
|
{
|
|||
|
plan.CheckDate = null;
|
|||
|
plan.State = "0";
|
|||
|
BLL.Hazard_PatrolPlanService.UpdatePatrolPlan(plan);
|
|||
|
}
|
|||
|
}
|
|||
|
BindGrid();
|
|||
|
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 转换字符串
|
|||
|
/// <summary>
|
|||
|
/// 转换工作阶段
|
|||
|
/// </summary>
|
|||
|
/// <param name="workStage"></param>
|
|||
|
/// <returns></returns>
|
|||
|
protected string ConvertWorkStage(object workStage)
|
|||
|
{
|
|||
|
if (workStage != null)
|
|||
|
{
|
|||
|
string workStages = string.Empty;
|
|||
|
string[] strList = workStage.ToString().Split(',');
|
|||
|
foreach (string str in strList)
|
|||
|
{
|
|||
|
Model.Base_WorkStage c = BLL.WorkStageService.GetWorkStageById(str);
|
|||
|
if (c != null)
|
|||
|
{
|
|||
|
workStages += c.WorkStageName + ",";
|
|||
|
}
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(workStages))
|
|||
|
{
|
|||
|
workStages = workStages.Substring(0, workStages.LastIndexOf(","));
|
|||
|
}
|
|||
|
return workStages;
|
|||
|
}
|
|||
|
return "";
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 获取按钮权限
|
|||
|
/// <summary>
|
|||
|
/// 获取按钮权限
|
|||
|
/// </summary>
|
|||
|
/// <param name="button"></param>
|
|||
|
/// <returns></returns>
|
|||
|
private void GetButtonPower()
|
|||
|
{
|
|||
|
if (Request.Params["value"] == "0")
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.UserId, BLL.Const.ProjectRoutingInspectionMenuId);
|
|||
|
if (buttonList.Count() > 0)
|
|||
|
{
|
|||
|
if (buttonList.Contains(BLL.Const.BtnDelete))
|
|||
|
{
|
|||
|
this.btnMenuDelete.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 = Grid1.RecordCount;
|
|||
|
this.BindGrid();
|
|||
|
Response.Write(GetGridTableHtml(Grid1));
|
|||
|
Response.End();
|
|||
|
}
|
|||
|
|
|||
|
#pragma warning disable CS0108 // “HazardList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
|
|||
|
/// <summary>
|
|||
|
/// 导出方法
|
|||
|
/// </summary>
|
|||
|
/// <param name="grid"></param>
|
|||
|
/// <returns></returns>
|
|||
|
private string GetGridTableHtml(Grid grid)
|
|||
|
#pragma warning restore CS0108 // “HazardList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
|
|||
|
{
|
|||
|
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;
|
|||
|
}
|
|||
|
if (column.ColumnID == "tfVersionNo")
|
|||
|
{
|
|||
|
html = (row.FindControl("lblVersionNo") as AspNet.Label).Text;
|
|||
|
}
|
|||
|
if (column.ColumnID == "tfWorkStage")
|
|||
|
{
|
|||
|
html = (row.FindControl("lblWorkStage") as AspNet.Label).Text;
|
|||
|
}
|
|||
|
sb.AppendFormat("<td>{0}</td>", html);
|
|||
|
}
|
|||
|
|
|||
|
sb.Append("</tr>");
|
|||
|
}
|
|||
|
|
|||
|
sb.Append("</table>");
|
|||
|
|
|||
|
return sb.ToString();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|