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

📄 登陆.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;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page 
{
    string strConnection = "server=F45F1B20D9B348B;database=Student;uid=sa;pwd=1017;";
    protected void Page_Load(object sender, EventArgs e)
    {
       
    }
   
    protected void Login1_Authenticate1(object sender, AuthenticateEventArgs e)
    {
        bool Authenticated = false;
        Authenticated = SiteLevelCustomAuthenticationMethod(Login1.UserName, Login1.Password);
        e.Authenticated = Authenticated;
        if (Authenticated == true)
        {
            if (Session["权限"].ToString() == "t")
            {
                Response.Redirect("releasework.aspx");
            }
            else if (Session["权限"].ToString() == "s")
            {
                Response.Redirect("student.aspx");
            }
        }
    }
    private bool SiteLevelCustomAuthenticationMethod(string UserName, string Password)
    {
        bool boolReturnValue = false;
        
        SqlConnection Connection = new SqlConnection();
        String strSQL = "select * from STUDENT";
        Connection.ConnectionString = strConnection;
        SqlCommand command = new SqlCommand(strSQL, Connection);
        Connection.Open();
        SqlDataReader Dr = command.ExecuteReader();
        while (Dr.Read())
        {
            if (UserName == (Dr["用户名"].ToString()) && Password ==( Dr["密码"].ToString()))
            {
                Session["用户名"] = Dr["用户名"].ToString();
                Session["权限"]=Dr["权限"].ToString();
                boolReturnValue = true;
                return boolReturnValue;
            }
        }
        Dr.Close();
        return boolReturnValue;
    }   
}

⌨️ 快捷键说明

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