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

📄 searchproducts.aspx.cs

📁 电子商城源代码,包含项目工程文件! 数据库建表语句 具体功能包括电子购物车,在线购物!
💻 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;

namespace EMall
{
	/// <summary>
	/// SearchProducts 的摘要说明。
	/// </summary>
	public class SearchProducts : System.Web.UI.Page
	{
		protected Pub pub = new Pub();
		protected System.Web.UI.WebControls.Label lbMsg;
		protected HenryFan.WebControls.DisPage DisPage1;
		protected System.Web.UI.WebControls.DataList DataList1;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// 在此处放置用户代码以初始化页面
			BindData();
		}

		/// <summary>
		/// 绑定数据
		/// </summary>
		private void BindData()
		{
			string sStr;
			// 判断是 商品快速查询 还是分类查询
			if (Request.Params["sStr"] != null)
			{
				// 如果是 商品快速查询
				sStr = Request.Params["sStr"];
				if (sStr.Length > 0)
				{
					string sSQL = "SELECT O.*, S.Name AS CategoryName, P.Name AS Vendor FROM dbo.Products O INNER JOIN	dbo.Categories S ON O.CategoryID = S.ID INNER JOIN dbo.Customers P ON O.VendorID = P.ID	WHERE O.ModelNumber LIKE '%" + sStr + "%' OR O.ModelName LIKE '%" + sStr + "%' OR	O.Description LIKE '%" + sStr + "%' ORDER BY O.ModelName, O.ModelNumber";
					pub.Fill(sSQL);
					this.DisPage1.Open(pub.DataSet1);
				}
				else
				{
					pub.sTitle = pub.sTitle + " -- 商品查询 -- 指定查询条件, 至少要输入1个字符";
					DisPage1.Visible = false;
				}
			}
			else if (Request.Params["CategoryID"] != null)
			{
				sStr = Request.Params["CategoryID"];
				if (Int32.Parse(sStr) >= 0)
				{
					int iID = int.Parse(sStr);
					string sSQL = "SELECT O.*, S.Name AS CategoryName, P.Name AS Vendor FROM dbo.Products O INNER JOIN	dbo.Categories S ON O.CategoryID = S.ID INNER JOIN dbo.Customers P ON O.VendorID = P.ID WHERE O.CategoryID = " + iID + " ORDER BY O.ModelName, O.ModelNumber";
					pub.Fill(sSQL);
					this.DisPage1.Open(pub.DataSet1);
					pub.sTitle = pub.sTitle + " -- 商品浏览 -- 所有 " + Request.Params["CategoryName"].ToString() + " 的商品";
				}
				else
				{
					pub.sTitle = pub.sTitle + " -- 商品浏览 -- 指定查询条件无效";
					DisPage1.Visible = false;
				}
				lbMsg.Text = pub.sTitle;
			}
			else
				Response.Redirect("Error.aspx?sStr=非法页面访问", true);
		}

		#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()
		{    
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion
	}
}

⌨️ 快捷键说明

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