529 lines
20 KiB
C#
529 lines
20 KiB
C#
using BLL;
|
|
using Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace FineUIPro.Web.HSSE.Hazard
|
|
{
|
|
public partial class ConstructionRisk : PageBase
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
GetButtonPower();//权限设置
|
|
|
|
this.InitTreeMenu();//加载树
|
|
}
|
|
}
|
|
|
|
#region 加载树施工单位
|
|
/// <summary>
|
|
/// 加载树
|
|
/// </summary>
|
|
private void InitTreeMenu()
|
|
{
|
|
this.tvControlItem.Nodes.Clear();
|
|
|
|
List<Base_Unit> units = null;
|
|
|
|
var user = UserService.GetUserByUserId(this.CurrUser.UserId);
|
|
if (!string.IsNullOrEmpty(user.UnitId))
|
|
{
|
|
var projectUnit = BLL.ProjectUnitService.GetProjectUnitByUnitIdProjectId(this.CurrUser.LoginProjectId, user.UnitId);
|
|
if (projectUnit != null)
|
|
{
|
|
if (projectUnit.UnitType == BLL.Const.ProjectUnitType_1 || projectUnit.UnitType == BLL.Const.ProjectUnitType_3 || projectUnit.UnitType == BLL.Const.ProjectUnitType_4)
|
|
{
|
|
var ids = Funs.DB.HSSE_ConstructionRisk.Where(x => x.ProjectId == this.CurrUser.LoginProjectId).Select(x => x.UnitId).Distinct().ToList();
|
|
units = (from x in Funs.DB.Base_Unit
|
|
where ids.Contains(x.UnitId)
|
|
select x).OrderBy(x => x.UnitCode).ToList();
|
|
}
|
|
else
|
|
{
|
|
units = (from x in Funs.DB.Base_Unit
|
|
where x.UnitId == this.CurrUser.UnitId
|
|
select x).ToList();
|
|
}
|
|
}
|
|
}
|
|
else if (user.UnitId == Const.UnitId_TCC || user.UserId == Const.hfnbdId)
|
|
{
|
|
var ids = Funs.DB.HSSE_ConstructionRisk.Where(x => x.ProjectId == this.CurrUser.LoginProjectId).Select(x => x.UnitId).Distinct().ToList();
|
|
units = (from x in Funs.DB.Base_Unit
|
|
where ids.Contains(x.UnitId)
|
|
select x).OrderBy(x => x.UnitCode).ToList();
|
|
}
|
|
|
|
|
|
if (units != null && units.Count > 0)
|
|
{
|
|
foreach (var unit in units)
|
|
{
|
|
|
|
TreeNode rootNode = new TreeNode();
|
|
rootNode.Text = unit.UnitName;
|
|
rootNode.NodeID = unit.UnitId;
|
|
rootNode.ToolTip = "单位";
|
|
rootNode.Expanded = false;
|
|
this.tvControlItem.Nodes.Add(rootNode);
|
|
this.BindNodes(rootNode);
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 关闭弹出窗口及刷新页面
|
|
/// <summary>
|
|
/// 关闭弹出窗口
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
this.InitTreeMenu();
|
|
this.BindGrid();
|
|
}
|
|
protected void Window2_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
if (!string.IsNullOrEmpty(hdState.Text))
|
|
{
|
|
string[] strs = hdState.Text.Split('|');
|
|
if (strs[0] == "A")
|
|
{
|
|
var ids = Grid1.SelectedRowID.Split('|');
|
|
if (ids.Length > 1)
|
|
{
|
|
hdState.Text = "";
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../Check/RectifyNoticesAdd.aspx?ControlId={0}", strs[1], "编辑 - ")));
|
|
}
|
|
|
|
}
|
|
else if (strs[0] == "B")
|
|
{
|
|
var ids = Grid1.SelectedRowID.Split('|');
|
|
if (ids.Length > 1)
|
|
{
|
|
hdState.Text = "";
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("../HiddenInspection/HiddenRectificationAdd.aspx?ControlId={0}", strs[1], "编辑 - ")));
|
|
}
|
|
}
|
|
}
|
|
this.InitTreeMenu();
|
|
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>
|
|
|
|
|
|
/// <summary>
|
|
/// 右键删除明细
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
var ids = rowID.Split('|');
|
|
if (ids.Length >= 1)
|
|
{
|
|
var list = Funs.DB.HSSE_ConstructionRiskControl.Where(x => x.ConstructionRiskId == ids[0]).ToList();
|
|
Funs.DB.HSSE_ConstructionRiskControl.DeleteAllOnSubmit(list);
|
|
var approves = Funs.DB.HSSE_ConstructionRiskApprove.Where(x => x.ConstructionRiskId == ids[0]).ToList();
|
|
Funs.DB.HSSE_ConstructionRiskApprove.DeleteAllOnSubmit(approves);
|
|
var constructionRisk = Funs.DB.HSSE_ConstructionRisk.Where(x => x.ConstructionRiskId == ids[0]).FirstOrDefault();
|
|
Funs.DB.HSSE_ConstructionRisk.DeleteOnSubmit(constructionRisk);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
}
|
|
ShowNotify("删除成功!", MessageBoxIcon.Success);
|
|
this.InitTreeMenu();
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 数据绑定
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
if (this.tvControlItem.SelectedNode != null && this.tvControlItem.SelectedNode.NodeID.Contains("|"))
|
|
{
|
|
var ids = this.tvControlItem.SelectedNode.NodeID.Split('|');
|
|
string strSql = @"select c.UnitWorkName, '' Id,*
|
|
,b.CheckResult"
|
|
+ @" from [dbo].[HSSE_ConstructionRisk] a left join [dbo].[HSSE_ConstructionRiskControl] b
|
|
on a.ConstructionRiskId =b.ConstructionRiskId left join WBS_UnitWork c on a.WorkAreaId = c.UnitWorkId
|
|
where a.UnitId=@UnitId and a.DateWeek=@DateWeek order by a.[ConstructionContent],b.[ShowIndex]";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
listStr.Add(new SqlParameter("@UnitId", ids[0]));
|
|
listStr.Add(new SqlParameter("@DateWeek", ids[1]));
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
foreach (DataRow row in tb.Rows)
|
|
{
|
|
row["Id"] = row["ConstructionRiskId"] + "|" + row["ControlId"];
|
|
}
|
|
|
|
Grid1.DataSource = tb;
|
|
Grid1.DataBind();
|
|
}
|
|
else
|
|
{
|
|
Grid1.DataSource = null;
|
|
Grid1.DataBind();
|
|
}
|
|
}
|
|
#region 绑定树节点
|
|
/// <summary>
|
|
/// 绑定树节点
|
|
/// </summary>
|
|
/// <param name="node"></param>
|
|
private void BindNodes(TreeNode node)
|
|
{
|
|
|
|
var DateWeek = (from x in Funs.DB.HSSE_ConstructionRisk
|
|
where x.ProjectId == this.CurrUser.LoginProjectId
|
|
&& x.UnitId == node.NodeID
|
|
select x.DateWeek).Distinct().ToList().OrderByDescending(x => x);
|
|
foreach (var d in DateWeek)
|
|
{
|
|
TreeNode newNode = new TreeNode();
|
|
newNode.Text = d; //string.Format("{0:yyyy-MM-dd}", d.AssessmentDate);
|
|
newNode.NodeID = node.NodeID + "|" + d;
|
|
newNode.EnableClickEvent = true;
|
|
newNode.ToolTip = "标签";
|
|
node.Nodes.Add(newNode);
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 获取按钮权限
|
|
private void GetButtonPower()
|
|
{
|
|
if (Request.Params["value"] == "0")
|
|
{
|
|
return;
|
|
}
|
|
|
|
|
|
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ConstructionRiskMenuId);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnAdd))
|
|
{
|
|
//this.btnImport.Hidden = false;
|
|
this.btnNew.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnDelete))
|
|
{
|
|
this.btnMenuDelete.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnModify))
|
|
{
|
|
this.btnMenuModify.Hidden = false;
|
|
this.btnMenuCheck.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnAuditing))
|
|
{
|
|
this.btnMenuComplete.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("ConstructionRiskDataIn.aspx", "导入 - ")));
|
|
}
|
|
#endregion
|
|
#region 导入
|
|
/// <summary>
|
|
/// 导入按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnNew_Click(object sender, EventArgs e)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ConstructionRiskEdit.aspx", "添加 - ")));
|
|
}
|
|
#endregion
|
|
|
|
protected void btnAudit_Click(object sender, EventArgs e)
|
|
{
|
|
//if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
//{
|
|
// Alert.ShowInTop("请选择一条记录!", MessageBoxIcon.Warning);
|
|
// return;
|
|
//}
|
|
//foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
//{
|
|
// string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
// var ids = rowID.Split('|');
|
|
// if (ids.Length >= 1)
|
|
// {
|
|
// var r = Funs.DB.HSSE_ConstructionRisk.FirstOrDefault(x => x.ConstructionRiskId == ids[0]);
|
|
// if (r != null && r.States == "2")
|
|
// {
|
|
// r.States = "3";
|
|
// }
|
|
// }
|
|
//}
|
|
var r = Funs.DB.HSSE_ConstructionRisk.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.States == "2");
|
|
foreach (var item in r)
|
|
{
|
|
item.States = "3";
|
|
}
|
|
Funs.DB.SubmitChanges();
|
|
BindGrid();
|
|
}
|
|
|
|
#region 点击TreeView
|
|
/// <summary>
|
|
/// 点击TreeView
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void tvControlItem_NodeCommand111(object sender, TreeCommandEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
#endregion
|
|
protected void btnMenuCheck_Click(object sender, EventArgs e)
|
|
{
|
|
var ids = Grid1.SelectedRowID.Split('|');
|
|
if (ids.Length > 1)
|
|
{
|
|
hdState.Text = "";
|
|
string id = ids[0];
|
|
var ins = BLL.ConstructionRiskListService.GetConstructionRisk(id);
|
|
if (ins != null)
|
|
{
|
|
if (ins.States.Equals(Const.ConstructionRisk_Complete))
|
|
{
|
|
Alert.ShowInTop("施工已完成,无需巡检!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
else if (ins.States != BLL.Const.ConstructionRisk_Audit3)
|
|
{
|
|
Alert.ShowInTop("尚未实施,无法巡检!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
PageContext.RegisterStartupScript(Window2.GetSaveStateReference(hdState.ClientID)
|
|
+ Window2.GetShowReference(String.Format("ConstructionRiskControlCheck.aspx?ConstructionRiskId={0}", id, "编辑 - ")));
|
|
}
|
|
}
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
btnMenuModify_Click(null, null);
|
|
}
|
|
|
|
#region 编辑
|
|
/// <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;
|
|
}
|
|
var ids = Grid1.SelectedRowID.Split('|');
|
|
string id = ids[0];
|
|
var ins = BLL.ConstructionRiskListService.GetConstructionRisk(id);
|
|
|
|
if (ins != null)
|
|
{
|
|
if (ins.States.Equals(Const.ConstructionRisk_Audit3))
|
|
{
|
|
Alert.ShowInTop("实施中,无法编辑,请右键查看!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if (ins.States.Equals(Const.ConstructionRisk_Complete))
|
|
{
|
|
Alert.ShowInTop("施工已完成,无法编辑,请右键查看!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
Model.HSSE_ConstructionRiskApprove approve = BLL.ConstructionRiskApproveService.GetConstructionRiskApproveByConstructionRiskId(id);
|
|
if (approve != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(approve.ApproveMan))
|
|
{
|
|
if (this.CurrUser.UserId == approve.ApproveMan || CurrUser.UserId == Const.sysglyId)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ConstructionRiskEdit.aspx?ConstructionRiskId={0}", id, "编辑 - ")));
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您不是当前办理人,无法编辑,请右键查看!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您不是当前办理人,无法编辑,请右键查看!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 完成
|
|
/// <summary>
|
|
/// 完成按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuComplete_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
var ids = Grid1.SelectedRowID.Split('|');
|
|
string id = ids[0];
|
|
var ins = BLL.ConstructionRiskListService.GetConstructionRisk(id);
|
|
if (ins != null)
|
|
{
|
|
if (ins.States == Const.ConstructionRisk_Audit3)
|
|
{
|
|
ins.States = Const.ConstructionRisk_Complete;
|
|
BLL.ConstructionRiskListService.UpdateConstructionRisk(ins);
|
|
BindGrid();
|
|
Alert.ShowInTop("操作成功!", MessageBoxIcon.Success);
|
|
return;
|
|
}
|
|
else if (ins.States == Const.ConstructionRisk_Complete)
|
|
{
|
|
Alert.ShowInTop("该记录已完成!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("该记录尚未实施,无法操作完成!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void btnMenuView_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
var ids = Grid1.SelectedRowID.Split('|');
|
|
string id = ids[0];
|
|
var ins = BLL.ConstructionRiskListService.GetConstructionRisk(id);
|
|
|
|
if (ins != null)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ConstructionRiskView.aspx?ConstructionRiskId={0}", id, "查看 - ")));
|
|
}
|
|
}
|
|
|
|
//<summary>
|
|
//获取办理人姓名
|
|
//</summary>
|
|
//<param name="state"></param>
|
|
//<returns></returns>
|
|
protected string ConvertMan(object Id)
|
|
{
|
|
if (Id != null)
|
|
{
|
|
var ids = Id.ToString().Split('|');
|
|
Model.HSSE_ConstructionRiskApprove a = BLL.ConstructionRiskApproveService.GetConstructionRiskApproveByConstructionRiskId(ids[0]);
|
|
if (a != null)
|
|
{
|
|
if (a.ApproveMan != null)
|
|
{
|
|
return BLL.UserService.GetUserNameByUserId(a.ApproveMan);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
|
|
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
|
{
|
|
var ids = e.RowID.Split('|');
|
|
if (e.CommandName.Equals("CheckSee"))
|
|
{
|
|
PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("ConstructionRiskCheckSee.aspx?ConstructionRiskId={0}", ids[0])));
|
|
}
|
|
}
|
|
}
|
|
}
|