246 lines
9.7 KiB
C#
246 lines
9.7 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace FineUIPro.Web.DigData
|
|
{
|
|
public partial class ShowProjectWBS : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string WorkPackageId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["WorkPackageId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["WorkPackageId"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
string level = Request.Params["level"];
|
|
if (!string.IsNullOrEmpty(level))
|
|
{
|
|
this.ckLevel.SelectedValue = level;
|
|
this.ckLevel.Readonly = true;
|
|
}
|
|
|
|
////加载树
|
|
SetSubUnitProjectTree(this.trWBS);
|
|
|
|
}
|
|
}
|
|
|
|
#region 绑定WBS
|
|
/// <summary>
|
|
/// 绑定WBS
|
|
/// </summary>
|
|
/// <param name="trWBS"></param>
|
|
public void SetSubUnitProjectTree(FineUIPro.Tree trWBS)
|
|
{
|
|
this.trWBS.Nodes.Clear();
|
|
this.trWBS.ShowBorder = false;
|
|
this.trWBS.ShowHeader = false;
|
|
this.trWBS.EnableIcons = true;
|
|
this.trWBS.AutoScroll = true;
|
|
this.trWBS.EnableSingleClickExpand = true;
|
|
|
|
TreeNode rootNode1 = new TreeNode();
|
|
rootNode1.Text = "建筑工程";
|
|
rootNode1.NodeID = "1";
|
|
rootNode1.CommandName = "ProjectType";
|
|
rootNode1.EnableExpandEvent = true;
|
|
rootNode1.EnableClickEvent = true;
|
|
this.trWBS.Nodes.Add(rootNode1);
|
|
TreeNode emptyNode = new TreeNode();
|
|
emptyNode.Text = "";
|
|
emptyNode.NodeID = "";
|
|
rootNode1.Nodes.Add(emptyNode);
|
|
//this.GetNodes(rootNode1.Nodes, rootNode1.NodeID);
|
|
|
|
TreeNode rootNode2 = new TreeNode();
|
|
rootNode2.Text = "安装工程";
|
|
rootNode2.NodeID = "2";
|
|
rootNode2.CommandName = "ProjectType";
|
|
rootNode2.EnableExpandEvent = true;
|
|
rootNode2.EnableClickEvent = true;
|
|
this.trWBS.Nodes.Add(rootNode2);
|
|
rootNode2.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();
|
|
if (e.Node.CommandName == "ProjectType") //展开工程类型
|
|
{
|
|
var trUnitWork = from x in Funs.DB.WBS_UnitWork
|
|
where x.ProjectId == this.CurrUser.LoginProjectId && x.SuperUnitWork == null && x.ProjectType == e.Node.NodeID
|
|
select x;
|
|
trUnitWork = trUnitWork.OrderBy(x => x.UnitWorkCode);
|
|
if (trUnitWork.Count() > 0)
|
|
{
|
|
foreach (var trUnitWorkItem in trUnitWork)
|
|
{
|
|
TreeNode newNode = new TreeNode();
|
|
newNode.Text = trUnitWorkItem.UnitWorkCode + "-" + trUnitWorkItem.UnitWorkName;
|
|
newNode.NodeID = trUnitWorkItem.UnitWorkId;
|
|
newNode.CommandName = "UnitWork";
|
|
|
|
newNode.EnableExpandEvent = true;
|
|
newNode.EnableClickEvent = true;
|
|
e.Node.Nodes.Add(newNode);
|
|
|
|
if (BLL.WorkPackageService.GetWorkPackages1ByUnitWorkId(trUnitWorkItem.UnitWorkId.ToString()) != null)
|
|
{
|
|
TreeNode temp = new TreeNode();
|
|
temp.Text = "temp";
|
|
temp.NodeID = "temp";
|
|
newNode.Nodes.Add(temp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (e.Node.CommandName == "UnitWork") //展开单位工程节点
|
|
{
|
|
var workPackages = from x in Funs.DB.WBS_WorkPackage where x.UnitWorkId == e.NodeID && x.SuperWorkPack == null && x.IsApprove == true orderby x.WorkPackageCode select x;
|
|
foreach (var workPackage in workPackages)
|
|
{
|
|
TreeNode newNode = new TreeNode();
|
|
newNode.Text = workPackage.PackageContent;
|
|
newNode.NodeID = workPackage.WorkPackageId;
|
|
newNode.ToolTip = "[" + workPackage.InitWorkPackageCode + "]";
|
|
newNode.CommandName = "WorkPackage";
|
|
newNode.EnableExpandEvent = true;
|
|
newNode.EnableClickEvent = true;
|
|
e.Node.Nodes.Add(newNode);
|
|
var childWorkPackages = from x in Funs.DB.WBS_WorkPackage where x.SuperWorkPackageId == workPackage.WorkPackageId && x.IsApprove == true select x;
|
|
if (childWorkPackages.Count() > 0)
|
|
{
|
|
TreeNode emptyNode = new TreeNode();
|
|
emptyNode.Text = "";
|
|
emptyNode.NodeID = "";
|
|
newNode.Nodes.Add(emptyNode);
|
|
}
|
|
}
|
|
}
|
|
else if (e.Node.CommandName == "WorkPackage") //展开工作包节点
|
|
{
|
|
var workPackages = from x in Funs.DB.WBS_WorkPackage where x.SuperWorkPackageId == e.Node.NodeID && x.IsApprove == true orderby x.WorkPackageCode select x;
|
|
if (workPackages.Count() > 0) //存在子单位工程
|
|
{
|
|
foreach (var workPackage in workPackages)
|
|
{
|
|
TreeNode newNode = new TreeNode();
|
|
newNode.Text = workPackage.PackageContent;
|
|
newNode.NodeID = workPackage.WorkPackageId;
|
|
newNode.CommandName = "WorkPackage";
|
|
newNode.ToolTip="["+ workPackage.InitWorkPackageCode+"]";
|
|
newNode.EnableExpandEvent = true;
|
|
newNode.EnableClickEvent = true;
|
|
e.Node.Nodes.Add(newNode);
|
|
var childWorkPackages = from x in Funs.DB.WBS_WorkPackage where x.SuperWorkPackageId == workPackage.WorkPackageId && x.IsApprove == true select x;
|
|
if (childWorkPackages.Count() > 0)
|
|
{
|
|
TreeNode emptyNode = new TreeNode();
|
|
emptyNode.Text = "";
|
|
emptyNode.NodeID = "";
|
|
newNode.Nodes.Add(emptyNode);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
protected void ckLevel_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
////加载树
|
|
SetSubUnitProjectTree(this.trWBS);
|
|
}
|
|
|
|
protected void btnSure_Click(object sender, EventArgs e)
|
|
{
|
|
if (this.trWBS.SelectedNode != null)
|
|
{
|
|
///Type1|0a1e39d1-693d-4b5f-a2f5-870dda8b9ff2|c0f20302-88e6-4415-9a86-06be5730c420[67]|c76e251e-d690-4d0e-959b-3b618701f6ff[6701]&建筑工程|083-全场管廊|框架/管廊|地基与基础
|
|
///返回 树 父节点ID+[初始WBS主键]+"|" +节点ID+[初始WBS主键]+"&"+树父节点名称+"|"+ 节点名称
|
|
string selectValues = getSelectIds(this.trWBS.SelectedNode, this.trWBS.SelectedNodeID+this.trWBS.SelectedNode.ToolTip) + "&" + getSelectNames(this.trWBS.SelectedNode, this.trWBS.SelectedNode.Text);
|
|
if (!string.IsNullOrEmpty(selectValues))
|
|
{
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetWriteBackValueReference(selectValues) + ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Alert.ShowInParent("请选择节点!", MessageBoxIcon.Warning);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// id
|
|
/// </summary>
|
|
/// <param name="node"></param>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
private string getSelectIds(TreeNode node,string id)
|
|
{
|
|
if (node.ParentNode != null)
|
|
{
|
|
if (node.ParentNode.NodeID == "1" || node.ParentNode.NodeID == "2")
|
|
{
|
|
id = "Type" + node.ParentNode.NodeID + "|" + id;
|
|
}
|
|
else
|
|
{
|
|
id = getSelectIds(node.ParentNode, node.ParentNode.NodeID + node.ParentNode.ToolTip + "|" + id);
|
|
}
|
|
}
|
|
|
|
return id;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 名称
|
|
/// </summary>
|
|
/// <param name="node"></param>
|
|
/// <param name="name"></param>
|
|
/// <returns></returns>
|
|
private string getSelectNames(TreeNode node, string name)
|
|
{
|
|
if (node.ParentNode != null)
|
|
{
|
|
if (node.ParentNode.NodeID == "1" || node.ParentNode.NodeID == "2")
|
|
{
|
|
name = node.ParentNode.Text + "|" + name;
|
|
}
|
|
else
|
|
{
|
|
name = getSelectNames(node.ParentNode, node.ParentNode.Text + "|" + name);
|
|
}
|
|
}
|
|
|
|
return name;
|
|
}
|
|
}
|
|
} |