当前位置:首页 > 汽车调度系统论文
5.2 用户登录页面
图5-1 用户登录页面
系统首页即为用户登录页面index.aspx,用户登录在本系统当中用一个共同的页面,如图5-1所示。用户在登录页面点击确定登录时,用户名称和密码不能为空。其中执行用户登录的主要代码如下:
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 {
///
25
protected void login_Click(object sender, System.EventArgs e) {
//检查帐号和密码
if(this.username.Text==\&this.password.Text==\) { } string
SqlConnection Conn=new SqlConnection(SqlConn);
Session[\]=\; Response.Redirect(\);
}
#endregion
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e) { }
///
/// 设计器支持所需的方法- 不要使用代码编辑器修改 /// 此方法的内容。 ///
private void InitializeComponent() {
//
// CODEGEN: 该调用是ASP.NET Web 窗体设计器所必需的。 //
InitializeComponent(); base.OnInit(e);
///
public partial class index : System.Web.UI.Page {
protected void Page_Load(object sender, System.EventArgs e) { }
// 在此处放置用户代码以初始化页面
SqlConn=System.Configuration.ConfigurationSettings.AppSettings[\];
26
Conn.Open();
string SqlStr0=\
username='\+this.username.Text+\+this.password.Text+\普通用户' and part='车队'\; '\; '\;
SqlCommand Comm2=new SqlCommand(SqlStr2,Conn); SqlDataReader read2=Comm2.ExecuteReader();
SqlCommand Comm1=new SqlCommand(SqlStr1,Conn); SqlDataReader read1=Comm1.ExecuteReader(); if(read1.Read()) { } else {
read1.Close();
string SqlStr2=\Response.Redirect(\); read1.Close(); Conn.Close();
this.Label1.Text=read1[\].ToString(); Session[\]=this.username.Text; Session[\]=this.password.Text; Session[\]=this.Label1.Text;
SqlCommand Comm0=new SqlCommand(SqlStr0,Conn); SqlDataReader read0=Comm0.ExecuteReader(); if(read0.Read()) { } else {
read0.Close();
string SqlStr1=\Session[\]=this.username.Text; Session[\]=this.password.Text; //Session[\Session[\]=\; Response.Redirect(\); read0.Close(); Conn.Close();
username='\+this.username.Text+\+this.password.Text+\超级用户
username='\+this.username.Text+\+this.password.Text+\普通用户
27
}
}
}
} else { }
read3.Close(); Conn.Close();
this.err.Text=\您输入的用户名或密码错误\; this.username.Text=\; this.password.Text=\;
if(read2.Read()) { } else {
read2.Close();
string SqlStr3=\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=\;
Session[\]=this.username.Text; Session[\]=this.password.Text; Session[\]=read2[\].ToString(); Session[\]=\; Response.Redirect(\); read2.Close(); Conn.Close();
username='\+this.username.Text+\+this.password.Text+\;
28
共分享92篇相关文档