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

📄 login.aspx.cs

📁 大中型酒店管理系统
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;
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;

public partial class login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Button2.Attributes.Add("onclick", "window.close();");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        bool power = false;//判断登陆人的身份
     
        //密码使用MD5加密
        //string Password = FormsAuthentication.HashPasswordForStoringInConfigFile(pwd.Text.ToString(), "MD5");
        SqlConnection Conn = db.createconn();

        SqlCommand Cmd = new SqlCommand("select * from Admin where UserAdmin='" + uid.Text + "' and Userpwd = '" + pwd.Text + "' ", Conn);

        Conn.Open();

        SqlDataReader Dr = Cmd.ExecuteReader();

        if (uid.Text != "" && pwd.Text != "")
        {
            if (Dr.Read())
            {
                power = (bool)Dr["POWER"];
                if (chkcode.Text == Session["Code"].ToString())
                {
                    Session["Admin"] = "Admin";
                    if (power == true)
                    {
                        Response.Redirect("main.aspx");
                    }
                    //如果是普通用户,则转到普通用户界面

                    else
                    {
                        Response.Redirect("user.htm");
                    }
                   
                }
                else
                {
                    Response.Write("<script>alert('验证码错误!');history.go(-1);</script>");
                    chkcode.Focus();
                }
            }
            else
            {
                Response.Write("<script>alert('用户名或密码错误!');history.go(-1);</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('请输入用户名和密码!');history.go(-1);</script>");
        }
    }
}

⌨️ 快捷键说明

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