Example #1
0
        //查询
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (this.dateEdit1.EditValue == null)
            {
                MessageBox.Show(Properties.Resources.DateNotNull, this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (this.cob_HandBookId.SelectedItem == null)
            {
                MessageBox.Show("手册号不能为空", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DateTime date       = this.dateEdit1.DateTime;
            string   handBookId = this.cob_HandBookId.SelectedItem.ToString();
            string   depotId    = lookUpEditDepotStar.EditValue == null ? null : lookUpEditDepotStar.EditValue.ToString();

            //查询出所有商品
            IList <Model.Product> pros = productManager.SelectForJishiShouCe(this.lookUpEditDepotStar.EditValue == null ? null : this.lookUpEditDepotStar.EditValue.ToString(), this.LookUpProductCategoryStart.EditValue == null ? null : this.LookUpProductCategoryStart.EditValue.ToString(), this.lookUpProductCategoryEnd.EditValue == null ? null : this.lookUpProductCategoryEnd.EditValue.ToString(), this.textProductNameOrId.Text);

            productList = new List <Model.Product>();
            foreach (var item in pros)
            {
                //再根据商品编号查询:日期小于等于查询日期的所有 -出倉單+入倉單+生產入庫單+委外入庫單-銷售出貨單+採購入庫單+銷售退貨-採購退貨+生产退料
                IList <Model.Product> list = stockManager.SelectJiShiForShouCe(item.ProductId, date, handBookId, depotId, this.checkEditGroupByPO.Checked);
                if (list != null && list.Count > 0)
                {
                    foreach (var ss in list)
                    {
                        ss.ProductId            = item.ProductId;
                        ss.Id                   = item.Id;
                        ss.ProductName          = item.ProductName;
                        ss.CustomerProductName  = item.CustomerProductName;
                        ss.ProductVersion       = item.ProductVersion;
                        ss.ProductCategoryName  = item.ProductCategoryName;
                        ss.ProductCategoryName2 = item.ProductCategoryName2;
                        ss.ProductCategoryName3 = item.ProductCategoryName3;
                        ss.NetWeight            = item.NetWeight;
                        ss.MaterialIds          = item.MaterialIds;
                        ss.MaterialNum          = item.MaterialNum;
                        ss.HandbookId           = handBookId;
                        ss.CnName               = item.CnName;

                        productList.Add(ss);
                    }
                }
            }

            //不显示0库存商品要在查出以后做判断。默认不显示
            if (!this.checkEditShowZeroProduct.Checked)
            {
                productList = productList.Where(s => s.StocksQuantity != 0).ToList();
            }

            this.gridControl1.DataSource = productList;
            this.labelControl1.Text      = productList.Count.ToString() + " 项";
        }