- 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 UserInfo : System.Web.UI.Page
- {
- /// <summary>
- /// 模板
- /// </summary>
- Model.Department MD = new Model.Department();
- /// <summary>
- /// 业务
- /// </summary>
- BLL.Department BD = new BLL.Department();
- Model.Users nc_Users = new Model.Users();
- BLL.Users bll_Users = new BLL.Users();
- protected void Page_Load(object sender, EventArgs e)
- {
- LoginLogic.MatchLoad("", "UserInfo");
- if (!IsPostBack)
- {
- TreeLoadSet();
- DropLoadSet();
- LoadInfoOneBord();
- }
- }
- public void DropLoadSet()
- {
- KeyValue_DeptId.DataTextField = "DeptName";
- KeyValue_DeptId.DataValueField = "ID";
- KeyValue_DeptId.DataSource = EnumGet.DepartmentGetEnum();
- KeyValue_DeptId.DataBind();
- KeyValue_PrivId.DataTextField = "privName";
- KeyValue_PrivId.DataValueField = "ID";
- KeyValue_PrivId.DataSource = new BLL.User_Priv().GetList();
- KeyValue_PrivId.DataBind();
- }
- public void LoadInfoOneBord()
- {
- object objid=Request.QueryString["id"];
- if (objid != null)
- {
- int IdNum = int.Parse(objid.ToString());
- nc_Users = bll_Users.GetModel(IdNum);
- //基本信息
- KeyValue_UserId.Text = nc_Users.UserId;//用户ID
- KeyValue_UserName.Text = nc_Users.UserName;//用户真实姓名
- KeyValue_DeptId.SelectedValue = nc_Users.DeptId.ToString();//部门
- KeyValue_PrivId.SelectedValue = nc_Users.PrivId.ToString();//角色
- KeyValue_UserNo.Text = nc_Users.UserNo.ToString();
- //用户权限信息
- KeyValue_PostPriv.SelectedValue = nc_Users.PostPriv;//管理范围
- KeyValue_Disabled.Checked = nc_Users.Disabled;//启用或禁用
- KeyValue_UsingKey.Checked = nc_Users.UsingKey;//USBKey是否使用
- if (nc_Users.NotUser == 1)//查看用户列表
- {
- KeyValue_NotUser.Checked = true;
- }
- else
- {
- KeyValue_NotUser.Checked = false;
- }
- if (nc_Users.NotTable == 1)//禁止桌面
- {
- KeyValue_NotTable.Checked = true;
- }
- else
- {
- KeyValue_NotTable.Checked = false;
- }
- TextBox4.Text = nc_Users.EmailCapacity.ToString();
- TextBox5.Text = nc_Users.FolderCapacity.ToString();
- TextBox6.Text = nc_Users.WebmailNum.ToString();
- TextBox7.Text = nc_Users.WebmailCapacity.ToString();
- TextBox8.Text = nc_Users.BindIp;
- this.KeyValue_UserId2.Text = nc_Users.UserId2;
- if (nc_Users.Sex)
- {
- this.KeyValue_Sex.SelectedValue = "0";
- }
- else
- {
- this.KeyValue_Sex.SelectedValue = "1";
- }
- this.DropDownList6.Text = nc_Users.Birthday.ToString("yyyy");
- this.DropDownList7.Text = nc_Users.Birthday.ToString("MM");
- this.DropDownList8.Text = nc_Users.Birthday.ToString("dd");
- TextBox12.Text = nc_Users.Mobile;
- }
- }
- protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
- {
- }
- 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.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.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);
- }
- }
- }
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- LoadSet();
- }
- public void LoadSet()
- {
- try
- {
- //UserNo
- int UserNo = 0;
- if (!int.TryParse(this.KeyValue_UserNo.Text, out UserNo))
- {
- throw new Exception("用户排序号必须为数字!");
- }
- //PrivId
- int PrivId = 0;
- if (!int.TryParse(this.KeyValue_PrivId.SelectedValue, out PrivId))
- {
- throw new Exception("角色不能为空!");
- }
- nc_Users = bll_Users.GetModel(int.Parse(Request.QueryString["id"].ToString()));
- nc_Users.UserId = this.KeyValue_UserId.Text;
- nc_Users.UserId2 = this.KeyValue_UserId2.Text;
- nc_Users.UserNo = UserNo;
- nc_Users.UserName = this.KeyValue_UserName.Text;
- nc_Users.PrivId = PrivId;
- nc_Users.PrivId2 = "";
- nc_Users.PostPriv = this.KeyValue_PostPriv.Text;
- nc_Users.PostDept = "";
- nc_Users.DeptId = int.Parse(this.KeyValue_DeptId.SelectedValue);
- nc_Users.DeptId2 = "";
- nc_Users.CanBroadcast = true;
- if (this.KeyValue_Sex.SelectedValue == "0")
- {
- nc_Users.Sex = true;
- }
- else
- {
- nc_Users.Sex = false;
- }
- nc_Users.Birthday = DateTime.Parse(this.DropDownList6.Text + "-" + this.DropDownList7.Text + "-" + this.DropDownList8.Text);
- nc_Users.IsHideBirthday = CheckBox5.Checked;
- nc_Users.TelNoDept = "";
- nc_Users.FaxNoDept = "";
- nc_Users.AddressHome = "";
- nc_Users.ZipHome = "";
- nc_Users.TelHome = "";
- nc_Users.Mobile = "";
- nc_Users.IsHideMobile = false;
- nc_Users.Bp = "";
- nc_Users.Email = "";
- nc_Users.Oicq = "";
- nc_Users.Icq = "";
- nc_Users.Msn = "";
- nc_Users.Skype = "";
- nc_Users.Photo = "";
- nc_Users.NickName = this.KeyValue_UserId.Text;
- nc_Users.Avatar = 0;
- nc_Users.MenuType = false;
- nc_Users.MenuHide = false;
- nc_Users.SmsOn = false;
- nc_Users.CallSound = 1;
- nc_Users.Theme = 1;
- nc_Users.Note = "";
- nc_Users.MytableLeft = "";
- nc_Users.MytableRight = "";
- nc_Users.EmailCapacity = 0;
- nc_Users.FolderCapacity = 0;
- nc_Users.OnlineTime = 10;
- nc_Users.DutyType = 1;
- nc_Users.AttendCard = "00000";
- nc_Users.State = 1;
- nc_Users.LastPassTime = DateTime.Now;
- nc_Users.LastVisitTime = DateTime.Now;
- nc_Users.LastIp = "127.0.0.1";
- nc_Users.Disabled = this.KeyValue_Disabled.Checked;
- nc_Users.BindIp = "";
- nc_Users.UsingKey = this.KeyValue_UsingKey.Checked;
- nc_Users.UGuid = "";
- nc_Users.UKey = "";
- nc_Users.UExt = "";
- if (this.KeyValue_NotUser.Checked)
- {
- nc_Users.NotUser = 1;
- }
- else
- {
- nc_Users.NotUser = 0;
- }
- if (this.KeyValue_NotTable.Checked)
- {
- nc_Users.NotTable = 1;
- }
- else
- {
- nc_Users.NotTable = 0;
- }
- nc_Users.DefaultMenu = "";
- nc_Users.TablePhoto = "";
- nc_Users.WebmailNum = 0;
- nc_Users.WebmailCapacity = 0;
- nc_Users.AdUserId = "";
- nc_Users.UsingAd = true;
- bll_Users.Update(nc_Users);
- MessageBox.Show("更新成功!");
- }
- catch (Exception exp)
- {
- MessageBox.Show(exp.Message);
- }
- }
- }