Beispiel #1
0
 //更新密码
 //修改密码
 protected void Button8_Click(object sender, EventArgs e)
 {
     AdminManager am = new AdminManager();
     Admin a = (Admin)Session["admin"];
     if (TextBox12.Text.ToString() == a.passwd)          //原密码是否正确
     {
         if (TextBox13.Text.ToString() != null)
         {
             a.passwd = TextBox14.Text.ToString();
             if (am.Update(a))                       //更新新密码
                 Response.Write("<Script Language=JavaScript>alert('修改成功,请重新登录!');</Script>");
         }
         else
             Response.Write("<Script Language=JavaScript>alert('密码不能为空');</Script>");
     }
     else
     {
         Response.Write("<Script Language=JavaScript>alert('原密码错误,请重试!');</Script>");
         TextBox12.Text = "";
     }
 }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(Request.QueryString["Action"]))//获取form的Action中的参数
                {
                    Action = Request.QueryString["Action"].Trim().ToLower();//去掉空格并变小写
                }
                switch (Action)
                {
                    case "login":
                        if (!string.IsNullOrEmpty(Request.Form["TxtUserName"]) && !string.IsNullOrEmpty(Request.Form["TxtPassword"]))//获取form中的参数
                        {
                            string UserName = Request.Form["TxtUserName"].ToString();
                            string UserPassword = Request.Form["TxtPassword"].ToString();
                            string Identity = Request.Form["DropExpiration"].ToString();
                            StudentManager StudentMan = new StudentManager();
                            TeacherManager TeacherMan = new TeacherManager();
                            AdminManager AdminMan = new AdminManager();

                            try
                            {
                                if (Identity.Equals("student"))
                                {
                                    if (UserPassword != StudentMan.GetStudent(UserName).passwd)
                                    {
                                        Response.Write("<Script Language=JavaScript>alert('密码或用户名错误,请重试!');</Script>");
                                    }
                                    else
                                    {
                                        Session["UserRole"] = "Student";
                                        Session["student"] = StudentMan.GetStudent(UserName);
                                        Response.Redirect("StudentMainForm.aspx");
                                    }
                                }

                                else if (Identity.Equals("teacher"))
                                {
                                    if (UserPassword != TeacherMan.GetTeacher(UserName).passwd)
                                    {
                                        Response.Write("<Script Language=JavaScript>alert('密码或用户名错误,请重试!');</Script>");
                                    }
                                    else
                                    {
                                        Session["UserRole"] = "Teacher";
                                        Session["teacher"] = TeacherMan.GetTeacher(UserName);
                                        Response.Redirect("AddCourse.aspx");
                                    }
                                }

                                else if (Identity.Equals("admin"))
                                {
                                    if (UserPassword != AdminMan.GetAdmin(UserName).passwd)
                                    {
                                        Response.Write("<Script Language=JavaScript>alert('密码或用户名错误,请重试!');</Script>");
                                    }
                                    else
                                    {
                                        Session["UserRole"] = "Admin";
                                        Session["admin"] = AdminMan.GetAdmin(UserName);
                                        Response.Redirect("admin.aspx?user="******"<Script Language=JavaScript>alert('错误的身份选择!');</Script>");
                            }

                        }
                        break;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }