199 lines
6.9 KiB
C#
199 lines
6.9 KiB
C#
using BLL;
|
|
using System;
|
|
using System.Data;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.Controls
|
|
{
|
|
public partial class WBSControl : System.Web.UI.UserControl
|
|
{
|
|
public string WorkPackageCode
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["WorkPackageCode"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["WorkPackageCode"] = value;
|
|
}
|
|
}
|
|
|
|
public string Level
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["Level"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["Level"] = value;
|
|
}
|
|
}
|
|
|
|
public bool IsShowAll
|
|
{
|
|
get;
|
|
set;
|
|
} = true;
|
|
|
|
|
|
#region 加载页面
|
|
/// <summary>
|
|
/// 加载页面
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
if (!IsShowAll)
|
|
{
|
|
this.ckLevel.Items.Remove(this.ckLevel.Items[0]);
|
|
this.ckLevel.SelectedIndex = 0;
|
|
}
|
|
|
|
////加载树
|
|
SetSubUnitProjectTree(this.trWBS);
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void trWBS_NodeCommand(object sender, TreeCommandEventArgs e)
|
|
{
|
|
this.Level = this.ckLevel.SelectedValue;
|
|
if (this.trWBS != null && !string.IsNullOrEmpty(this.trWBS.SelectedNodeID))
|
|
{
|
|
this.WorkPackageCode = this.trWBS.SelectedNodeID;
|
|
if (this.change != null)
|
|
{
|
|
this.change(this, e);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void ckLevel_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.Level = this.ckLevel.SelectedValue;
|
|
if (this.trWBS != null && !string.IsNullOrEmpty(this.trWBS.SelectedNodeID))
|
|
{
|
|
this.WorkPackageCode = this.trWBS.SelectedNodeID;
|
|
}
|
|
////加载树
|
|
SetSubUnitProjectTree(this.trWBS);
|
|
if (this.change != null)
|
|
{
|
|
this.change(this, e);
|
|
}
|
|
}
|
|
|
|
public delegate void userEvent(object sender, EventArgs arg);
|
|
|
|
public event userEvent change;
|
|
|
|
|
|
#region 绑定分公司 单位-项目树
|
|
/// <summary>
|
|
/// 绑定分公司 单位-项目树
|
|
/// </summary>
|
|
/// <param name="trWBS"></param>
|
|
/// <param name="CurrUser"></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);
|
|
|
|
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 workPackages = from x in Funs.DB.WBS_WorkPackageInit where x.ProjectType == e.NodeID && x.SuperWorkPack == null orderby x.WorkPackageCode select x;
|
|
foreach (var workPackage in workPackages)
|
|
{
|
|
TreeNode newNode = new TreeNode();
|
|
newNode.Text = workPackage.PackageContent;
|
|
newNode.NodeID = workPackage.WorkPackageCode;
|
|
newNode.CommandName = "WorkPackage";
|
|
newNode.EnableExpandEvent = true;
|
|
newNode.EnableClickEvent = true;
|
|
e.Node.Nodes.Add(newNode);
|
|
var childWorkPackages = from x in Funs.DB.WBS_WorkPackageInit where x.SuperWorkPack == workPackage.WorkPackageCode 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_WorkPackageInit where x.SuperWorkPack == e.Node.NodeID 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.WorkPackageCode;
|
|
newNode.CommandName = "WorkPackage";
|
|
newNode.EnableExpandEvent = true;
|
|
newNode.EnableClickEvent = true;
|
|
e.Node.Nodes.Add(newNode);
|
|
var childWorkPackages = from x in Funs.DB.WBS_WorkPackageInit where x.SuperWorkPack == workPackage.WorkPackageCode select x;
|
|
if (childWorkPackages.Count() > 0)
|
|
{
|
|
TreeNode emptyNode = new TreeNode();
|
|
emptyNode.Text = "";
|
|
emptyNode.NodeID = "";
|
|
newNode.Nodes.Add(emptyNode);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |