UserUpdata.aspx.cs
上传用户:tiancihang
上传日期:2014-03-12
资源大小:21387k
文件大小:6k
- using System;
- using System.Data;
- using System.Data.SqlClient;
- using System.Configuration;
- using System.Text;
- using System.Collections;
- 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;
- using System.Net;
- using com.etong.BusinessRule.Zwf;
- public partial class SysManage_UserUpdata : System.Web.UI.Page
- {
- protected string userid = "";
- protected void Page_Load(object sender, EventArgs e)
- {
- EtongZwf etongzwf = new EtongZwf();
- userid = Request.QueryString["userid"].Trim();
- if (!IsPostBack)
- {
- BT_Cancel.Attributes.Add("onclick", "javascript:if(confirm('确定要退出吗?')) {window.close();return;} else {return;}");
- if (userid == "")
- return;
-
- DataView dv = etongzwf.UserSearch(userid, "4",false);
- this.TB_Account.Text = dv[0]["UserAccount"].ToString().Trim();
- this.TB_Decs.Text = dv[0]["UserDecs"].ToString().Trim();
- //this.LB_EmpName.Text = dv[0]["OrgPath"].ToString().Trim() + "/" + dv[0]["EmpName"].ToString().Trim();
- this.TB_address.Text = dv[0]["IPAddress"].ToString();
- TB_employe.Text = dv[0]["EmpName"].ToString();
- ((HtmlInputHidden)this.FindControl("txt_employeid")).Value = dv[0]["EmpID"].ToString();
- ((HtmlInputHidden)this.FindControl("txt_password")).Value = dv[0]["UserPwd"].ToString();
- DataView dvRoleList=etongzwf.RoleGetByID(Convert.ToInt16(userid));
-
- string RoleList = "";
- string RoleIDList = "";
- for( int j=0;j<dvRoleList.Count;j++)
- {
- RoleList = RoleList + dvRoleList[j]["RoleName"].ToString().Trim() + ",";
- RoleIDList = RoleIDList + dvRoleList[j]["RoleID"].ToString().Trim() + ",";
- }
- this.TB_UserRole.Value = RoleList;
- ((HtmlInputHidden)this.FindControl("txt_RoleID")).Value = RoleIDList;
-
- DataView Roles = etongzwf.RoleGetByID(Convert.ToInt16(userid)); //绑定已选角色列表
- this.Select2.DataSource = Roles;
- this.Select2.DataTextField = "RoleName";
- this.Select2.DataValueField = "RoleID";
- this.Select2.DataBind();
-
- this.CB_isIPbound.Checked = false;//初始化checkbox为未选中状态
- this.CB_isLock.Checked = false;
- int islock=Convert.ToInt16(dv[0]["IsLock"].ToString().Trim());
- if (islock == 1)
- this.CB_isLock.Checked = true;
- else
- this.CB_isLock.Checked = false;
- int ipbound = Convert.ToInt16(dv[0]["IsIPBound"].ToString().Trim());
- if (ipbound == 1)
- this.CB_isIPbound.Checked = true;
- else
- this.CB_isIPbound.Checked = false;
- }
- DataView dvRoles=etongzwf.RoleGetAll(); //绑定所有角色列表
- this.Select1.DataSource = dvRoles;
- this.Select1.DataTextField = "RoleName";
- this.Select1.DataValueField = "RoleID";
- this.Select1.DataBind();
- }
- protected void BT_Confirm_Click(object sender, EventArgs e)
- {
- string strHostIP="";
- IPHostEntry iphost = Dns.Resolve(Environment.MachineName);
- if (iphost.AddressList.Length > 0)
- strHostIP = iphost.AddressList[0].ToString();
- string account = this.TB_Account.Text.Trim();
- string decs =this.TB_Decs.Text.Trim();
- HtmlInputHidden txt_employeid = ((HtmlInputHidden)this.FindControl("txt_employeid"));
- string employeid = txt_employeid.Value;
- HtmlInputHidden txt_password = ((HtmlInputHidden)this.FindControl("txt_password"));
- string password = txt_password.Value;
-
- int islock = 0;
- if (this.CB_isLock.Checked == true)
- islock = 1;
- int ipbound = 0;
- if (this.CB_isIPbound.Checked == true)
- ipbound = 1;
-
- EtongZwf etongzwf = new EtongZwf();
- bool returnvalue = false;
- //更新用户基本信息
- returnvalue = etongzwf.UserUpdata(Convert.ToInt32(userid), Convert.ToInt16(employeid), account, account, decs, 2, password, islock, strHostIP, ipbound, DateTime.Now, DateTime.Now, DateTime.Now);
- //更新用户角色权限信息
- etongzwf.UserRoleDelete(Convert.ToInt32(userid)); //清除该用户的角色权限
- HtmlInputHidden txt_RoleID = ((HtmlInputHidden)this.form1.FindControl("txt_RoleID"));
- string RoleID = txt_RoleID.Value;
- string[] cklist = RoleID.Split(new Char[] {','});
- bool returnvalue2 = false;
- for (int j = 0; j < cklist.Length; j++)//添加该用户的角色权限
- {
- if (cklist[j].ToString().Trim() != "")
- {
- int roleid = Convert.ToInt16(cklist[j].ToString().Trim());
- returnvalue2 = etongzwf.UserRoleAdd(Convert.ToInt32(userid), roleid, DateTime.Now);
- if (returnvalue2 == false)
- return;
- }
- }
-
- if (returnvalue && returnvalue2)
- Page.ClientScript.RegisterStartupScript(this.GetType(),"","<script>alert('系统提示:修改记录成功!');window.close();</script>");
- else
- Page.ClientScript.RegisterStartupScript(this.GetType(),"","<script>alert('系统提示:请选择关联角色!');</script>");
- this.TB_Account.Text = "";
- this.TB_Decs.Text = "";
- }
-
- }