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

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 UserManager : 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.        
  38.             TreeView1.Attributes.Add("OnClick", "OnTreeNodeChecked()");  
  39.             TreeLoadSet();
  40.             TiaoJian = "";
  41.             MyDataBind(1);
  42.         }
  43.     }
  44.     /// <summary>
  45.     /// 获取信息
  46.     /// </summary>
  47.     /// <param name="pidx">页号</param>
  48.     public void MyDataBind(int pidx)
  49.     {
  50.         AspNetPager1.RecordCount = BU.GetCount(TiaoJian);
  51.         GridView1.DataSource = BU.GetPageList(10, pidx, "ID", false, TiaoJian);
  52.         GridView1.DataBind();
  53.     }
  54.     protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
  55.     {
  56.         MyDataBind(e.NewPageIndex);
  57.     }
  58.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  59.     {
  60.         for (int i = 0; i < GridView1.Rows.Count; i++)
  61.         {
  62.             //首先判断是否是数据行
  63.             //if (e.Row.RowType == DataControlRowType.DataRow)
  64.             //{
  65.                 //当鼠标停留时更改背景色
  66.                 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F0F0FF';");
  67.                 //当鼠标移开时还原背景色
  68.                 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
  69.             //}
  70.         }
  71.     }
  72.     
  73.     protected void TreeLoadSet()
  74.     {
  75.         TreeView1.Nodes.Clear();
  76.         object objcount = OACommon.HLP.ExecuteScalar(CommandType.Text, "select  max(parentdept) from department", null);
  77.         if (objcount != null)
  78.         {
  79.             int AllCount = int.Parse(objcount.ToString());//最深的ID
  80.             List<Model.Department> DPMT = BD.GetList();
  81.             foreach (Model.Department MD in DPMT)
  82.             {
  83.                 if (MD.ParentDept == 0)
  84.                 {
  85.                     TreeNode tn = new TreeNode();
  86.                     tn.Text =  MD.DeptName ;
  87.                     tn.Value = MD.ID.ToString();
  88.                     tn.SelectAction = TreeNodeSelectAction.None;
  89.                     tn.ImageUrl = "~/images/node_dept.gif";
  90.                     TreeView1.Nodes.Add(tn);
  91.                 }
  92.             }
  93.             foreach (TreeNode tn in TreeView1.Nodes)
  94.             {
  95.                 CallMeTree(tn);
  96.             }
  97.         }
  98.     }
  99.     /// <summary>
  100.     /// 递归调用
  101.     /// </summary>
  102.     /// <param name="MaxDep"></param>
  103.     /// <param name="DepId"></param>
  104.     public void CallMeTree(TreeNode TNId)
  105.     {
  106.         List<Model.Department> DPMT = BD.GetList();
  107.         foreach (Model.Department MD in DPMT)
  108.         {
  109.             if (MD.ParentDept.ToString() == TNId.Value)
  110.             {
  111.                 TreeNode tn = new TreeNode();
  112.                 tn.Text = MD.DeptName;
  113.                 tn.Value = MD.ID.ToString();
  114.                 tn.ImageUrl = "~/images/node_dept.gif";
  115.                 //  Console.WriteLine(TreeView1.ExpandDepth.ToString());          
  116.                 TNId.ChildNodes.Add(tn);
  117.                 int Count = BD.GetCount("ParentDept=" + tn.Value);
  118.                 if (Count > 0)
  119.                 {
  120.                     CallMeTree(tn);
  121.                 }
  122.             }
  123.         }
  124.     }
  125.     //protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
  126.     //{
  127.     //    TiaoJian = "DeptId="+TreeView1.SelectedValue;
  128.     //    MyDataBind(1);
  129.     //}
  130. }