SelectUserForm.aspx.cs
上传用户:simon2hong
上传日期:2021-11-18
资源大小:16746k
文件大小:3k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Collections.Generic;
  5. using System.Web;
  6. using System.Web.Security;
  7. using System.Web.UI;
  8. using System.Web.UI.WebControls;
  9. using System.Web.UI.WebControls.WebParts;
  10. using System.Web.UI.HtmlControls;
  11. public partial class SelectForm_SelectUserForm : System.Web.UI.Page
  12. {
  13.     /// <summary>
  14.     /// 模板 
  15.     /// </summary>
  16.     public Model.Users MU = new Model.Users();
  17.     /// <summary>
  18.     /// 业务
  19.     /// </summary>
  20.     public BLL.Users BU = new BLL.Users();
  21.     /// <summary>
  22.     /// 模板 
  23.     /// </summary>
  24.     Model.Department MD = new Model.Department();
  25.     /// <summary>
  26.     /// 业务
  27.     /// </summary>
  28.     BLL.Department BD = new BLL.Department();
  29.     /// <summary>
  30.     /// 查询条件
  31.     /// </summary>
  32.     public string TiaoJian = "";
  33.     protected void Page_Load(object sender, EventArgs e)
  34.     {
  35.         if (!IsPostBack)
  36.         {
  37.             TreeLoadSet();
  38.             TiaoJian = "";
  39.     
  40.         }
  41.     }
  42.    
  43.     protected void TreeLoadSet()
  44.     {
  45.         TreeView1.Nodes.Clear();
  46.         object objcount = OACommon.HLP.ExecuteScalar(CommandType.Text, "select  max(parentdept) from department", null);
  47.         if (objcount != null)
  48.         {
  49.             int AllCount = int.Parse(objcount.ToString());//最深的ID
  50.             List<Model.Department> DPMT = BD.GetList();
  51.             foreach (Model.Department MD in DPMT)
  52.             {
  53.                 if (MD.ParentDept == 0)
  54.                 {
  55.                     TreeNode tn = new TreeNode();
  56.                     tn.Text = MD.DeptName;
  57.                     tn.Value = MD.ID.ToString();
  58.                     tn.Target = "content3";
  59.                     tn.NavigateUrl = "SelectUserFormData.aspx?id=" + MD.ID.ToString();
  60.                     tn.ImageUrl = "~/images/node_dept.gif";
  61.                     TreeView1.Nodes.Add(tn);
  62.                 }
  63.             }
  64.             foreach (TreeNode tn in TreeView1.Nodes)
  65.             {
  66.                 CallMeTree(tn);
  67.             }
  68.         }
  69.     }
  70.     /// <summary>
  71.     /// 递归调用
  72.     /// </summary>
  73.     /// <param name="MaxDep"></param>
  74.     /// <param name="DepId"></param>
  75.     public void CallMeTree(TreeNode TNId)
  76.     {
  77.         List<Model.Department> DPMT = BD.GetList();
  78.         foreach (Model.Department MD in DPMT)
  79.         {
  80.             if (MD.ParentDept.ToString() == TNId.Value)
  81.             {
  82.                 TreeNode tn = new TreeNode();
  83.                 tn.Text = MD.DeptName;
  84.                 tn.Value = MD.ID.ToString();
  85.                 tn.Target = "content3";
  86.                 tn.NavigateUrl = "SelectUserFormData.aspx?id=" + MD.ID.ToString();
  87.                 tn.ImageUrl = "~/images/node_dept.gif";
  88.                 //  Console.WriteLine(TreeView1.ExpandDepth.ToString());          
  89.                 TNId.ChildNodes.Add(tn);
  90.                 int Count = BD.GetCount("ParentDept=" + tn.Value);
  91.                 if (Count > 0)
  92.                 {
  93.                     CallMeTree(tn);
  94.                 }
  95.             }
  96.         }
  97.     }
  98. }