541 lines
21 KiB
C#
541 lines
21 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
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 CheckSpecialRecord : PageBase
|
|
{
|
|
#region 定义项
|
|
/// <summary>
|
|
/// GV被选择项列表
|
|
/// </summary>
|
|
public List<string> ItemSelectedList
|
|
{
|
|
get
|
|
{
|
|
return (List<string>)ViewState["ItemSelectedList"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ItemSelectedList"] = 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);
|
|
GetButtonPower();
|
|
this.ItemSelectedList = new List<string>();
|
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
SetProblemTypes();
|
|
SetUnitProject();
|
|
SetResponsibleUnit();
|
|
this.txtStartTime.Text = DateTime.Today.ToString("yyyy-MM-dd");
|
|
this.txtEndTime.Text = DateTime.Today.ToString("yyyy-MM-dd");
|
|
// 绑定表格
|
|
BindGrid();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
|
|
|
|
string strSql = "SELECT a.InspectionId,a.InspectionCode,a.ProjectId,(SELECT ProjectName FROM Base_Project as p WHERE p.ProjectId = a.ProjectId) as ProjectName, a.PersonResponsible,(SELECT UserName FROM Sys_User as u WHERE u.UserID = a.PersonResponsible) as PersonResponsibleName, (CASE WHEN a.States = '1' THEN '待检查' WHEN a.States = '2' THEN '待审核/整改' WHEN a.States = '3' THEN '已闭环' END ) as Status, a.CheckMan, a.CreateTime, a.ProblemTypeName,b.CompileTime as CheckTime, " +
|
|
"b.InspectionItemId,b.BeforelUrl,b.AfterUrl, (CASE WHEN b.States = '1'and a.States = '1' THEN '待提交' WHEN a.States = '2' and b.States = '1' THEN '待审核' WHEN a.States = '2' and b.States = '2' THEN '待整改' WHEN a.States = '2' and b.States = '3' THEN '已闭环' WHEN a.States = '3' THEN '已闭环' END) as itemStates," +
|
|
"a.Place FROM Inspect_InspectionItem as b LEFT JOIN Inspect_Inspection as a on b.InspectionId = a.InspectionId WHERE a.InspectType = '1'";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
|
{
|
|
strSql += "and a.ProjectId = @ProjectId";
|
|
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtCheckMan.Text.Trim()))
|
|
{
|
|
strSql += " AND a.CheckMan LIKE @CheckMan";
|
|
listStr.Add(new SqlParameter("@CheckMan", "%" + this.txtCheckMan.Text.Trim() + "%"));
|
|
}
|
|
if (this.txtType.SelectedText.Trim() != "请选择" && !string.IsNullOrEmpty(this.txtType.SelectedText.Trim()))
|
|
{
|
|
strSql += " AND a.ProblemTypeName = @Type";
|
|
listStr.Add(new SqlParameter("@Type", this.txtType.SelectedText.Trim()));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtWorkAreaName.SelectedText) && this.txtWorkAreaName.SelectedText.Trim() != "请选择")
|
|
{
|
|
strSql += " AND a.Place = @Place";
|
|
listStr.Add(new SqlParameter("@Place", this.txtWorkAreaName.SelectedText.Trim()));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtWorkAreaName.Text.Trim()))
|
|
{
|
|
strSql += " AND a.Place LIKE @Place";
|
|
listStr.Add(new SqlParameter("@Place", "%" + this.txtWorkAreaName.Text.Trim() + "%"));
|
|
}
|
|
if (!string.IsNullOrEmpty(txtStartTime.Text.Trim()))
|
|
{
|
|
strSql += " AND b.CompileTime >= @StartTime";
|
|
listStr.Add(new SqlParameter("@StartTime", string.Format("{0} {1}", this.txtStartTime.Text.Trim(), "00:00:00")));
|
|
}
|
|
if (!string.IsNullOrEmpty(this.txtEndTime.Text.Trim()))
|
|
{
|
|
strSql += " AND b.CompileTime <= @EndTime";
|
|
listStr.Add(new SqlParameter("@EndTime", string.Format("{0} {1}", this.txtEndTime.Text.Trim(), "23:59:59")));
|
|
}
|
|
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
|
|
|
|
|
|
#region 问题类型下拉框赋值
|
|
public void SetProblemTypes()
|
|
{
|
|
txtType.DataValueField = "RectifyId";
|
|
txtType.DataTextField = "RectifyName";
|
|
List<Model.Technique_Rectify> list = (from x in Funs.DB.Technique_Rectify select x).ToList();
|
|
list.Insert(0, new Model.Technique_Rectify()
|
|
{
|
|
RectifyId = "-1",
|
|
RectifyName = "请选择"
|
|
});
|
|
txtType.DataSource = list;
|
|
txtType.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
#region 单位工程下拉框赋值
|
|
public void SetUnitProject()
|
|
{
|
|
List<Model.WBS_UnitWork> list = new List<Model.WBS_UnitWork>() {
|
|
new Model.WBS_UnitWork()
|
|
{
|
|
UnitWorkId = "-1",
|
|
UnitWorkName = "请选择"
|
|
}
|
|
};
|
|
if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
|
{
|
|
list.AddRange((from x in Funs.DB.WBS_UnitWork where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList());
|
|
}
|
|
txtWorkAreaName.DataValueField = "UnitWorkId";
|
|
txtWorkAreaName.DataTextField = "UnitWorkName";
|
|
txtWorkAreaName.DataSource = list;
|
|
txtWorkAreaName.DataBind();
|
|
}
|
|
#endregion
|
|
|
|
#region 责任单位下拉框赋值
|
|
public void SetResponsibleUnit()
|
|
{
|
|
List<Model.UnitItem> list = new List<Model.UnitItem>() {
|
|
new Model.UnitItem()
|
|
{
|
|
UnitId = "-1",
|
|
UnitName = "请选择"
|
|
}
|
|
};
|
|
if (!string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
|
{
|
|
list.AddRange((from x in Funs.DB.Project_ProjectUnit
|
|
join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId
|
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|
select new Model.UnitItem()
|
|
{
|
|
UnitId = y.UnitId,
|
|
UnitName = y.UnitName
|
|
}).ToList());
|
|
}
|
|
txtResponsibilityUnitName.DataValueField = "UnitId";
|
|
txtResponsibilityUnitName.DataTextField = "UnitName";
|
|
txtResponsibilityUnitName.DataSource = list;
|
|
txtResponsibilityUnitName.DataBind();
|
|
}
|
|
#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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
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 Grid双击事件
|
|
/// <summary>
|
|
/// Grid行双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
btnMenuSee_Click(null, null);
|
|
}
|
|
#endregion
|
|
|
|
#region 查看
|
|
/// <summary>
|
|
/// 查看按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuSee_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string RegistrationId = Grid1.SelectedRowID;
|
|
|
|
if (RegistrationId != null)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("CheckSpecialView.aspx?InspectionItemId={0}", RegistrationId, "查看 - ")));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
protected void btnMenuDel_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
Model.Inspect_InspectionItem item = db.Inspect_InspectionItem.FirstOrDefault(x => x.InspectionItemId == rowID);
|
|
if (item != null)
|
|
{
|
|
|
|
db.Inspect_InspectionItem.DeleteOnSubmit(item);
|
|
db.SubmitChanges();
|
|
int count = db.Inspect_Inspection.Count(x => x.InspectionId == item.InspectionId);
|
|
if (count == 0)
|
|
{
|
|
db.Inspect_Inspection.DeleteOnSubmit(db.Inspect_Inspection.FirstOrDefault(x => x.InspectionId == item.InspectionId));
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
BindGrid();
|
|
ShowNotify("删除数据成功!");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region Grid行点击事件
|
|
/// <summary>
|
|
/// Grid行点击事件
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
string RegistrationId = Grid1.DataKeys[e.RowIndex][0].ToString();
|
|
Model.HSSE_Hazard_HazardRegister hazardRegister = BLL.HSSE_Hazard_HazardRegisterService.GetHazardRegisterByCheckItemDetailId(RegistrationId);
|
|
if (e.CommandName == "IsSelected")
|
|
{
|
|
CheckBoxField checkField = (CheckBoxField)Grid1.FindColumn("ckbIsSelected");
|
|
if (checkField.GetCheckedState(e.RowIndex))
|
|
{
|
|
if (!ItemSelectedList.Contains(RegistrationId))
|
|
{
|
|
ItemSelectedList.Add(RegistrationId);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (ItemSelectedList.Contains(RegistrationId))
|
|
{
|
|
ItemSelectedList.Remove(RegistrationId);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (e.CommandName == "del")
|
|
{
|
|
if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.HSSE_HiddenRectificationListMenuId, BLL.Const.BtnDelete))
|
|
{
|
|
if (hazardRegister.States != Const.State_3 || this.CurrUser.UserId == BLL.Const.hfnbdId) //待整改
|
|
{
|
|
var getD = BLL.HSSE_Hazard_HazardRegisterService.GetHazardRegisterByHazardRegisterId(RegistrationId);
|
|
if (getD != null)
|
|
{
|
|
BLL.LogService.AddSys_Log(this.CurrUser, getD.HazardCode, getD.HazardRegisterId, BLL.Const.HSSE_HiddenRectificationListMenuId, BLL.Const.BtnDelete);
|
|
BLL.HSSE_Hazard_HazardRegisterService.DeleteHazardRegisterByHazardRegisterId(RegistrationId);
|
|
BindGrid();
|
|
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("已闭环,无法删除!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 整改后图片
|
|
protected string ConvertImgUrl(object registrationId)
|
|
{
|
|
string url = string.Empty;
|
|
if (registrationId != null)
|
|
{
|
|
var imgUrl = Funs.DB.Inspect_InspectionItem.FirstOrDefault(x => x.InspectionItemId == registrationId.ToString()).AfterUrl;
|
|
if (imgUrl != null)
|
|
{
|
|
url = BLL.UploadAttachmentService.ShowImage(ConfigurationManager.AppSettings["CEMS_IMG_URL"], imgUrl);
|
|
}
|
|
}
|
|
return url;
|
|
}
|
|
#endregion
|
|
|
|
#region 整改前图片
|
|
protected string ConvertImgUrlByImage(object registrationId)
|
|
{
|
|
string url = string.Empty;
|
|
if (registrationId != null)
|
|
{
|
|
var imgUrl = Funs.DB.Inspect_InspectionItem.FirstOrDefault(x => x.InspectionItemId == registrationId.ToString()).BeforelUrl;
|
|
if (imgUrl != null)
|
|
{
|
|
url = BLL.UploadAttachmentService.ShowImage(ConfigurationManager.AppSettings["CEMS_IMG_URL"], imgUrl);
|
|
}
|
|
}
|
|
return url;
|
|
}
|
|
#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 = 100000;
|
|
this.BindGrid();
|
|
Response.Write(GetGridTableHtml(Grid1));
|
|
Response.End();
|
|
}
|
|
|
|
#pragma warning disable CS0108 // “HiddenRectificationList.GetGridTableHtml(Grid)”隐藏继承的成员“PageBase.GetGridTableHtml(Grid)”。如果是有意隐藏,请使用关键字 new。
|
|
/// <summary>
|
|
/// 导出方法
|
|
/// </summary>
|
|
/// <param name="grid"></param>
|
|
/// <returns></returns>
|
|
private string GetGridTableHtml(Grid grid)
|
|
#pragma warning restore CS0108 // “HiddenRectificationList.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)
|
|
{
|
|
if (column.ColumnID != "ckbIsSelected" && column.ColumnID != "tfImageUrl1" && column.ColumnID != "tfImageUrl2" && column.ColumnID != "Punish" && column.ColumnID != "Del")
|
|
{
|
|
sb.AppendFormat("<td style=\"vnd.ms-excel.numberformat:@\" >{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 != "tfImageUrl1" && column.ColumnID != "tfImageUrl2" && 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;
|
|
}
|
|
if (column.ColumnID == "tfImageUrl")
|
|
{
|
|
html = (row.FindControl("lbtnImageUrl") as AspNet.LinkButton).Text;
|
|
}
|
|
if (column.ColumnID == "tfRectificationImageUrl")
|
|
{
|
|
html = (row.FindControl("lbtnRectificationImageUrl") as AspNet.LinkButton).Text;
|
|
}
|
|
//if (column.ColumnID == "tfCutPayment")
|
|
//{
|
|
// html = (row.FindControl("lbtnCutPayment") as AspNet.LinkButton).Text;
|
|
//}
|
|
sb.AppendFormat("<td>{0}</td>", html);
|
|
}
|
|
}
|
|
sb.Append("</tr>");
|
|
}
|
|
sb.Append("</table>");
|
|
|
|
return sb.ToString();
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window3_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
//if (!string.IsNullOrEmpty(this.hdRemark.Text))
|
|
//{
|
|
string hazardRegisterIds = string.Empty;
|
|
foreach (var item in ItemSelectedList)
|
|
{
|
|
hazardRegisterIds += item + ",";
|
|
}
|
|
if (!string.IsNullOrEmpty(hazardRegisterIds))
|
|
{
|
|
hazardRegisterIds = hazardRegisterIds.Substring(0, hazardRegisterIds.LastIndexOf(","));
|
|
}
|
|
}
|
|
|
|
#region 获取按钮权限
|
|
/// <summary>
|
|
/// 获取按钮权限
|
|
/// </summary>
|
|
/// <param name="button"></param>
|
|
/// <returns></returns>
|
|
private void GetButtonPower()
|
|
{
|
|
if (Request.Params["value"] == "0")
|
|
{
|
|
return;
|
|
}
|
|
var buttonList = CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, "C7481FEE-EA92-44B8-99F6-C5CA6BBDCFF5");
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnSee))
|
|
{
|
|
this.btnMenuSee.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnDelete))
|
|
{
|
|
this.btnMenuDel.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected string ConvertState(object state)
|
|
{
|
|
if (state != null)
|
|
{
|
|
var registration = BLL.HSSE_Hazard_HazardRegisterService.GetHazardRegisterByCheckItemDetailId(state.ToString());
|
|
if (registration != null)
|
|
{
|
|
if (registration.States == "1") //待整改
|
|
{
|
|
return "待整改";
|
|
}
|
|
else if(registration.States == "2") //待整改
|
|
{
|
|
return "已整改-待复查验收";
|
|
}
|
|
else if(registration.States == "3") //待整改
|
|
{
|
|
return "已闭环";
|
|
}
|
|
{
|
|
return "编制";
|
|
}
|
|
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
}
|
|
} |