selectallreserve.aspx.cs

来自「c#三层架构项目开发的全过程」· CS 代码 · 共 70 行

CS
70
字号
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using BLL;
namespace Enterprise_management
{
    public partial class SelectAllReserve : System.Web.UI.Page
    {
        BLL.Goods.ProductBll productbllshow;
        BLL.Store.StoreBll storeIDshow;
        public SelectAllReserve()
        {
            productbllshow = new BLL.Goods.ProductBll();
            storeIDshow = new BLL.Store.StoreBll();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //将所有商品编号添加到DropDownList里
                List<Model.Goods.ProductModel> productid = productbllshow.SelectProductID();
                foreach (var item in productid)
                {
                    this.ddlProduct.Items.Add(item.product_id);
                }
                //将所有分店编号添加到DropDownList
                List<Model.Store.StoreModel> storeid = storeIDshow.SelectStoreID();
                foreach (var item in storeid)
                {
                    this.ddlShop.Items.Add(item.store_id.ToString());
                }
                //将所有商品颜色添加到DropDownList
                List<Model.Store.StoreModel> storecolor = storeIDshow.GetProductColor();
                foreach (var item in storecolor)
                {
                    this.ddlColor.Items.Add(item.store_color);
                }
                Show();
            }
        }

        protected void btnsearch_Click(object sender, EventArgs e)
        {
            Show();
        }

        private void Show()
        {
            List<Model.Store.StoreModel> storeall = storeIDshow.SelectStoreAll();
            if (this.ddlShop.SelectedIndex != 0)
            {
                storeall = storeall.FindAll(o => o.store_id.ToString().Contains(this.ddlShop.Text));
            }
            if (this.ddlProduct.SelectedIndex != 0)
            {
                storeall = storeall.FindAll(o => o.product_id.Contains(this.ddlProduct.Text));
            }
            if (this.ddlColor.SelectedIndex != 0)
            {
                storeall = storeall.FindAll(o => o.store_color.Contains(this.ddlColor.Text));
            }
            this.gvshow.DataSource = storeall;
            this.gvshow.DataBind();
        }
    }
}

⌨️ 快捷键说明

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