selectstockinfro.aspx.cs

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

CS
146
字号
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 金利来分销管理系统.Stock
{
    public partial class SelectStockInfro : System.Web.UI.Page
    {
        //实例化BLL层
        BLL.Stock.Stock_SetailsBll stocksetailbllshow;
        BLL.Store.StoreBll storebllshow;
        BLL.Goods.ProductBll productbllshow;
        BLL.Employee.EmployeeBll employeebllshow;

        public SelectStockInfro()
        {
            stocksetailbllshow = new BLL.Stock.Stock_SetailsBll();
            storebllshow = new BLL.Store.StoreBll();
            productbllshow = new BLL.Goods.ProductBll();
            employeebllshow = new BLL.Employee.EmployeeBll();      

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                
                //用户权限
                if (Session["employee_id"] == null)
                {
                    Response.Write("<script>alert('请您登陆系统');location.href='../Enter.aspx'</script>");
                }
                else
                {
                    if (employeebllshow.UserRole(Session["role_id"].ToString(), "44") == true)
                    {
                        //判断“stockformid”是否为空(是否接收到采购单据查询页面中的采购单号)
                        if (Request.QueryString["stockformid"] != null)
                        {
                            //通过采购单据查询页面中的采购单号显示数据
                            this.gvShow.DataSource = stocksetailbllshow.stocksetailbystockform(Request.QueryString["stockformid"].ToString());
                        }
                        else
                        {
                            //显示所有采购明细中的数据
                            this.gvShow.DataSource = stocksetailbllshow.stocksetail();
                        }
                        this.gvShow.DataBind();
                        //实例化采购明细的泛型集合(商品品牌)
                        List<Model.Stock.Stock_SetailsModel> stockbrand = stocksetailbllshow.SelectBrand();
                        //查询所有品牌名称
                        foreach (var item in stockbrand)
                        {
                            this.ddlBrand.Items.Add(item.brand_Name);
                        }
                        //实例化商品泛型集合
                        List<Model.Goods.ProductModel> productid = productbllshow.SelectProductID();
                        //查询商品编号
                        foreach (var item in productid)
                        {
                            this.ddlProductID.Items.Add(item.product_id);
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('你无权查看此功能,请与管理员联系');location.href='../Aboutus.aspx'</script>");
                    }
                }
            }
        }
        //查询
        protected void btnSelect_Click(object sender, EventArgs e)
        {
            ShowMethod();
        }
        //显示
        private void ShowMethod()
        {
            //实例化采购明细泛型集合
            List<Model.Stock.Stock_SetailsModel> list = stocksetailbllshow.stocksetail();
            //按采购单据编号查找
            if (ddlStockFormID.SelectedValue != "请选择采购单据号")
            {
                list = list.FindAll(o => o.stockform_id.Contains(this.ddlStockFormID.Text));
            }
            //按商品编号查找
            if (ddlProductID.SelectedIndex != 0)
            {
                list = list.FindAll(o => o.product_id.Contains(this.ddlProductID.Text));
            }
            //按商品品牌查找
            if (ddlBrand.SelectedIndex != 0)
            {
                list = list.FindAll(o => o.stock_setails_brand.Contains(this.ddlBrand.Text.Trim()));
            }
            //显示数据
            this.gvShow.DataSource = list;
            this.gvShow.DataBind();
        }
        //获取改天单据编号
        protected void btnSele_Click(object sender, EventArgs e)
        {
            //if (this.txtTime.Text == "")
            //{
            //    this.lblTime.Visible = true;
            //    this.ddlStockFormID.Text = "请选择采购单据号";
            //}
            //else
            //{
                //this.lblTime.Visible = false ;
                //清空采购单据编号
                this.ddlStockFormID.Items.Clear();
             if (this.txtTime.Text == "")
            {
                this.lblTime.Visible = true;
            }
            else
            {
                //实例化采购明细的泛型集合(通过时间)
                List<Model.Stock.Stock_SetailsModel> stockid = storebllshow.SelectStockFormIDByTime(DateTime.Parse(this.txtTime.Text));
                //查询所有采购单据编号
                foreach (var item in stockid)
                {
                    this.ddlStockFormID.Items.Add(item.stockform_id);
                }
                if (ddlStockFormID.Text == "")
                {
                    this.gvShow.DataSource = null;
                    this.gvShow.DataBind();
                }
           }
        }
        //分页
        protected void gvShow_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {

            this.gvShow.PageIndex = e.NewPageIndex;
            ShowMethod();
        }
    }
}

⌨️ 快捷键说明

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