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

📄 登陆页面.aspx.cs

📁 学生管理系统 功能不是很强大 但是很实用
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;
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 
{
    int temp = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DropDownList1.Items.Add("管理员");
            DropDownList1.Items.Add("教师");
            DropDownList1.Items.Add("学生");
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string strcnn="server=.;database=学生成绩智能管理系统;user id=sa;password=sa;";
        string strcmd="";
        if(TextBox1.Text!=""&&TextBox2.Text!="")
        {
            if (DropDownList1.Text == "管理员")
            {
                strcmd = "select count(*) from 用户表  where  用户名='" + TextBox1.Text + "' and 密码='" + TextBox2.Text + "'";
                temp = 1;
            }
            if (DropDownList1.Text == "教师")
            {
                strcmd = "select count(*) from  教师表 where  教师编号='" + TextBox1.Text + "' and 密码='" + TextBox2.Text + "'";
                temp = 2;
            }
            if (DropDownList1.Text == "学生")
            {
                strcmd = "select count(*) from  学生表 where  学号='" + TextBox1.Text + "' and 密码='" + TextBox2.Text + "'";
                temp = 3;
            }
            SqlConnection cnn = new SqlConnection(strcnn);
            cnn.Open();
            SqlCommand cmd = new SqlCommand(strcmd,cnn);
            if ((int)cmd.ExecuteScalar() == 1)
            {
                this.Session.Add("name", Convert.ToString(TextBox1.Text));
                if (temp == 1)
                    Response.Redirect("管理模块//学生信息管理.aspx");
                if (temp == 2)
                    Response.Redirect("教师模块//Default1.aspx");
                if (temp == 3)
                    Response.Redirect("学生模块//Default.aspx");
            }
            else
                Response.Write("<script LANGUAGE='javascript'>alert('账号或密码错误!');history.go(-1);</script>");
            cnn.Close();
        }
        else 
             Response.Write("<script LANGUAGE='javascript'>alert('请输入账号或密码!');history.go(-1);</script>");
    }
    protected void 登陆_Click(object sender, EventArgs e)
    {
        DropDownList1.Text = "管理员";
        TextBox1.Text = "";
        TextBox2.Text = "";
    }
}

⌨️ 快捷键说明

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