public string PromptUpdatePwdSuccess = string.Empty; //密码修改成功! #endregion Fields #region Methods protected void btnOk_Click(object sender, EventArgs e) { string userid = this.txtUserID.Text; string oldPassword = this.txtOldPassword.Text; CommonFunction comFun = new CommonFunction(); oldPassword = comFun.setMD5Password(oldPassword); string resultDspName = comFun.checkLogin(userid, oldPassword);//登录人显示名 if (string.IsNullOrEmpty(resultDspName) == true) { this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "oldpassword", "alert('" + PromptOldPwdError + "');", true); return; } string newPassword = this.txtNewPassword.Text.Trim(); string confimrPassword = this.txtConfirmPassword.Text.Trim(); newPassword = comFun.setMD5Password(newPassword); int i = updatePassword(userid, newPassword); if (i == 1) { this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "success", "alert('" + PromptUpdatePwdSuccess + "');", true); } else { this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "fail", "alert('" + PromptUpdatePwdFaild + "');", true); return; } }
protected void btnOK_Click(object sender, EventArgs e) { CommonFunction comFun = new CommonFunction(); string strUserAccount = CommonFunction.StringFilter(this.txtUserAccount.Text.Trim()); string strUserName = CommonFunction.StringFilter(this.txtUserName.Text.Trim()); string strPwd = CommonFunction.StringFilter(this.txtPwd.Text.Trim()); strPwd = comFun.setMD5Password(strPwd); string strEmail = CommonFunction.StringFilter(this.txtEmail.Text.Trim()); string strHRID = CommonFunction.StringFilter(this.txtHRID.Text.Trim()); string strTel = CommonFunction.StringFilter(this.txtTel.Text.Trim()); string strTitle = "";// CommonFunction.StringFilter(this.txtTitle.Text.Trim()); string strUserManager = CommonFunction.StringFilter(this.txtUserManager.Text.Trim()); if (String.IsNullOrEmpty(strTel)) { } try { switch (this.type) { case "add": addUser(strUserAccount, strUserName, strEmail, strPwd, strHRID, strTel, strTitle, strUserManager); this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "key", "alert('" + GetLocalResourceObject("PromptAddSuccess").ToString() + "');window.location.href='UserManage.aspx'", true); break; case "update": updateUser(strUserAccount, strUserName, strEmail, strPwd, strHRID, strTel, strTitle, strUserManager); this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "key", "alert('" + GetLocalResourceObject("PromptUpdateSuccess").ToString() + "');window.location.href='UserManage.aspx'", true); break; } // BaseUserInfo.GetUsers(); } catch { this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "key", "alert('" + GetLocalResourceObject("PromptAddFailure").ToString() + "');", true); return; } }
private void Login_KFCUser() { //string strUserAccount = this.txtUserID.Text.Trim();//登录人账户 //string strPwd = this.txtPwd.Text.Trim();//登录人密码 //CommonFunction comFun = new CommonFunction(); //strPwd = comFun.setMD5Password(strPwd);//md5加密 //string resultDspName = comFun.checkLogin(strUserAccount, strPwd);//登录人显示名 //if (!string.IsNullOrEmpty(resultDspName)) //{ // comFun.setSesssionAndCookies(strUserAccount,resultDspName); // this.Response.Redirect("~/Default.aspx"); //} //else //{ // this.lblRegMsgPopup.Text = "登录失败!"; // return; //} string strUserAccount = this.txtUserID.Text.Trim();//登录人账户 string strPwd = this.txtPwd.Text.Trim();//登录人密码 CommonFunction comFun = new CommonFunction(); strPwd = comFun.setMD5Password(strPwd);//md5加密 string strTemp = comFun.checkLogin(strUserAccount, strPwd); string resultDspName = strTemp.Split(',')[1];//登录人显示名 strUserAccount = strTemp.Split(',')[0]; if (!string.IsNullOrEmpty(resultDspName)) { //System.Web.Security.FormsAuthentication.SetAuthCookie(strUserAccount, false); FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, "LoginCookieInfo", DateTime.Now, DateTime.Now.AddMinutes(60), false, strUserAccount); // User data string encryptedTicket = FormsAuthentication.Encrypt(authTicket); //加密 // 存入Cookie HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); authCookie.Expires = authTicket.Expiration; Response.Cookies.Add(authCookie); if (chkRemember.Checked)//再写入cookie { if (Request.Cookies["RememberMe"] == null || String.IsNullOrEmpty(Response.Cookies["RememberMe"].Value)) { Response.Cookies["RememberMe"].Value = HttpUtility.UrlEncode(strUserAccount, System.Text.Encoding.GetEncoding("gb2312")); Response.Cookies["RememberMe"].Expires = DateTime.Now.AddMonths(1); } } else { if (Response.Cookies["RememberMe"] != null) Response.Cookies["RememberMe"].Expires = DateTime.Now.AddDays(-1);//删除 } comFun.setSesssionAndCookies(strUserAccount, resultDspName, ""); this.Response.Redirect("~/Default.aspx"); //if (Request.QueryString.ToString().Contains("ReturnUrl") && !String.IsNullOrEmpty(Request.QueryString["ReturnUrl"].ToString())) //{ // this.Response.Redirect(Request.QueryString["ReturnUrl"].ToString()); //} //else //{ // this.Response.Redirect("~/Default.aspx"); //} } else { this.lblRegMsgPopup.Text = "登录失败!"; return; } }