📄 quicksearch.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 RobertSoft.BookStore.DBClass;
namespace BookStore
{
/// <summary>
/// QuickSearch 的摘要说明。
/// </summary>
public class QuickSearch : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid SearchDTGrid;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.HtmlControls.HtmlForm QuickSearchFrom;
protected System.Web.UI.WebControls.Label lbCount;
protected Lei.WebControls.PagerDataList pdlSubTypeDetail;
protected System.Web.UI.WebControls.Label lbNobook;
RobertSoft.BookStore.Book currentBook = new RobertSoft.BookStore.Book();
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
string strSearchType;
string strSearchKeyword;
string strSql;
// [12/1/2004]
// Get the value we wanted
if(!Object.Equals(Request["strSearchType"],null))
{
// Get query from Left pannel(leftControl.ascx)
strSearchType = Request["strSearchType"];
strSearchKeyword = Request["SearchKeyword"];
strSql = "select * from BookInfo where 1=1 and " + strSearchType + " like '%"
+ strSearchKeyword + "%'";
}
else
{
// Get query from Search.aspx
strSql = "select * from BookInfo where 1=1";
if(!Object.Equals(Request["Author"],null))
{
strSql = strSql + " and Author like '%" + Request["Author"].Trim() + "%'";
}
if(!Object.Equals(Request["Publisher"],null))
{
strSql = strSql + " and PublishingHouse like '%" + Request["Publisher"].Trim() + "%'";
}
if(!Object.Equals(Request["BookName"],null))
{
strSql = strSql + " and BookName like '%" + Request["BookName"].Trim() + "%'";
}
}
// [12/1/2004]
// Bind to datagrid and be ready to display
GridBind(strSql);
}
}
private void GridBind(string str)
{
// [12/1/2004]
DataView currentDV;
currentDV = currentBook.GetBookEx(str);
if(currentDV.Count !=0)
{
this.pdlSubTypeDetail.DataSource = currentDV;
this.pdlSubTypeDetail.DataBind();
this.lbCount.Text = "共找到" + currentDV.Count + "个符合搜索条件的书籍:";
}
else
{
this.pdlSubTypeDetail.Visible = false;
this.lbNobook.Visible = true;
this.lbNobook.Text = "很抱歉没有找到符合您给定条件的书籍。您可以去<a href='LackBook.aspx'>缺书登记</a>登记您的需求!谢谢。" ;
}
this.pdlSubTypeDetail.DataSource = currentDV;
this.pdlSubTypeDetail.DataBind();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.pdlSubTypeDetail.ItemCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.pdlSubTypeDetail_ItemCommand);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void pdlSubTypeDetail_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
{
if(e.CommandName == "select")
{
string strUrl;
strUrl = "ShowBookDetail.aspx?ID=" + e.CommandArgument;
Response.Redirect(strUrl);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -