protected void signIn_Click(object sender, EventArgs e) { string _userName = userName.Value.Trim(); string _userPaw = userPaw.Value.Trim(); UserSignInServlet userSignInservlet = UserSignInServlet.getUserSignInservletInstance(); bool isTrue = userSignInservlet.userSignIn(_userName, _userPaw); if (isTrue) { Session["studentId"] = _userName; Response.Write("<script>alert('success')</script>"); HttpCookie cookie = new HttpCookie("studentInfo"); cookie["studentId"] = _userName; cookie.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(cookie); if (_userPaw == "123456") { Response.Redirect("Exchange.aspx"); } else { // 如果密码安全 Response.Redirect("Summarize.aspx"); } } else { Response.Write("<script>alert('账号或密码错误,请重新尝试')</script>"); userName.Value = userPaw.Value = ""; } }
/* * 优化:1)密码不满足要求时, 不运行点击提交按钮 -> 前端进行判断 * 2) 后端进行判断,截取密码,进行匹配,不满足要求这刷新页面,要求重新填写 */ protected void ecBtn_Click(object sender, EventArgs e) { UserSignInServlet userSignInservlet = UserSignInServlet.getUserSignInservletInstance(); bool isTrue = userSignInservlet.userModifyPwd(student_id, recipient_name.Value); if (isTrue) { //往主页面跳转 } else { Response.Redirect("Exchange.aspx"); } }
protected void Demand_Click(object sender, EventArgs e) { UserSignInServlet us = UserSignInServlet.getUserSignInservletInstance(); //为了测试方便 string stdId = "123"; //string stdId = Session["studentId"].ToString(); string mark = us.getMarkByStudentId(stdId); DemandServlet dm = DemandServlet.getDemandServletInstance(); bool isTrue = dm.exitRecording(mark); // true 代表没有查到 if (isTrue == true) { Response.Redirect("1#"); } else { Response.Redirect("Demand.aspx"); } }