コード例 #1
0
        protected void Query_Click(object sender, EventArgs e)
        {
            string stuSno = this.txtGradeSno.Value.Trim();
            string Pwd    = this.txtGradePwd.Value.Trim();

            if (stuSno == "" || Pwd == "")
            {
                this.hintGrade.InnerHtml = "学号或者密码不能为空!";
            }
            else
            {
                MD5Encrypt MD5    = new MD5Encrypt();
                string     stuPwd = MD5.GetMD5(Pwd);
                StudentMgr mgr    = new StudentMgr();
                ExamSignSystemEntity.Student student = mgr.Login(stuSno, stuPwd);
                if (student != null)
                {
                    GradeMgr     grade = new GradeMgr();
                    List <Grade> list  = grade.ShowGradeList(stuSno);
                    if (list != null)
                    {
                        this.showGrade.Attributes.Add("style", "display:block");
                        this.Repeater1.DataSource = list;
                        this.Repeater1.DataBind();
                        this.hintGrade.InnerHtml = "";
                    }
                    else
                    {
                        this.hintGrade.InnerHtml = "可能没有考试!";
                        this.showGrade.Attributes.Add("style", "display:none");
                    }
                }
                else
                {
                    this.hintGrade.InnerHtml = "账号或者密码输入错误!";
                    this.showGrade.Attributes.Add("style", "display:none");
                }
            }
        }
コード例 #2
0
        //学生登录
        protected void LoginClick(object sender, EventArgs e)
        {
            string     stuSno = this.txtSno.Value.Trim();
            string     Pwd    = this.stuPwd.Value.Trim();
            MD5Encrypt MD5    = new MD5Encrypt();
            string     stuPwd = MD5.GetMD5(Pwd);
            //隐藏框的值
            string hint = this.ps.Value.Trim();

            if (Session["CheckCode"] != null && hint == "")
            {
                //这样写可以不能区分大小写
                if (Session["CheckCode"].ToString().ToUpper() == this.txtVerificate.Value.Trim().ToString().ToUpper())
                {
                    StudentMgr mgr = new StudentMgr();
                    ExamSignSystemEntity.Student student = mgr.Login(stuSno, stuPwd);
                    if (student != null)
                    {
                        // 把当前用户保存下来
                        ContextObjects.CurrentStudent = student;
                        Response.Redirect("../Main/Operate.aspx", true);
                    }
                    else
                    {
                        string sp = "账号或密码错误";
                        this.hint.InnerHtml      = sp;
                        this.txtVerificate.Value = "";
                    }
                }
                else
                {
                    this.hint.InnerHtml      = "验证码错误";
                    this.txtVerificate.Value = "";
                }
            }
            else if (Session["CheckCode"] != null && hint != "")
            {
                string stuPassword = this.stuPwd.Value.Trim();
                //这样写可以不能区分大小写
                if (Session["CheckCode"].ToString().ToUpper() == this.txtVerificate.Value.Trim().ToString().ToUpper())
                {
                    StudentMgr mgr = new StudentMgr();
                    ExamSignSystemEntity.Student student = mgr.Login(stuSno, stuPassword);
                    if (student != null)
                    {
                        // 把当前用户保存下来
                        ContextObjects.CurrentStudent = student;
                        Response.Redirect("../Main/Operate.aspx", true);
                    }
                    else
                    {
                        string sp = "账号或密码错误";
                        this.hint.InnerHtml      = sp;
                        this.txtVerificate.Value = "";
                    }
                }
                else
                {
                    this.hint.InnerHtml      = "验证码错误";
                    this.txtVerificate.Value = "";
                }
            }
        }