login.aspx.cs

来自「医院护理管理系统」· CS 代码 · 共 78 行

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