protected void resetBtn_Click(object sender, EventArgs e) { AdminServices Lg = new AdminServices(); if (Lg.ResetPwd(userName.Text)==true) { Response.Redirect("~/Default.aspx"); } else { Response.Write("<script>alert('重置失败')</script>"); } }
protected void nextBtn_Click(object sender, EventArgs e) { AdminServices chge = new AdminServices(); bool change = chge.ChangePwd(username,userPwd.Text); if (change == true) { Response.Write("<script>alert('修改成功')location.href='~/Default.aspx'</script>"); } else { Response.Write("<script>alert('修改失败')</script>"); userPwd.Text = string.Empty; userPwdCheck.Text = string.Empty; } }
protected void nextBtn_Click(object sender, EventArgs e) { AdminServices Lg = new AdminServices(); if (Lg.CheckReset(userName.Text, phoNum.Text)) { Response.Write("<script>alert('验证成功')</script>"); resetBtn.Enabled = true; } else { Response.Write("<script>alert('验证失败')</script>"); userName.Text = string.Empty; phoNum.Text = string.Empty; } }
/// <summary> /// 登陆按钮响应 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void loginBtn_Click(object sender, EventArgs e) { // 用户名及密码获取 string sName = userName.Text.Trim(); string passWord = userPwd.Text.Trim(); string scenicId = string.Empty; // 实例化对象,便于基本数据的访问 AdminServices Lg = new AdminServices(); // 验证码判断 if (Session["CheckCode"].ToString() == validCode.Text.Trim()) { scenicId = Lg.CheckLogin(sName, passWord); // 密码校验 if (!string.IsNullOrEmpty(scenicId)) { Session["userName"] = sName; Session["ScenicId"] = scenicId; Session["userLimit"] = Lg.GetUserMode(sName); Session["userId"] = Lg.GetUserID(sName); // 自动登录 if (autoLoging.Checked) { HttpCookie userNamece = new HttpCookie("userName"); HttpCookie userPwdce = new HttpCookie("userPwd"); userNamece.Value = sName; userNamece.Expires = DateTime.Now.AddDays(7); userPwdce.Value = passWord; userPwdce.Expires = DateTime.Now.AddDays(7); Response.AppendCookie(userNamece); Response.AppendCookie(userPwdce); } else { HttpCookie userNamece = new HttpCookie("userName"); HttpCookie userPwdce = new HttpCookie("userPwd"); userNamece.Value = sName; userPwdce.Value = passWord; Response.AppendCookie(userNamece); Response.AppendCookie(userPwdce); } // 强制修改密码 if (passWord.Equals("11111111")) { // 执行js响应 string url = @"<script language=javascript> alert('您的密码已被初始化,需要重置!'); window.location.href='PwdChange.aspx'; </script>"; Response.Write(url); } else { Response.Redirect("HomePage.aspx"); } } else { Response.Write("<script>alert('密码错误!')</script>"); validCode.Text = string.Empty; } } else { Response.Write("<script>alert('验证码错误!')</script>"); validCode.Text = string.Empty; } }
/// <summary> /// 修改密码 /// </summary> /// <param name="userName"></param> /// <param name="pwd"></param> /// <returns></returns> public string ChangePwd(string userName, string pwd) { // 调用底层方法 bool result = new AdminServices().ChangePwd(userName, pwd); return (result ? "true" : "false"); }
protected void Page_Load(object sender, EventArgs e) { // 手动验证码失效 Session["CheckCode"] = string.Empty; HttpCookie cookie = Request.Cookies["userName"]; if (Request.Cookies["userName"] != null) { userName = Request.Cookies["userName"].Value; userId = new AdminServices().GetUserID(userName); scenicId = new AdminServices().CheckLogin(userName,Request.Cookies["userPwd"].Value ); userLimit = (new AdminServices().GetUserMode(userName)); // 保存用户信息 Session.Add("userName", Request.Cookies["userName"].Value); Session.Add("ScenicId", scenicId); Session.Add("userLimit", userLimit); Session.Add("AId", userId); // 页面添加选项 LinkButton user = new LinkButton(); user.Text = (string)Session["userName"]; user.Attributes.Add("href", "PwdChange.aspx"); Place.Controls.Add(user); } else { Response.Redirect("Default.aspx"); } // 用户权限判断 if (userLimit == "1") { DataOut.Visible = false; } }