예제 #1
0
        void stockInConfirmView_ConfirmStockInEvent(object sender, StockInConfirmEventArgs e)
        {
            try
            {
                ObjectCriteria objectCriteria = new ObjectCriteria();
                objectCriteria.AddSearchInCriteria("StockInId", e.ConfirmStockInList);
                objectCriteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                IList stockInList = StockInLogic.FindAll(objectCriteria);

                if (stockInList != null && stockInList.Count > 0)
                {
                    foreach (StockIn stockIn in stockInList)
                    {
                        if (stockIn.ConfirmFlg == 1)
                        {
                            stockIn.ConfirmFlg = 0;
                            StockInLogic.Update(stockIn);
                        }
                    }
                }
                else
                {
                    throw new BusinessException("Khong co gi de luu");
                }
            }
            catch (Exception exception)
            {
                e.EventResult = " Error !";
                e.HasErrors = true;
            }
        }
예제 #2
0
        public void stockCreateView_SearchStockInDetailEvent(object sender, StockCreateEventArgs e)
        {
            // Search StockInDetail
            var subCriteria = new SubObjectCriteria("StockIn");
            subCriteria.AddGreaterOrEqualsCriteria("StockInDate", DateUtility.ZeroTime(e.ImportDateFrom));
            subCriteria.AddLesserOrEqualsCriteria("StockInDate", DateUtility.MaxTime(e.ImportDateTo));
            subCriteria.AddEqCriteria("DelFlg", (long)0);

            var criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", (long)0);
            criteria.AddEqCriteria("StockInType", (Int64)e.StockInStatus);
            criteria.AddSubCriteria("StockIn", subCriteria);
            IList stockInDetailList = StockInDetailLogic.FindAll(criteria);
            e.StockInDetailList = stockInDetailList;

            // Search Stock
            if (stockInDetailList.Count > 0)
            {
                // build the Product id list
                IList productIdList = new ArrayList();
                foreach (StockInDetail stockInDetail in stockInDetailList)
                {
                    productIdList.Add(stockInDetail.Product.ProductId);
                }
                criteria = new ObjectCriteria();
                criteria.AddSearchInCriteria("Product.ProductId", productIdList);
                e.StockList = StockLogic.FindAll(criteria);

                criteria = new ObjectCriteria();
                criteria.AddSearchInCriteria("ProductId", productIdList);
                e.ReturnProductList = ReturnProductLogic.FindAll(criteria);
            }
        }
 void processPeriodMoneyView_LoadProcessPeriodMoneyEvent(object sender, ProcessPeriodMoneyEventArgs e)
 {
     DateTime toDay = DateUtility.DateOnly(DateTime.Now);
     ObjectCriteria objectCriteria = new ObjectCriteria();
     objectCriteria.AddEqCriteria("EmployeeMoneyPK.WorkingDay", toDay);
     IList list  = EmployeeMoneyLogic.FindAll(objectCriteria);
     e.PeriodMoneyList = list;
 }
예제 #4
0
 void closedPeriodView_LoadClosedPeriodEvent(object sender, ClosedPeriodEventArgs e)
 {
     DateTime fromDay = DateUtility.DateOnly(e.FromDate);
     DateTime toDay = DateUtility.DateOnly(e.ToDate);
     ObjectCriteria objectCriteria = new ObjectCriteria();
     objectCriteria.AddBetweenCriteria("EmployeeMoneyPK.WorkingDay", fromDay,toDay);
     IList list = EmployeeMoneyLogic.FindAll(objectCriteria);
     e.EmployeeMoneyList = 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 departmentStockDetailView_SearchDepartmentStockInDetailEvent(object sender, DepartmentStockDetailEventArgs e)
 {
     long deptId = CurrentDepartment.Get().DepartmentId;
     var objectCriteria = new ObjectCriteria(true);
     objectCriteria.AddEqCriteria("s.DelFlg", CommonConstants.DEL_FLG_NO);
     objectCriteria.AddEqCriteria("pm.ProductMasterId", e.ProductMasterId);
     objectCriteria.AddEqCriteria("s.DepartmentStockInDetailPK.DepartmentId", deptId);
     objectCriteria.AddGreaterOrEqualsCriteria("deptStockIn.StockInDate", e.StockInDateFrom);
     objectCriteria.AddLesserOrEqualsCriteria("deptStockIn.StockInDate", e.StockInDateTo);
     e.DepartmentStockInDetailList = DepartmentStockInDetailLogic.FindByQuery(objectCriteria);
     e.ProductPrice = DepartmentPriceLogic.FindById(new DepartmentPricePK { ProductMasterId = e.ProductMasterId, DepartmentId = deptId });
 }
예제 #8
0
 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);
 }
예제 #9
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;
 }
예제 #10
0
        void employeeWorkingView_LoadEmployeesWorkingDay(object sender, EmployeeWorkingsLogicEventArg e)
        {
            ObjectCriteria wDayCrit = new ObjectCriteria();
            wDayCrit.AddEqCriteria("Department.DepartmentId", CurrentDepartment.Get().DepartmentId);
            wDayCrit.AddBetweenCriteria("EmployeeWorkingDayPK.WorkingDay", DateUtility.ZeroTime(DateTime.Now),
                                        DateUtility.MaxTime(DateTime.Now));

            IList wDayResult = EmployeeWorkingDayLogic.FindAll(wDayCrit);
            e.EmployeeWorkingList = wDayResult;
            if(wDayResult!=null && wDayResult.Count > 0)
            {
                foreach (EmployeeWorkingDay workingDay in wDayResult)
                {
                    ObjectCriteria criteria = new ObjectCriteria();
                    criteria.AddEqCriteria("EmployeePK.EmployeeId", workingDay.EmployeeWorkingDayPK.EmployeeId);
                    IList list = EmployeeLogic.FindAll(criteria);
                    workingDay.Employee = (Employee)list[0];
                }
            }
        }
예제 #11
0
        /// <summary>
        /// Find all EmployeeMoney from database. No pagination.
        /// </summary>
        /// <param name="criteria"></param>
        /// <returns></returns>
        public IList FindAll(ObjectCriteria criteria)
        {
            ISession session = HibernateTemplate.SessionFactory.OpenSession();
            try
            {
                ICriteria hibernateCriteria = session.CreateCriteria(typeof(EmployeeMoney));
                if (criteria != null)
                {
                    IDictionary<string, SubObjectCriteria> map = criteria.GetSubCriteria();
                    if (map.Count > 0)
                    {
                        foreach (string key in map.Keys)
                        {
                            hibernateCriteria.CreateAlias(key, key);
                        }
                        AddCriteriaAndOrder(hibernateCriteria, criteria.GetWhere(), criteria.GetOrder());

                        foreach (string key in map.Keys)
                        {
                            SubObjectCriteria subCriteria = null;
                            map.TryGetValue(key, out subCriteria);
                            AddCriteriaAndOrder(hibernateCriteria, subCriteria.GetWhere(), subCriteria.GetOrder());
                        }
                    }
                    else
                    {
                        AddCriteriaAndOrder(hibernateCriteria, criteria.GetWhere(), criteria.GetOrder());
                    }
                }
                return hibernateCriteria.List();
            }
            finally
            {
                if (session != null)
                {
                    session.Disconnect();
                }
            }
        }
예제 #12
0
        private void productMasterView_InitProductMasterEvent(object sender, ProductMasterEventArgs e)
        {
            var criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            e.ProductTypeList = ProductTypeLogic.FindAll(criteria);
            e.ProductTypeList.Insert(0, new ProductType());
            e.ProductSizeList = ProductSizeLogic.FindAll(criteria);
            e.ProductSizeList.Insert(0, new ProductSize());
            e.ProductColorList = ProductColorLogic.FindAll(criteria);
            e.ProductColorList.Insert(0, new ProductColor());
            e.CountryList = CountryLogic.FindAll(criteria);
            e.CountryList.Insert(0, new Country());
            e.ManufacturerList = ManufacturerLogic.FindAll(criteria);
            e.ManufacturerList.Insert(0, new Manufacturer());
            e.PackagerList = PackagerLogic.FindAll(criteria);
            e.PackagerList.Insert(0, new Packager());
            e.DistributorList = DistributorLogic.FindAll(criteria);
            e.DistributorList.Insert(0, new Distributor());

            if (e.ProductMasterForInit != null)
            {
                criteria = new ObjectCriteria();
                criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                criteria.AddEqCriteria("ProductName", e.ProductMasterForInit.ProductName);
                criteria.AddEqCriteria("ProductType", e.ProductMasterForInit.ProductType);
                criteria.AddEqCriteria("Manufacturer", e.ProductMasterForInit.Manufacturer);
                criteria.AddEqCriteria("Distributor", e.ProductMasterForInit.Distributor);
                criteria.AddEqCriteria("Packager", e.ProductMasterForInit.Packager);
                criteria.AddEqCriteria("Country", e.ProductMasterForInit.Country);

                e.SameProductMasterList = ProductMasterLogic.FindAll(criteria);
            }
        }
예제 #13
0
        public void productMasterView_LoadProductMasterEvent(object sender, ProductMasterEventArgs e)
        {
            if (!string.IsNullOrEmpty(e.ProductMasterId))
            {
                e.ProductMaster = ProductMasterLogic.FindById(e.ProductMasterId);
                if (e.ProductMaster != null)
                {
                    // all the dept has same price
                    var criteria = new ObjectCriteria();
                    criteria.AddEqCriteria("DepartmentPricePK.ProductMasterId", e.ProductMasterId);
                    criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
                    IList list = DepartmentPriceLogic.FindAll(criteria);
                    if (list.Count > 0)
                    {
                        e.DepartmentPrice = (DepartmentPrice)list[0];
                    }
                }

            }
        }
        void _departmentStockAdhocProcessingView_LoadAdhocStocksEvent(object sender, DepartmentStockAdhocProcessingEventArgs e)
        {
            ObjectCriteria criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            criteria.AddEqCriteria("Fixed", CommonConstants.DEL_FLG_NO);
            criteria.AddOrder("ProductMaster.ProductMasterId", true);
            IList list = DepartmentStockTempLogic.FindAll(criteria);
            IList deptStockTempList = null;
            if (list != null && list.Count > 0)
            {
                deptStockTempList = new ArrayList();

                foreach (DepartmentStockTemp stockTemp in list)
                {
                    int viewIndex = -1;
                    if(HasInList(stockTemp,deptStockTempList,out viewIndex))
                    {
                        DepartmentStockTempView view = (DepartmentStockTempView) deptStockTempList[viewIndex];
                        view.Quantity += stockTemp.Quantity;

                        view.GoodQuantity += stockTemp.GoodQuantity;
                        view.ErrorQuantity += stockTemp.ErrorQuantity;
                        view.DamageQuantity += stockTemp.DamageQuantity;
                        view.LostQuantity += stockTemp.LostQuantity;
                        view.UnconfirmQuantity += stockTemp.UnconfirmQuantity;
                        view.RealQuantity += stockTemp.GoodQuantity + stockTemp.ErrorQuantity + stockTemp.DamageQuantity +
                                        stockTemp.LostQuantity + stockTemp.UnconfirmQuantity;
                        view.DepartmentStockTemps.Add(stockTemp);
                    }
                    else
                    {
                        DepartmentStockTempView view = new DepartmentStockTempView();
                        view.Quantity += stockTemp.Quantity;
                        view.GoodQuantity += stockTemp.GoodQuantity;
                        view.ErrorQuantity += stockTemp.ErrorQuantity;
                        view.DamageQuantity += stockTemp.DamageQuantity;
                        view.LostQuantity += stockTemp.LostQuantity;
                        view.UnconfirmQuantity += stockTemp.UnconfirmQuantity;
                        view.RealQuantity += stockTemp.GoodQuantity + stockTemp.ErrorQuantity + stockTemp.DamageQuantity +
                                        stockTemp.LostQuantity + stockTemp.UnconfirmQuantity;

                        view.ProductMaster = stockTemp.ProductMaster;
                        view.DepartmentStockTemps = new ArrayList();
                        view.DepartmentStockTemps.Add(stockTemp);
                        deptStockTempList.Add(view);
                    }
                }

            }

            e.DeptStockAdhocList = deptStockTempList;
        }
예제 #15
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 _departmentStockOutView_LoadProductSizeEvent(object sender, DepartmentStockOutEventArgs e)
 {
     if (e.SelectedDepartmentStockOutDetail != null && e.SelectedDepartmentStockOutDetail.Product != null && !string.IsNullOrEmpty(e.SelectedDepartmentStockOutDetail.Product.ProductMaster.ProductName))
     {
         var subCriteria = new SubObjectCriteria("ProductMasters");
         subCriteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
         subCriteria.AddEqCriteria("ProductType", e.SelectedDepartmentStockOutDetail.Product.ProductMaster.ProductType);
         subCriteria.AddEqCriteria("ProductName", e.SelectedDepartmentStockOutDetail.Product.ProductMaster.ProductName);
         subCriteria.AddEqCriteria("ProductColor", e.SelectedDepartmentStockOutDetail.Product.ProductMaster.ProductColor);
         subCriteria.AddEqCriteria("Country", e.SelectedDepartmentStockOutDetail.Product.ProductMaster.Country);
         subCriteria.AddEqCriteria("Manufacturer", e.SelectedDepartmentStockOutDetail.Product.ProductMaster.Manufacturer);
         subCriteria.AddEqCriteria("Distributor", e.SelectedDepartmentStockOutDetail.Product.ProductMaster.Distributor);
         subCriteria.AddEqCriteria("Packager", e.SelectedDepartmentStockOutDetail.Product.ProductMaster.Packager);
         var criteria = new ObjectCriteria();
         criteria.AddSubCriteria("ProductMasters", subCriteria);
         IList productSizes = ProductSizeLogic.FindAll(criteria);
         e.ProductSizeList = productSizes;
     }
 }
        public void _departmentStockOutView_FindBarcodeEvent(object sender, DepartmentStockOutEventArgs e)
        {
            var criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            criteria.AddEqCriteria("Product.ProductId", e.ProductId);
            IList list = DepartmentStockLogic.FindAll(criteria);
            if (list.Count == 0)
            {
                return;
            }
            Stock stock = list[0] as Stock;
            e.SelectedDepartmentStockOutDetail = new DepartmentStockOutDetail();
            e.SelectedDepartmentStockOutDetail.Product = stock.Product;
            e.SelectedDepartmentStockOutDetail.Quantity = stock.Quantity;
            e.SelectedDepartmentStockOutDetail.GoodQuantity = stock.Quantity;
            e.SelectedDepartmentStockOutDetail.ErrorQuantity = stock.ErrorQuantity;
            e.SelectedDepartmentStockOutDetail.LostQuantity = stock.LostQuantity;
            e.SelectedDepartmentStockOutDetail.DamageQuantity = stock.DamageQuantity;
            e.SelectedDepartmentStockOutDetail.UnconfirmQuantity = stock.UnconfirmQuantity;

            e.EventResult = "Success";
        }
예제 #18
0
        private void SearchGoodsAndReturnsInRange(object sender, GoodsSaleListEventArgs args)
        {
            IList list = PurchaseOrderLogic.FindAll(args.PurchaseOrderSearchCriteria);
            IList collection = new ArrayList();
            foreach (PurchaseOrder order in list)
            {
                PurchaseOrderView view = new PurchaseOrderView();
                view.PurchaseOrder = order;
                view.PurchaseOrderId = order.PurchaseOrderPK.PurchaseOrderId;

                long SellAmount = 0;
                long SellQuantity = 0;
                string SellDescription = "";
                long RetAmount = 0;
                long RetQuantity = 0;
                string RetDescription = "";
                foreach (PurchaseOrderDetail detail in order.PurchaseOrderDetails)
                {
                    SellDescription += detail.Product.ProductMaster.ProductName + " ";
                    SellAmount += detail.Quantity*detail.Price;
                    SellQuantity += detail.Quantity;
                }

                ObjectCriteria criteria = new ObjectCriteria();
                criteria.AddEqCriteria("NextPurchaseOrderId", order.PurchaseOrderPK.PurchaseOrderId);
                criteria.AddEqCriteria("ReturnPoPK.DepartmentId", order.PurchaseOrderPK.DepartmentId);
                IList returnPOList = ReturnPoLogic.FindAll(criteria);
                foreach (ReturnPo returnPo in returnPOList)
                {
                    RetDescription += returnPo.Product.ProductMaster.ProductName + " ";
                    long retPrice = returnPo.Price;
                    if (retPrice == 0)
                    {
                        DepartmentPricePK deptPricePK = new DepartmentPricePK();
                        deptPricePK.DepartmentId = 0;
                        deptPricePK.ProductMasterId = returnPo.Product.ProductMaster.ProductMasterId;
                        DepartmentPrice price = DepartmentPriceLogic.FindById(deptPricePK);
                        if (price != null)
                        {
                            retPrice = price.Price;
                        }
                    }
                    RetAmount += returnPo.Quantity * retPrice;
                    RetQuantity += returnPo.Quantity;
                }

                view.ReturnPOList = returnPOList;
                view.SellDescription = SellDescription;
                view.SellAmount = SellAmount;
                view.SellQuantity = SellQuantity;
                view.ReturnAmount = RetAmount;
                view.ReturnDescription = RetDescription;
                view.ReturnQuantity = RetQuantity;
                view.IssueDate = order.CreateDate;
                collection.Add(view);
            }

            ObjectCriteria NAcriteria = new ObjectCriteria();
            NAcriteria.AddEqCriteria("ReturnPoPK.DepartmentId", CurrentDepartment.Get().DepartmentId);
            NAcriteria.AddGreaterOrEqualsCriteria("ReturnPoPK.CreateDate", args.FromDate)
                .AddLesserOrEqualsCriteria("ReturnPoPK.CreateDate", args.ToDate);
            IList allReturnPOList = ReturnPoLogic.FindAll(NAcriteria);

            IList legalReturnPOList = new ArrayList();
            if(allReturnPOList!= null)
            {
                foreach (ReturnPo returnPo in allReturnPOList)
                {
                    if(string.IsNullOrEmpty(returnPo.NextPurchaseOrderId))
                            legalReturnPOList.Add(returnPo);

                }
            }

            string retNAPOId = "";
            PurchaseOrderView retNAView = new PurchaseOrderView();
            retNAView.ReturnPOList = new ArrayList();
            IList retNAList = new ArrayList();
            foreach (ReturnPo returnPo in legalReturnPOList)
            {
                if (!retNAPOId.Equals(returnPo.ReturnPoPK.PurchaseOrderId))
                {
                    if(!string.IsNullOrEmpty(retNAPOId))
                    {
                        collection.Add(retNAView);
                        retNAView = new PurchaseOrderView();
                        retNAView.ReturnPOList = new ArrayList();
                    }
                    retNAPOId = returnPo.ReturnPoPK.PurchaseOrderId;
                    retNAView.PurchaseOrderId = retNAPOId;
                    retNAView.IssueDate = returnPo.ReturnPoPK.CreateDate;
                }
                retNAView.ReturnDescription += returnPo.Product.ProductMaster.ProductName + " ";
                long retPrice = returnPo.Price;
                    if (retPrice == 0)
                    {
                        DepartmentPricePK deptPricePK = new DepartmentPricePK();
                        deptPricePK.DepartmentId = 0;
                        deptPricePK.ProductMasterId = returnPo.Product.ProductMaster.ProductMasterId;
                        DepartmentPrice price = DepartmentPriceLogic.FindById(deptPricePK);
                        if (price != null)
                        {
                            retPrice = price.Price;
                        }
                    }
                retNAView.ReturnAmount += returnPo.Quantity * retPrice;
                retNAView.ReturnQuantity += returnPo.Quantity;
                retNAView.ReturnPOList.Add(returnPo);
            }
            collection.Add(retNAView);

            GoodsSaleListEventArgs goodsSaleListEventArgs = new GoodsSaleListEventArgs();
            goodsSaleListEventArgs.PurchaseOrderViewList = collection;
            EventUtility.fireEvent(CompletedGoodsSaleListSearchEvent, this, goodsSaleListEventArgs);
        }
 void inventoryCheckingView_LoadGoodsByProductIdEvent(object sender, InventoryCheckingEventArgs e)
 {
     ObjectCriteria objectCriteria  = new ObjectCriteria();
     objectCriteria.AddEqCriteria("Product.ProductId", e.InputBarcode);
     objectCriteria.AddEqCriteria("DelFlg", (long)0);
     IList stockList = StockLogic.FindAll(objectCriteria);
     if(stockList != null && stockList.Count > 0)
     {
         e.ScannedStock = (Stock)stockList[0];
     }
     else
     {
         e.ScannedStock = null;
     }
     IList stockDefectList = StockLogic.FindAll(objectCriteria);
     if(stockDefectList!=null && stockDefectList.Count > 0)
     {
         e.ScannedStock = (Stock)stockDefectList[0];
     }
     else
     {
         e.ScannedStock = null;
     }
 }
        private IList GetRemainStockNumber(IList departmentStockIns)
        {
            IList productLists = new ArrayList();
            foreach (DepartmentStockOutDetail detail in departmentStockIns)
            {
                if (detail.Product != null)
                    productLists.Add(detail.Product.ProductId);
            }
            if (productLists.Count == 0)
            {
                return new ArrayList();
            }
            var criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            criteria.AddEqCriteria("DepartmentStockPK.DepartmentId", CurrentDepartment.Get().DepartmentId);
            criteria.AddSearchInCriteria("DepartmentStockPK.ProductId", productLists);
            IList stockList = DepartmentStockLogic.FindAll(criteria);

            if (stockList != null && stockList.Count > 0)
            {
                foreach (DepartmentStockOutDetail detail in departmentStockIns)
                {
                    foreach (DepartmentStock stock in stockList)
                    {
                        if (stock.DepartmentStockPK.ProductId.Equals(detail.Product.ProductId))
                        {
                            detail.Quantity = stock.Quantity;
                            break;
                        }
                    }
                }
            }

            return stockList;
        }
 void deptStockOutView_FindByStockInIdEvent(object sender, DepartmentStockOutEventArgs e)
 {
     if (e.SelectedStockInIds.Count > 0)
     {
         ObjectCriteria objectCriteria = new ObjectCriteria();
         objectCriteria.AddSearchInCriteria("DepartmentStockInDetailPK.StockInId", e.SelectedStockInIds);
         IList list = DepartmentStockInDetailLogic.FindAll(objectCriteria);
         IList stockOutList = new ArrayList();
         foreach (DepartmentStockInDetail inDetail in list)
         {
             DepartmentStockOutDetail deptDetail = new DepartmentStockOutDetail();
             deptDetail.CreateDate = DateTime.Now;
             deptDetail.UpdateDate = DateTime.Now;
             deptDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name;
             deptDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name;
             //deptDetail. = new DepartmentStockInDetailPK();
             deptDetail.Product = inDetail.Product;
             deptDetail.ProductMaster = inDetail.Product.ProductMaster;
             deptDetail.Quantity = inDetail.Quantity;
             deptDetail.GoodQuantity = inDetail.Quantity;
             stockOutList.Add(deptDetail);
         }
         IList stockList = GetRemainStockNumber(stockOutList);
         e.FoundDepartmentStockOutDetailList = stockOutList;
         e.DepartmentStockList = stockList;
     }
     EventUtility.fireEvent(CompletedFindByStockInEvent, this, e);
 }
        public void _departmentStockOutView_LoadStockStatusEvent(object sender, DepartmentStockOutEventArgs e)
        {
            if (e.SelectedProductMasterList == null || e.SelectedProductMasterList.Count == 0) return;

            IList productMasterIds = new ArrayList();
            foreach (ProductMaster master in e.SelectedProductMasterList)
            {
                productMasterIds.Add(master.ProductMasterId);
            }
            ObjectCriteria prdCrit = new ObjectCriteria();
            prdCrit.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            prdCrit.AddSearchInCriteria("ProductMaster.ProductMasterId", productMasterIds);
            IList prdList = ProductLogic.FindAll(prdCrit);

            IList stkPrdIdsList = new ArrayList();
            foreach (Product product in prdList)
            {
                stkPrdIdsList.Add(product.ProductId);
            }

            var criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            criteria.AddSearchInCriteria("DepartmentStockPK.ProductId", stkPrdIdsList);

            IList list = DepartmentStockLogic.FindAll(criteria);
            if (list.Count == 0)
            {
                return;
            }

            e.DepartmentStockList = new ArrayList();
            e.FoundDepartmentStockOutDetailList = new ArrayList();
            foreach (DepartmentStock stock in list)
            {
                /*if(stock.Quantity == 0)
                {
                    continue;
                }*/
                DepartmentStockOutDetail detail = new DepartmentStockOutDetail();
                detail.DepartmentStockOutDetailPK = new DepartmentStockOutDetailPK
                                                        {
                                                            DepartmentId = CurrentDepartment.Get().DepartmentId
                                                        };
                detail.Product = stock.Product;
                detail.GoodQuantity = stock.GoodQuantity;
                detail.ErrorQuantity = stock.ErrorQuantity;
                detail.LostQuantity = stock.LostQuantity;
                detail.DamageQuantity = stock.DamageQuantity;
                detail.UnconfirmQuantity = stock.UnconfirmQuantity;
                detail.Quantity = stock.Quantity;
                e.DepartmentStockList.Add(stock);
                e.FoundDepartmentStockOutDetailList.Add(detail);
            }
        }
        public void _departmentStockOutView_FindBarcodeEvent(object sender, DepartmentStockOutEventArgs e)
        {
            var criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
            criteria.AddEqCriteria("DepartmentStockPK.DepartmentId", CurrentDepartment.Get().DepartmentId);
            criteria.AddEqCriteria("DepartmentStockPK.ProductId", e.ProductId);
            IList list = DepartmentStockLogic.FindAll(criteria);
            if (list.Count == 0)
            {

                /* begin +++++++++++++++++++ XUAT TRUOT LO CHO KHO PHU +++++++++++++++++++++ */
                if(ClientSetting.IsBlockSliding && ClientSetting.IsSubStock())
                {
                    // just sub-stock has the right to do block sliding
                    if(ClientSetting.IsSubStock())
                    {
                        Product product = ProductLogic.FindById(e.ProductId);
                        if(product == null ) throw new BusinessException("Mã vạch này chưa từng được nhập vào kho.");
                        ProductColor color = product.ProductMaster.ProductColor;
                        ProductSize size = product.ProductMaster.ProductSize;
                        string productName = product.ProductMaster.ProductName;
                        var productCriteria = new ObjectCriteria();
                        IList slidedStockList = DepartmentStockLogic.FindSlidingStock(productName,color.ColorName,size.SizeName);
                        BusinessException emptyStockException = new BusinessException(" Hàng " + productName + " - Màu:" + color.ColorName + " - Size:" + size.SizeName + " đã hết. Xin kiểm tra lại !");
                        if (slidedStockList.Count == 0) throw emptyStockException;
                        foreach (DepartmentStock departmentStock in slidedStockList)
                        {
                            if(departmentStock.Quantity > 0 && departmentStock.GoodQuantity > 0 )
                            {
                                list.Add(departmentStock);
                                break;
                            }
                        }
                        if (list.Count == 0) throw emptyStockException;
                    }
                    else // throw error if not sub stock
                    {
                        throw new BusinessException("Bạn đang dùng chức năng xuất trượt lô cho mã vạch không có trong kho. Chức năng xuất trượt lô chỉ có trong kho phụ.");
                        return;
                    }
                }
                else
                {
                    throw new BusinessException("Mã vạch này không có trong kho ?!?! Đề nghị kiểm tra lại.");
                    return;
                }
                /* end +++++++++++++++++++ XUAT TRUOT LO CHO KHO PHU +++++++++++++++++++++ */
            }
            DepartmentStock stock = list[0] as DepartmentStock;
            e.SelectedDepartmentStockOutDetail = new DepartmentStockOutDetail();
            e.SelectedDepartmentStockOutDetail.DepartmentStockOutDetailPK = new DepartmentStockOutDetailPK
                                                                                {
                                                                                    DepartmentId = CurrentDepartment.Get().DepartmentId
                                                                                };
            e.SelectedDepartmentStockOutDetail.Product = stock.Product;
            e.SelectedDepartmentStockOutDetail.Quantity = stock.Quantity;
            e.SelectedDepartmentStockOutDetail.GoodQuantity = stock.Quantity;
            e.SelectedDepartmentStockOutDetail.ErrorQuantity = stock.ErrorQuantity;
            e.SelectedDepartmentStockOutDetail.LostQuantity = stock.LostQuantity;
            e.SelectedDepartmentStockOutDetail.DamageQuantity = stock.DamageQuantity;
            e.SelectedDepartmentStockOutDetail.UnconfirmQuantity = stock.UnconfirmQuantity;
            e.DepartmentStock = stock;

            e.EventResult = "Success";
        }
 void inventoryCheckingView_LoadGoodsByProductIdEvent(object sender, DepartmentStockCheckingEventArgs e)
 {
     ObjectCriteria objectCriteria = new ObjectCriteria();
     objectCriteria.AddEqCriteria("DepartmentStockPK.ProductId", e.InputBarcode);
     objectCriteria.AddEqCriteria("DepartmentStockPK.DepartmentId", CurrentDepartment.Get().DepartmentId);
     objectCriteria.AddEqCriteria("DelFlg", (long)0);
     System.Collections.IList stockList = DepartmentStockLogic.FindAll(objectCriteria);
     if (stockList != null && stockList.Count > 0)
     {
         e.ScannedStock = (DepartmentStock)stockList[0];
     }
     else
     {
         e.ScannedStock = null;
     }
 }
        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;
            }
        }
예제 #26
0
 public void stockSearchView_InitStockSearchEvent(object sender, StockSearchEventArgs e)
 {
     var criteria = new ObjectCriteria();
     criteria.AddEqCriteria("DelFlg", (long)0);
     e.ProductTypeList = ProductTypeLogic.FindAll(criteria);
     e.ProductTypeList.Insert(0, new ProductType());
     e.ProductSizeList = ProductSizeLogic.FindAll(criteria);
     e.ProductSizeList.Insert(0, new ProductSize());
     e.ProductColorList = ProductColorLogic.FindAll(criteria);
     e.ProductColorList.Insert(0, new ProductColor());
     e.CountryList = CountryLogic.FindAll(criteria);
     e.CountryList.Insert(0, new Country());
     e.ManufacturerList = ManufacturerLogic.FindAll(criteria);
     e.ManufacturerList.Insert(0, new Manufacturer());
     e.PackagerList = PackagerLogic.FindAll(criteria);
     e.PackagerList.Insert(0, new Packager());
     e.DistributorList = DistributorLogic.FindAll(criteria);
     e.DistributorList.Insert(0, new Distributor());
 }
 public void _departmentStockOutView_LoadGoodsByNameEvent(object sender, DepartmentStockOutEventArgs e)
 {
     DepartmentStockOutDetail detail = e.SelectedDepartmentStockOutDetail;
     ObjectCriteria objectCriteria = new ObjectCriteria();
     objectCriteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);
     objectCriteria.AddEqCriteria("ProductName", detail.Product.ProductMaster.ProductName);
     IList list = ProductMasterLogic.FindAll(objectCriteria);
     e.FoundProductMasterList = list;
     if (list == null || list.Count == 0)
     {
         return;
     }
     ProductMaster prodMaster = list[0] as ProductMaster;
     detail.Product.ProductMaster = prodMaster;
     e.SelectedDepartmentStockOutDetail = detail;
     IList detailList = new ArrayList();
     detailList.Add(detail);
     //            GetRemainStockNumber(detailList);
 }
예제 #28
0
        public void stockSearchView_RemainSearchStockEvent(object sender, StockSearchEventArgs e)
        {
            var criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", (long)0);
            criteria.AddLesserOrEqualsCriteria("CreateDate", e.FromDate);
            IList deptStockInDetailFromList = DepartmentStockInDetailLogic.FindAll(criteria);

            criteria.AddNotEqualsCriteria("StockInType", (long)1);
            IList stockInDetailFromList = StockInDetailLogic.FindAll(criteria);

            criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", (long)0);
            criteria.AddLesserOrEqualsCriteria("CreateDate", e.ToDate);

            IList deptStockInDetailToList = DepartmentStockInDetailLogic.FindAll(criteria);
            criteria.AddNotEqualsCriteria("StockInType", (long)1);
            IList stockInDetailToList = StockInDetailLogic.FindAll(criteria);

            //            IList stockHistoryList = StockHistoryLogic.FindByMaxDate(criteria);
            var reportList = new List<UniversalStockReportObject>();

            // calculate dau` ton`
            foreach (StockInDetail stockInDetail in stockInDetailFromList)
            {
                UniversalStockReportObject report = null;
                foreach (var reportObject in reportList)
                {
                    if (stockInDetail.Product.ProductMaster.ProductMasterId.Equals(reportObject.ProductMaster.ProductMasterId))
                    {
                        report = reportObject;
                        break;
                    }
                }

                if (report != null)
                {
                    report.StockStartQuantity += stockInDetail.Quantity;
                    report.StockInStartQuantity += stockInDetail.Quantity;

                }
                else
                {
                    report = new UniversalStockReportObject();
                    reportList.Add(report);
                    report.StockStartQuantity = stockInDetail.Quantity;
                    report.StockInStartQuantity = stockInDetail.Quantity;
                }

                report.ProductMaster = stockInDetail.Product.ProductMaster;
                foreach (DepartmentStockInDetail deptStockInDetail in deptStockInDetailFromList)
                {
                    if (report.ProductMaster.ProductMasterId.Equals(deptStockInDetail.Product.ProductMaster.ProductMasterId))
                    {
                        report.StockStartQuantity -= deptStockInDetail.Quantity;
                        report.DepartmentStockInStartQuantity += deptStockInDetail.Quantity;
                    }
                }
                reportList.Add(report);
            }

            // calculate cuoi ton
            foreach (StockInDetail stockInDetail in stockInDetailToList)
            {
                UniversalStockReportObject report = null;
                foreach (var reportObject in reportList)
                {
                    if (stockInDetail.Product.ProductMaster.ProductMasterId.Equals(reportObject.ProductMaster.ProductMasterId))
                    {
                        report = reportObject;
                        break;
                    }
                }
                if (report != null)
                {
                    report.StockEndQuantity += stockInDetail.Quantity;
                    report.StockInEndQuantity += stockInDetail.Quantity;

                }
                else
                {
                    report = new UniversalStockReportObject();
                    report.ProductMaster = stockInDetail.Product.ProductMaster;
                    reportList.Add(report);
                    report.StockEndQuantity = stockInDetail.Quantity;
                    report.StockInEndQuantity = stockInDetail.Quantity;
                }

                foreach (DepartmentStockInDetail deptStockInDetail in deptStockInDetailToList)
                {
                    if (report.ProductMaster.ProductMasterId.Equals(deptStockInDetail.Product.ProductMaster.ProductMasterId))
                    {
                        report.StockEndQuantity -= deptStockInDetail.Quantity;
                        report.DepartmentStockInEndQuantity += deptStockInDetail.Quantity;
                    }
                }
            //                foreach (StockHistory stockHistory in stockHistoryList)
            //                {
            //                    if (report.ProductMaster.ProductMasterId.Equals(stockHistory.Product.ProductMaster.ProductMasterId))
            //                    {
            //                        report.LostCount += stockHistory.LostCount;
            //                        report.GoodCount += stockHistory.GoodCount;
            //                        report.ErrorCount += stockHistory.ErrorCount;
            //                        report.DamageCount += stockHistory.DamageCount;
            //                    }
            //                }
            }
            e.ReportList = reportList;
        }
        public void _departmentStockOutView_LoadStockStatusEvent(object sender, DepartmentStockOutEventArgs e)
        {
            IList productMasterIds = new ArrayList();
            foreach (ProductMaster master in e.SelectedProductMasterList)
            {
                productMasterIds.Add(master.ProductMasterId);
            }
            var criteria = new ObjectCriteria();
            criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO);

            //criteria.AddSearchInCriteria("Product.ProductMaster.ProductMasterId", productMasterIds);
            //criteria.AddSubCriteria("Product", new SubObjectCriteria("ProductMaster").AddSearchInCriteria("ProductMasterId", productMasterIds));
            IList list = DepartmentStockLogic.FindAllInProductMasterId(productMasterIds);
            if (list.Count == 0)
            {
                return;
            }

            e.DepartmentStockList = new ArrayList();
            e.FoundDepartmentStockOutDetailList = new ArrayList();
            foreach (DepartmentStock stock in list)
            {
                DepartmentStockOutDetail detail = new DepartmentStockOutDetail();
                detail.Product = stock.Product;
                detail.GoodQuantity = stock.GoodQuantity;
                detail.ErrorQuantity = stock.ErrorQuantity;
                detail.LostQuantity = stock.LostQuantity;
                detail.DamageQuantity = stock.DamageQuantity;
                detail.UnconfirmQuantity = stock.UnconfirmQuantity;
                detail.Quantity = stock.Quantity;

                e.DepartmentStockList.Add(stock);
                e.FoundDepartmentStockOutDetailList.Add(detail);
            }
        }
예제 #30
0
        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;
        }