Example #1
0
 private void posLogView_SearchPosLogEvent(object sender, PosLogEventArgs e)
 {
     var criteria = new ObjectCriteria();
     if(!string.IsNullOrEmpty(e.Username))
     {
         criteria.AddLikeCriteria("PosUser", e.Username + "%");
     }
     if(!string.IsNullOrEmpty(e.Action))
     {
         criteria.AddLikeCriteria("PosAction", e.Action + "%");
     }
     criteria.AddGreaterOrEqualsCriteria("Date", DateUtility.ZeroTime(e.LogDateFrom));
     criteria.AddLesserOrEqualsCriteria("Date", DateUtility.MaxTime(e.LogDateTo));
     criteria.AddOrder("Date", false);
     IList list = PosLogLogic.FindAll(criteria);
     e.PosLogList = list;
 }
 public void departmentStockInSearchView_SearchMainStockInEvent(object sender, MainStockInSearchEventArgs e)
 {
     var criteria = new ObjectCriteria();
     criteria.AddGreaterOrEqualsCriteria("StockInDate", e.StockInDateFrom);
     criteria.AddLesserOrEqualsCriteria("StockInDate", e.StockInDateTo);
     criteria.AddLikeCriteria("StockInId", e.StockInId + "%");
     criteria.AddEqCriteria("DelFlg", (long)0);
     e.StockInList = StockInLogic.FindAll(criteria);
 }
 public void departmentStockInSearchView_SearchDepartmentStockInEvent(object sender, DepartmentStockInSearchEventArgs e)
 {
     var criteria = new ObjectCriteria();
     criteria.AddEqCriteria("DepartmentStockInPK.DepartmentId", CurrentDepartment.Get().DepartmentId);
     criteria.AddGreaterOrEqualsCriteria("StockInDate", e.StockInDateFrom);
     criteria.AddLesserOrEqualsCriteria("StockInDate", e.StockInDateTo);
     criteria.AddLikeCriteria("DepartmentStockInPK.StockInId", e.StockInId + "%");
     criteria.AddEqCriteria("DelFlg", (long)0);
     e.DepartmeneStockInList = DepartmentStockInLogic.FindAll(criteria);
     EventUtility.fireEvent(CompletedSearchDepartmentStockInEvent,this,e);
 }
 public void goodsIOSearchView_SearchBlockInDetailEvent(object sender, GoodsIOSearchEventArgs e)
 {
     var criteria = new ObjectCriteria();
     if (!string.IsNullOrEmpty(e.BlockDetailId))
     {
         criteria.AddLikeCriteria("BlockInDetailPK.BlockDetailId", string.Format("{0}%", e.BlockDetailId));
     }
     criteria.AddGreaterOrEqualsCriteria("ImportDate", DateUtility.ZeroTime(e.ImportDateFrom));
     criteria.AddLesserOrEqualsCriteria("ImportDate", DateUtility.MaxTime(e.ImportDateTo));
     if (!e.IsNeedDelete)
     {
         criteria.AddEqCriteria("DelFlg", (Int64)0);
     }
     e.BlockDetailList = BlockInDetailLogic.FindAll(criteria);
 }
        public void _departmentStockOutView_FillProductToComboEvent(object sender, DepartmentStockOutEventArgs e)
        {
            ComboBox comboBox = (ComboBox) sender;
            string originalText = comboBox.Text;
            if (e.IsFillToComboBox)
            {
                ProductMaster searchPM = e.SelectedDepartmentStockOutDetail.Product.ProductMaster;
                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.MaxResult = 50;
                IList list = DepartmentStockLogic.FindByQueryForDeptStock(criteria);

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

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

                var productMasters = new BindingList<ProductMaster>();
                foreach (ProductMaster master in result)
                {
                    productMasters.Add(master);
                }

                var 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.MaxDropDownItems = 10;
            }
        }
        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 stockSearchView_SearchStockEvent(object sender, StockSearchEventArgs e)
        {
            /*            var subCriteria1 = new SubObjectCriteria("Product");
                        var subCriteria2 = new SubObjectCriteria("ProductMaster");
                        subCriteria2.AddLikeCriteria("ProductMasterId", e.ProductMasterId);
                        subCriteria2.AddLikeCriteria("ProductName", e.ProductMasterName);*/

            var criteria = new ObjectCriteria(true);
            criteria.AddEqCriteria("stock.DelFlg", CommonConstants.DEL_FLG_NO);
            criteria.AddLikeCriteria("pm.ProductMasterId", e.ProductMasterId + "%");
            criteria.AddLikeCriteria("pm.ProductName", "%" + e.ProductMasterName + "%");
            criteria.AddEqCriteria("pm.ProductType", e.ProductType);
            criteria.AddEqCriteria("pm.ProductSize", e.ProductSize);
            criteria.AddEqCriteria("pm.ProductColor", e.ProductColor);
            criteria.AddEqCriteria("pm.Country", e.Country);
            criteria.AddEqCriteria("pm.Manufacturer", e.Manufacturer);
            criteria.AddEqCriteria("pm.Packager", e.Packager);
            criteria.AddEqCriteria("pm.Distributor", e.Distributor);
            IList list = StockLogic.FindByQuery(criteria);
            if(!CheckUtility.IsNullOrEmpty(GlobalCache.Instance().WarningText))
            {
                MessageBox.Show(GlobalCache.Instance().WarningText);
                GlobalCache.Instance().WarningText = null;
            }
            e.StockList = list;
        }
        public void stockSearchView_SearchStockEvent(object sender, DepartmentStockSearchEventArgs e)
        {
            var objectCriteria = new ObjectCriteria(true);
            objectCriteria.AddEqCriteria("s.DelFlg", (long)0);
            objectCriteria.AddEqCriteria("sdetail.DelFlg", (long)0);
            objectCriteria.AddLikeCriteria("pm.ProductMasterId", e.ProductMasterId + "%");
            objectCriteria.AddLikeCriteria("pm.ProductName", e.ProductMasterName + "%");
            objectCriteria.AddEqCriteria("pm.ProductType", e.ProductType);
            objectCriteria.AddEqCriteria("pm.ProductSize", e.ProductSize);
            objectCriteria.AddEqCriteria("pm.ProductColor", e.ProductColor);
            objectCriteria.AddEqCriteria("pm.Manufacturer", e.Manufacturer);
            objectCriteria.AddEqCriteria("pm.Country", e.Country);
            objectCriteria.AddEqCriteria("s.DepartmentStockPK.DepartmentId", CurrentDepartment.Get().DepartmentId);

            e.DepartmentStockList = DepartmentStockLogic.FindByQuery(objectCriteria);
        }
        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 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.MaxResult = 50;
                        IList list = StockLogic.FindByQueryForStockIn(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;
                    }
        }
        void _departmentStockInView_FillProductToComboEvent(object sender, MainStockInEventArgs e)
        {
            ComboBox comboBox = (ComboBox) sender;
            string originalText = comboBox.Text;
            if (e.IsFillToComboBox)
            {
                ProductMaster searchPM = e.SelectedStockInDetail.Product.ProductMaster;
                System.Collections.IList result = null;
                if (e.ComboBoxDisplayMember.Equals("ProductMasterId"))
                {
                    result = ProductMasterLogic.FindProductMasterById(searchPM.ProductMasterId, 50,true);
                }
                else
                {
                    //result = ProductMasterLogic.FindProductMasterByName(searchPM.ProductName, 50,true);
                    ObjectCriteria criteria = new ObjectCriteria();
                    criteria.AddLikeCriteria("ProductName", "%" + searchPM.ProductName + "%");
                    criteria.AddOrder("ProductName", true);
                    criteria.MaxResult = 200;
                    result = ProductMasterLogic.FindAll(criteria);

                }
                if(result==null)
                {
                    return;
                }

                BindingList<ProductMaster> productMasters = new BindingList<ProductMaster>();
                if (result != null)
                {
                    result = RemoveDuplicateName(result);
                    foreach (ProductMaster master in result)
                    {

                        productMasters.Add(master);
                    }
                }
                BindingSource bindingSource = new BindingSource();
                bindingSource.DataSource = productMasters;
                comboBox.DataSource = bindingSource;
                comboBox.DisplayMember = "ProductName";
                comboBox.ValueMember = e.ComboBoxDisplayMember;
                comboBox.DropDownWidth = 300;
                comboBox.DropDownHeight = 200;
                // keep the original text
                comboBox.Text = originalText;
                if (result.Count > 0)
                {
                    comboBox.SelectedIndex = 0;
                }

                comboBox.SelectionStart = comboBox.Text.Length;
                //comboBox.DroppedDown = false;
                comboBox.MaxDropDownItems = 15;
            }
        }
 void _productMasterSearchOrCreateView_SearchCommonProductMasterEvent(object sender, ProductMasterSearchOrCreateEventArgs e)
 {
     var criteria = new ObjectCriteria();
     if (!string.IsNullOrEmpty(e.ProductMasterId))
     {
         /*long value = 0;
         Int64.TryParse(e.ProductMasterId, out value);*/
         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);
     }
     IList list = ProductMasterLogic.FindAll(criteria);
     IList returnList = new ArrayList();
     if(list!=null && list.Count > 0)
     {
         foreach (ProductMaster master in list)
         {
             AddNonDuplicateItem(returnList, master);
         }
     }
     e.ProductMasterList = returnList;
 }
        private void productMasterView_SearchProductMasterEvent(object sender, ProductMasterSearchOrCreateEventArgs e)
        {
            var criteria = new ObjectCriteria();
            if (!string.IsNullOrEmpty(e.ProductMasterId))
            {
                /*long value = 0;
                Int64.TryParse(e.ProductMasterId, out value);*/
                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);
            }

            e.ProductMasterList = ProductMasterLogic.FindAll(criteria);
        }
        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;
            }
        }