?? index.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.OleDb;
namespace SCard
{
/// <summary>
/// Default 的摘要說明。
/// </summary>
public class index : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList ddlClass;
protected System.Web.UI.WebControls.TextBox txtSelect;
protected System.Web.UI.WebControls.Button btnSelect;
protected System.Web.UI.WebControls.DataList HDataList;
protected System.Web.UI.WebControls.DataList NDataList;
protected System.Web.UI.WebControls.Repeater CRepeater;
protected System.Web.UI.WebControls.Repeater JRepeater;
protected System.Web.UI.WebControls.Label lblAnnounce;
protected System.Web.UI.HtmlControls.HtmlForm SelectForm;
private void Page_Load(object sender, System.EventArgs e)
{
if( !IsPostBack )
{
CData();//分類列表綁定
setSelectClass();//綁定 類別選框
getHotDataList();//熱賣商品
getNewDataList();//最新上架
getTJDataList();//精品推薦
getAnnounce();//獲取公告信息
}
}
private void getAnnounce()//獲取公告信息
{
string mySql="select * from append where id='3'";
DBConn myDB = new DBConn();
OleDbDataReader mydr = myDB.getDataReader( mySql );
if( mydr.Read() )
{
lblAnnounce.Text = CleanString.htmlOutputText( mydr["text"].ToString() );
}
mydr.Close();
myDB.Close();
}
private void CData()//分類列表綁定
{
DBConn myDB = new DBConn();
string sql = "select * from Category";
CRepeater.DataSource = myDB.getDataReader( sql );
CRepeater.DataBind();
myDB.Close();
}
private void setSelectClass()//綁定 類別選框
{
DBConn myDB = new DBConn();
string mySql = "select CID,CName from Category order by CID desc";
ddlClass.DataSource = myDB.getDataReader( mySql );
ddlClass.DataTextField = "CName";
ddlClass.DataValueField = "CID";
ddlClass.DataBind();
myDB.Close();
ddlClass.Items.Insert(0,new ListItem("所有分類","-1"));
}
private void getHotDataList()//熱賣商品
{
DBConn myDB = new DBConn();
string sql = "select top 10 * from Products where PHot=1 order by PID desc";
HDataList.DataSource = myDB.getDataReader( sql );
HDataList.DataBind();
myDB.Close();
}
private void getNewDataList()//最新上架
{
DBConn myDB = new DBConn();
string sql = "select top 4 * from Products order by PID desc";
NDataList.DataSource = myDB.getDataReader( sql );
NDataList.DataBind();
myDB.Close();
}
private void getTJDataList()//精品推薦
{
DBConn myDB = new DBConn();
string sql = "select top 10 * from Products where PCommend=1 order by PID desc";
JRepeater.DataSource = myDB.getDataReader( sql );
JRepeater.DataBind();
myDB.Close();
}
#region Web 窗體設(shè)計器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調(diào)用是 ASP.NET Web 窗體設(shè)計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設(shè)計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.btnSelect.Click += new System.EventHandler(this.btnSelect_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btnSelect_Click(object sender, System.EventArgs e)
{
string strClass = ddlClass.SelectedValue;
string strText = Server.UrlEncode( txtSelect.Text );
Response.Redirect("Select.aspx?class=" + strClass + "&text=" + strText);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -