⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 default.aspx.cs

📁 在线考试系统 主要真对考试 开发的个人项目
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Session.RemoveAll();
    }
    protected void BtnLogin_Click(object sender, EventArgs e)
    {
        if (this.userName.Text.Trim() == "" || this.userPwd.Text.Trim() == ""||this.TextBox1.Text=="")
        {
            if (this.userName.Text.Trim() == "" && this.userPwd.Text.Trim() == ""&&this.TextBox1.Text.Trim()=="")
            {
                Response.Write("<script>alert('用户名、密码、验证码不能为空!')</script>");
            }
            else if (this.userName.Text.Trim() == "")
            {
                Response.Write("<script>alert('用户名不能为空!')</script>");
            }
            else if (this.userPwd.Text.Trim() == "")
            {
                Response.Write("<script>alert('密码不能为空!')</script>");
            }
            else {
                Response.Write("<script>alert('验证码不能为空!')</script>");
            }
        }        
        else
        {
            if (String.Compare(Request.Cookies["CheckCode"].Value, this.TextBox1.Text, true) == 0)
            {
                int count = 0;
                if (this.DDLtype.SelectedValue == "学生")
                {

                    int exist;
                    exist = (new projClass()).ifStuExist(this.userName.Text);
                    if (exist == 1)
                    {
                        count = (new projClass()).getUser(this.userName.Text, this.userPwd.Text);
                        if (count == 1)
                        {
                            string stuId = this.userName.Text;
                            Session["stuId"] = stuId;
                            Response.Redirect("StudentInfo.aspx");
                            //	Response.Redirect("userInfo.aspx?stuId="+stuId);
                        }
                        else Response.Write("<script>alert(\"密码错误!请重新输入\");</script>");
                    }
                    //else if(count==2)
                    //Response.Write("<script>alert(\"密码错误!请重新输入\");</script>");
                    else Response.Write("<script>alert(\"学号不存在!请确认学号输入正确\");</script>");
                }
                else if (this.DDLtype.SelectedValue == "管理员")
                {
                    count = (new projClass()).getAdmin(this.userName.Text, this.userPwd.Text);
                    if (count > 0)
                    {
                        // Response.Write("<script>alert(\"登陆成功!\");</script>");
                        string adminId = this.userName.Text;
                        Session["adminId"] = adminId;
                        Response.Redirect("AdministratorInfo.aspx");
                    }
                    else Response.Write("<script>alert(\"登录失败!\");</script>");


                }
                else if (this.DDLtype.SelectedValue == "教师")
                {
                    count = (new projClass()).getTeacher(this.userName.Text, this.userPwd.Text);
                    if (count > 0)
                    {
                        string teacherId = this.userName.Text;
                        Session["teacherId"] = teacherId;
                        Response.Redirect("TeacherInfo.aspx");
                    }
                    else Response.Write("<script>alert(\"登录失败!\");</script>");

                }
            }
            else if (String.Compare(Request.Cookies["CheckCode"].Value, this.TextBox1.Text, true) != 0) {
                Response.Write("<script>alert(\"验证码错误,请输入正确的验证码!\");</script>");
                return;
            }
            else{
                Response.Write("<script>alert(\"您的浏览器设置已被禁用 Cookies,您必须设置浏览器允许使用 Cookies 选项后才能使用本系统!\");</script>");
                return;
            }

        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -