default.aspx.cs

来自「网络企业信息管理系统」· CS 代码 · 共 52 行

CS
52
字号
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 + =
减小字号Ctrl + -
显示快捷键?