- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections.Generic;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- public partial class SelectForm_SelectUserForm : System.Web.UI.Page
- {
- /// <summary>
- /// 模板
- /// </summary>
- public Model.Users MU = new Model.Users();
- /// <summary>
- /// 业务
- /// </summary>
- public BLL.Users BU = new BLL.Users();
- /// <summary>
- /// 模板
- /// </summary>
- Model.Department MD = new Model.Department();
- /// <summary>
- /// 业务
- /// </summary>
- BLL.Department BD = new BLL.Department();
- /// <summary>
- /// 查询条件
- /// </summary>
- public string TiaoJian = "";
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- TreeLoadSet();
- TiaoJian = "";
- }
- }
- protected void TreeLoadSet()
- {
- TreeView1.Nodes.Clear();
- object objcount = OACommon.HLP.ExecuteScalar(CommandType.Text, "select max(parentdept) from department", null);
- if (objcount != null)
- {
- int AllCount = int.Parse(objcount.ToString());//最深的ID
- List<Model.Department> DPMT = BD.GetList();
- foreach (Model.Department MD in DPMT)
- {
- if (MD.ParentDept == 0)
- {
- TreeNode tn = new TreeNode();
- tn.Text = MD.DeptName;
- tn.Value = MD.ID.ToString();
- tn.Target = "content3";
- tn.NavigateUrl = "SelectUserFormData.aspx?id=" + MD.ID.ToString();
- tn.ImageUrl = "~/images/node_dept.gif";
- TreeView1.Nodes.Add(tn);
- }
- }
- foreach (TreeNode tn in TreeView1.Nodes)
- {
- CallMeTree(tn);
- }
- }
- }
- /// <summary>
- /// 递归调用
- /// </summary>
- /// <param name="MaxDep"></param>
- /// <param name="DepId"></param>
- public void CallMeTree(TreeNode TNId)
- {
- List<Model.Department> DPMT = BD.GetList();
- foreach (Model.Department MD in DPMT)
- {
- if (MD.ParentDept.ToString() == TNId.Value)
- {
- TreeNode tn = new TreeNode();
- tn.Text = MD.DeptName;
- tn.Value = MD.ID.ToString();
- tn.Target = "content3";
- tn.NavigateUrl = "SelectUserFormData.aspx?id=" + MD.ID.ToString();
- tn.ImageUrl = "~/images/node_dept.gif";
- // Console.WriteLine(TreeView1.ExpandDepth.ToString());
- TNId.ChildNodes.Add(tn);
- int Count = BD.GetCount("ParentDept=" + tn.Value);
- if (Count > 0)
- {
- CallMeTree(tn);
- }
- }
- }
- }
- }