Esempio n. 1
0
 protected void btnChange_Click(object sender, EventArgs e)
 {
     if (Session["adminName"] == null)
     {
         if (BaseClass.CheckAdmin(Session["admin"].ToString(), txtOldPwd.Text.Trim()))
         {
             string strsql = "update tb_Admin set AdminPwd='" + txtNewPwdA.Text.Trim() + "' where AdminID='" + Session["admin"].ToString() + "'";
             BaseClass.OperateData(strsql);
             lblMessage.ForeColor = Color.Blue;
             lblMessage.Text      = "密码修改成功";
             txtNewPwd.Text       = "";
             txtNewPwdA.Text      = "";
             txtOldPwd.Text       = "";
         }
         else
         {
             lblMessage.ForeColor = Color.Red;
             lblMessage.Text      = "旧密码错误";
             txtOldPwd.Text       = "";
             txtOldPwd.Focus();
             return;
         }
     }
     else if (BaseClass.CheckAdminByName(Session["adminName"].ToString(), txtOldPwd.Text.Trim()))
     {
         string strsql = "update tb_Admin set AdminPwd='" + txtNewPwdA.Text.Trim() + "' where adminName='" + Session["admin"].ToString() + "'";
         BaseClass.OperateData(strsql);
         lblMessage.ForeColor = Color.Blue;
         lblMessage.Text      = "密码修改成功";
         txtNewPwd.Text       = "";
         txtNewPwdA.Text      = "";
         txtOldPwd.Text       = "";
     }
     else
     {
         lblMessage.ForeColor = Color.Red;
         lblMessage.Text      = "旧密码错误";
         txtOldPwd.Text       = "";
         txtOldPwd.Focus();
         return;
     }
 }
Esempio n. 2
0
    protected void btnlogin_Click(object sender, EventArgs e)
    {
        if (txtCode.Text.Trim() != Session["verify"].ToString())
        {
            Response.Write("<script>alert('验证码错误');location='Login.aspx'</script>");
        }
        else
        {
            if (this.ddlstatus.SelectedValue == "学生")
            {
                if (BaseClass.CheckStudent(txtNum.Text.Trim(), txtPwd.Text.Trim()))
                {
                    Session["studentID"] = txtNum.Text.Trim();
                    Response.Redirect("student/student.aspx");
                }
                else
                {
                    Response.Write("<script>alert('您不是学生或者用户名和密码错误');location='Login.aspx'</script>");
                }
            }
            if (this.ddlstatus.SelectedValue == "教师")
            {
                string mode = Session["accountMode"].ToString();
                if (mode == "id")
                {
                    if (BaseClass.CheckTeacher(txtNum.Text.Trim(), txtPwd.Text.Trim()))
                    {
                        Session["teacherID"] = txtNum.Text;
                        Response.Redirect("teacher/Teacher.aspx");
                    }
                    else
                    {
                        Response.Write("<script>alert('您不是教师或者用户名和密码错误');location='Login.aspx'</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('你现在是用账户名来登录');location='Login.aspx'</script>");

                    string id = BaseClass.CheckTeacherByName(txtNum.Text.Trim(), txtPwd.Text.Trim());
                    Label1.Text = id;
                    //if (BaseClass.CheckTeacherByName(txtNum.Text.Trim(), txtPwd.Text.Trim()))
                    //{
                    //    Session["teacherIName"] = txtNum.Text;
                    //    Response.Redirect("teacher/Teacher.aspx");
                    //}
                    if (id != "")
                    {
                        Session["teacherID"] = id;
                        Response.Redirect("teacher/Teacher.aspx");
                    }
                    else
                    {
                        Response.Write("<script>alert('您不是教师或者用户名和密码错误');location='Login.aspx'</script>");
                    }
                }
            }

            //5~1~a~s~p~x
            if (this.ddlstatus.SelectedValue == "管理员")
            {
                string mode = Session["accountMode"].ToString();
                if (mode == "id")
                {
                    if (BaseClass.CheckAdmin(txtNum.Text.Trim(), txtPwd.Text.Trim()))
                    {
                        Session["admin"] = txtNum.Text;

                        Response.Redirect("admin/Admin.aspx");
                    }
                    else
                    {
                        Response.Write("<script>alert('您不是管理员或者用户名和密码错误');location='Login.aspx'</script>");
                    }
                }//5@1@a@s@p@x
                else
                {
                    if (BaseClass.CheckAdminByName(txtNum.Text.Trim(), txtPwd.Text.Trim()))
                    {
                        Session["adminName"] = txtNum.Text;
                        Session["admin"]     = "";
                        Response.Redirect("admin/Admin.aspx");
                    }
                    else
                    {
                        Response.Write("<script>alert('您不是管理员或者用户名和密码错误');location='Login.aspx'</script>");
                    }
                }
            }
        }
    }