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

📄 login.aspx.cs

📁 数据结构管理系统 数据结构管理系统
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 Backtop_用户管理_login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        UserName.Text = Password.Text = "";

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        if (Page.IsValid == true)
        {
            string userId = "";
            int IsAdmin = 0;

            ///定义类并获取用户的登陆信息            
            IUser user = new User();

            ///对用户输入进行编码
            string sUserName = Server.HtmlEncode(UserName.Text.Trim());
            string sPassword = Server.HtmlEncode(Password.Text.Trim());

            ///获取用户信息
            SqlDataReader recu = user.GetUserLoginBySQL(sUserName, sPassword);

            ///判断用户是否合法 
          
            if (recu.Read())
            {
                userId = recu["UserID"].ToString();
                IsAdmin = Convert.ToInt32(recu["IsAdmin"]);
            }
            recu.Close();
            ///验证用户合法性,并跳转到系统平台
            if ((userId != null) && (userId != ""))
            {
                Session["UserID"] = userId;
                Session["isadmin"] = "0";
                //如果用户为管理员,系统跳转至系统管理页面
                if (IsAdmin == 1)
                {
                    Session["isadmin"] = "1";
                    Response.Redirect("/数据结构学习系统/Backtop/Backindex.aspx");
                }
                //用户为非管理员
                else
                {
                    Response.Redirect("/数据结构学习系统/Desktop/Index.aspx");
                }
            }
            else
            {
            }
        }
    }
    }

⌨️ 快捷键说明

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