?? advancedsearch.aspx.cs
字號(hào):
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 BMS
{
/// <summary>
/// AdvancedSearch 的摘要說(shuō)明。
/// </summary>
public partial class AdvancedSearch : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack) BindGrid();
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:該調(diào)用是 ASP.NET Web 窗體設(shè)計(jì)器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
}
#endregion
public void DataGrid_Page(Object sender,DataGridPageChangedEventArgs E)
{
dgd_booklist.CurrentPageIndex =E.NewPageIndex ;
BindGrid();
}
public void BindGrid()
{ //從文件Web.config中讀取連接字符串
string strconn= ConfigurationSettings.AppSettings["dsn"];
//連接本地計(jì)算機(jī)的LMS數(shù)據(jù)庫(kù)
SqlConnection cn= new SqlConnection (strconn);
//創(chuàng)建帶篩子的SQL語(yǔ)句
string mysql="select * from book where 1=1";
//對(duì)控建進(jìn)行篩選
if (tbx_bid.Text .ToString ()!="")//如果“書(shū)號(hào)”有輸入
{
try
{
mysql=mysql+" and bid="+Convert.ToInt32 (tbx_bid.Text .ToString ());
}
catch
{
Response.Write ("書(shū)號(hào)輸入有誤!");
Response.End();
}
}
if (tbx_bname.Text .ToString ()!="")//如果“書(shū)名”有輸入
{
mysql=mysql+" and bname like '%"+tbx_bname.Text .ToString ()+"%'";
}
if (tbx_bauthor.Text .ToString ()!="")//如果“書(shū)作者”有輸入
{
mysql=mysql+" and bauthor like '%"+tbx_bauthor.Text .ToString ()+"%'";
}
if (tbx_bisbn.Text .ToString ()!="")//如果“書(shū)ISBN”有輸入
{
mysql=mysql+" and bisbn='"+tbx_bisbn.Text .ToString ()+"'";
}
if (tbx_bpress.Text .ToString ()!="")//如果“書(shū)出版社”有輸入
{
mysql=mysql+" and bpress like '%"+tbx_bpress.Text .ToString ()+"%'";
}
if (tbx_btheme.Text .ToString ()!="")//如果“主題詞”有輸入
{
mysql=mysql+" and btheme like '%"+tbx_btheme.Text .ToString ()+"%'";
}
//創(chuàng)建SqlDataAdapter對(duì)象,調(diào)用視圖
SqlDataAdapter da=new SqlDataAdapter (mysql,cn);
//創(chuàng)建并填充DataSet
DataSet ds=new DataSet ();
da.Fill (ds);
dgd_booklist.DataSource =ds;
dgd_booklist.DataBind ();
cn.Close ();
}
protected void btn_search_Click(object sender, System.EventArgs e)
{
BindGrid();
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -