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

📄 viewsearch.aspx.cs

📁 电子商务网站转载而来[展开所有目录] [建议增加分类] (重要) 您上载的源码为何会被站长不采用或帐号被删除? 1.源码太简单 2.不是源码 3.缺少文件 4.所选类别和开发环境
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Model;
using BLL;

public partial class ViewSearch : System.Web.UI.Page
{
    public string txtCategory = string.Empty;
    public string txtProduct = string.Empty;
    public string txtPriceStart = string.Empty;
    public string txtPriceEnd = string.Empty;
    public string txtItem = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindCategory();
        }

    }
    public void BindCategory() {

        Category bll = new Category();
        IList<CategoryInfo> category = bll.GetCategory();
        SelectCategory.Items.Add(new ListItem("所有商品", "all"));

        for (int i = 0; i < category.Count; i++)
        {

            SelectCategory.Items.Add(new ListItem(category[i].CategoryName, category[i].CategoryId));

        }
    
    }
    protected void ButtonSearch_Click(object sender, EventArgs e)
    {
        txtCategory = SelectCategory.SelectedItem.Value;
        txtProduct = SelectProduct.SelectedItem.Value;
        txtPriceStart = PriceStart.Value.Trim().ToString();
        if (string.IsNullOrEmpty(txtPriceStart)) {

            txtPriceStart = "0";
        
        }
        txtPriceEnd = PriceEnd.Value.Trim().ToString();
        if (string.IsNullOrEmpty(txtPriceEnd)) {

            txtPriceEnd = "0";
        
        }
        txtItem = Server.HtmlEncode(ItemName.Value.Trim().ToString().Replace(",", ""));
        if (string.IsNullOrEmpty(txtItem)) {

            txtItem = "0";
        
        }
        if (int.Parse(txtPriceStart) > int.Parse(txtPriceEnd))
        {

            Response.Redirect("ViewSearch.aspx");

        }

        Response.Redirect("ViewSearchItem.aspx?Category=" + txtCategory + "&Product=" + txtProduct + "&PriceStart=" + txtPriceStart + "&PriceEnd=" + txtPriceEnd + "&Key=" + txtItem + "");

    }
    protected void SelectCategory_SelectedIndexChanged(object sender, EventArgs e)
    {
        Product bll = new Product();
        string txtCategory = string.Empty;
        SelectProduct.Items.Clear();

        SelectProduct.Enabled = true;
        IList<ProductInfo> product = bll.GetProductByCategory(SelectCategory.SelectedItem.Value);
        SelectProduct.Items.Add(new ListItem("所有目录", "all"));
        for (int i = 0; i < product.Count; i++)
        {

            SelectProduct.Items.Add(new ListItem(product[i].ProductName, product[i].ProductId));


        }
    }
}

⌨️ 快捷键说明

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