?? landing.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.Configuration;
using System.Data.SqlClient;
namespace Supermart
{
/// <summary>
/// landing 的摘要說明。
/// </summary>
public class landing : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox txt_username;
protected System.Web.UI.WebControls.TextBox txt_pwd;
protected System.Web.UI.WebControls.Button btn_landing;
protected System.Web.UI.WebControls.Button btn_giveup;
private string strConn=System.Configuration.ConfigurationSettings.AppSettings["SQLCONNECTION"];
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.btn_landing.Click += new System.EventHandler(this.btn_landing_Click);
this.btn_giveup.Click += new System.EventHandler(this.btn_giveup_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btn_landing_Click(object sender, System.EventArgs e)
{
SqlConnection con=new SqlConnection(strConn);
con.Open();
SqlCommand cmd=new SqlCommand("select * from personnel where perName='"+this.txt_username.Text+"' and perPwd='"+this.txt_pwd.Text+"'",con);
SqlDataReader sdr=cmd.ExecuteReader();
if(sdr.Read())
{
Session["userName"]=sdr["perName"].ToString();
Session["relName"]=sdr["relName"].ToString();
Session["department"]=sdr["department"].ToString();
Response.Write("<script>alert(\"歡迎你,"+Session["department"].ToString()+""+this.txt_username.Text+"光臨!!\");window.location.href='main.aspx';</script>");
}
else
{
Response.Write("<script>alert(\"用戶名或密碼錯誤,請重新輸入!\");window.location.href='landing.aspx';</script>");
}
}
private void btn_giveup_Click(object sender, System.EventArgs e)
{
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -