⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 advancedsearch.aspx.cs

📁 book shop system how to sell and buy online
💻 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.Configuration ;
using System.Data .SqlClient ;

namespace BMS
{
	/// <summary>
	/// AdvancedSearch 。
	/// </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:该调用是 ASP.NET Web 窗体设计器所必需的。
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{    

		}
		#endregion


		public void DataGrid_Page(Object sender,DataGridPageChangedEventArgs E)
		{
			dgd_booklist.CurrentPageIndex =E.NewPageIndex ;
			BindGrid();
		}
		public void BindGrid()
		{	//from the Web.config read the connection
			
			string strconn = "server=ABUOSAMA; uid=sa; database=BMS";
			//connecet the computer with the bms database
			SqlConnection cn= new SqlConnection (strconn);
			//create the sql 
			string mysql="select * from book,bookprice where book.bid=bookprice.ppid";
			//control  press
			if (tbx_bid.Text .ToString ()!="")//search using the book no.
			{
				mysql=mysql+" and bid="+Convert.ToInt16 (tbx_bid.Text .ToString ());
			}
			if (tbx_bname.Text .ToString ()!="")//search using book name
			{
				mysql=mysql+" and bname like '%"+tbx_bname.Text .ToString ()+"%'";
			}
			if (tbx_bauthor.Text .ToString ()!="")//serach using  book's author
			{
				mysql=mysql+" and bauthor like '%"+tbx_bauthor.Text .ToString ()+"%'";
			}
			if (tbx_bisbn.Text .ToString ()!="")//using ISBN
			{
				mysql=mysql+" and bisbn='"+tbx_bisbn.Text .ToString ()+"'";
			}
			if (tbx_bpress.Text .ToString ()!="")//using the press
			{
				mysql=mysql+" and bpress like '%"+tbx_bpress.Text .ToString ()+"%'";
			}
			if (ddl_bgroup.SelectedItem .Value .ToString ()!="-1")//using the type -1 for unknown type
			{
				mysql=mysql+" and bgroup="+Convert.ToInt16 (ddl_bgroup.SelectedItem .Value .ToString ());
			}
			//create SqlDataAdapter using the view
			SqlDataAdapter da=new SqlDataAdapter (mysql,cn);
			//create 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();
		}

		protected void ddl_bgroup_SelectedIndexChanged(object sender, System.EventArgs e)
		{
		
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -