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

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 UserInfo : System.Web.UI.Page
  12. {
  13.     /// <summary>
  14.     /// 模板 
  15.     /// </summary>
  16.     Model.Department MD = new Model.Department();
  17.     /// <summary>
  18.     /// 业务
  19.     /// </summary>
  20.     BLL.Department BD = new BLL.Department();
  21.     Model.Users nc_Users = new Model.Users();
  22.     BLL.Users bll_Users = new BLL.Users();
  23.     protected void Page_Load(object sender, EventArgs e)
  24.     {
  25.         LoginLogic.MatchLoad("", "UserInfo");
  26.         if (!IsPostBack)
  27.         {
  28.             TreeLoadSet();
  29.             DropLoadSet();
  30.         LoadInfoOneBord();
  31.     }
  32.     }
  33.     public void DropLoadSet()
  34.     {
  35.         KeyValue_DeptId.DataTextField = "DeptName";
  36.         KeyValue_DeptId.DataValueField = "ID";
  37.         KeyValue_DeptId.DataSource = EnumGet.DepartmentGetEnum();
  38.         KeyValue_DeptId.DataBind();
  39.  
  40.         KeyValue_PrivId.DataTextField = "privName";
  41.         KeyValue_PrivId.DataValueField = "ID";
  42.         KeyValue_PrivId.DataSource = new BLL.User_Priv().GetList();
  43.         KeyValue_PrivId.DataBind();
  44.     }
  45.     public void LoadInfoOneBord()
  46.     { 
  47.         object objid=Request.QueryString["id"];
  48.         if (objid != null)
  49.         {
  50.             int IdNum = int.Parse(objid.ToString());
  51.             nc_Users = bll_Users.GetModel(IdNum);
  52.             //基本信息
  53.             KeyValue_UserId.Text = nc_Users.UserId;//用户ID
  54.             KeyValue_UserName.Text = nc_Users.UserName;//用户真实姓名
  55.             KeyValue_DeptId.SelectedValue = nc_Users.DeptId.ToString();//部门
  56.             KeyValue_PrivId.SelectedValue = nc_Users.PrivId.ToString();//角色
  57.             KeyValue_UserNo.Text = nc_Users.UserNo.ToString();
  58.             //用户权限信息
  59.             KeyValue_PostPriv.SelectedValue = nc_Users.PostPriv;//管理范围
  60.             KeyValue_Disabled.Checked = nc_Users.Disabled;//启用或禁用
  61.             KeyValue_UsingKey.Checked = nc_Users.UsingKey;//USBKey是否使用
  62.             if (nc_Users.NotUser == 1)//查看用户列表
  63.             {
  64.                 KeyValue_NotUser.Checked = true;
  65.             }
  66.             else
  67.             {
  68.                 KeyValue_NotUser.Checked = false;
  69.             }
  70.             if (nc_Users.NotTable == 1)//禁止桌面
  71.             {
  72.                 KeyValue_NotTable.Checked = true;
  73.             }
  74.             else
  75.             {
  76.                 KeyValue_NotTable.Checked = false;
  77.             }
  78.             TextBox4.Text = nc_Users.EmailCapacity.ToString();
  79.             TextBox5.Text = nc_Users.FolderCapacity.ToString();
  80.             TextBox6.Text = nc_Users.WebmailNum.ToString();
  81.             TextBox7.Text = nc_Users.WebmailCapacity.ToString();
  82.             TextBox8.Text = nc_Users.BindIp;
  83.             this.KeyValue_UserId2.Text = nc_Users.UserId2;
  84.             if (nc_Users.Sex)
  85.             {
  86.             this.KeyValue_Sex.SelectedValue = "0";
  87.             }
  88.             else
  89.             {
  90.             this.KeyValue_Sex.SelectedValue = "1";
  91.             }
  92.             this.DropDownList6.Text = nc_Users.Birthday.ToString("yyyy");
  93.             this.DropDownList7.Text = nc_Users.Birthday.ToString("MM");
  94.             this.DropDownList8.Text = nc_Users.Birthday.ToString("dd");
  95.             TextBox12.Text = nc_Users.Mobile;
  96.         }
  97.     }
  98.     protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
  99.     {
  100.     }
  101.     protected void TreeLoadSet()
  102.     {
  103.         TreeView1.Nodes.Clear();
  104.         object objcount = OACommon.HLP.ExecuteScalar(CommandType.Text, "select  max(parentdept) from department", null);
  105.         if (objcount != null)
  106.         {
  107.             int AllCount = int.Parse(objcount.ToString());//最深的ID
  108.             List<Model.Department> DPMT = BD.GetList();
  109.             foreach (Model.Department MD in DPMT)
  110.             {
  111.                 if (MD.ParentDept == 0)
  112.                 {
  113.                     TreeNode tn = new TreeNode();
  114.                     tn.Text = MD.DeptName;
  115.                     tn.Value = MD.ID.ToString();
  116.                     tn.ImageUrl = "~/images/node_dept.gif";
  117.                     TreeView1.Nodes.Add(tn);
  118.                 }
  119.             }
  120.             foreach (TreeNode tn in TreeView1.Nodes)
  121.             {
  122.                 CallMeTree(tn);
  123.             }
  124.         }
  125.     }
  126.     /// <summary>
  127.     /// 递归调用
  128.     /// </summary>
  129.     /// <param name="MaxDep"></param>
  130.     /// <param name="DepId"></param>
  131.     public void CallMeTree(TreeNode TNId)
  132.     {
  133.         List<Model.Department> DPMT = BD.GetList();
  134.         foreach (Model.Department MD in DPMT)
  135.         {
  136.             if (MD.ParentDept.ToString() == TNId.Value)
  137.             {
  138.                 TreeNode tn = new TreeNode();
  139.                 tn.Text = MD.DeptName;
  140.                 tn.Value = MD.ID.ToString();
  141.                 tn.ImageUrl = "~/images/node_dept.gif";
  142.                 //  Console.WriteLine(TreeView1.ExpandDepth.ToString());          
  143.                 TNId.ChildNodes.Add(tn);
  144.                 int Count = BD.GetCount("ParentDept=" + tn.Value);
  145.                 if (Count > 0)
  146.                 {
  147.                     CallMeTree(tn);
  148.                 }
  149.             }
  150.         }
  151.     }
  152.     protected void Button1_Click(object sender, EventArgs e)
  153.     {
  154.         LoadSet();
  155.     }
  156.     public void LoadSet()
  157.     {
  158.         try
  159.         {
  160.     
  161.             //UserNo
  162.             int UserNo = 0;
  163.             if (!int.TryParse(this.KeyValue_UserNo.Text, out UserNo))
  164.             {
  165.                 throw new Exception("用户排序号必须为数字!");
  166.             }
  167.             //PrivId
  168.             int PrivId = 0;
  169.             if (!int.TryParse(this.KeyValue_PrivId.SelectedValue, out PrivId))
  170.             {
  171.                 throw new Exception("角色不能为空!");
  172.             }
  173.             nc_Users = bll_Users.GetModel(int.Parse(Request.QueryString["id"].ToString()));
  174.             nc_Users.UserId = this.KeyValue_UserId.Text;
  175.             nc_Users.UserId2 = this.KeyValue_UserId2.Text;
  176.             nc_Users.UserNo = UserNo;
  177.             nc_Users.UserName = this.KeyValue_UserName.Text;
  178.     
  179.             nc_Users.PrivId = PrivId;
  180.             nc_Users.PrivId2 = "";
  181.             nc_Users.PostPriv = this.KeyValue_PostPriv.Text;
  182.             nc_Users.PostDept = "";
  183.             nc_Users.DeptId = int.Parse(this.KeyValue_DeptId.SelectedValue);
  184.             nc_Users.DeptId2 = "";
  185.             nc_Users.CanBroadcast = true;
  186.             if (this.KeyValue_Sex.SelectedValue == "0")
  187.             {
  188.                 nc_Users.Sex = true;
  189.             }
  190.             else
  191.             {
  192.                 nc_Users.Sex = false;
  193.             }
  194.             nc_Users.Birthday = DateTime.Parse(this.DropDownList6.Text + "-" + this.DropDownList7.Text + "-" + this.DropDownList8.Text);
  195.             nc_Users.IsHideBirthday = CheckBox5.Checked;
  196.             nc_Users.TelNoDept = "";
  197.             nc_Users.FaxNoDept = "";
  198.             nc_Users.AddressHome = "";
  199.             nc_Users.ZipHome = "";
  200.             nc_Users.TelHome = "";
  201.             nc_Users.Mobile = "";
  202.             nc_Users.IsHideMobile = false;
  203.             nc_Users.Bp = "";
  204.             nc_Users.Email = "";
  205.             nc_Users.Oicq = "";
  206.             nc_Users.Icq = "";
  207.             nc_Users.Msn = "";
  208.             nc_Users.Skype = "";
  209.             nc_Users.Photo = "";
  210.             nc_Users.NickName = this.KeyValue_UserId.Text;
  211.             nc_Users.Avatar = 0;
  212.             nc_Users.MenuType = false;
  213.             nc_Users.MenuHide = false;
  214.             nc_Users.SmsOn = false;
  215.             nc_Users.CallSound = 1;
  216.             nc_Users.Theme = 1;
  217.             nc_Users.Note = "";
  218.             nc_Users.MytableLeft = "";
  219.             nc_Users.MytableRight = "";
  220.             nc_Users.EmailCapacity = 0;
  221.             nc_Users.FolderCapacity = 0;
  222.             nc_Users.OnlineTime = 10;
  223.             nc_Users.DutyType = 1;
  224.             nc_Users.AttendCard = "00000";
  225.             nc_Users.State = 1;
  226.             nc_Users.LastPassTime = DateTime.Now;
  227.             nc_Users.LastVisitTime = DateTime.Now;
  228.             nc_Users.LastIp = "127.0.0.1";
  229.             nc_Users.Disabled = this.KeyValue_Disabled.Checked;
  230.             nc_Users.BindIp = "";
  231.             nc_Users.UsingKey = this.KeyValue_UsingKey.Checked;
  232.             nc_Users.UGuid = "";
  233.             nc_Users.UKey = "";
  234.             nc_Users.UExt = "";
  235.             if (this.KeyValue_NotUser.Checked)
  236.             {
  237.                 nc_Users.NotUser = 1;
  238.             }
  239.             else
  240.             {
  241.                 nc_Users.NotUser = 0;
  242.             }
  243.             if (this.KeyValue_NotTable.Checked)
  244.             {
  245.                 nc_Users.NotTable = 1;
  246.             }
  247.             else
  248.             {
  249.                 nc_Users.NotTable = 0;
  250.             }
  251.             nc_Users.DefaultMenu = "";
  252.             nc_Users.TablePhoto = "";
  253.             nc_Users.WebmailNum = 0;
  254.             nc_Users.WebmailCapacity = 0;
  255.             nc_Users.AdUserId = "";
  256.             nc_Users.UsingAd = true;
  257.             bll_Users.Update(nc_Users);
  258.             MessageBox.Show("更新成功!");
  259.         }
  260.         catch (Exception exp)
  261.         {
  262.             MessageBox.Show(exp.Message);
  263.         }
  264.     }
  265. }