📄 login.aspx.cs
字号:
using System;
using System.Data;
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;
using System.Data.OleDb;
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
txtUserName.Focus();
}
protected void btnOK_Click(object sender, EventArgs e)
{
OleDbConnection connAcc = new OleDbConnection();
string connStr = "Provider =Microsoft.Jet.OLEDB.4.0;Data Source = " + Server.MapPath("App_Data/Nurse.mdb");
connAcc.ConnectionString = connStr;
string strSql = "";
connAcc.Open();
if (Session["identify"].ToString().Equals("admin"))
{
strSql = "select Password from Administor where AdminName='" + txtUserName.Text + "'";
}
else if (Session["identify"].ToString().Equals("nurse"))
{
strSql = "select NurPassword from NurseInfo where NurName='" + txtUserName.Text + "'";
}
if ((txtUserName.Text == "") || (txtPWD.Text == ""))
{
Response.Write("<script language=javascript>alert('请输入完整的登录信息');</script>");
}
else
{
OleDbCommand CommAdmin = new OleDbCommand(strSql, connAcc);
if (txtPWD.Text.Equals((String)CommAdmin.ExecuteScalar()))
{
connAcc.Close();
Session["UserName"] = txtUserName.Text;
if (Session["identify"].ToString().Equals("admin"))
{
Server.Transfer("AdminLogin.aspx", true);
}
else if (Session["identify"].ToString().Equals("nurse"))
{
Server.Transfer("NurseLogin.aspx", true);
}
}
else
{
lblResult.Text = "There is no such a person! please enter again~~";
txtUserName.Text = "";
txtPWD.Text = "";
txtUserName.Focus();
}
}
}
protected void btnCancel_Click(object sender, EventArgs e)
{
txtUserName.Text = "";
txtPWD.Text = "";
txtUserName.Focus();
}
protected void btnRegist_Click(object sender, EventArgs e)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -