예제 #1
0
        private void stockSearchView_BarcodeSearchStockEvent(object sender, StockSearchEventArgs e)
        {
            var subCriteria = new SubObjectCriteria("ProductMaster");
            subCriteria.AddLikeCriteria("ProductName", "%" + e.ProductMasterName + "%");
            subCriteria.AddEqCriteria("ProductType", e.ProductType);
            subCriteria.AddEqCriteria("ProductSize", e.ProductSize);
            subCriteria.AddEqCriteria("ProductColor", e.ProductColor);
            subCriteria.AddEqCriteria("Country", e.Country);
            subCriteria.AddEqCriteria("Manufacturer", e.Manufacturer);
            subCriteria.AddEqCriteria("Packager", e.Packager);
            subCriteria.AddEqCriteria("Distributor", e.Distributor);

            var criteria = new ObjectCriteria(true);
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            criteria.AddLikeCriteria("Product.ProductId", e.ProductMasterId + "%");
            criteria.AddSubCriteria("ProductMaster", subCriteria);
            criteria.AddGreaterOrEqualsCriteria("CreateDate", DateUtility.ZeroTime(e.FromDate));
            criteria.AddLesserOrEqualsCriteria("CreateDate", DateUtility.MaxTime(e.ToDate));
            IList list = StockLogic.FindAll(criteria);
            e.StockList = list;
        }
        public void departmentStockDetailView_SearchDepartmentPriceEvent(object sender, DepartmentPriceUpdateEventArgs e)
        {
            var subCriteria = new SubObjectCriteria("ProductMaster");
            subCriteria.AddLikeCriteria("ProductMasterId", e.ProductMasterId + "%");
            subCriteria.AddLikeCriteria("ProductName", e.ProductMasterName + "%");
            subCriteria.AddEqCriteria("ProductType", e.ProductType);
            subCriteria.AddEqCriteria("ProductSize",  e.ProductSize);
            subCriteria.AddEqCriteria("ProductColor", e.ProductColor);
            subCriteria.AddEqCriteria("Country", e.Country);
            subCriteria.AddEqCriteria("Packager", e.Packager);
            subCriteria.AddEqCriteria("Manufacturer", e.Manufacturer);
            subCriteria.AddEqCriteria("Distributor", e.Distributor);

            var criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            criteria.AddSubCriteria("ProductMaster", subCriteria);
            criteria.AddEqCriteria("DepartmentPricePK.DepartmentId", CurrentDepartment.Get().DepartmentId);

            e.DepartmentPriceList = DepartmentPriceLogic.FindAll(criteria);
        }
        void _departmentStockInView_FillProductToComboEvent(object sender, DepartmentStockInEventArgs e)
        {
            ComboBox comboBox = (ComboBox) sender;
                    string originalText = comboBox.Text;
                    if (e.IsFillToComboBox)
                    {
                        ProductMaster searchPM = e.SelectedDepartmentStockInDetail.Product.ProductMaster;
                        var subCrit = new SubObjectCriteria("ProductMaster");
                        subCrit.AddLikeCriteria("ProductName", "%" + searchPM.ProductName + "%");
                        subCrit.AddOrder("ProductName", true);

                        var criteria = new ObjectCriteria(true);
                        /*criteria.AddEqCriteria("pm.DelFlg", CommonConstants.DEL_FLG_NO);
                        criteria.AddEqCriteria("stock.DelFlg", CommonConstants.DEL_FLG_NO);
                        criteria.AddLikeCriteria("pm.ProductName", "%" + searchPM.ProductName + "%");*/
                        criteria.AddSubCriteria("ProductMaster", subCrit);
                        criteria.MaxResult = 200;
                        /*IList list = StockLogic.FindByQueryForStockIn(criteria);*/
                        IList list = StockLogic.FindAll(criteria);
            //                        if (e.ComboBoxDisplayMember.Equals("ProductMasterId"))
            //                        {
            //                            result = ProductMasterLogic.FindProductMasterById(searchPM.ProductMasterId, 50,true);
            //                        }
            //                        else
            //                        {
            //                            result = ProductMasterLogic.FindProductMasterByName(searchPM.ProductName, 50,true);
            //                        }

                        if(list ==null || list.Count == 0)
                        {
                            return;
                        }
                        IList result = new ArrayList();
                        foreach (Stock stock in list)
                        {
                            result.Add(stock.ProductMaster);
                        }
                        IList retlist = RemoveDuplicateName(result);

                        result = new ArrayList();
                        int count = 0;
                        foreach (var p in retlist)
                        {
                            result.Add(p);
                            count++;
                        }

                        BindingList<ProductMaster> productMasters = new BindingList<ProductMaster>();
                        if (result != null)
                        {
                            foreach (ProductMaster master in result)
                            {
                                productMasters.Add(master);
                            }
                        }
                        BindingSource bindingSource = new BindingSource();
                        bindingSource.DataSource = productMasters;
                        comboBox.DataSource = bindingSource;
                        comboBox.DisplayMember = "TypeAndName";
                        comboBox.ValueMember = e.ComboBoxDisplayMember;
                        comboBox.DropDownWidth = 300;
                        comboBox.DropDownHeight = 200;
                        // keep the original text
                        comboBox.Text = originalText;
                        //comboBox.SelectedIndex = -1;
                        //comboBox.SelectionStart = comboBox.Text.Length;
                        //comboBox.DroppedDown = true;
                        comboBox.MaxDropDownItems = 10;
                    }
        }
        public void departmentStockDetailView_SearchDepartmentPriceEvent(object sender, DepartmentPriceUpdateEventArgs e)
        {
            var subCriteria = new SubObjectCriteria("ProductMaster");
            subCriteria.AddLikeCriteria("ProductMasterId", "%" + e.ProductMasterId + "%");
            if(e.AbsoluteFinding)
            {
                subCriteria.AddEqCriteria("ProductName", e.ProductMasterName);
            }
            else
            {
                subCriteria.AddLikeCriteria("ProductName", "%" + e.ProductMasterName + "%");
            }
            if(e.ProductType!=null)
            {
                subCriteria.AddEqCriteria("ProductType", e.ProductType);
            }

            if (e.ProductSize != null)
            {
                subCriteria.AddEqCriteria("ProductSize", e.ProductSize);
            }

            if (e.ProductColor != null)
            {
                subCriteria.AddEqCriteria("ProductColor", e.ProductColor);
            }

            if (e.Country != null)
            {
                subCriteria.AddEqCriteria("Country", e.Country);
            }

            if (e.Packager != null)
            {
                subCriteria.AddEqCriteria("Packager", e.Packager);
            }

            if (e.Manufacturer != null)
            {
                subCriteria.AddEqCriteria("Manufacturer", e.Manufacturer);
            }

            if (e.Distributor != null)
            {
                subCriteria.AddEqCriteria("Distributor", e.Distributor);
            }

            subCriteria.AddOrder("ProductName",false);
            subCriteria.AddOrder("ProductColor", false);
            subCriteria.AddOrder("ProductSize", false);
            var criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            if(e.ZeroPrice)
            {
                criteria.AddEqCriteria("Price", (long) 0);
            }
            if(e.ZeroWholeSalePrice)
            {
                criteria.AddEqCriteria("WholeSalePrice", (long) 0);
            }
            criteria.AddSubCriteria("ProductMaster", subCriteria);
            /*criteria.AddEqCriteria("DepartmentPricePK.DepartmentId", 0);*/

            e.DepartmentPriceList = DepartmentPriceLogic.FindAll(criteria);
        }
