?? default.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 secondhand
{
/// <summary>
/// _default 的摘要說明。
/// </summary>
public class _default : System.Web.UI.Page
{
protected System.Web.UI.WebControls.ImageButton ImageButton1;
protected System.Web.UI.WebControls.ImageButton ImageButton2;
protected System.Web.UI.WebControls.ImageButton ImageButton3;
protected System.Web.UI.WebControls.ImageButton ImageButton4;
protected System.Web.UI.WebControls.Button Button3;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Panel Panel1;
protected System.Web.UI.WebControls.ImageButton ImageButton5;
public int isLogin=0;
private void Page_Load(object sender, System.EventArgs e)
{
isLogin=Convert.ToInt32(Request.QueryString["isLogin"]);
// 在此處放置用戶代碼以初始化頁面
}
#region Web 窗體設計器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調用是 ASP.NET Web 窗體設計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.ImageButton1.Click += new System.Web.UI.ImageClickEventHandler(this.ImageButton1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
Server.Transfer("default.aspx");
}
private void ImageButton2_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
Server.Transfer("mybuy.aspx");
}
private void ImageButton3_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
if( Session["ID"]==null||Session["pwd"]==null)
Response.Write ("<script>alert(\"請先登陸!\");</script>");
else
Server.Transfer("myyigo.aspx");
}
private void ImageButton4_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
if( Session["ID"]==null||Session["pwd"]==null)
Response.Write ("<script>alert(\"請先登陸!\");</script>");
else
Server.Transfer("myyigo.aspx");
}
private void ImageButton5_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
if( Session["ID"]==null||Session["pwd"]==null)
Response.Write ("<script>alert(\"請先登陸!\");</script>");
else
Server.Transfer("myyigo.aspx");
}
private void TextBox1_TextChanged(object sender, System.EventArgs e)
{
}
private void Button1_Click(object sender, System.EventArgs e)
{
string ID=TextBox1.Text;
string pwd=TextBox2.Text;
string ec_Data =
"Server=(local);"+
"uid=sa;pwd=sa;"+
"database=ec";
SqlConnection conn =
new SqlConnection(ec_Data);
conn.Open();
SqlCommand cmd =
new SqlCommand( "SELECT * FROM userInfo WHERE userID='"+ID+"'and pwd='"+pwd+"'", conn );
SqlDataReader dr=cmd.ExecuteReader();
if(dr.Read())
{
Session["ID"]=ID;
Session["pwd"]=pwd;
Label3.Visible=true;
Label3.Text="歡迎你來到易購網!";
if(this.isLogin==0)
{
Panel1.Visible=false;
this.isLogin=1;
}
Button3.Visible=true;
}
else
{
conn.Close();
conn.Open();
SqlCommand cmd1 =
new SqlCommand( "SELECT * FROM adminInfo WHERE adminID='"+ID+"'and pwd='"+pwd+"'", conn );
SqlDataReader dr1=cmd1.ExecuteReader();
if(dr1.Read())
{
Session["ID"]=ID;
Session["pwd"]=pwd;
Server.Transfer("admin.aspx");
}
else
{
Response.Write ("<script>alert(\"用戶名或密碼出錯,單擊重新填寫!\");</script>");
TextBox1.Text="";
TextBox2.Text="";
}
}
}
private void Button2_Click(object sender, System.EventArgs e)
{
Server.Transfer("regist.aspx");
}
private void Button3_Click(object sender, System.EventArgs e)
{
Session["ID"]=null;
Session["pwd"]=null;
Label3.Visible=false;
Panel1.Visible=true;
Button3.Visible=false;
TextBox1.Text="";
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -