xinjiang/SGGL/FineUIPro.Web/JDGL/WBS/WBSSetAudit.aspx.cs

3356 lines
221 KiB
C#

using BLL;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.JDGL.WBS
{
public partial class WBSSetAudit : PageBase
{
#region
/// <summary>
/// 页面加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetButtonPower();
InitTreeMenu();
}
}
/// <summary>
/// 树加载
/// </summary>
private void InitTreeMenu()
{
this.trWBS.Nodes.Clear();
this.trWBS.ShowBorder = false;
this.trWBS.ShowHeader = false;
this.trWBS.EnableIcons = true;
this.trWBS.AutoScroll = true;
this.trWBS.EnableSingleClickExpand = true;
var projects = from x in Funs.DB.Base_Project
join z in Funs.DB.Project_ProjectUser on x.ProjectId equals z.ProjectId
join y in Funs.DB.Sys_User on z.UserId equals y.UserId
where y.UserId == this.CurrUser.UserId
select x;
if (this.CurrUser.UserId == BLL.Const.sysglyId || this.CurrUser.UserId == BLL.Const.hfnbdId)
{
projects = from x in Funs.DB.Base_Project orderby x.ProjectCode select x;
}
foreach (var project in projects)
{
TreeNode rootNode = new TreeNode();
rootNode.Text = project.ProjectName;
rootNode.NodeID = project.ProjectId;
rootNode.CommandName = "project";
rootNode.EnableExpandEvent = true;
this.trWBS.Nodes.Add(rootNode);
if (BLL.Project_InstallationService.IsExitProjectInstallation(project.ProjectId))
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
rootNode.Nodes.Add(emptyNode);
}
}
}
#endregion
#region
/// <summary>
/// 树节点展开
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void trWBS_NodeExpand(object sender, TreeNodeEventArgs e)
{
e.Node.Nodes.Clear();
bool needAddTempNode = false; //是否需要增加空节点
if (e.Node.CommandName == "project") //展开项目节点
{
var installations = from x in Funs.DB.Project_Installation
where x.ProjectId == e.Node.NodeID && x.SuperInstallationId == "0"
orderby x.InstallationCode
select x;
foreach (var installation in installations)
{
TreeNode newNode = new TreeNode();
newNode.Text = installation.InstallationName;
newNode.NodeID = installation.InstallationId;
newNode.CommandName = "installation";
newNode.EnableExpandEvent = true;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
else if (e.Node.CommandName == "installation") //展开装置/单元节点
{
var installations = from x in Funs.DB.Project_Installation
where x.SuperInstallationId == e.Node.NodeID
orderby x.InstallationCode
select x;
if (installations.Count() > 0)
{
foreach (var installation in installations)
{
TreeNode newNode = new TreeNode();
newNode.Text = installation.InstallationName;
newNode.NodeID = installation.InstallationId;
newNode.CommandName = "installation";
newNode.EnableExpandEvent = true;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
else
{
var cnProfessions = from x in Funs.DB.WBS_CnProfession where x.InstallationId == e.Node.NodeID orderby x.OldId select x;
if (cnProfessions.Count() > 0) //普通装置主项
{
foreach (var cnProfession in cnProfessions)
{
TreeNode newNode = new TreeNode();
newNode.Text = cnProfession.CnProfessionName;
newNode.NodeID = cnProfession.CnProfessionId;
newNode.CommandName = "cnProfession";
newNode.EnableExpandEvent = true;
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
else //总图
{
var unitProjects = from x in Funs.DB.Wbs_UnitProject where x.InstallationId == e.Node.NodeID && x.SuperUnitProjectId == null orderby x.SortIndex, x.UnitProjectCode select x;
foreach (var unitProject in unitProjects)
{
TreeNode newNode = new TreeNode();
newNode.Text = unitProject.UnitProjectName;
newNode.NodeID = unitProject.UnitProjectId;
newNode.CommandName = "unitProject";
newNode.EnableExpandEvent = true;
newNode.EnableCheckBox = true;
newNode.EnableCheckEvent = true;
if (unitProject.IsSelected == true && unitProject.IsApprove == null)
{
unitProject.IsApprove = true;
BLL.UnitProjectService.UpdateUnitProject(unitProject);
}
if (unitProject.IsApprove == true)
{
newNode.Checked = true;
}
else
{
newNode.Checked = false;
}
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
}
}
else if (e.Node.CommandName == "cnProfession") //展开专业节点
{
var unitProjects = from x in Funs.DB.Wbs_UnitProject where x.CnProfessionId == e.Node.NodeID && x.SuperUnitProjectId == null orderby x.SortIndex, x.UnitProjectCode select x;
foreach (var unitProject in unitProjects)
{
TreeNode newNode = new TreeNode();
newNode.Text = unitProject.UnitProjectName;
newNode.NodeID = unitProject.UnitProjectId;
newNode.CommandName = "unitProject";
newNode.EnableExpandEvent = true;
newNode.EnableCheckBox = true;
newNode.EnableCheckEvent = true;
if (unitProject.IsSelected == true && unitProject.IsApprove == null)
{
unitProject.IsApprove = true;
BLL.UnitProjectService.UpdateUnitProject(unitProject);
}
if (unitProject.IsApprove == true)
{
newNode.Checked = true;
}
else
{
newNode.Checked = false;
}
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
else if (e.Node.CommandName == "unitProject") //展开单位工程节点
{
var childUnitProjects = from x in Funs.DB.Wbs_UnitProject where x.SuperUnitProjectId == e.Node.NodeID orderby x.SortIndex, x.UnitProjectCode select x;
if (childUnitProjects.Count() > 0) //存在子单位工程
{
foreach (var childUnitProject in childUnitProjects)
{
TreeNode newNode = new TreeNode();
newNode.Text = childUnitProject.UnitProjectName;
newNode.NodeID = childUnitProject.UnitProjectId;
newNode.CommandName = "childUnitProject";
newNode.EnableExpandEvent = true;
newNode.EnableCheckBox = true;
newNode.EnableCheckEvent = true;
if (childUnitProject.IsSelected == true && childUnitProject.IsApprove == null)
{
childUnitProject.IsApprove = true;
BLL.UnitProjectService.UpdateUnitProject(childUnitProject);
}
if (childUnitProject.IsApprove == true)
{
newNode.Checked = true;
}
else
{
newNode.Checked = false;
}
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
needAddTempNode = false;
var wbsSets = from x in Funs.DB.Wbs_WbsSet where x.Flag == 1 && x.UnitProjectId == childUnitProject.UnitProjectId && x.NoShow == null orderby x.SortIndex, x.WbsSetCode select x;
foreach (var wbsSet in wbsSets)
{
var childWbsSets = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == wbsSet.WbsSetId select x;
if (childWbsSets.Count() > 0)
{
needAddTempNode = true;
break;
}
}
if (needAddTempNode)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
}
else //不存在子单位工程,加载分部工程
{
var wbsSet1s = from x in Funs.DB.Wbs_WbsSet where x.Flag == 1 && x.UnitProjectId == e.Node.NodeID && x.NoShow == null orderby x.SortIndex, x.WbsSetCode select x;
if (wbsSet1s.Count() > 0)
{
foreach (var wbsSet1 in wbsSet1s)
{
TreeNode newNode = new TreeNode();
newNode.Text = wbsSet1.WbsSetName;
newNode.NodeID = wbsSet1.WbsSetId;
newNode.CommandName = "wbsSet";
newNode.EnableExpandEvent = true;
newNode.EnableCheckBox = true;
newNode.EnableCheckEvent = true;
if (wbsSet1.IsSelected == true && wbsSet1.IsApprove == null)
{
wbsSet1.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet1);
}
if (wbsSet1.IsApprove == true)
{
newNode.Checked = true;
}
else
{
newNode.Checked = false;
}
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
needAddTempNode = false;
var wbsSets = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet1.WbsSetId);
foreach (var wbsSet in wbsSets)
{
var childWbsSets = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == wbsSet.WbsSetId && x.NoShow == null select x;
if (childWbsSets.Count() > 0)
{
needAddTempNode = true;
break;
}
}
if (needAddTempNode)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
}
else //单位工程下直接是分项内容,如质量行为
{
var wbsSet3s = from x in Funs.DB.Wbs_WbsSet where x.Flag == 3 && x.UnitProjectId == e.Node.NodeID && x.NoShow == null orderby x.SortIndex, x.WbsSetCode select x;
if (wbsSet3s.Count() > 0)
{
foreach (var wbsSet3 in wbsSet3s)
{
TreeNode newNode = new TreeNode();
newNode.Text = wbsSet3.WbsSetName;
newNode.NodeID = wbsSet3.WbsSetId;
newNode.CommandName = "wbsSet";
newNode.EnableExpandEvent = true;
newNode.EnableCheckBox = true;
newNode.EnableCheckEvent = true;
if (wbsSet3.IsSelected == true && wbsSet3.IsApprove == null)
{
wbsSet3.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet3);
}
if (wbsSet3.IsApprove == true)
{
newNode.Checked = true;
}
else
{
newNode.Checked = false;
}
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
needAddTempNode = false;
var wbsSets = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet3.WbsSetId);
foreach (var wbsSet in wbsSets)
{
var childWbsSets = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == wbsSet.WbsSetId && x.NoShow == null select x;
if (childWbsSets.Count() > 0)
{
needAddTempNode = true;
break;
}
}
if (needAddTempNode)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
}
else
{
var wbsSet4s = from x in Funs.DB.Wbs_WbsSet where x.Flag == 4 && x.UnitProjectId == e.Node.NodeID && x.NoShow == null orderby x.SortIndex, x.WbsSetCode select x;
if (wbsSet4s.Count() > 0)
{
foreach (var wbsSet4 in wbsSet4s)
{
TreeNode newNode = new TreeNode();
newNode.Text = wbsSet4.WbsSetName;
newNode.NodeID = wbsSet4.WbsSetId;
newNode.CommandName = "wbsSet";
newNode.EnableExpandEvent = true;
newNode.EnableCheckBox = true;
newNode.EnableCheckEvent = true;
if (wbsSet4.IsSelected == true && wbsSet4.IsApprove == null)
{
wbsSet4.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet4);
}
if (wbsSet4.IsApprove == true)
{
newNode.Checked = true;
}
else
{
newNode.Checked = false;
}
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
}
}
}
}
}
}
else if (e.Node.CommandName == "childUnitProject") //展开子单位工程节点
{
var wbsSet1s = from x in Funs.DB.Wbs_WbsSet where x.Flag == 1 && x.UnitProjectId == e.Node.NodeID && x.NoShow == null orderby x.SortIndex, x.WbsSetCode select x;
foreach (var wbsSet1 in wbsSet1s)
{
TreeNode newNode = new TreeNode();
newNode.Text = wbsSet1.WbsSetName;
newNode.NodeID = wbsSet1.WbsSetId;
newNode.CommandName = "wbsSet";
newNode.EnableExpandEvent = true;
newNode.EnableCheckBox = true;
newNode.EnableCheckEvent = true;
if (wbsSet1.IsSelected == true && wbsSet1.IsApprove == null)
{
wbsSet1.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet1);
}
if (wbsSet1.IsApprove == true)
{
newNode.Checked = true;
}
else
{
newNode.Checked = false;
}
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
needAddTempNode = false;
var wbsSets = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet1.WbsSetId);
foreach (var wbsSet in wbsSets)
{
var childWbsSets = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == wbsSet.WbsSetId && x.NoShow == null select x;
if (childWbsSets.Count() > 0)
{
needAddTempNode = true;
break;
}
}
if (needAddTempNode)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
}
else if (e.Node.CommandName == "wbsSet") //展开分部/子分部/分项/子分项工程节点
{
var childWbsSets = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(e.Node.NodeID);
foreach (var wbsSet in childWbsSets)
{
TreeNode newNode = new TreeNode();
newNode.Text = wbsSet.WbsSetName;
newNode.NodeID = wbsSet.WbsSetId;
newNode.CommandName = "wbsSet";
newNode.EnableExpandEvent = true;
newNode.EnableCheckBox = true;
newNode.EnableCheckEvent = true;
if (wbsSet.IsSelected == true && wbsSet.IsApprove == null)
{
wbsSet.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet);
}
if (wbsSet.IsApprove == true)
{
newNode.Checked = true;
}
else
{
newNode.Checked = false;
}
newNode.EnableClickEvent = true;
e.Node.Nodes.Add(newNode);
needAddTempNode = false;
var wbsSets = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet.WbsSetId);
foreach (var wbsSetc in wbsSets)
{
var childWbsSets1 = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == wbsSetc.WbsSetId && x.NoShow == null select x;
if (childWbsSets1.Count() > 0)
{
needAddTempNode = true;
break;
}
}
if (needAddTempNode)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNode.Nodes.Add(emptyNode);
}
}
}
}
#endregion
#region
/// <summary>
/// 树节点复选框勾选事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void trWBS_NodeCheck(object sender, FineUIPro.TreeCheckEventArgs e)
{
//if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.WBSSetAuditMenuId, BLL.Const.BtnSave))
//{
if (e.Checked)
{
CheckAllParentNodes(e.Node);
CheckAllChildNodes(e.Node);
this.UpdateSelect(e.Node, true);
}
else
{
if (auditText == string.Empty)
{
trWBS.UncheckAllNodes(e.Node.Nodes);
this.UpdateSelect(e.Node, false);
}
else
{
auditText = auditText.Substring(0, auditText.Length - 1);
e.Node.Checked = true;
ShowNotify("权重已有设置审核项:'" + auditText + "',不能取消设置!", MessageBoxIcon.Success);
}
}
BindGrid();
//}
//else
//{
// ShowNotify("您没有保存(勾选)这个权限,请与管理员联系!", MessageBoxIcon.Warning);
//}
}
private void CheckAllParentNodes(TreeNode node)
{
if (node.ParentNode != null)
{
node.ParentNode.Checked = true;
CheckAllParentNodes(node.ParentNode);
}
}
private void CheckAllChildNodes(TreeNode node)
{
trWBS.CheckAllNodes(node.Nodes);
foreach (TreeNode tn in node.Nodes)
{
if (tn.Nodes.Count() > 0)
{
CheckAllChildNodes(tn);
}
}
}
private string auditText = string.Empty;
/// <summary>
/// 反向选择时判断是否有设置权重的项
/// </summary>
/// <param name="node"></param>
/// <param name="isSelected"></param>
private void IsAuditUnSelect(TreeNode node)
{
if (node.CommandName == "unitProject" || node.CommandName == "childUnitProject")
{
Model.Wbs_UnitProject unitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(node.NodeID);
if (unitProject != null)
{
if (unitProject.IsWeightsApprove == true)
{
auditText = auditText + unitProject.UnitProjectName + ",";
}
if (!node.Leaf)
{
foreach (var childNode in node.Nodes)
{
this.IsAuditUnSelect(childNode);
}
}
}
}
else
{
Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(node.NodeID);
if (wbsSet != null)
{
if (wbsSet.IsWeightsApprove == true)
{
auditText = auditText + wbsSet.WbsSetName + ",";
}
if (!node.Leaf)
{
foreach (var childNode in node.Nodes)
{
this.IsAuditUnSelect(childNode);
}
}
}
}
}
/// <summary>
/// 循环更新选择状态
/// </summary>
/// <param name="node"></param>
/// <param name="isSelected"></param>
private void UpdateSelect(TreeNode node, bool isSelected)
{
if (node.CommandName == "unitProject" || node.CommandName == "childUnitProject")
{
Model.Wbs_UnitProject unitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(node.NodeID);
if (unitProject != null)
{
unitProject.IsSelected = isSelected;
unitProject.IsApprove = isSelected;
BLL.UnitProjectService.UpdateUnitProject(unitProject);
if (!node.Leaf)
{
foreach (var childNode in node.Nodes)
{
this.UpdateSelect(childNode, isSelected);
}
}
else //末级节点更新其子项状态
{
var wbsSets = from x in Funs.DB.Wbs_WbsSet where x.UnitProjectId == node.NodeID select x;
foreach (var wbsSet in wbsSets)
{
wbsSet.IsSelected = isSelected;
wbsSet.IsApprove = isSelected;
BLL.WbsSetService.UpdateWbsSet(wbsSet);
}
}
UpdateParentSelect(node, isSelected);
}
}
else
{
Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(node.NodeID);
if (wbsSet != null)
{
wbsSet.IsSelected = isSelected;
wbsSet.IsApprove = isSelected;
BLL.WbsSetService.UpdateWbsSet(wbsSet);
if (!node.Leaf)
{
foreach (var childNode in node.Nodes)
{
this.UpdateSelect(childNode, isSelected);
}
}
else //末级节点更新其子项状态
{
var wbsSet1s = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == node.NodeID select x;
foreach (var wbsSet1 in wbsSet1s)
{
wbsSet1.IsSelected = isSelected;
wbsSet1.IsApprove = isSelected;
BLL.WbsSetService.UpdateWbsSet(wbsSet1);
}
}
UpdateParentSelect(node, isSelected);
}
}
}
/// <summary>
/// 循环更新父级选择状态
/// </summary>
/// <param name="node"></param>
/// <param name="isSelected"></param>
private void UpdateParentSelect(TreeNode node, bool isSelected)
{
if (node.CommandName == "childUnitProject")
{
Model.Wbs_UnitProject parentUnitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(node.ParentNode.NodeID);
if (parentUnitProject != null)
{
parentUnitProject.IsSelected = isSelected;
parentUnitProject.IsApprove = isSelected;
BLL.UnitProjectService.UpdateUnitProject(parentUnitProject);
}
}
else if (node.CommandName == "wbsSet")
{
if (node.ParentNode.CommandName == "wbsSet")
{
Model.Wbs_WbsSet parentWbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(node.ParentNode.NodeID);
if (parentWbsSet != null)
{
parentWbsSet.IsSelected = isSelected;
parentWbsSet.IsApprove = isSelected;
BLL.WbsSetService.UpdateWbsSet(parentWbsSet);
UpdateParentSelect(node.ParentNode, isSelected);
}
}
else if (node.ParentNode.CommandName == "childUnitProject")
{
Model.Wbs_UnitProject parentUnitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(node.ParentNode.NodeID);
if (parentUnitProject != null)
{
parentUnitProject.IsSelected = isSelected;
parentUnitProject.IsApprove = isSelected;
BLL.UnitProjectService.UpdateUnitProject(parentUnitProject);
UpdateParentSelect(node.ParentNode, isSelected);
}
}
else if (node.ParentNode.CommandName == "unitProject")
{
Model.Wbs_UnitProject parentUnitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(node.ParentNode.NodeID);
if (parentUnitProject != null)
{
parentUnitProject.IsSelected = isSelected;
parentUnitProject.IsApprove = isSelected;
BLL.UnitProjectService.UpdateUnitProject(parentUnitProject);
}
}
}
}
/// <summary>
/// 循环更新选择状态
/// </summary>
/// <param name="node"></param>
/// <param name="isSelected"></param>
private void UpdateSelect(TreeNode node)
{
if (node.CommandName == "unitProject" || node.CommandName == "childUnitProject")
{
Model.Wbs_UnitProject unitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(node.NodeID);
if (unitProject != null)
{
if (node.Checked)
{
unitProject.IsSelected = true;
unitProject.IsApprove = true;
}
else
{
unitProject.IsSelected = null;
unitProject.IsApprove = null;
}
BLL.UnitProjectService.UpdateUnitProject(unitProject);
if (!node.Leaf)
{
foreach (var childNode in node.Nodes)
{
this.UpdateSelect(childNode);
}
}
}
}
else
{
Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(node.NodeID);
if (wbsSet != null)
{
if (node.Checked)
{
wbsSet.IsSelected = true;
wbsSet.IsApprove = true;
}
else
{
wbsSet.IsSelected = null;
wbsSet.IsApprove = null;
}
BLL.WbsSetService.UpdateWbsSet(wbsSet);
if (!node.Leaf)
{
foreach (var childNode in node.Nodes)
{
this.UpdateSelect(childNode);
}
}
}
}
}
#endregion
#region Tree点击事件
/// <summary>
/// Tree点击事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void trWBS_NodeCommand(object sender, TreeCommandEventArgs e)
{
BindGrid();
}
#endregion
#region
/// <summary>
/// 保存方法
/// </summary>
private void SaveData()
{
bool result = this.trWBS.SelectedNode.Checked;
if (string.IsNullOrEmpty(this.Grid1.Rows[0].Values[2].ToString()))
{
Alert.ShowInTop("进度计划开始日期不能为空!", MessageBoxIcon.Warning);
return;
}
if (string.IsNullOrEmpty(this.Grid1.Rows[0].Values[3].ToString()))
{
Alert.ShowInTop("进度计划结束日期不能为空!", MessageBoxIcon.Warning);
return;
}
string rowId = this.Grid1.Rows[0].RowID;
string type = this.Grid1.Rows[0].Values[4].ToString();
if (type == "cnProfession")
{
Model.WBS_CnProfession cnProfession = BLL.CnProfessionService.GetCnProfessionByCnProfessionId(rowId);
if (cnProfession != null)
{
cnProfession.StartDate = Convert.ToDateTime(this.Grid1.Rows[0].Values[2].ToString());
cnProfession.EndDate = Convert.ToDateTime(this.Grid1.Rows[0].Values[3].ToString());
BLL.CnProfessionService.UpdateCnProfession(cnProfession);
}
}
else if (type == "unitProject")
{
Model.Wbs_UnitProject unitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(rowId);
if (unitProject != null)
{
unitProject.StartDate = Convert.ToDateTime(this.Grid1.Rows[0].Values[2].ToString());
unitProject.EndDate = Convert.ToDateTime(this.Grid1.Rows[0].Values[3].ToString());
BLL.UnitProjectService.UpdateUnitProject(unitProject);
Model.Project_Sys_Set sysSet = BLL.Project_SysSetService.GetSysSetBySetId("20", unitProject.ProjectId);
if (sysSet != null)
{
if (sysSet.SetValue == "1") //单位工程批量审核
{
List<Model.Wbs_UnitProject> childUnitProjects = BLL.UnitProjectService.GetUnitProjectsBySuperUnitProjectId(rowId);
if (childUnitProjects.Count > 0) //存在子单位工程
{
foreach (var childUnitProject in childUnitProjects)
{
if (result)
{
if (childUnitProject.IsSelected == true && childUnitProject.IsApprove == null)
{
childUnitProject.IsApprove = true;
BLL.UnitProjectService.UpdateUnitProject(childUnitProject);
List<Model.Wbs_WbsSet> wbsSets = (from x in Funs.DB.Wbs_WbsSet where x.UnitProjectId == childUnitProject.UnitProjectId select x).ToList();
foreach (var wbsSet in wbsSets)
{
if (wbsSet.IsSelected == true && wbsSet.IsApprove == null)
{
wbsSet.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet);
}
}
}
}
else
{
childUnitProject.IsApprove = false;
BLL.UnitProjectService.UpdateUnitProject(childUnitProject);
List<Model.Wbs_WbsSet> wbsSets = (from x in Funs.DB.Wbs_WbsSet where x.UnitProjectId == childUnitProject.UnitProjectId select x).ToList();
foreach (var wbsSet in wbsSets)
{
wbsSet.IsApprove = false;
BLL.WbsSetService.UpdateWbsSet(wbsSet);
}
}
}
}
else //不存在子单位工程
{
List<Model.Wbs_WbsSet> wbsSets = (from x in Funs.DB.Wbs_WbsSet where x.UnitProjectId == unitProject.UnitProjectId select x).ToList();
foreach (var wbsSet in wbsSets)
{
if (result)
{
if (wbsSet.IsSelected == true && wbsSet.IsApprove == null)
{
wbsSet.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet);
}
}
else
{
wbsSet.IsApprove = false;
BLL.WbsSetService.UpdateWbsSet(wbsSet);
}
}
}
}
}
}
}
else if (type == "childUnitProject")
{
Model.Wbs_UnitProject unitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(rowId);
if (unitProject != null)
{
unitProject.StartDate = Convert.ToDateTime(this.Grid1.Rows[0].Values[2].ToString());
unitProject.EndDate = Convert.ToDateTime(this.Grid1.Rows[0].Values[3].ToString());
BLL.UnitProjectService.UpdateUnitProject(unitProject);
Model.Project_Sys_Set sysSet = BLL.Project_SysSetService.GetSysSetBySetId("20", unitProject.ProjectId);
if (sysSet != null)
{
if (sysSet.SetValue == "1" || sysSet.SetValue == "2") //单位/子单位工程批量审核
{
List<Model.Wbs_WbsSet> wbsSets = (from x in Funs.DB.Wbs_WbsSet where x.UnitProjectId == unitProject.UnitProjectId select x).ToList();
foreach (var wbsSet in wbsSets)
{
if (result)
{
if (wbsSet.IsSelected == true && wbsSet.IsApprove == null)
{
wbsSet.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet);
}
}
else
{
wbsSet.IsApprove = false;
BLL.WbsSetService.UpdateWbsSet(wbsSet);
}
}
}
}
}
}
else if (type == "wbsSet")
{
Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(rowId);
if (wbsSet != null)
{
wbsSet.StartDate = Convert.ToDateTime(this.Grid1.Rows[0].Values[2].ToString());
wbsSet.EndDate = Convert.ToDateTime(this.Grid1.Rows[0].Values[3].ToString());
BLL.WbsSetService.UpdateWbsSet(wbsSet);
Model.Project_Sys_Set sysSet = BLL.Project_SysSetService.GetSysSetBySetId("20", wbsSet.ProjectId);
if (sysSet != null)
{
#region
if (wbsSet.Flag == 1) //分部节点
{
if (sysSet.SetValue == "1" || sysSet.SetValue == "2" || sysSet.SetValue == "3") //分部节点批量审批
{
var wbsSets1 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet.WbsSetId);
if (wbsSets1.Count > 0)
{
foreach (var wbsSet1 in wbsSets1)
{
if (result)
{
if (wbsSet1.IsSelected == true && wbsSet1.IsApprove == null)
{
wbsSet1.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet1);
}
}
else
{
wbsSet1.IsApprove = false;
BLL.WbsSetService.UpdateWbsSet(wbsSet1);
}
var wbsSets2 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet1.WbsSetId);
if (wbsSets2.Count > 0)
{
foreach (var wbsSet2 in wbsSets2)
{
if (result)
{
if (wbsSet2.IsSelected == true && wbsSet2.IsApprove == null)
{
wbsSet2.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet2);
}
}
else
{
wbsSet2.IsApprove = false;
BLL.WbsSetService.UpdateWbsSet(wbsSet2);
}
var wbsSets3 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet2.WbsSetId);
if (wbsSets3.Count > 0)
{
foreach (var wbsSet3 in wbsSets3)
{
if (result)
{
if (wbsSet3.IsSelected == true && wbsSet3.IsApprove == null)
{
wbsSet3.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet3);
}
}
else
{
wbsSet3.IsApprove = false;
BLL.WbsSetService.UpdateWbsSet(wbsSet3);
}
}
}
}
}
}
}
}
}
#endregion
#region
else if (wbsSet.Flag == 2) //子分部节点
{
if (sysSet.SetValue == "1" || sysSet.SetValue == "2" || sysSet.SetValue == "3" || sysSet.SetValue == "4") //子分部节点批量审批
{
var wbsSets1 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet.WbsSetId);
if (wbsSets1.Count > 0)
{
foreach (var wbsSet1 in wbsSets1)
{
if (result)
{
if (wbsSet1.IsSelected == true && wbsSet1.IsApprove == null)
{
wbsSet1.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet1);
}
}
else
{
wbsSet1.IsApprove = false;
BLL.WbsSetService.UpdateWbsSet(wbsSet1);
}
var wbsSets2 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet1.WbsSetId);
if (wbsSets2.Count > 0)
{
foreach (var wbsSet2 in wbsSets2)
{
if (result)
{
if (wbsSet2.IsSelected == true && wbsSet2.IsApprove == null)
{
wbsSet2.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet2);
}
}
else
{
wbsSet2.IsApprove = false;
BLL.WbsSetService.UpdateWbsSet(wbsSet2);
}
}
}
}
}
}
}
#endregion
#region
else if (wbsSet.Flag == 3) //分项节点
{
if (sysSet.SetValue == "1" || sysSet.SetValue == "2" || sysSet.SetValue == "3" || sysSet.SetValue == "4" || sysSet.SetValue == "5") //分项节点批量审批
{
var wbsSets1 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet.WbsSetId);
if (wbsSets1.Count > 0)
{
foreach (var wbsSet1 in wbsSets1)
{
if (result)
{
if (wbsSet1.IsSelected == true && wbsSet1.IsApprove == null)
{
wbsSet1.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet1);
}
}
else
{
wbsSet1.IsApprove = false;
BLL.WbsSetService.UpdateWbsSet(wbsSet1);
}
}
}
}
}
#endregion
}
}
}
//处理之前已存在的月份记录
List<Model.WbsDetail> details = BLL.WbsDetailService.GetTotalWbsDetailsByToWbs(this.trWBS.SelectedNodeID);
if (details.Count > 0)
{
DateTime startDate, endDate, startMonth, endMonth;
List<DateTime> months = new List<DateTime>();
startDate = Convert.ToDateTime(this.Grid1.Rows[0].Values[2].ToString());
endDate = Convert.ToDateTime(this.Grid1.Rows[0].Values[3].ToString());
startMonth = Convert.ToDateTime(startDate.Year + "-" + startDate.Month + "-01");
endMonth = Convert.ToDateTime(endDate.Year + "-" + endDate.Month + "-01");
do
{
months.Add(startMonth);
startMonth = startMonth.AddMonths(1);
} while (startMonth <= endMonth);
foreach (var detail in details)
{
if (!months.Contains(Convert.ToDateTime(detail.Months)))
{
BLL.WbsDetailService.DeleteWbsDetail(detail.WbsDetailId);
}
}
}
//BLL.Sys_LogService.AddLog(BLL.Const.System_1, this.CurrUser.LoginProjectId, this.CurrUser.UserId, "审核单位、分部、分项工程");
}
#endregion
#region
/// <summary>
/// 导出焊口信息
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOut_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("WBSOut.aspx", "导出 - ")));
}
#endregion
#region
/// <summary>
/// 导入按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnImport_Click(object sender, EventArgs e)
{
PageContext.RegisterStartupScript(Window3.GetShowReference(String.Format("WBSIn.aspx", "导入 - ")));
}
#endregion
#region
/// <summary>
/// 关闭窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
ShowNotify("修改成功!", MessageBoxIcon.Success);
getWBSSet();
}
#endregion
#region
/// <summary>
/// 拷贝关闭窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window2_Close(object sender, WindowCloseEventArgs e)
{
ShowNotify("拷贝成功!", MessageBoxIcon.Success);
getWBSSet();
}
#endregion
#region
/// <summary>
/// 右键增加事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuAdd_Click(object sender, EventArgs e)
{
if (this.trWBS.SelectedNode != null)
{
//if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.WBSSetAuditMenuId, BLL.Const.BtnAdd))
//{
if (this.trWBS.SelectedNode.CommandName != "project" && this.trWBS.SelectedNode.CommandName != "installation") //非项目、装置节点可以增加
{
string window = String.Format("WBSSetAuditEdit.aspx?Id={0}&Type={1}&oper=add", this.trWBS.SelectedNode.NodeID, this.trWBS.SelectedNode.CommandName, "编辑 - ");
PageContext.RegisterStartupScript(Window1.GetSaveStateReference(hdSelectId.ClientID) + Window1.GetShowReference(window));
}
else
{
if (this.trWBS.SelectedNode.Text == "总图")
{
string window = String.Format("WBSSetAuditEdit.aspx?Id={0}&Type={1}&oper=add", this.trWBS.SelectedNode.NodeID, this.trWBS.SelectedNode.CommandName, "编辑 - ");
PageContext.RegisterStartupScript(Window1.GetSaveStateReference(hdSelectId.ClientID) + Window1.GetShowReference(window));
}
else
{
ShowNotify("项目、装置节点无法修改!", MessageBoxIcon.Warning);
}
}
//}
//else
//{
// ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
//}
}
else
{
ShowNotify("请选择树节点!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 右键修改事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuEdit_Click(object sender, EventArgs e)
{
if (this.trWBS.SelectedNode != null)
{
//if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.WBSSetAuditMenuId, BLL.Const.BtnModify))
//{
if (this.trWBS.SelectedNode.CommandName != "project" && this.trWBS.SelectedNode.CommandName != "installation") //非项目、装置节点可以修改
{
this.hdSelectId.Text = this.trWBS.SelectedNode.NodeID;
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WBSSetAuditEdit.aspx?Id={0}&Type={1}&oper=modify", this.trWBS.SelectedNode.NodeID, this.trWBS.SelectedNode.CommandName, "编辑 - ")));
}
else
{
if (this.trWBS.SelectedNode.Text == "总图")
{
this.hdSelectId.Text = this.trWBS.SelectedNode.NodeID;
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("WBSSetAuditEdit.aspx?Id={0}&Type={1}&oper=modify", this.trWBS.SelectedNode.NodeID, this.trWBS.SelectedNode.CommandName, "编辑 - ")));
}
else
{
ShowNotify("项目、装置节点无法修改!", MessageBoxIcon.Warning);
}
}
//}
//else
//{
// ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
//}
}
else
{
ShowNotify("请选择树节点!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 拷贝
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuCopy_Click(object sender, EventArgs e)
{
if (this.trWBS.SelectedNode != null)
{
//if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.WBSSetAuditMenuId, BLL.Const.BtnAdd))
//{
if (this.trWBS.SelectedNode.CommandName != "project" && this.trWBS.SelectedNode.CommandName != "installation" && this.trWBS.SelectedNode.CommandName != "cnProfession" && this.trWBS.SelectedNode.CommandName != "unitProject") //非项目、装置、专业、单位工程节点可以拷贝
{
if (this.trWBS.SelectedNode.CommandName == "childUnitProject")
{
var wbsSet1s = from x in Funs.DB.Wbs_WbsSet where x.UnitProjectId == this.trWBS.SelectedNodeID && x.Flag == 1 select x;
bool isCanCopy = true; //子单位工程下只有一级子级时可以拷贝
foreach (var wbsSet1 in wbsSet1s)
{
var wbsSet2s = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == wbsSet1.WbsSetId select x;
if (wbsSet2s.Count() > 0)
{
isCanCopy = false;
break;
}
}
if (isCanCopy)
{
string openUrl = String.Format("WBSSetCopy.aspx?Id={0}&Type={1}", this.trWBS.SelectedNode.NodeID, this.trWBS.SelectedNode.CommandName, "拷贝 - ");
PageContext.RegisterStartupScript(Window2.GetSaveStateReference(hdSelectId.ClientID)
+ Window2.GetShowReference(openUrl));
}
else
{
bool isCopyed = false; //是否拷贝过
foreach (var wbsSet1 in wbsSet1s)
{
if (wbsSet1.NoShow == true)
{
isCopyed = true;
break;
}
}
if (isCopyed)
{
string openUrl = String.Format("WBSSetCopy.aspx?Id={0}&Type={1}", this.trWBS.SelectedNode.NodeID, this.trWBS.SelectedNode.CommandName, "拷贝 - ");
PageContext.RegisterStartupScript(Window2.GetSaveStateReference(hdSelectId.ClientID)
+ Window2.GetShowReference(openUrl));
}
else
{
ShowNotify("所选节点并非只有一级子级,无法拷贝!", MessageBoxIcon.Warning);
}
}
}
else if (this.trWBS.SelectedNode.CommandName == "wbsSet")
{
var wbsSet1s = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == this.trWBS.SelectedNodeID select x;
bool isCanCopy = true; //分部分项下只有一级子级时可以拷贝
foreach (var wbsSet1 in wbsSet1s)
{
var wbsSet2s = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == wbsSet1.WbsSetId select x;
if (wbsSet2s.Count() > 0)
{
isCanCopy = false;
break;
}
}
if (isCanCopy)
{
string openUrl = String.Format("WBSSetCopy.aspx?Id={0}&Type={1}", this.trWBS.SelectedNode.NodeID, this.trWBS.SelectedNode.CommandName, "拷贝 - ");
PageContext.RegisterStartupScript(Window2.GetSaveStateReference(hdSelectId.ClientID)
+ Window2.GetShowReference(openUrl));
}
else
{
bool isCopyed = false; //是否拷贝过
foreach (var wbsSet1 in wbsSet1s)
{
if (wbsSet1.NoShow == true)
{
isCopyed = true;
break;
}
}
if (isCopyed)
{
string openUrl = String.Format("WBSSetCopy.aspx?Id={0}&Type={1}", this.trWBS.SelectedNode.NodeID, this.trWBS.SelectedNode.CommandName, "拷贝 - ");
PageContext.RegisterStartupScript(Window2.GetSaveStateReference(hdSelectId.ClientID)
+ Window2.GetShowReference(openUrl));
}
else
{
ShowNotify("所选节点并非只有一级子级,无法拷贝!", MessageBoxIcon.Warning);
}
}
}
}
else
{
ShowNotify("项目、装置、专业和单位工程节点无法拷贝!", MessageBoxIcon.Warning);
}
//}
//else
//{
// ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
//}
}
else
{
ShowNotify("请选择树节点!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 分级
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuCopy2_Click(object sender, EventArgs e)
{
if (this.trWBS.SelectedNode != null)
{
//if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectWBSSetAuditMenuId, BLL.Const.BtnAdd))
//{
if (this.trWBS.SelectedNode.CommandName != "project" && this.trWBS.SelectedNode.CommandName != "installation" && this.trWBS.SelectedNode.CommandName != "cnProfession" && this.trWBS.SelectedNode.CommandName != "unitProject") //非项目、装置、专业、单位工程节点可以拷贝
{
if (this.trWBS.SelectedNode.CommandName == "childUnitProject")
{
string openUrl = String.Format("WBSSetCopy2.aspx?Id={0}&Type={1}", this.trWBS.SelectedNode.NodeID, this.trWBS.SelectedNode.CommandName, "分级 - ");
PageContext.RegisterStartupScript(Window2.GetSaveStateReference(hdSelectId.ClientID)
+ Window2.GetShowReference(openUrl));
}
else if (this.trWBS.SelectedNode.CommandName == "wbsSet")
{
string openUrl = String.Format("WBSSetCopy2.aspx?Id={0}&Type={1}", this.trWBS.SelectedNode.NodeID, this.trWBS.SelectedNode.CommandName, "分级 - ");
PageContext.RegisterStartupScript(Window2.GetSaveStateReference(hdSelectId.ClientID)
+ Window2.GetShowReference(openUrl));
}
}
else
{
ShowNotify("项目、装置、专业和单位工程节点无法分级!", MessageBoxIcon.Warning);
}
//}
//else
//{
// ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
//}
}
else
{
ShowNotify("请选择树节点!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 右键删除事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuDelete_Click(object sender, EventArgs e)
{
if (this.trWBS.SelectedNode != null)
{
//if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectWBSSetAuditMenuId, BLL.Const.BtnAuditing))
//{
if (this.trWBS.SelectedNode.CommandName != "project" && this.trWBS.SelectedNode.CommandName != "installation" && this.trWBS.SelectedNode.CommandName != "cnProfession") //非项目、装置、专业节点可以修改
{
DeleteData();
}
else
{
ShowNotify("项目、装置和专业节点无法删除!", MessageBoxIcon.Warning);
}
//}
//else
//{
// ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
//}
}
else
{
ShowNotify("请选择树节点!", MessageBoxIcon.Warning);
}
}
/// <summary>
/// 删除方法
/// </summary>
private void DeleteData()
{
string id = this.trWBS.SelectedNodeID;
if (this.trWBS.SelectedNode.CommandName == "unitProject")
{
Model.Wbs_UnitProject unitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(id);
if (unitProject != null)
{
if (unitProject.IsIn == true)
{
ShowNotify("内置项无法删除!", MessageBoxIcon.Warning);
return;
}
else
{
List<Model.Wbs_UnitProject> childUnitProjects = BLL.UnitProjectService.GetUnitProjectsBySuperUnitProjectId(id);
if (childUnitProjects.Count > 0) //存在子单位工程
{
this.hdSelectId.Text = unitProject.CnProfessionId;
foreach (var childUnitProject in childUnitProjects)
{
BLL.WbsSetService.DeleteWbsSetByUnitProjectId(childUnitProject.UnitProjectId);
}
BLL.UnitProjectService.DeleteUnitProjectBySuperUnitProjectId(id);
BLL.UnitProjectService.DeleteUnitProject(id);
}
else
{
this.hdSelectId.Text = unitProject.CnProfessionId;
BLL.WbsSetService.DeleteWbsSetByUnitProjectId(id);
BLL.UnitProjectService.DeleteUnitProject(id);
}
}
}
}
else if (this.trWBS.SelectedNode.CommandName == "childUnitProject")
{
Model.Wbs_UnitProject childUnitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(id);
if (childUnitProject != null)
{
if (childUnitProject.IsIn == true)
{
ShowNotify("内置项无法删除!", MessageBoxIcon.Warning);
return;
}
else
{
this.hdSelectId.Text = childUnitProject.SuperUnitProjectId;
BLL.WbsSetService.DeleteWbsSetByUnitProjectId(id);
BLL.UnitProjectService.DeleteUnitProject(id);
}
}
}
else if (this.trWBS.SelectedNode.CommandName == "wbsSet")
{
Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(id);
if (wbsSet != null)
{
if (wbsSet.IsIn == true)
{
ShowNotify("内置项无法删除!", MessageBoxIcon.Warning);
return;
}
else
{
List<Model.Wbs_WbsSet> childWbsSet1s = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(id);
Model.Wbs_WbsSet set = BLL.WbsSetService.GetWbsSetByWbsSetId(id);
if (set != null)
{
if (!string.IsNullOrEmpty(set.SuperWbsSetId))
{
this.hdSelectId.Text = wbsSet.SuperWbsSetId;
}
else
{
this.hdSelectId.Text = wbsSet.UnitProjectId;
}
}
foreach (var childWbsSet1 in childWbsSet1s)
{
List<Model.Wbs_WbsSet> childWbsSet2s = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(childWbsSet1.WbsSetId);
foreach (var childWbsSet2 in childWbsSet2s)//3
{
List<Model.Wbs_WbsSet> childWbsSet3s = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(childWbsSet2.WbsSetId);
foreach (var childWbsSet3 in childWbsSet3s)
{
BLL.WbsSetService.DeleteWbsSet(childWbsSet3.WbsSetId);
}
BLL.WbsSetService.DeleteWbsSet(childWbsSet2.WbsSetId);
}
BLL.WbsSetService.DeleteWbsSet(childWbsSet1.WbsSetId);
}
BLL.WbsSetService.DeleteWbsSet(id);
}
}
}
ShowNotify("删除成功!", MessageBoxIcon.Success);
getWBSSet();
}
/// <summary>
/// 审核
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnMenuAudit_Click(object sender, EventArgs e)
{
if (this.trWBS.SelectedNode != null)
{
//if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectWBSSetAuditMenuId, BLL.Const.BtnAuditing))
////{
if (this.trWBS.SelectedNode.CommandName != "project" && this.trWBS.SelectedNode.CommandName != "installation" && this.trWBS.SelectedNode.CommandName != "cnProfession") //非项目、装置、专业节点可以修改
{
this.UpdateSelect(trWBS.SelectedNode);
BindGrid();
ShowNotify("已审核成功!", MessageBoxIcon.Warning);
}
else
{
ShowNotify("请选择专业下项进行审核!", MessageBoxIcon.Warning);
}
//}
//else
//{
// ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
//}
}
else
{
ShowNotify("请选择树节点!", MessageBoxIcon.Warning);
}
}
#endregion
#region
/// <summary>
/// 点击勾选按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void cbIsApprove_CheckedChanged(object sender, EventArgs e)
{
System.Web.UI.WebControls.CheckBox cbIsApprove1 = sender as System.Web.UI.WebControls.CheckBox;
for (int i = 0; i < this.Grid1.Rows.Count; i++)
{
System.Web.UI.WebControls.CheckBox cbIsApprove = (System.Web.UI.WebControls.CheckBox)(this.Grid1.Rows[i].FindControl("cbIsApprove"));
if (cbIsApprove1.ClientID == cbIsApprove.ClientID)
{
string id = this.Grid1.Rows[i].DataKeys[0].ToString();
Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(id);
if (cbIsApprove1.Checked)
{
wbsSet.IsApprove = true;
}
else
{
wbsSet.IsApprove = false;
}
BLL.WbsSetService.UpdateWbsSet(wbsSet);
}
}
}
#endregion
#region
/// <summary>
/// 提交
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
//protected void btnSave1_Click(object sender, EventArgs e)
//{
// Grid1.CommitChanges();
// for (int i = 0; i < this.Grid1.Rows.Count; i++)
// {
// string id = this.Grid1.Rows[i].Values[9].ToString();
// if (id.Length > 10)
// {
// string changeDateType = this.Grid1.Rows[i].Values[10].ToString();
// string type = this.Grid1.Rows[i].Values[4].ToString();
// if (changeDateType == "StartDate")
// {
// DateTime? startDate = Convert.ToDateTime(this.Grid1.Rows[i].Values[2].ToString());
// BLL.Project_InstallationService.UpdateChildWBSDate(id, type, changeDateType, startDate);
// BLL.Project_InstallationService.UpdateParentWBSDate(id, type, changeDateType, startDate);
// }
// else if (changeDateType == "EndDate")
// {
// DateTime? endDate = Convert.ToDateTime(this.Grid1.Rows[i].Values[3].ToString());
// BLL.Project_InstallationService.UpdateChildWBSDate(id, type, changeDateType, endDate);
// BLL.Project_InstallationService.UpdateParentWBSDate(id, type, changeDateType, endDate);
// }
// else if (changeDateType == "ControlPoint")
// {
// string controlPoint = this.Grid1.Rows[i].Values[5].ToString();
// Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(id);
// if (wbsSet != null)
// {
// wbsSet.ControlPoint = controlPoint;
// BLL.WbsSetService.UpdateWbsSet(wbsSet);
// }
// }
// else if (changeDateType == "Cycle")
// {
// string cycle = this.Grid1.Rows[i].Values[6].ToString();
// Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(id);
// if (wbsSet != null)
// {
// wbsSet.Cycle = Funs.GetNewIntOrZero(cycle);
// BLL.WbsSetService.UpdateWbsSet(wbsSet);
// }
// }
// else if (changeDateType == "Frequency")
// {
// string frequency = this.Grid1.Rows[i].Values[7].ToString();
// Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(id);
// if (wbsSet != null)
// {
// wbsSet.Frequency = Funs.GetNewIntOrZero(frequency);
// BLL.WbsSetService.UpdateWbsSet(wbsSet);
// }
// }
// }
// }
// BindGrid();
//}
#endregion
#region
/// <summary>
/// 保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
//if (BLL.CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.ProjectWBSSetAuditMenuId, BLL.Const.BtnSave))
//{
if (Grid1.Rows.Count > 0)
{
JArray mergedData = Grid1.GetMergedData();
bool isPass = true;
if (isPass)
{
foreach (JObject mergedRow in mergedData)
{
JObject values = mergedRow.Value<JObject>("values");
string id = values.Value<string>("Id");
string type = values.Value<string>("Type");
string startDate = values.Value<string>("StartDate");
string endDate = values.Value<string>("EndDate");
string controlPoint = values.Value<string>("ControlPoint");
int? cycle = Funs.GetNewInt(values.Value<string>("Cycle"));
int? frequency = Funs.GetNewInt(values.Value<string>("Frequency"));
if (type == "cnProfession")
{
Model.WBS_CnProfession cnProfession = BLL.CnProfessionService.GetCnProfessionByCnProfessionId(id);
cnProfession.StartDate = Convert.ToDateTime(startDate);
cnProfession.EndDate = Convert.ToDateTime(endDate);
Model.Project_Installation installation = BLL.Project_InstallationService.GetInstallationByInstallationId(cnProfession.InstallationId);
if (cnProfession.StartDate < installation.StartDate)
{
installation.StartDate = cnProfession.StartDate;
}
if (cnProfession.EndDate > installation.EndDate)
{
installation.EndDate = cnProfession.EndDate;
}
}
if (type == "unitProject" || type == "childUnitProject")
{
Model.Wbs_UnitProject unitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(id);
unitProject.StartDate = Convert.ToDateTime(startDate);
unitProject.EndDate = Convert.ToDateTime(endDate);
if (type == "childUnitProject")
{
Model.Wbs_UnitProject pUnitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(unitProject.SuperUnitProjectId);
if (unitProject.StartDate < pUnitProject.StartDate)
{
pUnitProject.StartDate = unitProject.StartDate;
}
if (unitProject.EndDate > pUnitProject.EndDate)
{
pUnitProject.EndDate = unitProject.EndDate;
}
}
else
{
Model.WBS_CnProfession cnProfession = BLL.CnProfessionService.GetCnProfessionByCnProfessionId(unitProject.CnProfessionId);
if (unitProject.StartDate < cnProfession.StartDate)
{
cnProfession.StartDate = unitProject.StartDate;
}
if (unitProject.EndDate > cnProfession.EndDate)
{
cnProfession.EndDate = unitProject.EndDate;
}
}
}
if (type == "wbsSet")
{
Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(id);
wbsSet.StartDate = Convert.ToDateTime(startDate);
wbsSet.EndDate = Convert.ToDateTime(endDate);
wbsSet.ControlPoint = controlPoint;
wbsSet.Cycle = cycle;
wbsSet.Frequency = frequency;
if (wbsSet.SuperWbsSetId == null)
{
Model.Wbs_UnitProject unitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(wbsSet.UnitProjectId);
if (wbsSet.StartDate < unitProject.StartDate)
{
unitProject.StartDate = wbsSet.StartDate;
}
if (wbsSet.EndDate > unitProject.EndDate)
{
unitProject.EndDate = wbsSet.EndDate;
}
}
else
{
Model.Wbs_WbsSet pWbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(wbsSet.SuperWbsSetId);
if (wbsSet.StartDate < pWbsSet.StartDate)
{
pWbsSet.StartDate = wbsSet.StartDate;
}
if (wbsSet.EndDate > pWbsSet.EndDate)
{
pWbsSet.EndDate = wbsSet.EndDate;
}
}
}
Funs.DB.SubmitChanges();
}
}
BindGrid();
SaveData();
}
Alert.ShowInTop("保存成功!", MessageBoxIcon.Warning);
//}
//else
//{
// ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
//}
}
#endregion
#region
private string upStartDate = string.Empty;
private string upEndDate = string.Empty;
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
{
string id = e.RowID;
string type = e.Values[4].ToString();
if (id == trWBS.SelectedNodeID)
{
foreach (GridColumn column in Grid1.Columns)
{
e.CellCssClasses[column.ColumnIndex] = "f-grid-cell-uneditable";
}
upStartDate = e.Values[2].ToString();
upEndDate = e.Values[3].ToString();
}
else
{
if ((Convert.ToDateTime(e.Values[2]) >= Convert.ToDateTime(upStartDate) && Convert.ToDateTime(e.Values[2]) <= Convert.ToDateTime(upEndDate))
&& (Convert.ToDateTime(e.Values[3]) >= Convert.ToDateTime(upStartDate) && Convert.ToDateTime(e.Values[3]) <= Convert.ToDateTime(upEndDate))
&& Convert.ToDateTime(e.Values[3]) >= Convert.ToDateTime(e.Values[2]))
{
}
else
{
e.RowCssClass = "orange";
}
}
if (type == "unitProject" || type == "childUnitProject")
{
Model.Wbs_UnitProject unitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(id);
if (unitProject.IsApprove != true)
{
e.RowCssClass = "red";
}
}
if (type == "wbsSet")
{
Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(id);
if (wbsSet.IsApprove != true)
{
e.RowCssClass = "red";
}
}
}
/// <summary>
/// 绑定数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_FilterChange(object sender, EventArgs e)
{
BindGrid();
}
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
Grid1.PageIndex = e.NewPageIndex;
BindGrid();
}
/// <summary>
/// Grid1排序
/// </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>
/// 加载Grid
/// </summary>
private void BindGrid()
{
List<Model.WBSSetItem> items = new List<Model.WBSSetItem>();
bool showApprove = false;
if (this.trWBS.SelectedNode != null)
{
if (this.trWBS.SelectedNode.CommandName == "installation")
{
Model.Project_Installation installation = BLL.Project_InstallationService.GetInstallationByInstallationId(this.trWBS.SelectedNode.NodeID);
Model.WBSSetItem item = new Model.WBSSetItem();
if (installation != null)
{
item.Id = this.trWBS.SelectedNode.NodeID;
item.Code = installation.InstallationCode;
item.Name = installation.InstallationName;
item.Type = "installation";
item.StartDate = installation.StartDate;
item.EndDate = installation.EndDate;
items.Add(item);
var cnProfessions = from x in Funs.DB.WBS_CnProfession where x.InstallationId == this.trWBS.SelectedNode.NodeID orderby x.OldId select x;
foreach (var cnProfession in cnProfessions)
{
Model.WBSSetItem childitem = new Model.WBSSetItem();
if (cnProfession != null)
{
childitem.Id = cnProfession.CnProfessionId;
childitem.Code = cnProfession.CnProfessionCode;
childitem.Name = cnProfession.CnProfessionName;
childitem.Type = "cnProfession";
childitem.StartDate = cnProfession.StartDate;
childitem.EndDate = cnProfession.EndDate;
items.Add(childitem);
}
}
}
}
else if (this.trWBS.SelectedNode.CommandName == "cnProfession")
{
Model.WBS_CnProfession cnProfession = BLL.CnProfessionService.GetCnProfessionByCnProfessionId(this.trWBS.SelectedNode.NodeID);
Model.WBSSetItem item = new Model.WBSSetItem();
if (cnProfession != null)
{
item.Id = this.trWBS.SelectedNode.NodeID;
item.Code = cnProfession.CnProfessionCode;
item.Name = cnProfession.CnProfessionName;
item.Type = "cnProfession";
item.StartDate = cnProfession.StartDate;
item.EndDate = cnProfession.EndDate;
items.Add(item);
var unitProjects = from x in Funs.DB.Wbs_UnitProject where x.CnProfessionId == this.trWBS.SelectedNode.NodeID && x.SuperUnitProjectId == null && x.IsSelected == true orderby x.SortIndex, x.UnitProjectCode select x;
foreach (var unitProject in unitProjects)
{
Model.WBSSetItem childitem = new Model.WBSSetItem();
if (unitProject != null)
{
childitem.Id = unitProject.UnitProjectId;
childitem.Code = unitProject.UnitProjectCode;
childitem.Name = unitProject.UnitProjectName;
childitem.Type = "unitProject";
childitem.StartDate = unitProject.StartDate;
childitem.EndDate = unitProject.EndDate;
items.Add(childitem);
}
}
}
}
else if (this.trWBS.SelectedNode.CommandName == "unitProject")
{
Model.Wbs_UnitProject unitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(this.trWBS.SelectedNode.NodeID);
Model.WBSSetItem item = new Model.WBSSetItem();
if (unitProject != null)
{
item.Id = this.trWBS.SelectedNode.NodeID;
item.Code = unitProject.UnitProjectCode;
item.Name = unitProject.UnitProjectName;
item.Type = "unitProject";
item.StartDate = unitProject.StartDate;
item.EndDate = unitProject.EndDate;
items.Add(item);
var childUnitProjects = from x in Funs.DB.Wbs_UnitProject where x.SuperUnitProjectId == this.trWBS.SelectedNode.NodeID && x.IsApprove == true orderby x.SortIndex, x.UnitProjectCode select x;
if (childUnitProjects.Count() > 0) //存在子单位工程
{
foreach (var childUnitProject in childUnitProjects)
{
Model.WBSSetItem childitem = new Model.WBSSetItem();
if (childUnitProject != null)
{
childitem.Id = childUnitProject.UnitProjectId;
childitem.Code = childUnitProject.UnitProjectCode;
childitem.Name = childUnitProject.UnitProjectName;
childitem.Type = "childUnitProject";
childitem.StartDate = childUnitProject.StartDate;
childitem.EndDate = childUnitProject.EndDate;
items.Add(childitem);
}
}
}
else //不存在子单位工程,加载分部工程
{
var wbsSet1s = from x in Funs.DB.Wbs_WbsSet where x.Flag == 1 && x.UnitProjectId == this.trWBS.SelectedNode.NodeID && x.IsApprove == true && x.NoShow == null orderby x.SortIndex, x.WbsSetCode select x;
if (wbsSet1s.Count() > 0)
{
foreach (var wbsSet in wbsSet1s)
{
Model.WBSSetItem childitem = new Model.WBSSetItem();
if (wbsSet != null)
{
childitem.Id = wbsSet.WbsSetId;
childitem.Code = wbsSet.WbsSetCode;
childitem.Name = wbsSet.WbsSetName;
childitem.Type = "wbsSet";
childitem.StartDate = wbsSet.StartDate;
childitem.EndDate = wbsSet.EndDate;
childitem.ControlPoint = wbsSet.ControlPoint;
childitem.Cycle = wbsSet.Cycle.ToString();
childitem.Frequency = wbsSet.Frequency.ToString();
childitem.ControlItemDef = wbsSet.ControlItemDef;
items.Add(childitem);
}
}
}
else //单位工程下直接是分项内容,如质量行为
{
var wbsSet3s = from x in Funs.DB.Wbs_WbsSet where x.Flag == 3 && x.UnitProjectId == this.trWBS.SelectedNode.NodeID && x.IsApprove == true && x.NoShow == null orderby x.SortIndex, x.WbsSetCode select x;
if (wbsSet3s.Count() > 0)
{
foreach (var wbsSet in wbsSet3s)
{
Model.WBSSetItem childitem = new Model.WBSSetItem();
if (wbsSet != null)
{
childitem.Id = wbsSet.WbsSetId;
childitem.Code = wbsSet.WbsSetCode;
childitem.Name = wbsSet.WbsSetName;
childitem.Type = "wbsSet";
childitem.StartDate = wbsSet.StartDate;
childitem.EndDate = wbsSet.EndDate;
childitem.ControlPoint = wbsSet.ControlPoint;
childitem.Cycle = wbsSet.Cycle.ToString();
childitem.Frequency = wbsSet.Frequency.ToString();
childitem.ControlItemDef = wbsSet.ControlItemDef;
items.Add(childitem);
}
}
}
}
}
}
}
else if (this.trWBS.SelectedNode.CommandName == "childUnitProject")
{
Model.Wbs_UnitProject unitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(this.trWBS.SelectedNode.NodeID);
Model.WBSSetItem item = new Model.WBSSetItem();
if (unitProject != null)
{
item.Id = this.trWBS.SelectedNode.NodeID;
item.Code = unitProject.UnitProjectCode;
item.Name = unitProject.UnitProjectName;
item.Type = "childUnitProject";
item.StartDate = unitProject.StartDate;
item.EndDate = unitProject.EndDate;
items.Add(item);
var wbsSet1s = from x in Funs.DB.Wbs_WbsSet where x.Flag == 1 && x.UnitProjectId == this.trWBS.SelectedNode.NodeID && x.IsApprove == true && x.NoShow == null orderby x.SortIndex, x.WbsSetCode select x;
foreach (var wbsSet in wbsSet1s)
{
Model.WBSSetItem childitem = new Model.WBSSetItem();
if (wbsSet != null)
{
childitem.Id = wbsSet.WbsSetId;
childitem.Code = wbsSet.WbsSetCode;
childitem.Name = wbsSet.WbsSetName;
childitem.Type = "wbsSet";
childitem.StartDate = wbsSet.StartDate;
childitem.EndDate = wbsSet.EndDate;
childitem.ControlPoint = wbsSet.ControlPoint;
childitem.Cycle = wbsSet.Cycle.ToString();
childitem.Frequency = wbsSet.Frequency.ToString();
childitem.ControlItemDef = wbsSet.ControlItemDef;
items.Add(childitem);
}
}
}
}
else if (this.trWBS.SelectedNode.CommandName == "wbsSet")
{
Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(this.trWBS.SelectedNode.NodeID);
var childWbsSets = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(this.trWBS.SelectedNodeID);
Model.WBSSetItem item = new Model.WBSSetItem();
if (wbsSet != null)
{
item.Id = this.trWBS.SelectedNode.NodeID;
item.Code = wbsSet.WbsSetCode;
item.Name = wbsSet.WbsSetName;
item.Type = "wbsSet";
item.StartDate = wbsSet.StartDate;
item.EndDate = wbsSet.EndDate;
item.ControlPoint = wbsSet.ControlPoint;
item.Cycle = wbsSet.Cycle.ToString();
item.Frequency = wbsSet.Frequency.ToString();
item.ControlItemDef = wbsSet.ControlItemDef;
items.Add(item);
foreach (var childwbsSet in childWbsSets)
{
Model.WBSSetItem childitem = new Model.WBSSetItem();
if (childwbsSet != null)
{
if (BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(childwbsSet.WbsSetId).Count() == 0) //加载子项为末级
{
showApprove = true;
}
childitem.Id = childwbsSet.WbsSetId;
childitem.Code = childwbsSet.WbsSetCode;
childitem.Name = childwbsSet.WbsSetName;
childitem.Type = "wbsSet";
childitem.StartDate = childwbsSet.StartDate;
childitem.EndDate = childwbsSet.EndDate;
childitem.ControlPoint = childwbsSet.ControlPoint;
childitem.Cycle = childwbsSet.Cycle.ToString();
childitem.Frequency = childwbsSet.Frequency.ToString();
childitem.ControlItemDef = childwbsSet.ControlItemDef;
items.Add(childitem);
}
}
}
}
this.Grid1.Columns[10].Hidden = true;
if (showApprove)
{
this.Grid1.Columns[10].Hidden = false;
}
this.Grid1.DataSource = items;
this.Grid1.DataBind();
for (int i = 0; i < this.Grid1.Rows.Count; i++)
{
string id = this.Grid1.Rows[i].DataKeys[0].ToString();
Model.Wbs_WbsSet wbsSet = BLL.WbsSetService.GetWbsSetByWbsSetId(id);
System.Web.UI.WebControls.CheckBox cbIsApprove = (System.Web.UI.WebControls.CheckBox)(this.Grid1.Rows[i].FindControl("cbIsApprove"));
if (wbsSet != null)
{
if (wbsSet.IsApprove == true)
{
cbIsApprove.Checked = true; //已勾选
}
else
{
cbIsApprove.Checked = false; //未勾选
}
}
}
}
}
#endregion
#region Id定位到对应具体的专业
private void getWBSSet()
{
string ProjectId = string.Empty;
string ppInstallationId = string.Empty;
string pInstallationId = string.Empty;
string InstallationId = string.Empty;
string CnProfessionId = string.Empty;
string UnitProjectId = string.Empty;
string childUnitProjectId = string.Empty;
string wbsSetParentId1 = string.Empty;
string wbsSetParentId2 = string.Empty;
string wbsSetParentId3 = string.Empty;
Model.WBS_CnProfession cnPro = BLL.CnProfessionService.GetCnProfessionByCnProfessionId(this.hdSelectId.Text);
Model.Wbs_UnitProject UnitProject = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(this.hdSelectId.Text);
Model.Wbs_WbsSet wbsSetParm = BLL.WbsSetService.GetWbsSetByWbsSetId(this.hdSelectId.Text);
Model.Project_Installation installationZT = BLL.Project_InstallationService.GetInstallationByInstallationId(this.hdSelectId.Text);
if (cnPro != null)
{
ProjectId = cnPro.ProjectId;
InstallationId = cnPro.InstallationId;
pInstallationId = (from x in Funs.DB.Project_Installation
join y in Funs.DB.Project_Installation
on x.InstallationId equals y.SuperInstallationId
where y.InstallationId == InstallationId
select x.InstallationId).FirstOrDefault();
ppInstallationId = (from x in Funs.DB.Project_Installation
join y in Funs.DB.Project_Installation
on x.InstallationId equals y.SuperInstallationId
join z in Funs.DB.Project_Installation
on y.InstallationId equals z.SuperInstallationId
where z.InstallationId == InstallationId
select x.InstallationId).FirstOrDefault();
}
else if (UnitProject != null)
{
if (string.IsNullOrEmpty(UnitProject.SuperUnitProjectId))
{
UnitProjectId = UnitProject.UnitProjectId;
}
else
{
childUnitProjectId = UnitProject.UnitProjectId;
UnitProjectId = UnitProject.SuperUnitProjectId;
}
Model.WBS_CnProfession cn = BLL.CnProfessionService.GetCnProfessionByCnProfessionId(UnitProject.CnProfessionId);
if (cn != null)
{
ProjectId = cn.ProjectId;
InstallationId = cn.InstallationId;
CnProfessionId = cn.CnProfessionId;
pInstallationId = (from x in Funs.DB.Project_Installation
join y in Funs.DB.Project_Installation
on x.InstallationId equals y.SuperInstallationId
where y.InstallationId == InstallationId
select x.InstallationId).FirstOrDefault();
ppInstallationId = (from x in Funs.DB.Project_Installation
join y in Funs.DB.Project_Installation
on x.InstallationId equals y.SuperInstallationId
join z in Funs.DB.Project_Installation
on y.InstallationId equals z.SuperInstallationId
where z.InstallationId == InstallationId
select x.InstallationId).FirstOrDefault();
}
else //总图
{
Model.Project_Installation installation = BLL.Project_InstallationService.GetInstallationByInstallationId(UnitProject.InstallationId);
if (installation != null)
{
ProjectId = installation.ProjectId;
ppInstallationId = installation.InstallationId;
}
}
}
else if (wbsSetParm != null)
{
Model.WBS_CnProfession cn = BLL.CnProfessionService.GetCnProfessionByCnProfessionId(wbsSetParm.CnProfessionId);
if (cn != null)
{
ProjectId = cn.ProjectId;
InstallationId = cn.InstallationId;
pInstallationId = (from x in Funs.DB.Project_Installation
join y in Funs.DB.Project_Installation
on x.InstallationId equals y.SuperInstallationId
where y.InstallationId == InstallationId
select x.InstallationId).FirstOrDefault();
ppInstallationId = (from x in Funs.DB.Project_Installation
join y in Funs.DB.Project_Installation
on x.InstallationId equals y.SuperInstallationId
join z in Funs.DB.Project_Installation
on y.InstallationId equals z.SuperInstallationId
where z.InstallationId == InstallationId
select x.InstallationId).FirstOrDefault();
}
else
{
Model.Project_Installation installation = BLL.Project_InstallationService.GetInstallationByInstallationId(wbsSetParm.InstallationId);
if (installation != null)
{
ProjectId = installation.ProjectId;
ppInstallationId = installation.InstallationId;
}
}
CnProfessionId = wbsSetParm.CnProfessionId;
Model.Wbs_UnitProject unitpro = BLL.UnitProjectService.GetUnitProjectByUnitProjectId(wbsSetParm.UnitProjectId);
if (string.IsNullOrEmpty(unitpro.SuperUnitProjectId))
{
UnitProjectId = unitpro.UnitProjectId;
}
else
{
childUnitProjectId = unitpro.UnitProjectId;
UnitProjectId = unitpro.SuperUnitProjectId;
}
if (!string.IsNullOrEmpty(wbsSetParm.SuperWbsSetId))
{
wbsSetParentId1 = wbsSetParm.SuperWbsSetId;
Model.Wbs_WbsSet wbsSetParent1 = BLL.WbsSetService.GetWbsSetByWbsSetId(wbsSetParentId1);
if (wbsSetParent1 != null)
{
if (!string.IsNullOrEmpty(wbsSetParent1.SuperWbsSetId))
{
wbsSetParentId2 = wbsSetParent1.SuperWbsSetId;
Model.Wbs_WbsSet wbsSetParent2 = BLL.WbsSetService.GetWbsSetByWbsSetId(wbsSetParentId2);
if (wbsSetParent2 != null)
{
if (!string.IsNullOrEmpty(wbsSetParent2.SuperWbsSetId))
{
wbsSetParentId3 = wbsSetParent2.SuperWbsSetId;
}
}
}
}
}
}
else if (installationZT != null)
{
ProjectId = installationZT.ProjectId;
ppInstallationId = installationZT.InstallationId;
}
this.trWBS.Nodes.Clear();
this.trWBS.ShowBorder = false;
this.trWBS.ShowHeader = false;
this.trWBS.EnableIcons = true;
this.trWBS.AutoScroll = true;
this.trWBS.EnableSingleClickExpand = true;
var projects = from x in Funs.DB.Base_Project
join z in Funs.DB.Project_ProjectUser on x.ProjectId equals z.ProjectId
join y in Funs.DB.Sys_User on z.UserId equals y.UserId
where y.UserId == this.CurrUser.UserId
select x;
if (this.CurrUser.UserId == BLL.Const.sysglyId || this.CurrUser.UserId == BLL.Const.hfnbdId)
{
projects = from x in Funs.DB.Base_Project orderby x.ProjectCode select x;
}
foreach (var project in projects)
{
TreeNode rootNode = new TreeNode();
rootNode.Text = project.ProjectName;
rootNode.NodeID = project.ProjectId;
rootNode.CommandName = "project";
rootNode.EnableExpandEvent = true;
this.trWBS.Nodes.Add(rootNode);
if (project.ProjectId == ProjectId)
{
rootNode.Expanded = true;
var installations = from x in Funs.DB.Project_Installation
where x.ProjectId == ProjectId && x.SuperInstallationId == "0"
orderby x.InstallationCode
select x;
foreach (var installation in installations)
{
TreeNode newInstallationNode = new TreeNode();
newInstallationNode.Text = installation.InstallationName;
newInstallationNode.NodeID = installation.InstallationId;
newInstallationNode.CommandName = "installation";
newInstallationNode.EnableExpandEvent = true;
rootNode.Nodes.Add(newInstallationNode);
if (installation.InstallationId == ppInstallationId)
{
var installation2s = from x in Funs.DB.Project_Installation
where x.ProjectId == ProjectId && x.SuperInstallationId == installation.InstallationId
orderby x.InstallationCode
select x;
if (installation2s.Count() > 0)
{
newInstallationNode.Expanded = true;
foreach (var installation2 in installation2s)
{
TreeNode newInstallationNode2 = new TreeNode();
newInstallationNode2.Text = installation2.InstallationName;
newInstallationNode2.NodeID = installation2.InstallationId;
newInstallationNode2.CommandName = "installation";
newInstallationNode2.EnableExpandEvent = true;
newInstallationNode.Nodes.Add(newInstallationNode2);
if (installation2.InstallationId == pInstallationId)
{
newInstallationNode2.Expanded = true;
var installation3s = from x in Funs.DB.Project_Installation
where x.ProjectId == ProjectId && x.SuperInstallationId == installation2.InstallationId
orderby x.InstallationCode
select x;
foreach (var installation3 in installation3s)
{
TreeNode newInstallationNode3 = new TreeNode();
newInstallationNode3.Text = installation3.InstallationName;
newInstallationNode3.NodeID = installation3.InstallationId;
newInstallationNode3.CommandName = "installation";
newInstallationNode3.EnableExpandEvent = true;
newInstallationNode2.Nodes.Add(newInstallationNode3);
if (installation3.InstallationId == InstallationId)
{
newInstallationNode3.Expanded = true;
#region
var cnProfessions = from x in Funs.DB.WBS_CnProfession where x.InstallationId == InstallationId orderby x.OldId select x;
foreach (var cnProfession in cnProfessions)
{
TreeNode newCnProfessionNode = new TreeNode();
newCnProfessionNode.Text = cnProfession.CnProfessionName;
newCnProfessionNode.NodeID = cnProfession.CnProfessionId;
newCnProfessionNode.CommandName = "cnProfession";
newCnProfessionNode.CommandArgument = cnProfession.Weights == null ? null : cnProfession.Weights.ToString();
newCnProfessionNode.ToolTip = cnProfession.CnProfessionCode;
newCnProfessionNode.EnableExpandEvent = true;
newCnProfessionNode.EnableClickEvent = true;
newInstallationNode3.Nodes.Add(newCnProfessionNode);
if (!string.IsNullOrEmpty(UnitProjectId))
{
//加载专业下的单位工程
if (cnProfession.CnProfessionId == CnProfessionId)
{
newCnProfessionNode.Expanded = true;
var UnitProjects = from x in Funs.DB.Wbs_UnitProject where x.CnProfessionId == CnProfessionId && x.SuperUnitProjectId == null orderby x.UnitProjectCode select x;
foreach (var unitProject in UnitProjects)
{
TreeNode newNodeUnitPorject = new TreeNode();
newNodeUnitPorject.Text = unitProject.UnitProjectName;
newNodeUnitPorject.NodeID = unitProject.UnitProjectId;
newNodeUnitPorject.CommandName = "unitProject";
newNodeUnitPorject.EnableExpandEvent = true;
newNodeUnitPorject.EnableCheckBox = true;
newNodeUnitPorject.EnableCheckEvent = true;
if (unitProject.IsSelected == true && unitProject.IsApprove == null)
{
unitProject.IsApprove = true;
BLL.UnitProjectService.UpdateUnitProject(unitProject);
}
if (unitProject.IsApprove == true)
{
newNodeUnitPorject.Checked = true;
}
else
{
newNodeUnitPorject.Checked = false;
}
newNodeUnitPorject.EnableClickEvent = true;
newCnProfessionNode.Expanded = true;
newCnProfessionNode.Nodes.Add(newNodeUnitPorject);
if (unitProject.UnitProjectId != UnitProjectId)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNodeUnitPorject.Nodes.Add(emptyNode);
}
else
{
#region
if (!string.IsNullOrEmpty(childUnitProjectId))//存在子单位工程
{
newNodeUnitPorject.Expanded = true;
var childUnitProjects = BLL.UnitProjectService.GetUnitProjectsBySuperUnitProjectId(newNodeUnitPorject.NodeID);
foreach (var childUnitProject in childUnitProjects)
{
TreeNode newChildUnitProjectNode = new TreeNode();
newChildUnitProjectNode.Text = childUnitProject.UnitProjectName;
newChildUnitProjectNode.NodeID = childUnitProject.UnitProjectId;
newChildUnitProjectNode.CommandName = "childUnitProject";
newChildUnitProjectNode.CommandArgument = childUnitProject.Weights == null ? null : childUnitProject.Weights.ToString();
newChildUnitProjectNode.ToolTip = childUnitProject.UnitProjectCode;
newChildUnitProjectNode.EnableExpandEvent = true;
newChildUnitProjectNode.EnableCheckBox = true;
newChildUnitProjectNode.EnableCheckEvent = true;
if (childUnitProject.IsSelected == true && childUnitProject.IsApprove == null)
{
childUnitProject.IsApprove = true;
BLL.UnitProjectService.UpdateUnitProject(childUnitProject);
}
if (childUnitProject.IsApprove == true)
{
newChildUnitProjectNode.Checked = true;
}
else
{
newChildUnitProjectNode.Checked = false;
}
newChildUnitProjectNode.EnableClickEvent = true;
newNodeUnitPorject.Nodes.Add(newChildUnitProjectNode);
if (wbsSetParm != null)
{
if (wbsSetParm.UnitProjectId != childUnitProject.UnitProjectId)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newChildUnitProjectNode.Nodes.Add(emptyNode);
}
else
{
newChildUnitProjectNode.Expanded = true;
var wbsSet1s = from x in Funs.DB.Wbs_WbsSet where x.Flag == 1 && x.UnitProjectId == wbsSetParm.UnitProjectId && x.NoShow == null orderby x.WbsSetCode select x;
foreach (var wbsSet1 in wbsSet1s)
{
TreeNode newwbsSet1Node = new TreeNode();
newwbsSet1Node.Text = wbsSet1.WbsSetName;
newwbsSet1Node.NodeID = wbsSet1.WbsSetId;
newwbsSet1Node.CommandName = "wbsSet";
newwbsSet1Node.CommandArgument = wbsSet1.Weights == null ? null : wbsSet1.Weights.ToString();
newwbsSet1Node.ToolTip = wbsSet1.WbsSetCode;
newwbsSet1Node.EnableExpandEvent = true;
newwbsSet1Node.EnableCheckBox = true;
newwbsSet1Node.EnableCheckEvent = true;
if (wbsSet1.IsSelected == true && wbsSet1.IsApprove == null)
{
wbsSet1.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet1);
}
if (wbsSet1.IsApprove == true)
{
newwbsSet1Node.Checked = true;
}
else
{
newwbsSet1Node.Checked = false;
}
newwbsSet1Node.EnableClickEvent = true;
newChildUnitProjectNode.Nodes.Add(newwbsSet1Node);
bool needAddTempNode = false;
var wbsSets = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet1.WbsSetId);
foreach (var wbsSet in wbsSets)
{
var childWbsSets = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == wbsSet.WbsSetId && x.NoShow == null select x;
if (childWbsSets.Count() > 0)
{
needAddTempNode = true;
break;
}
}
if (needAddTempNode)
{
var childWbsSets2 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(newwbsSet1Node.NodeID);
if (childWbsSets2.Count() > 0)
{
if (BLL.WbsSetService.IsExitWbsSetById2(wbsSet1.WbsSetId, wbsSetParm.WbsSetId))
{
newwbsSet1Node.Expanded = true;
foreach (var wbsSet2 in childWbsSets2)
{
TreeNode newwbsSet2Node = new TreeNode();
newwbsSet2Node.Text = wbsSet2.WbsSetName;
newwbsSet2Node.NodeID = wbsSet2.WbsSetId;
newwbsSet2Node.CommandName = "wbsSet";
newwbsSet2Node.CommandArgument = wbsSet2.Weights == null ? null : wbsSet2.Weights.ToString();
newwbsSet2Node.ToolTip = wbsSet2.WbsSetCode;
newwbsSet2Node.EnableExpandEvent = true;
newwbsSet2Node.EnableCheckBox = true;
newwbsSet2Node.EnableCheckEvent = true;
if (wbsSet2.IsSelected == true && wbsSet2.IsApprove == null)
{
wbsSet2.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet2);
}
if (wbsSet2.IsApprove == true)
{
newwbsSet2Node.Checked = true;
}
else
{
newwbsSet2Node.Checked = false;
}
newwbsSet2Node.EnableClickEvent = true;
newwbsSet1Node.Nodes.Add(newwbsSet2Node);
bool needAddTempNode2 = false;
var ws2 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet2.WbsSetId);
foreach (var w2 in ws2)
{
var childWbsSets = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == w2.WbsSetId && x.NoShow == null select x;
if (childWbsSets.Count() > 0)
{
needAddTempNode2 = true;
break;
}
}
if (needAddTempNode2)
{
var childWbsSets3 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(newwbsSet2Node.NodeID);
if (BLL.WbsSetService.IsExitWbsSetById2(wbsSet2.WbsSetId, wbsSetParm.WbsSetId))
{
newwbsSet2Node.Expanded = true;
if (childWbsSets3.Count() > 0)
{
foreach (var wbsSet3 in childWbsSets3)
{
TreeNode newwbsSet3Node = new TreeNode();
newwbsSet3Node.Text = wbsSet3.WbsSetName;
newwbsSet3Node.NodeID = wbsSet3.WbsSetId;
newwbsSet3Node.CommandName = "wbsSet";
newwbsSet3Node.CommandArgument = wbsSet3.Weights == null ? null : wbsSet3.Weights.ToString();
newwbsSet3Node.ToolTip = wbsSet3.WbsSetCode;
newwbsSet3Node.EnableExpandEvent = true;
newwbsSet3Node.EnableCheckBox = true;
newwbsSet3Node.EnableCheckEvent = true;
if (wbsSet3.IsSelected == true && wbsSet3.IsApprove == null)
{
wbsSet3.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet3);
}
if (wbsSet3.IsApprove == true)
{
newwbsSet3Node.Checked = true;
}
else
{
newwbsSet3Node.Checked = false;
}
newwbsSet3Node.EnableClickEvent = true;
newwbsSet2Node.Nodes.Add(newwbsSet3Node);
bool needAddTempNode3 = false;
var ws3 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet3.WbsSetId);
foreach (var w3 in ws3)
{
var childWbsSets = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == w3.WbsSetId && x.NoShow == null select x;
if (childWbsSets.Count() > 0)
{
needAddTempNode3 = true;
break;
}
}
if (needAddTempNode3)
{
var childWbsSets4 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(newwbsSet3Node.NodeID);
if (BLL.WbsSetService.IsExitWbsSetById2(wbsSet3.WbsSetId, wbsSetParm.WbsSetId))
{
newwbsSet3Node.Expanded = true;
if (childWbsSets4.Count() > 0)
{
foreach (var wbsSet4 in childWbsSets4)
{
TreeNode newwbsSet4Node = new TreeNode();
newwbsSet4Node.Text = wbsSet4.WbsSetName;
newwbsSet4Node.NodeID = wbsSet4.WbsSetId;
newwbsSet4Node.CommandName = "wbsSet";
newwbsSet4Node.CommandArgument = wbsSet4.Weights == null ? null : wbsSet4.Weights.ToString();
newwbsSet4Node.ToolTip = wbsSet4.WbsSetCode;
newwbsSet4Node.EnableExpandEvent = true;
newwbsSet4Node.EnableCheckBox = true;
newwbsSet4Node.EnableCheckEvent = true;
if (wbsSet4.IsSelected == true && wbsSet4.IsApprove == null)
{
wbsSet4.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet4);
}
if (wbsSet4.IsApprove == true)
{
newwbsSet4Node.Checked = true;
}
else
{
newwbsSet4Node.Checked = false;
}
newwbsSet4Node.EnableClickEvent = true;
newwbsSet3Node.Nodes.Add(newwbsSet4Node);
}
}
}
else
{
if (childWbsSets4.Count() > 0)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newwbsSet3Node.Nodes.Add(emptyNode);
}
}
}
}
}
}
else
{
if (childWbsSets3.Count() > 0)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newwbsSet2Node.Nodes.Add(emptyNode);
}
}
}
}
}
else
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newwbsSet1Node.Nodes.Add(emptyNode);
}
}
}
}
}
}
else
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newChildUnitProjectNode.Nodes.Add(emptyNode);
}
}
}
#endregion
else
{
#region
if (wbsSetParm != null)
{
if (wbsSetParm.UnitProjectId != UnitProjectId)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNodeUnitPorject.Nodes.Add(emptyNode);
}
else
{
newNodeUnitPorject.Expanded = true;
var wbsSet1s = from x in Funs.DB.Wbs_WbsSet where x.Flag == 1 && x.UnitProjectId == UnitProjectId && x.NoShow == null orderby x.WbsSetCode select x;
if (wbsSet1s.Count() > 0)
{
foreach (var wbsSet1 in wbsSet1s)
{
TreeNode newwbsSet1Node = new TreeNode();
newwbsSet1Node.Text = wbsSet1.WbsSetName;
newwbsSet1Node.NodeID = wbsSet1.WbsSetId;
newwbsSet1Node.CommandName = "wbsSet";
newwbsSet1Node.CommandArgument = wbsSet1.Weights == null ? null : wbsSet1.Weights.ToString();
newwbsSet1Node.ToolTip = wbsSet1.WbsSetCode;
newwbsSet1Node.EnableExpandEvent = true;
newwbsSet1Node.EnableCheckBox = true;
newwbsSet1Node.EnableCheckEvent = true;
if (wbsSet1.IsSelected == true && wbsSet1.IsApprove == null)
{
wbsSet1.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet1);
}
if (wbsSet1.IsApprove == true)
{
newwbsSet1Node.Checked = true;
}
else
{
newwbsSet1Node.Checked = false;
}
newwbsSet1Node.EnableClickEvent = true;
newNodeUnitPorject.Nodes.Add(newwbsSet1Node);
bool needAddTempNode = false;
var wbsSets = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet1.WbsSetId);
foreach (var wbsSet in wbsSets)
{
var childWbsSets = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == wbsSet.WbsSetId && x.NoShow == null select x;
if (childWbsSets.Count() > 0)
{
needAddTempNode = true;
break;
}
}
if (needAddTempNode)
{
var childWbsSets2 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(newwbsSet1Node.NodeID);
if (childWbsSets2.Count() > 0)
{
if (BLL.WbsSetService.IsExitWbsSetById2(wbsSet1.WbsSetId, wbsSetParm.WbsSetId))
{
foreach (var wbsSet2 in childWbsSets2)
{
if (wbsSet1.WbsSetId == wbsSet2.SuperWbsSetId)
{
newwbsSet1Node.Expanded = true;
}
TreeNode newwbsSet2Node = new TreeNode();
newwbsSet2Node.Text = wbsSet2.WbsSetName;
newwbsSet2Node.NodeID = wbsSet2.WbsSetId;
newwbsSet2Node.CommandName = "wbsSet";
newwbsSet2Node.CommandArgument = wbsSet2.Weights == null ? null : wbsSet2.Weights.ToString();
newwbsSet2Node.ToolTip = wbsSet2.WbsSetCode;
newwbsSet2Node.EnableExpandEvent = true;
newwbsSet2Node.EnableCheckBox = true;
newwbsSet2Node.EnableCheckEvent = true;
if (wbsSet2.IsSelected == true && wbsSet2.IsApprove == null)
{
wbsSet2.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet2);
}
if (wbsSet2.IsApprove == true)
{
newwbsSet2Node.Checked = true;
}
else
{
newwbsSet2Node.Checked = false;
}
newwbsSet2Node.EnableClickEvent = true;
newwbsSet1Node.Nodes.Add(newwbsSet2Node);
bool needAddTempNode2 = false;
var ws2 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet2.WbsSetId);
foreach (var w2 in ws2)
{
var childWbsSets = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == w2.WbsSetId && x.NoShow == null select x;
if (childWbsSets.Count() > 0)
{
needAddTempNode2 = true;
break;
}
}
if (needAddTempNode2)
{
var childWbsSets3 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(newwbsSet2Node.NodeID);
if (BLL.WbsSetService.IsExitWbsSetById2(wbsSet2.WbsSetId, wbsSetParm.WbsSetId))
{
newwbsSet2Node.Expanded = true;
if (childWbsSets3.Count() > 0)
{
foreach (var wbsSet3 in childWbsSets3)
{
TreeNode newwbsSet3Node = new TreeNode();
newwbsSet3Node.Text = wbsSet3.WbsSetName;
newwbsSet3Node.NodeID = wbsSet3.WbsSetId;
newwbsSet3Node.CommandName = "wbsSet";
newwbsSet3Node.CommandArgument = wbsSet3.Weights == null ? null : wbsSet3.Weights.ToString();
newwbsSet3Node.ToolTip = wbsSet3.WbsSetCode;
newwbsSet3Node.EnableExpandEvent = true;
newwbsSet3Node.EnableCheckBox = true;
newwbsSet3Node.EnableCheckEvent = true;
if (wbsSet3.IsSelected == true && wbsSet3.IsApprove == null)
{
wbsSet3.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet3);
}
if (wbsSet3.IsApprove == true)
{
newwbsSet3Node.Checked = true;
}
else
{
newwbsSet3Node.Checked = false;
}
newwbsSet3Node.EnableClickEvent = true;
newwbsSet2Node.Nodes.Add(newwbsSet3Node);
bool needAddTempNode3 = false;
var ws3 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet3.WbsSetId);
foreach (var w3 in ws3)
{
var childWbsSets = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == w3.WbsSetId && x.NoShow == null select x;
if (childWbsSets.Count() > 0)
{
needAddTempNode3 = true;
break;
}
}
if (needAddTempNode3)
{
var childWbsSets4 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(newwbsSet3Node.NodeID);
if (BLL.WbsSetService.IsExitWbsSetById2(wbsSet3.WbsSetId, wbsSetParm.WbsSetId))
{
newwbsSet3Node.Expanded = true;
if (childWbsSets4.Count() > 0)
{
foreach (var wbsSet4 in childWbsSets4)
{
TreeNode newwbsSet4Node = new TreeNode();
newwbsSet4Node.Text = wbsSet4.WbsSetName;
newwbsSet4Node.NodeID = wbsSet4.WbsSetId;
newwbsSet4Node.CommandName = "wbsSet";
newwbsSet4Node.CommandArgument = wbsSet4.Weights == null ? null : wbsSet4.Weights.ToString();
newwbsSet4Node.ToolTip = wbsSet4.WbsSetCode;
newwbsSet4Node.EnableExpandEvent = true;
newwbsSet4Node.EnableCheckBox = true;
newwbsSet4Node.EnableCheckEvent = true;
if (wbsSet4.IsSelected == true && wbsSet4.IsApprove == null)
{
wbsSet4.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet4);
}
if (wbsSet4.IsApprove == true)
{
newwbsSet4Node.Checked = true;
}
else
{
newwbsSet4Node.Checked = false;
}
newwbsSet4Node.EnableClickEvent = true;
newwbsSet3Node.Nodes.Add(newwbsSet4Node);
}
}
}
else
{
if (childWbsSets4.Count() > 0)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newwbsSet3Node.Nodes.Add(emptyNode);
}
}
}
}
}
}
else
{
if (childWbsSets3.Count() > 0)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newwbsSet2Node.Nodes.Add(emptyNode);
}
}
}
}
}
else
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newwbsSet1Node.Nodes.Add(emptyNode);
}
}
}
}
}
else //单位工程下直接是分项内容,如质量行为
{
var wbsSet3s = from x in Funs.DB.Wbs_WbsSet where x.Flag == 3 && x.UnitProjectId == UnitProjectId && x.NoShow == null orderby x.WbsSetCode select x;
if (wbsSet3s.Count() > 0)
{
foreach (var wbsSet3 in wbsSet3s)
{
TreeNode newwbsSet3Node = new TreeNode();
newwbsSet3Node.Text = wbsSet3.WbsSetName;
newwbsSet3Node.NodeID = wbsSet3.WbsSetId;
newwbsSet3Node.CommandName = "wbsSet";
newwbsSet3Node.CommandArgument = wbsSet3.Weights == null ? null : wbsSet3.Weights.ToString();
newwbsSet3Node.ToolTip = wbsSet3.WbsSetCode;
newwbsSet3Node.EnableExpandEvent = true;
newwbsSet3Node.EnableCheckBox = true;
newwbsSet3Node.EnableCheckEvent = true;
if (wbsSet3.IsSelected == true && wbsSet3.IsApprove == null)
{
wbsSet3.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet3);
}
if (wbsSet3.IsApprove == true)
{
newwbsSet3Node.Checked = true;
}
else
{
newwbsSet3Node.Checked = false;
}
newwbsSet3Node.EnableClickEvent = true;
newNodeUnitPorject.Nodes.Add(newwbsSet3Node);
}
}
}
}
}
else
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNodeUnitPorject.Nodes.Add(emptyNode);
}
#endregion
}
}
}
}
else
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newCnProfessionNode.Nodes.Add(emptyNode);
}
}
else
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newCnProfessionNode.Nodes.Add(emptyNode);
}
}
#endregion
}
else
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newInstallationNode3.Nodes.Add(emptyNode);
}
}
}
else
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newInstallationNode2.Nodes.Add(emptyNode);
}
}
}
else //总图
{
var unitProjects = from x in Funs.DB.Wbs_UnitProject where x.InstallationId == installation.InstallationId && x.SuperUnitProjectId == null orderby x.SortIndex, x.UnitProjectCode select x;
foreach (var unitProject in unitProjects)
{
TreeNode newNodeUnitPorject = new TreeNode();
newNodeUnitPorject.Text = unitProject.UnitProjectName;
newNodeUnitPorject.NodeID = unitProject.UnitProjectId;
newNodeUnitPorject.CommandName = "unitProject";
newNodeUnitPorject.EnableExpandEvent = true;
newNodeUnitPorject.EnableCheckBox = true;
newNodeUnitPorject.EnableCheckEvent = true;
if (unitProject.IsSelected == true && unitProject.IsApprove == null)
{
unitProject.IsApprove = true;
BLL.UnitProjectService.UpdateUnitProject(unitProject);
}
if (unitProject.IsApprove == true)
{
newNodeUnitPorject.Checked = true;
}
else
{
newNodeUnitPorject.Checked = false;
}
newNodeUnitPorject.EnableClickEvent = true;
if (!string.IsNullOrEmpty(UnitProjectId))
{
newInstallationNode.Expanded = true;
}
newInstallationNode.Nodes.Add(newNodeUnitPorject);
if (unitProject.UnitProjectId != UnitProjectId)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNodeUnitPorject.Nodes.Add(emptyNode);
}
else
{
if (wbsSetParm != null)
{
newNodeUnitPorject.Expanded = true;
var wbsSet1s = from x in Funs.DB.Wbs_WbsSet where x.Flag == 1 && x.UnitProjectId == UnitProjectId && x.NoShow == null orderby x.WbsSetCode select x;
if (wbsSet1s.Count() > 0)
{
foreach (var wbsSet1 in wbsSet1s)
{
TreeNode newwbsSet1Node = new TreeNode();
newwbsSet1Node.Text = wbsSet1.WbsSetName;
newwbsSet1Node.NodeID = wbsSet1.WbsSetId;
newwbsSet1Node.CommandName = "wbsSet";
newwbsSet1Node.CommandArgument = wbsSet1.Weights == null ? null : wbsSet1.Weights.ToString();
newwbsSet1Node.ToolTip = wbsSet1.WbsSetCode;
newwbsSet1Node.EnableExpandEvent = true;
newwbsSet1Node.EnableCheckBox = true;
newwbsSet1Node.EnableCheckEvent = true;
if (wbsSet1.IsSelected == true && wbsSet1.IsApprove == null)
{
wbsSet1.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet1);
}
if (wbsSet1.IsApprove == true)
{
newwbsSet1Node.Checked = true;
}
else
{
newwbsSet1Node.Checked = false;
}
newwbsSet1Node.EnableClickEvent = true;
newNodeUnitPorject.Nodes.Add(newwbsSet1Node);
bool needAddTempNode = false;
var wbsSets = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet1.WbsSetId);
foreach (var wbsSet in wbsSets)
{
var childWbsSets = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == wbsSet.WbsSetId && x.NoShow == null select x;
if (childWbsSets.Count() > 0)
{
needAddTempNode = true;
break;
}
}
if (needAddTempNode)
{
var childWbsSets2 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(newwbsSet1Node.NodeID);
if (childWbsSets2.Count() > 0)
{
if (BLL.WbsSetService.IsExitWbsSetById2(wbsSet1.WbsSetId, wbsSetParm.WbsSetId))
{
foreach (var wbsSet2 in childWbsSets2)
{
if (wbsSet1.WbsSetId == wbsSet2.SuperWbsSetId)
{
newwbsSet1Node.Expanded = true;
}
TreeNode newwbsSet2Node = new TreeNode();
newwbsSet2Node.Text = wbsSet2.WbsSetName;
newwbsSet2Node.NodeID = wbsSet2.WbsSetId;
newwbsSet2Node.CommandName = "wbsSet";
newwbsSet2Node.CommandArgument = wbsSet2.Weights == null ? null : wbsSet2.Weights.ToString();
newwbsSet2Node.ToolTip = wbsSet2.WbsSetCode;
newwbsSet2Node.EnableExpandEvent = true;
newwbsSet2Node.EnableCheckBox = true;
newwbsSet2Node.EnableCheckEvent = true;
if (wbsSet2.IsSelected == true && wbsSet2.IsApprove == null)
{
wbsSet2.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet2);
}
if (wbsSet2.IsApprove == true)
{
newwbsSet2Node.Checked = true;
}
else
{
newwbsSet2Node.Checked = false;
}
newwbsSet2Node.EnableClickEvent = true;
newwbsSet1Node.Nodes.Add(newwbsSet2Node);
bool needAddTempNode2 = false;
var ws2 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet2.WbsSetId);
foreach (var w2 in ws2)
{
var childWbsSets = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == w2.WbsSetId && x.NoShow == null select x;
if (childWbsSets.Count() > 0)
{
needAddTempNode2 = true;
break;
}
}
if (needAddTempNode2)
{
var childWbsSets3 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(newwbsSet2Node.NodeID);
if (BLL.WbsSetService.IsExitWbsSetById2(wbsSet2.WbsSetId, wbsSetParm.WbsSetId))
{
newwbsSet2Node.Expanded = true;
if (childWbsSets3.Count() > 0)
{
foreach (var wbsSet3 in childWbsSets3)
{
TreeNode newwbsSet3Node = new TreeNode();
newwbsSet3Node.Text = wbsSet3.WbsSetName;
newwbsSet3Node.NodeID = wbsSet3.WbsSetId;
newwbsSet3Node.CommandName = "wbsSet";
newwbsSet3Node.CommandArgument = wbsSet3.Weights == null ? null : wbsSet3.Weights.ToString();
newwbsSet3Node.ToolTip = wbsSet3.WbsSetCode;
newwbsSet3Node.EnableExpandEvent = true;
newwbsSet3Node.EnableCheckBox = true;
newwbsSet3Node.EnableCheckEvent = true;
if (wbsSet3.IsSelected == true && wbsSet3.IsApprove == null)
{
wbsSet3.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet3);
}
if (wbsSet3.IsApprove == true)
{
newwbsSet3Node.Checked = true;
}
else
{
newwbsSet3Node.Checked = false;
}
newwbsSet3Node.EnableClickEvent = true;
newwbsSet2Node.Nodes.Add(newwbsSet3Node);
bool needAddTempNode3 = false;
var ws3 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(wbsSet3.WbsSetId);
foreach (var w3 in ws3)
{
var childWbsSets = from x in Funs.DB.Wbs_WbsSet where x.SuperWbsSetId == w3.WbsSetId && x.NoShow == null select x;
if (childWbsSets.Count() > 0)
{
needAddTempNode3 = true;
break;
}
}
if (needAddTempNode3)
{
var childWbsSets4 = BLL.WbsSetService.GetWbsSetsBySuperWbsSetId(newwbsSet3Node.NodeID);
if (BLL.WbsSetService.IsExitWbsSetById2(wbsSet3.WbsSetId, wbsSetParm.WbsSetId))
{
newwbsSet3Node.Expanded = true;
if (childWbsSets4.Count() > 0)
{
foreach (var wbsSet4 in childWbsSets4)
{
TreeNode newwbsSet4Node = new TreeNode();
newwbsSet4Node.Text = wbsSet4.WbsSetName;
newwbsSet4Node.NodeID = wbsSet4.WbsSetId;
newwbsSet4Node.CommandName = "wbsSet";
newwbsSet4Node.CommandArgument = wbsSet4.Weights == null ? null : wbsSet4.Weights.ToString();
newwbsSet4Node.ToolTip = wbsSet4.WbsSetCode;
newwbsSet4Node.EnableExpandEvent = true;
newwbsSet4Node.EnableCheckBox = true;
newwbsSet4Node.EnableCheckEvent = true;
if (wbsSet4.IsSelected == true && wbsSet4.IsApprove == null)
{
wbsSet4.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet4);
}
if (wbsSet4.IsApprove == true)
{
newwbsSet4Node.Checked = true;
}
else
{
newwbsSet4Node.Checked = false;
}
newwbsSet4Node.EnableClickEvent = true;
newwbsSet3Node.Nodes.Add(newwbsSet4Node);
}
}
}
else
{
if (childWbsSets4.Count() > 0)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newwbsSet3Node.Nodes.Add(emptyNode);
}
}
}
}
}
}
else
{
if (childWbsSets3.Count() > 0)
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newwbsSet2Node.Nodes.Add(emptyNode);
}
}
}
}
}
else
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newwbsSet1Node.Nodes.Add(emptyNode);
}
}
}
}
}
else //单位工程下直接是分项内容,如质量行为
{
var wbsSet3s = from x in Funs.DB.Wbs_WbsSet where x.Flag == 3 && x.UnitProjectId == UnitProjectId && x.NoShow == null orderby x.WbsSetCode select x;
if (wbsSet3s.Count() > 0)
{
foreach (var wbsSet3 in wbsSet3s)
{
TreeNode newwbsSet3Node = new TreeNode();
newwbsSet3Node.Text = wbsSet3.WbsSetName;
newwbsSet3Node.NodeID = wbsSet3.WbsSetId;
newwbsSet3Node.CommandName = "wbsSet";
newwbsSet3Node.CommandArgument = wbsSet3.Weights == null ? null : wbsSet3.Weights.ToString();
newwbsSet3Node.ToolTip = wbsSet3.WbsSetCode;
newwbsSet3Node.EnableExpandEvent = true;
newwbsSet3Node.EnableCheckBox = true;
newwbsSet3Node.EnableCheckEvent = true;
if (wbsSet3.IsSelected == true && wbsSet3.IsApprove == null)
{
wbsSet3.IsApprove = true;
BLL.WbsSetService.UpdateWbsSet(wbsSet3);
}
if (wbsSet3.IsApprove == true)
{
newwbsSet3Node.Checked = true;
}
else
{
newwbsSet3Node.Checked = false;
}
newwbsSet3Node.EnableClickEvent = true;
newNodeUnitPorject.Nodes.Add(newwbsSet3Node);
}
}
}
}
else
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newNodeUnitPorject.Nodes.Add(emptyNode);
}
}
}
}
}
else
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
newInstallationNode.Nodes.Add(emptyNode);
}
}
}
else
{
TreeNode emptyNode = new TreeNode();
emptyNode.Text = "";
emptyNode.NodeID = "";
rootNode.Nodes.Add(emptyNode);
}
}
this.trWBS.SelectedNodeID = this.hdSelectId.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.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.WBSSetAuditMenuId);
if (buttonList.Count() > 0)
{
if (buttonList.Contains(BLL.Const.BtnAdd))
{
this.btnMenuAdd.Hidden = false;
this.btnMenuCopy.Hidden = false;
this.btnMenuCopy2.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnModify))
{
this.btnMenuEdit.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnDelete))
{
this.btnMenuDelete.Hidden = false;
}
if (buttonList.Contains(BLL.Const.BtnAuditing))
{
this.btnMenuAudit.Hidden = false;
}
}
}
#endregion
}
}