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

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.         LoginLogic.MatchLoad("", "UserManager");
  36.         if (!IsPostBack)
  37.         {
  38.             TreeLoadSet();
  39.             TiaoJian = "";
  40.             MyDataBind(1);
  41.         }
  42.     }
  43.     /// <summary>
  44.     /// 获取信息
  45.     /// </summary>
  46.     /// <param name="pidx">页号</param>
  47.     public void MyDataBind(int pidx)
  48.     {
  49.         AspNetPager1.RecordCount = BU.GetCount(TiaoJian);
  50.         GridView1.DataSource = BU.GetPageList(20, pidx, "ID", false, TiaoJian);
  51.         GridView1.DataBind();
  52.     }
  53.     protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
  54.     {
  55.         MyDataBind(e.NewPageIndex);
  56.     }
  57.     protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  58.     {
  59.         for (int i = 0; i < GridView1.Rows.Count; i++)
  60.         {
  61.             //首先判断是否是数据行
  62.             if (e.Row.RowType == DataControlRowType.DataRow)
  63.             {
  64.                 //当鼠标停留时更改背景色
  65.                 e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#F0F0F0'");
  66.                 //当鼠标移开时还原背景色
  67.                 e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");//5|1|a|s|p|x
  68.             }
  69.         }
  70.     }
  71.     /// <summary>
  72.     /// 角色
  73.     /// </summary>
  74.     /// <returns></returns>
  75.     public string JueSe()
  76.     {
  77.         int Id = int.Parse(Eval("PrivId").ToString());
  78.      return   OACommon.GetRole(Id);
  79.   
  80.     }
  81.     /// <summary>
  82.     /// 部门
  83.     /// </summary>
  84.     /// <returns></returns>
  85.     public string BuMen()
  86.     {
  87.         int Id = int.Parse(Eval("DeptId").ToString());
  88.         return OACommon.GetDept(Id);
  89.     }
  90.         /// <summary>
  91.     /// 帐户状态
  92.     /// </summary>
  93.     /// <returns></returns>
  94.     public string ZhuangTai()
  95.     {
  96.         bool Id = bool.Parse(Eval("Disabled").ToString());
  97.         if (Id )
  98.         {
  99.             return "禁用";
  100.         }
  101.         else
  102.         {
  103.             return "启用";
  104.         }
  105.         
  106.     }
  107.     /// <summary>
  108.     /// 操作
  109.     /// </summary>
  110.     /// <returns></returns>
  111.     public string CaoZuo()
  112.     {
  113.         string Id = Eval("Id").ToString();
  114.         //编辑 清空密码 删除
  115.         string Rtstr = "<a href='UserInfo.aspx?id=" + Id + "'>编辑</a>&nbsp;&nbsp;";
  116.         Rtstr += "<a href='ResponseReBack/ClearUserPassWord.aspx?id=" + Id + "'>清空密码</a>&nbsp;&nbsp;";
  117.         Rtstr += "<a href='ResponseReBack/DelUser.aspx?id=" + Id + "'>删除</a>&nbsp;&nbsp;";
  118.         return Rtstr;
  119.     }
  120.     
  121.     protected void TreeLoadSet()
  122.     {
  123.         TreeView1.Nodes.Clear();
  124.         object objcount = OACommon.HLP.ExecuteScalar(CommandType.Text, "select  max(parentdept) from department", null);
  125.         if (objcount != null)
  126.         {
  127.             int AllCount = int.Parse(objcount.ToString());//最深的ID
  128.             List<Model.Department> DPMT = BD.GetList();
  129.             foreach (Model.Department MD in DPMT)
  130.             {
  131.                 if (MD.ParentDept == 0)
  132.                 {
  133.                     TreeNode tn = new TreeNode();
  134.                     tn.Text = MD.DeptName;
  135.                     tn.Value = MD.ID.ToString();
  136.                     tn.ImageUrl = "~/images/node_dept.gif";
  137.                     TreeView1.Nodes.Add(tn);
  138.                 }
  139.             }
  140.             foreach (TreeNode tn in TreeView1.Nodes)
  141.             {
  142.                 CallMeTree(tn);
  143.             }
  144.         }
  145.     }
  146.     /// <summary>
  147.     /// 递归调用
  148.     /// </summary>
  149.     /// <param name="MaxDep"></param>
  150.     /// <param name="DepId"></param>
  151.     public void CallMeTree(TreeNode TNId)
  152.     {
  153.         List<Model.Department> DPMT = BD.GetList();
  154.         foreach (Model.Department MD in DPMT)
  155.         {
  156.             if (MD.ParentDept.ToString() == TNId.Value)
  157.             {
  158.                 TreeNode tn = new TreeNode();
  159.                 tn.Text = MD.DeptName;
  160.                 tn.Value = MD.ID.ToString();
  161.                 tn.ImageUrl = "~/images/node_dept.gif";
  162.                 //  Console.WriteLine(TreeView1.ExpandDepth.ToString());          
  163.                 TNId.ChildNodes.Add(tn);
  164.                 int Count = BD.GetCount("ParentDept=" + tn.Value);
  165.                 if (Count > 0)
  166.                 {
  167.                     CallMeTree(tn);
  168.                 }
  169.             }
  170.         }
  171.     }
  172.     protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
  173.     {
  174.         TiaoJian = "DeptId="+TreeView1.SelectedValue;
  175.         MyDataBind(1);
  176.     }
  177. }