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

📄 default.aspx.cs

📁 OA系统,数据库为SQLSever 。net c#
💻 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 
{
    WebService webService = new WebService();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (this.TextBox1.Text == "" || this.TextBox2.Text == "")//判断是否输入完整
        {
            this.lblMsg.Text = "请完整输入用户名和密码!";
        }
        else
        {
            string strName = this.TextBox1.Text;
            string strPsw = this.TextBox2.Text;
            string strSql = "Select Person_Psw,Person_ID,Person_Level from z_Person where Person_UserName='" + strName + "';";
            DataTable table = webService.ExcuteSelect(strSql);//读取谁据库
            //没有此用户名
            if (table.Rows.Count == 0)
            {
                this.lblMsg.Text = "没有此用户名!";
            }
            else
            {
                if (strPsw == table.Rows[0]["Person_Psw"].ToString())//验证正确
                {
                    Session["UserLevel"] = table.Rows[0]["Person_Level"].ToString();
                    Session["UserID"] = table.Rows[0]["Person_ID"].ToString();
                    Session["UserName"] = strName;
                    Response.Redirect("Main.aspx");
                }
                else//密码错误
                {
                    this.lblMsg.Text = "密码错误!";
                }
            }
        }
    }
}

⌨️ 快捷键说明

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