升级
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using BLL;
|
||||
using Aspose.Words.Lists;
|
||||
using BLL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@@ -43,7 +44,8 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
/// <summary>
|
||||
/// 定义集合
|
||||
/// </summary>
|
||||
private static List<string> list = new List<string>();
|
||||
private static HashSet<string> list = new HashSet<string>();
|
||||
private static HashSet<string> listNoSelected = new HashSet<string>();
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -58,13 +60,14 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
if (!IsPostBack)
|
||||
{
|
||||
Funs.DropDownPageSize(this.ddlPageSize);
|
||||
list = new List<string>();
|
||||
WorkStageService.InitWorkPostDropDownList(this.drpWorkStages, true);
|
||||
list = new HashSet<string>();
|
||||
listNoSelected= new HashSet<string>();
|
||||
WorkStageService.InitWorkPostDropDownList(this.drpWorkStages, false);
|
||||
this.HazardListId = Request.Params["HazardListId"];
|
||||
this.WorkStageIds = Request.Params["WorkStageIds"];
|
||||
if (!string.IsNullOrEmpty(this.WorkStageIds))
|
||||
{
|
||||
this.drpWorkStages.SelectedValueArray = this.WorkStageIds.Split(',');
|
||||
this.drpWorkStages.SelectedValueArray = this.WorkStageIds.Split(',');
|
||||
}
|
||||
hazardSelectedItems = BLL.Hazard_HazardSelectedItemService.GetHazardSelectedItemsByHazardListId(this.HazardListId);
|
||||
foreach (var item in hazardSelectedItems)
|
||||
@@ -136,6 +139,7 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
{
|
||||
Text = "危险源清单",
|
||||
NodeID = "0",
|
||||
EnableCheckEvent = true,
|
||||
Expanded = true
|
||||
};
|
||||
this.trHazardListType.Nodes.Add(rootNode);
|
||||
@@ -147,6 +151,7 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
{
|
||||
Text = works.FirstOrDefault(x => x.WorkStageId == item).WorkStageName,
|
||||
NodeID = item,
|
||||
EnableCheckEvent = true,
|
||||
CommandArgument = item
|
||||
};
|
||||
rootNode.Nodes.Add(newNode);
|
||||
@@ -155,7 +160,7 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
}
|
||||
|
||||
private void BoundTree(TreeNode node, string supHazardListTypeId)
|
||||
{
|
||||
{
|
||||
var dt = GetNewHazardListType(node, supHazardListTypeId);
|
||||
if (dt.Count() > 0)
|
||||
{
|
||||
@@ -168,6 +173,7 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
ToolTip = dr.HazardListTypeName,
|
||||
NodeID = node.NodeID + "#" + dr.HazardListTypeId,
|
||||
CommandArgument = node.CommandArgument,
|
||||
EnableCheckEvent = true,
|
||||
EnableClickEvent = true
|
||||
};
|
||||
node.Nodes.Add(tn);
|
||||
@@ -249,46 +255,84 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
/// </summary>
|
||||
private void BindGrid()
|
||||
{
|
||||
string nodeId = this.trHazardListType.SelectedNode.NodeID;
|
||||
if (!string.IsNullOrEmpty(nodeId) && nodeId.Contains("#"))
|
||||
string[] nodeIds = this.trHazardListType.GetCheckedNodeIDs();
|
||||
Dictionary<string, List<string>> ids = new Dictionary<string, List<string>>();
|
||||
foreach (var nodeId in nodeIds)
|
||||
{
|
||||
nodeId = nodeId.Substring(nodeId.LastIndexOf('#') + 1);
|
||||
}
|
||||
string strSql = @"SELECT H.HazardId,T.HazardListTypeId,T.HazardListTypeCode,T.HazardListTypeName,H.HazardCode,H.HazardItems,H.DefectsType,"
|
||||
+ @" H.MayLeadAccidents,H.HelperMethod,H.HazardJudge_L,H.HazardJudge_E,H.HazardJudge_C,H.HazardJudge_D,RiskLevel.RiskLevelName AS HazardLevel,"
|
||||
+ @" H.ControlMeasures,H.CompileMan,H.CompileDate,H.AuditMan,H.AuditDate,H.IsPass,U.UserName AS CompileManName,UR.UserName AS AuditManName"
|
||||
+ @" FROM Technique_HazardList AS H"
|
||||
+ @" LEFT JOIN Technique_HazardListType AS T ON T.HazardListTypeId = H.HazardListTypeId"
|
||||
+ @" LEFT JOIN Sys_User AS U ON U.UserId = H.CompileMan"
|
||||
+ @" LEFT JOIN Sys_User AS UR ON UR.UserId = H.AuditMan"
|
||||
+ @" LEFT JOIN Base_RiskLevel AS RiskLevel ON RiskLevel.RiskLevelId = H.HazardLevel "
|
||||
+ @" WHERE T.HazardListTypeId = @HazardListTypeId ";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>
|
||||
{
|
||||
new SqlParameter("@HazardListTypeId", nodeId),
|
||||
};
|
||||
|
||||
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();
|
||||
if (list.Count() > 0)
|
||||
{
|
||||
for (int i = 0; i < Grid1.Rows.Count; i++)
|
||||
if (!string.IsNullOrEmpty(nodeId) && nodeId.Contains("#"))
|
||||
{
|
||||
string id = Grid1.DataKeys[i][0].ToString();
|
||||
if (list.Contains(id))
|
||||
string wid = nodeId.Substring(0, nodeId.IndexOf('#'));
|
||||
|
||||
string nid = nodeId.Substring(nodeId.LastIndexOf('#') + 1);
|
||||
if (ids.ContainsKey(wid))
|
||||
{
|
||||
//CheckBoxField checkField = (CheckBoxField)Grid1.FindColumn("ckbIsSelected");
|
||||
//checkField.SetCheckedState(i, true);
|
||||
Grid1.Rows[i].Values[0] = true;
|
||||
ids[wid].Add(nid);
|
||||
}
|
||||
else
|
||||
{
|
||||
ids.Add(wid, new List<string>());
|
||||
ids[wid].Add(nid);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ids.Count > 0)
|
||||
{
|
||||
int ii = 0;
|
||||
string strSql = "";
|
||||
|
||||
foreach (string key in ids.Keys)
|
||||
{
|
||||
var idStr = string.Join("','", ids[key].ToArray());
|
||||
strSql += @"SELECT '"+ key + "|'+ H.HazardId id, '" + key + @"' wid, H.HazardId,T.HazardListTypeId,T.HazardListTypeCode,T.HazardListTypeName,H.HazardCode,H.HazardItems,H.DefectsType,"
|
||||
+ @" H.MayLeadAccidents,H.HelperMethod,H.HazardJudge_L,H.HazardJudge_E,H.HazardJudge_C,H.HazardJudge_D,RiskLevel.RiskLevelName AS HazardLevel,"
|
||||
+ @" H.ControlMeasures,H.CompileMan,H.CompileDate,H.AuditMan,H.AuditDate,H.IsPass,U.UserName AS CompileManName,UR.UserName AS AuditManName"
|
||||
+ @" FROM Technique_HazardList AS H"
|
||||
+ @" LEFT JOIN Technique_HazardListType AS T ON T.HazardListTypeId = H.HazardListTypeId"
|
||||
+ @" LEFT JOIN Sys_User AS U ON U.UserId = H.CompileMan"
|
||||
+ @" LEFT JOIN Sys_User AS UR ON UR.UserId = H.AuditMan"
|
||||
+ @" LEFT JOIN Base_RiskLevel AS RiskLevel ON RiskLevel.RiskLevel= H.HazardLevel "
|
||||
;
|
||||
strSql += @" WHERE T.HazardListTypeId in ('" + idStr + "') ";
|
||||
if (ii != (ids.Count - 1))
|
||||
{
|
||||
strSql += " union all ";
|
||||
}
|
||||
ii++;
|
||||
}
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, null);
|
||||
Grid1.RecordCount = tb.Rows.Count;
|
||||
list.Clear();
|
||||
foreach (DataRow row in tb.Rows)
|
||||
{
|
||||
if (!listNoSelected.Contains(row["id"].ToString()))
|
||||
{
|
||||
list.Add(row["id"].ToString());
|
||||
}
|
||||
|
||||
}
|
||||
var table = this.GetPagedDataTable(Grid1, tb);
|
||||
Grid1.DataSource = table;
|
||||
Grid1.DataBind();
|
||||
if (list.Count() > 0)
|
||||
{
|
||||
for (int i = 0; i < Grid1.Rows.Count; i++)
|
||||
{
|
||||
string id = Grid1.DataKeys[i][0].ToString();
|
||||
if (list.Contains(id))
|
||||
{
|
||||
CheckBoxField checkField = (CheckBoxField)Grid1.FindColumn("ckbIsSelected");
|
||||
checkField.SetCheckedState(i, true);
|
||||
///Grid1.Rows[i].Values[0] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Grid1.RecordCount = 0;
|
||||
Grid1.DataSource = null;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -376,7 +420,7 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
protected void Grid1_RowCommand(object sender, GridCommandEventArgs e)
|
||||
{
|
||||
GetHazardSelectedItem();
|
||||
string rowID = Grid1.DataKeys[e.RowIndex][0].ToString() + "," + this.trHazardListType.SelectedNode.CommandArgument;
|
||||
string rowID = Grid1.DataKeys[e.RowIndex][0].ToString();
|
||||
if (e.CommandName == "IsSelected")
|
||||
{
|
||||
CheckBoxField checkField = (CheckBoxField)Grid1.FindColumn("ckbIsSelected");
|
||||
@@ -386,6 +430,11 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
{
|
||||
list.Add(rowID);
|
||||
}
|
||||
if (listNoSelected.Contains(rowID))
|
||||
{
|
||||
listNoSelected.Remove(rowID);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -393,6 +442,7 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
{
|
||||
list.Remove(rowID);
|
||||
}
|
||||
listNoSelected.Add(rowID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -465,7 +515,7 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||||
{
|
||||
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
||||
var getD= BLL.HazardListService.GetHazardListById(rowID);
|
||||
var getD = BLL.HazardListService.GetHazardListById(rowID);
|
||||
if (getD != null)
|
||||
{
|
||||
if (BLL.Hazard_HazardSelectedItemService.GetHazardSelectedItemByHazardId(rowID) != null)
|
||||
@@ -475,7 +525,7 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
}
|
||||
BLL.LogService.AddSys_Log(this.CurrUser, getD.HazardCode, getD.HazardId, BLL.Const.HazardListMenuId, BLL.Const.BtnDelete);
|
||||
BLL.HazardListService.DeleteHazardListById(rowID);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
BindGrid();
|
||||
@@ -510,14 +560,14 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
return;
|
||||
}
|
||||
string ids = string.Empty;
|
||||
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
ids += item + "|";
|
||||
ids += item + ",";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(ids))
|
||||
{
|
||||
ids = ids.Substring(0, ids.LastIndexOf("|"));
|
||||
ids = ids.Substring(0, ids.LastIndexOf(","));
|
||||
Session["workStages"] = ids;
|
||||
}
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
@@ -574,5 +624,27 @@ namespace FineUIPro.Web.HSSE.Hazard
|
||||
InitTreeMenu();
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected void trHazardListType_NodeCheck(object sender, TreeCheckEventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public string BindWorkStages(object wid)
|
||||
{
|
||||
string res = "";
|
||||
|
||||
if (wid != null)
|
||||
{
|
||||
var w = Funs.DB.Base_WorkStage.FirstOrDefault(x => x.WorkStageId == wid.ToString());
|
||||
if (w != null)
|
||||
{
|
||||
res = w.WorkStageName;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user