📄 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.IO;
namespace BookShop
{
/// <summary>
/// Default 的摘要说明。
/// </summary>
public class Default : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox tbKeyword;
protected System.Web.UI.WebControls.DropDownList ddChoice;
protected System.Web.UI.WebControls.DataGrid dgTopHits;
protected System.Web.UI.WebControls.DataGrid dgBestSold;
protected System.Web.UI.WebControls.Button btQuickSearch;
protected System.Web.UI.WebControls.DataGrid dgQuickBookType;
protected System.Web.UI.HtmlControls.HtmlForm QuickSearchFrom;
protected System.Web.UI.WebControls.HyperLink HyperLink1;
protected System.Web.UI.WebControls.DataList dlNewBook;
protected System.Web.UI.WebControls.DataList dlSpecialPriceBook;
protected System.Web.UI.WebControls.DataGrid dgNews;
RobertSoft.BookStore.Book currentBook = new RobertSoft.BookStore.Book();
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
BindData();
}
}
private void BindData()
{
DataView currentDVNewBook, currentDVTopHits, currentDVNews, currentDVSpecialPriceBook, currentDVTypeSearch, currentDVBestSold;
currentDVNewBook = currentBook.GetNewBook();
this.dlNewBook.DataSource = currentDVNewBook;
this.dlNewBook.DataBind();
currentDVTopHits = RobertSoft.BookStore.Book.GetHitTop10();
dgTopHits.DataSource = currentDVTopHits;
dgTopHits.DataBind();
currentDVNews = currentBook.GetNews();
this.dgNews.DataSource = currentDVNews;
this.dgNews.DataBind();
currentDVSpecialPriceBook = currentBook.GetSpecialPriceBook();
this.dlSpecialPriceBook.DataSource = currentDVSpecialPriceBook;
this.dlSpecialPriceBook.DataBind();
currentDVTypeSearch = RobertSoft.BookStore.Book.GetQuickType();
this.dgQuickBookType.DataSource = currentDVTypeSearch;
this.dgQuickBookType.DataBind();
currentDVBestSold = currentBook.GetSaleTop10();
this.dgBestSold.DataSource = currentDVBestSold;
this.dgBestSold.DataBind();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.btQuickSearch.Click += new System.EventHandler(this.btQuickSearch_Click);
this.dlNewBook.ItemCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.dlNewBook_ItemCommand);
this.dlSpecialPriceBook.ItemCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.dlSpecialPriceBook_ItemCommand);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void btQuickSearch_Click(object sender, System.EventArgs e)
{
string strURL;
strURL = "QuickSearch.aspx?strSearchType=" + ddChoice.SelectedValue + "&SearchKeyword=" + tbKeyword.Text;
Response.Redirect(strURL);
}
private void dlNewBook_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
{
if(e.CommandName == "BookName")
{
string strUrl;
strUrl = "ShowBookDetail.aspx?ID=" + e.CommandArgument;
Response.Redirect(strUrl);
}
}
private void dlSpecialPriceBook_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
{
if(e.CommandName == "Special")
{
string strUrl;
strUrl = "ShowBookDetail.aspx?ID=" + e.CommandArgument;
Response.Redirect(strUrl);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -