📄 index.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace car1
{
//该源码下载自www.51aspx.com(51aspx.com)
/// <summary>
/// index 的摘要说明。
/// </summary>
public class index : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label err;
protected System.Web.UI.WebControls.Button login;
protected System.Web.UI.WebControls.RequiredFieldValidator repw;
protected System.Web.UI.WebControls.TextBox password;
protected System.Web.UI.WebControls.RequiredFieldValidator reusername;
protected System.Web.UI.WebControls.TextBox username;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.HtmlControls.HtmlForm Form1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.login.Click += new System.EventHandler(this.login_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void login_Click(object sender, System.EventArgs e)
{
//检查帐号和密码
if(this.username.Text=="user"&this.password.Text=="user")
{
Session["S_username"]="";
Response.Redirect("main2.aspx");
}
string SqlConn=System.Configuration.ConfigurationSettings.AppSettings["ConnString"];
SqlConnection Conn=new SqlConnection(SqlConn);
Conn.Open();
string SqlStr0="select username,userpwd,userrule from [user] where username='"+this.username.Text+"' and userpwd='"+this.password.Text+"' and userrule='普通用户' and part='院办(车队)'";
SqlCommand Comm0=new SqlCommand(SqlStr0,Conn);
SqlDataReader read0=Comm0.ExecuteReader();
if(read0.Read())
{
Session["S_username"]=this.username.Text;
Session["S_userpwd"]=this.password.Text;
//Session["S_part"]=read0["part"].ToString();
Session["S_userrule"]="";
Response.Redirect("main3.aspx");
read0.Close();
Conn.Close();
}
else
{
read0.Close();
string SqlStr1="select username,userpwd,userrule from [user] where username='"+this.username.Text+"' and userpwd='"+this.password.Text+"' and userrule='超级用户'";
SqlCommand Comm1=new SqlCommand(SqlStr1,Conn);
SqlDataReader read1=Comm1.ExecuteReader();
if(read1.Read())
{
this.Label1.Text=read1["userrule"].ToString();
Session["S_username"]=this.username.Text;
Session["S_userpwd"]=this.password.Text;
Session["S_userrule"]=this.Label1.Text;
Response.Redirect("main.aspx");
read1.Close();
Conn.Close();
}
else
{
read1.Close();
string SqlStr2="select username,userpwd,part from [user] where username='"+this.username.Text+"' and userpwd='"+this.password.Text+"' and userrule='普通用户'";
SqlCommand Comm2=new SqlCommand(SqlStr2,Conn);
SqlDataReader read2=Comm2.ExecuteReader();
if(read2.Read())
{
Session["S_username"]=this.username.Text;
Session["S_userpwd"]=this.password.Text;
Session["S_part"]=read2["part"].ToString();
Session["S_userrule"]="";
Response.Redirect("main1.aspx");
read2.Close();
Conn.Close();
}
else
{
read2.Close();
string SqlStr3="select username,userpwd from [user] where username='"+this.username.Text+"' and userpwd='"+this.password.Text+"' and shenhe='0'";
SqlCommand Comm3=new SqlCommand(SqlStr3,Conn);
SqlDataReader read3=Comm3.ExecuteReader();
if(read3.Read())
{
this.err.Text="对不起,您还没有通过审核!";
read3.Close();
Conn.Close();
this.username.Text="";
this.password.Text="";
}
else
{
read3.Close();
Conn.Close();
this.err.Text="您输入的用户名或密码错误";
this.username.Text="";
this.password.Text="";
}
}
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -