安全不符合项清单
This commit is contained in:
@@ -0,0 +1,491 @@
|
||||
using BLL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
namespace FineUIPro.Web.Check.HSE
|
||||
{
|
||||
public partial class CheckProblem : PageBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 项目id
|
||||
/// </summary>
|
||||
public string ProjectId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["ProjectId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["ProjectId"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
#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.CurrUser.LoginProjectId)
|
||||
{
|
||||
this.ProjectId = Request.Params["projectId"];
|
||||
}
|
||||
//权限按钮方法
|
||||
GetButtonPower();
|
||||
InitDropDownList();
|
||||
|
||||
//Funs.FineUIPleaseSelect(this.dpState);
|
||||
btnNew.OnClientClick = Window1.GetShowReference("CheckProblemEdit.aspx") + "return false;";
|
||||
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
||||
|
||||
// 绑定表格
|
||||
BindGrid();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化下拉框
|
||||
/// </summary>
|
||||
private void InitDropDownList()
|
||||
{
|
||||
////受检单位
|
||||
//UnitService.InitBranchUnitDropDownList(this.drpUnit, true);
|
||||
////受检项目
|
||||
//ProjectService.InitProjectDropDownList(this.drpProject, true);
|
||||
//问题分类
|
||||
SafetyProblemClassifyService.InitClassifyDropDownList(this.drpClassify, true);
|
||||
//问题性质
|
||||
SafetyProblemNatureService.InitNatureDropDownList(this.drpNature, true);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 查询
|
||||
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.BindGrid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定数据
|
||||
/// </summary>
|
||||
|
||||
public void BindGrid()
|
||||
{
|
||||
DataTable tb = ChecklistData();
|
||||
|
||||
// 2.获取当前分页数据
|
||||
//var table = this.GetPagedDataTable(Grid1, tb1);
|
||||
|
||||
Grid1.RecordCount = tb.Rows.Count;
|
||||
tb = GetFilteredTable(Grid1.FilteredData, tb);
|
||||
var table = this.GetPagedDataTable(Grid1, tb);
|
||||
|
||||
Grid1.DataSource = table;
|
||||
Grid1.DataBind();
|
||||
|
||||
for (int i = 0; i < Grid1.Rows.Count; i++)
|
||||
{
|
||||
var state = table.Rows[i]["State"].ToString().Trim();
|
||||
var limitDate = table.Rows[i]["LimitDate"].ToString();
|
||||
DateTime dtLimitDate = Convert.ToDateTime(limitDate);
|
||||
if (Grid1.Rows[i].DataKeys[0] != null && !string.IsNullOrWhiteSpace(state) && state == "1")
|
||||
{
|
||||
if (dtLimitDate.AddDays(1) < DateTime.Now) //延期未整改
|
||||
{
|
||||
Grid1.Rows[i].CellCssClasses[7] = "Red";
|
||||
}
|
||||
else//期内未整改
|
||||
{
|
||||
Grid1.Rows[i].CellCssClasses[7] = " Yellow ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据加载
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected DataTable ChecklistData()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("SELECT spc.ClassifyName,spcItem.ClassifyItemName,spn.NatureName,spnItem.NatureItemContent,tba.* ");
|
||||
sb.Append("FROM CheckProblem_Safety AS tba WITH(NOLOCK) ");
|
||||
sb.Append("LEFT JOIN Base_SafetyProblemClassify AS spc ON spc.ClassifyId=tba.ClassifyId ");
|
||||
sb.Append("LEFT JOIN Base_SafetyProblemClassifyItem AS spcItem ON spcItem.ClassifyItemId=tba.ClassifyItemId ");
|
||||
sb.Append("LEFT JOIN Base_SafetyProblemNature AS spn ON spn.NatureId=tba.NatureId ");
|
||||
sb.Append("LEFT JOIN Base_SafetyProblemNatureItem AS spnItem ON spnItem.NatureItemId=tba.NatureItemId ");
|
||||
sb.Append("WHERE 1=1 ");
|
||||
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
//listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(this.txtSearch.Text.Trim()))
|
||||
{
|
||||
sb.Append("AND (tba.UnitName LIKE @SearchTxt OR tba.ProjectName LIKE @SearchTxt OR tba.Description LIKE @SearchTxt OR tba.CheckTeamUser LIKE @SearchTxt) ");
|
||||
listStr.Add(new SqlParameter("@SearchTxt", "%" + this.txtSearch.Text.Trim() + "%"));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(this.drpClassify.SelectedValue) && this.drpClassify.SelectedValue != Const._Null)
|
||||
{
|
||||
sb.Append("AND tba.ClassifyId=@ClassifyId ");
|
||||
listStr.Add(new SqlParameter("@ClassifyId", this.drpClassify.SelectedValue));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(this.drpNature.SelectedValue) && this.drpNature.SelectedValue != Const._Null)
|
||||
{
|
||||
sb.Append("AND tba.NatureId=@NatureId ");
|
||||
listStr.Add(new SqlParameter("@NatureId", this.drpNature.SelectedValue));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(this.rblState.SelectedValue))
|
||||
{
|
||||
sb.Append("AND tba.State=@State ");
|
||||
listStr.Add(new SqlParameter("@State", this.rblState.SelectedValue));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(this.rblUnitType.SelectedValue))
|
||||
{
|
||||
sb.Append("AND tba.UnitType=@UnitType ");
|
||||
listStr.Add(new SqlParameter("@UnitType", this.rblUnitType.SelectedValue));
|
||||
}
|
||||
string startDate = this.txtStartTime.Text.Trim();
|
||||
string endDate = this.txtEndTime.Text.Trim();
|
||||
if (!string.IsNullOrWhiteSpace(startDate))
|
||||
{
|
||||
sb.Append("AND tba.CheckDate >= @StartDate ");
|
||||
listStr.Add(new SqlParameter("@StartDate", startDate));
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(endDate))
|
||||
{
|
||||
sb.Append("AND tba.CheckDate <= @EndDate ");
|
||||
listStr.Add(new SqlParameter("@EndDate", $"{endDate} 23:59:59"));
|
||||
}
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(sb.ToString(), parameter);
|
||||
return tb;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/***整改前、后照片***
|
||||
|
||||
protected string ConvertImageUrlByImage(object registrationId)
|
||||
{
|
||||
string url = string.Empty;
|
||||
if (registrationId != null)
|
||||
{
|
||||
IList<Model.AttachFile> sourlist = AttachFileService.GetBeforeFileList(registrationId.ToString(), BLL.Const.SafetyCheckProblemMenuId);
|
||||
|
||||
if (sourlist != null&& sourlist.Count>0)
|
||||
{
|
||||
string AttachUrl = "";
|
||||
foreach(var item in sourlist)
|
||||
{ if(!string.IsNullOrEmpty(item.AttachUrl)&& item.AttachUrl.ToLower().EndsWith(".jpg")|| item.AttachUrl.ToLower().EndsWith(".jpeg")|| item.AttachUrl.ToLower().EndsWith(".png"))
|
||||
AttachUrl += item.AttachUrl.TrimEnd(',')+",";
|
||||
}
|
||||
url = BLL.UploadAttachmentService.ShowImage(ConfigurationManager.AppSettings["CEMS_IMG_URL"], AttachUrl.TrimEnd(','));
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
protected string ConvertImgUrlByImage(object registrationId)
|
||||
{
|
||||
string url = string.Empty;
|
||||
if (registrationId != null)
|
||||
{
|
||||
IList<Model.AttachFile> sourlist = AttachFileService.Getfilelist(registrationId.ToString()+"r", BLL.Const.SafetyCheckProblemMenuId);
|
||||
|
||||
if (sourlist != null && sourlist.Count > 0)
|
||||
{
|
||||
string AttachUrl = "";
|
||||
foreach (var item in sourlist)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.AttachUrl) && item.AttachUrl.ToLower().EndsWith(".jpg") || item.AttachUrl.ToLower().EndsWith(".jpeg") || item.AttachUrl.ToLower().EndsWith(".png"))
|
||||
AttachUrl += item.AttachUrl.TrimEnd(',') + ",";
|
||||
}
|
||||
url = BLL.UploadAttachmentService.ShowImage(ConfigurationManager.AppSettings["CEMS_IMG_URL"], AttachUrl.TrimEnd(','));
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
******/
|
||||
|
||||
/// <summary>
|
||||
/// 检查问题状态
|
||||
/// </summary>
|
||||
/// <param name="obj"></param>
|
||||
/// <returns></returns>
|
||||
public string ConvertStates(Object obj)
|
||||
{
|
||||
string result = "整改中";
|
||||
string state = obj.ToString();
|
||||
if (state == "0")
|
||||
{
|
||||
result = "已闭环";
|
||||
}
|
||||
else
|
||||
{ //闭环
|
||||
result = "整改中";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
#region 过滤表头、排序、分页、关闭窗口
|
||||
/// <summary>
|
||||
/// 过滤表头
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_FilterChange(object sender, EventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||||
{
|
||||
Grid1.PageIndex = e.NewPageIndex;
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
/// <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();
|
||||
}
|
||||
|
||||
/// <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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭弹出窗
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 鼠标操作事件
|
||||
|
||||
/// <summary>
|
||||
/// Grid行双击事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
||||
{
|
||||
btnMenuModify_Click(null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnMenuModify_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||||
{
|
||||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
string checkId = Grid1.SelectedRowID;
|
||||
var model = CheckProblemSafetyService.GetCheckProblemById(checkId);
|
||||
if (model != null)
|
||||
{
|
||||
if (model.State == (int)CheckProblemSafetyService.StateInt.已闭环) //双击事件 已闭环
|
||||
{
|
||||
Alert.ShowInTop("当前隐患已闭环,无法编辑,请右键查看!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CheckProblemEdit.aspx?CheckId={0}", checkId), "编辑安全不符合项"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 右键删除
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnMenuDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||||
{
|
||||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
string checkId = Grid1.SelectedRowID;
|
||||
var model = CheckProblemSafetyService.GetCheckProblemById(checkId);
|
||||
if (model != null)
|
||||
{
|
||||
if (model.State == (int)CheckProblemSafetyService.StateInt.已闭环)//双击事件 已闭环
|
||||
{
|
||||
Alert.ShowInTop("当前隐患已闭环,无法删除!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
BLL.CheckProblemSafetyService.DeleteCheckProblemById(checkId);
|
||||
BLL.LogService.AddSys_Log(this.CurrUser, model.CheckId, model.CheckId, BLL.Const.SafetyCheckProblemMenuId, "删除HSE不符合记录");
|
||||
Grid1.DataBind();
|
||||
BindGrid();
|
||||
Alert.ShowInTop("删除数据成功!", MessageBoxIcon.Success);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 checkId = Grid1.SelectedRowID;
|
||||
var model = CheckProblemSafetyService.GetCheckProblemById(checkId);
|
||||
if (model != null)
|
||||
{
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CheckProblemView.aspx?CheckId={0}", checkId), "查看安全不符合项"));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 查询按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnQuery_Click(object sender, EventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
/// <summary>
|
||||
/// 条件重置
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnRset_Click(object sender, EventArgs e)
|
||||
{
|
||||
rblUnitType.SelectedIndex = 0;
|
||||
drpClassify.SelectedIndex = 0;
|
||||
drpNature.SelectedIndex = 0;
|
||||
rblState.SelectedIndex = 0;
|
||||
txtSearch.Text = "";
|
||||
txtStartTime.Text = "";
|
||||
txtEndTime.Text = "";
|
||||
BindGrid();
|
||||
}
|
||||
#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.SafetyCheckProblemMenuId);
|
||||
if (buttonList.Count() > 0)
|
||||
{
|
||||
if (buttonList.Contains(BLL.Const.BtnAdd))
|
||||
{
|
||||
this.btnNew.Hidden = false;
|
||||
this.btnImport.Hidden = false;
|
||||
}
|
||||
if (buttonList.Contains(BLL.Const.BtnModify))
|
||||
{
|
||||
this.btnMenuModify.Hidden = false;
|
||||
}
|
||||
if (buttonList.Contains(BLL.Const.BtnDelete))
|
||||
{
|
||||
this.btnMenuDel.Hidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 导入
|
||||
|
||||
/// <summary>
|
||||
/// 导入按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnImport_Click(object sender, EventArgs e)
|
||||
{
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CheckProblemIn.aspx"), "导入安全不符合项"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 导出
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 导出
|
||||
/// </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 = 100000;
|
||||
this.BindGrid();
|
||||
Response.Write(GetGridTableHtml(Grid1));
|
||||
Response.End();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user