예제 #5
0
        private void stockSearchView_BarcodeSearchStockEvent(object sender, StockSearchEventArgs e)
        {
            var subCriteria = new SubObjectCriteria("ProductMaster");
            if(!string.IsNullOrEmpty(e.ProductMasterId))
            {
                subCriteria.AddLikeCriteria("ProductMasterId", "%" + e.ProductMasterId + "%");
            }
            if(!string.IsNullOrEmpty(e.ProductMasterName))
            {
                subCriteria.AddLikeCriteria("ProductName", "%" + e.ProductMasterName + "%");
            }
            if (e.ProductType != null)
            {
                subCriteria.AddEqCriteria("ProductType", e.ProductType);
            }
            if (e.ProductSize != null)
            {
                subCriteria.AddEqCriteria("ProductSize", e.ProductSize);
            }
            if (e.ProductColor != null)
            {
                subCriteria.AddEqCriteria("ProductColor", e.ProductColor);
            }
            if (e.Country != null)
            {
                subCriteria.AddEqCriteria("Country", e.Country);
            }
            if(e.Manufacturer!=null)
            {
                subCriteria.AddEqCriteria("Manufacturer", e.Manufacturer);
            }
            if(e.Packager!=null)
            {
                subCriteria.AddEqCriteria("Packager", e.Packager);
            }
            if (e.Distributor != null)
            {
                subCriteria.AddEqCriteria("Distributor", e.Distributor);
            }
            if (!string.IsNullOrEmpty(e.Description))
            {
                subCriteria.AddLikeCriteria("Description", "%" + e.Description + "%");
            }

            var criteria = new ObjectCriteria(true);
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            bool searchByProductId = !string.IsNullOrEmpty(e.ProductId);
            if(searchByProductId)
            {
                criteria.AddLikeCriteria("Product.ProductId", "%" + e.ProductId + "%");
            }

            criteria.AddSubCriteria("ProductMaster", subCriteria);
            criteria.AddOrder("ProductMaster.ProductName", true);
            criteria.AddOrder("Product.ProductId",true);
            IList list = StockLogic.FindAll(criteria);
            if(searchByProductId && e.RelevantProductFinding)
            {
                if(list!=null && list.Count > 0)
                {
                    IList extraList = new ArrayList();
                    foreach (Stock stock in list)
                    {
                        Product product = stock.Product;
                        subCriteria = new SubObjectCriteria("ProductMaster");
                        subCriteria.AddEqCriteria("ProductName", product.ProductMaster.ProductName);
                        criteria = new ObjectCriteria(true);
                        criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                        criteria.AddSubCriteria("ProductMaster", subCriteria);
                        criteria.AddOrder("Product.ProductId", true);
                        IList subList = StockLogic.FindAll(criteria);
                        if(subList!=null && subList.Count > 0 )
                        {
                            foreach (Stock stock1 in subList)
                            {
                                AddStockToList(extraList, stock1);
                            }
                        }
                    }
                    // add to original list
                    foreach (Stock stock in extraList)
                    {
                        AddStockToList(list,stock);
                    }
                }
            }
            e.StockList = list;
        }
        public void stockSearchView_SearchStockEvent(object sender, DepartmentStockSearchEventArgs e)
        {
            var criteria = new SubObjectCriteria("ProductMaster");
            if (!string.IsNullOrEmpty(e.ProductMasterId))
            {
                criteria.AddLikeCriteria("ProductMasterId", "%" + e.ProductMasterId + "%");
            }
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            criteria.AddLikeCriteria("ProductName", "%" +e.ProductMasterName + "%");
            if (e.ProductType != null && e.ProductType.TypeId > 0)
            {
                criteria.AddEqCriteria("ProductType.TypeId", e.ProductType.TypeId);
            }
            if (e.ProductSize != null && e.ProductSize.SizeId > 0)
            {
                criteria.AddEqCriteria("ProductSize.SizeId", e.ProductSize.SizeId);
            }
            if (e.ProductColor != null && e.ProductColor.ColorId > 0)
            {
                criteria.AddEqCriteria("ProductColor.ColorId", e.ProductColor.ColorId);
            }
            if (e.Country != null && e.Country.CountryId > 0)
            {
                criteria.AddEqCriteria("Country.CountryId", e.Country.CountryId);
            }
            if (!string.IsNullOrEmpty(e.Description))
            {
                criteria.AddLikeCriteria("Description", "%" + e.Description +"%");
            }
            criteria.AddOrder("ProductName",true);

            var objectCriteria = new ObjectCriteria(true);
            objectCriteria.AddEqCriteria("DelFlg", (long)0);
            if (!string.IsNullOrEmpty(e.ProductId))
            {
                objectCriteria.AddLikeCriteria("DepartmentStockPK.ProductId", "%" + e.ProductMasterId + "%");
            }
            objectCriteria.AddEqCriteria("DepartmentStockPK.DepartmentId", CurrentDepartment.Get().DepartmentId);
            objectCriteria.AddSubCriteria("ProductMaster",criteria);

            IList departmentStocks = DepartmentStockLogic.FindAll(objectCriteria);
            IList stockViewList = new ArrayList();
            // create stock view
            if (departmentStocks != null && departmentStocks.Count > 0)
            {
                DepartmentStockView stockView = null;
                foreach (DepartmentStock departmentStock in departmentStocks)
                {
                    if (stockView!=null)
                    {
                       if(!stockView.ProductMaster.ProductName.Equals(
                           departmentStock.Product.ProductMaster.ProductName))
                       {
                           stockViewList.Add(stockView);
                           stockView = null;
                       }
                    }
                    if(stockView == null)
                    {
                        stockView = new DepartmentStockView();
                        stockView.ProductMaster = departmentStock.Product.ProductMaster;
                        stockView.DepartmentStocks = new ArrayList();
                    }

                    stockView.DepartmentStocks.Add(departmentStock);
                    stockView.Quantity += departmentStock.Quantity;
                    stockView.GoodQuantity += departmentStock.GoodQuantity;

                }
                // add last item
                if(stockView!=null)
                {
                    stockViewList.Add(stockView);
                    stockView = null;
                }
                e.DepartmentStockList = stockViewList;
            }
        }