/// <summary> /// 将数据填充到页面显示 /// </summary> /// <param name="info">实体类数据</param> protected void BindPage(T_UserInfo info) { txtUserName.Value = info.UserName; txtUserPWD.Value = "123456"; txtRealName.Value = info.RealName; txtDep.Value = info.Dep; txtEmail.Value = info.Email; txtTel.Value = info.Tel; ddlRole.SelectedValue = info.RoleID.ToString(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindDDL(ddlRole); T_UserInfo userInfo = new T_UserInfo(); userInfo = BLLFactory<T_UserInfoManager>.Instance.FindByID(LoginUser.Instance.UserID); BindPage(userInfo); } }
/// <summary> /// 将数据填充到页面显示 /// </summary> /// <param name="info">实体类数据</param> protected void BindPage(T_UserInfo info) { txtUserName.Value = info.UserName; if(Mode=="edit") { txtUserPWD.Disabled = true; } // txtUserPWD.Value = "123456"; txtRealName.Value = info.RealName; txtDep.Value = info.Dep; txtEmail.Value = info.Email; txtTel.Value = info.Tel; ddlRole.SelectedValue = info.RoleID.ToString(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Mode = Request.QueryString["action"]; string id = Request.QueryString["id"] as string; BindDDL(ddlRole); if (!string.IsNullOrEmpty(id)) { T_UserInfo userInfo = new T_UserInfo(); userInfo = BLLFactory<T_UserInfoManager>.Instance.FindByID(id); BindPage(userInfo); ViewState["ID"] = id; } } }
protected void btn_Click(object sender, EventArgs eventArgs) { string js = "alert('操作失败!');"; T_UserInfo user = new T_UserInfo(); user.UserName = Util.querySQL(txtUserName.Value.Trim()); if (!string.IsNullOrEmpty(txtUserPWD.Value)) { user.UserPWD = Util.SHA1(txtUserPWD.Value); } user.RealName = Util.querySQL(txtRealName.Value.Trim()); user.Dep = Util.querySQL(txtDep.Value.Trim()); user.Email = Util.querySQL(txtEmail.Value.Trim()); user.Tel = Util.querySQL(txtTel.Value.Trim()); user.Status = 1; user.RoleID = int.Parse(ddlRole.SelectedValue); user.CreatTime = DateTime.Now; if (Mode == "add") { //新增 if (BLLFactory<T_UserInfoManager>.Instance.Insert(user)) { js = "window.opener.select();window.close();"; } } else { //修改 if (BLLFactory<T_UserInfoManager>.Instance.Edit(user, ViewState["ID"].ToString())>0) { js = "window.opener.select();window.close();"; } } Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", js, true); }
protected void btn_Click(object sender, EventArgs e) { string js = "alert('操作失败!');"; T_UserInfo user = new T_UserInfo(); user.UserID = int.Parse(LoginUser.Instance.UserID); user.UserName = Util.querySQL(txtUserName.Value.Trim()); user.UserPWD = Util.SHA1(txtUserPWD.Value); user.RealName = Util.querySQL(txtRealName.Value.Trim()); user.Dep = Util.querySQL(txtDep.Value.Trim()); user.Email = Util.querySQL(txtEmail.Value.Trim()); user.Tel = Util.querySQL(txtTel.Value.Trim()); if(!string.IsNullOrEmpty(txtUserPWD.Value)) { user.UserPWD = Util.SHA1(txtUserPWD.Value); } //修改 if (BLLFactory<T_UserInfoManager>.Instance.Edit(user)>0) { js = "window.close();"; } Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "", js, true); }
protected void loginBtn_Click(object sender, EventArgs e) { var userName = Util.querySQL(idInput.Value.Trim()); if (string.IsNullOrEmpty(userName)) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "alert('用户名不能为空!');", true); return; } var userPwd = pwdInput.Value; if (string.IsNullOrEmpty(userPwd)) { Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "alert('密码不能为空!');", true); return; } var loginuser = new T_UserInfo(); loginuser.UserName = userName; loginuser.UserPWD = Util.SHA1(userPwd); var currUser = new T_UserInfo(); if (BLLFactory<T_UserInfoManager>.Instance.Login(loginuser, out currUser)) { Session.Add("UserID", currUser.UserID.ToString()); Session.Add("UserName", currUser.UserName); Session.Add("RealName", currUser.RealName); Session.Add("Email", currUser.Email); Session.Add("Tel", currUser.Tel); Session.Add("RoleID", currUser.RoleID.ToString()); FormsAuthentication.SetAuthCookie(currUser.UserID.ToString(), false); FormsAuthentication.RedirectFromLoginPage(currUser.UserID.ToString(), false); Response.Redirect("Manage/Main.aspx"); } else { Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "alert('用户名密码不正确!');", true); } }