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; }
private void productMasterView_InitProductMasterEvent(object sender, ProductMasterEventArgs e) { var criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); 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()); // product type criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddOrder("TypeName", true); e.ProductTypeList = SortType((ArrayList)ProductTypeLogic.FindAll(criteria)); e.ProductTypeList.Insert(0, new ProductType()); // product size criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddOrder("SizeName", true); e.ProductSizeList = SortSize((ArrayList)ProductSizeLogic.FindAll(criteria)); e.ProductSizeList.Insert(0, new ProductSize()); // product color criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddOrder("ColorName", true); e.ProductColorList = SortColor((ArrayList)ProductColorLogic.FindAll(criteria)); e.ProductColorList.Insert(0, new ProductColor()); 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); } }
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; }
private void productMasterSearchDepartmentView_SearchProductEvent(object sender, ProductMasterSearchDepartmentEventArgs e) { ProductMaster searchProductMaster = e.SelectedProductMaster; ObjectCriteria searchByProductMasterCriteria = new ObjectCriteria(); searchByProductMasterCriteria.AddEqCriteria("Department", CurrentDepartment.Get()); searchByProductMasterCriteria.AddEqCriteria("ProductMaster", searchProductMaster); searchByProductMasterCriteria.AddOrder("CreateDate", false); searchByProductMasterCriteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); IList productsStockIn = DepartmentStockInDetailLogic.FindAllProductMaster(searchProductMaster); IList productsInStock = new ArrayList(); IList productIds = new ArrayList(); foreach (DepartmentStockInDetail detail in productsStockIn) { productIds.Add(detail.Product.ProductId); } ObjectCriteria stockCrit = new ObjectCriteria(); stockCrit.AddSearchInCriteria("DepartmentStockPK.ProductId", productIds); if(e.AvailableInStock) { stockCrit.AddGreaterCriteria("GoodQuantity", (long) 0); } IList stockList = DepartmentStockLogic.FindAll(stockCrit); if (stockList != null && stockList.Count > 0) { foreach (DepartmentStock departmentStock in stockList) { departmentStock.Product = ProductLogic.FindById(departmentStock.DepartmentStockPK.ProductId); productsInStock.Add(departmentStock); } } e.ProductsInDepartment = productsInStock; }
void DepartmentStockAdhocProcessingViewLoadAdhocStocksEvent(object sender, DepartmentStockFixingEventArgs e) { ObjectCriteria criteria = new ObjectCriteria(); criteria.AddLesserCriteria("GoodQuantity", (long)0); criteria.AddEqCriteria("DelFlg", (long)0); criteria.AddOrder("DepartmentStockPK.DepartmentId", true); IList list = DepartmentStockLogic.FindAll(criteria); if (list != null && list.Count > 0) { e.DeptStockAdhocList = list; } }
void departmentStockCheckingView_LoadTempInventoryCheckingEvent(object sender, DepartmentStockCheckingEventArgs e) { // search in temp stock ObjectCriteria criteria = new ObjectCriteria(); criteria.AddEqCriteria("DepartmentStockTempPK.DepartmentId", CurrentDepartment.Get().DepartmentId); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddEqCriteria("Fixed", CommonConstants.DEL_FLG_NO); criteria.AddEqCriteria("TempSave", 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 stockTempSave in list) { int viewIndex = -1; DepartmentStock stockTemp = new DepartmentStockMapper().Convert(stockTempSave); if (HasInList(stockTemp, deptStockTempList, out viewIndex)) { DepartmentStockView view = (DepartmentStockView)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.DepartmentStocks.Add(stockTemp); } else { DepartmentStockView view = new DepartmentStockView(); 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.ProductMaster = stockTemp.ProductMaster; view.DepartmentStocks = new ArrayList(); view.DepartmentStocks.Add(stockTemp); deptStockTempList.Add(view); } } } e.ReturnStockViewList = deptStockTempList; }
void departmentStockCheckingView_LoadGoodsByProductIdEvent(object sender, AppFrame.Presenter.GoodsIO.DepartmentGoodsIO.DepartmentStockCheckingEventArgs e) { string barCode = e.InputBarcode; Product product = ProductLogic.FindById(barCode); if(product==null) { return; } // search in temp stock ObjectCriteria criteria = new ObjectCriteria(); criteria.AddEqCriteria("DepartmentStockTempPK.ProductId", product.ProductId); criteria.AddEqCriteria("DepartmentStockTempPK.DepartmentId", CurrentDepartment.Get().DepartmentId); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); IList tempList =DepartmentStockTempLogic.FindAll(criteria); if(tempList!=null && tempList.Count > 0) { e.UnconfirmTempBarcode = true; throw new BusinessException("Mã vạch này đã kiểm trước đó và chưa được xác nhận. Xin liên hệ người quản lý kho."); } // search in stock ProductMaster searchProductMaster = product.ProductMaster; ObjectCriteria searchByProductMasterCriteria = new ObjectCriteria(); /*searchByProductMasterCriteria.AddEqCriteria("Department", CurrentDepartment.Get()); searchByProductMasterCriteria.AddEqCriteria("ProductMaster", searchProductMaster); searchByProductMasterCriteria.AddOrder("CreateDate", false); searchByProductMasterCriteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); IList productsStockIn = DepartmentStockInDetailLogic.FindAllProductMaster(searchProductMaster);*/ searchByProductMasterCriteria.AddEqCriteria("ProductMaster", searchProductMaster); IList productsStockIn = ProductLogic.FindAll(searchByProductMasterCriteria); IList productsInStock = new ArrayList(); IList productIds = new ArrayList(); //foreach (DepartmentStockInDetail detail in productsStockIn) foreach (Product detail in productsStockIn) { productIds.Add(detail.ProductId); } ObjectCriteria stockCrit = new ObjectCriteria(); stockCrit.AddSearchInCriteria("DepartmentStockPK.ProductId", productIds); stockCrit.AddEqCriteria("DepartmentStockPK.DepartmentId", CurrentDepartment.Get().DepartmentId); stockCrit.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); stockCrit.AddOrder("DepartmentStockPK.ProductId",true); IList departmentStocks = DepartmentStockLogic.FindAll(stockCrit); // create stock view if (departmentStocks != null && departmentStocks.Count > 0) { DepartmentStockView stockView = new DepartmentStockView(); stockView.ProductMaster = product.ProductMaster; stockView.DepartmentStocks = departmentStocks; foreach (DepartmentStock departmentStock in departmentStocks) { // empty old stock departmentStock.GoodQuantity = 0; departmentStock.ErrorQuantity = 0; departmentStock.UnconfirmQuantity = 0; departmentStock.LostQuantity = 0; departmentStock.DamageQuantity = 0; // sum new stock stockView.Quantity += departmentStock.Quantity; stockView.GoodQuantity += departmentStock.Quantity; stockView.ErrorQuantity += departmentStock.ErrorQuantity; stockView.UnconfirmQuantity += departmentStock.UnconfirmQuantity; stockView.LostQuantity += departmentStock.LostQuantity; stockView.DamageQuantity += departmentStock.DamageQuantity; stockView.ProductId = product.ProductId; stockView.ProductId = product.ProductId; } e.ScannedStockView = stockView; } }
void departmentCostSummaryView_CommitDepartmentCostEvent(object sender, DepartmentCostEventArgs e) { // Save the end of period // select 5 day nearest //IList departmentTimelineList = new ArrayList(); ObjectCriteria crit = new ObjectCriteria(); crit.AddOrder("EmployeeMoneyPK.WorkingDay", false); crit.MaxResult = 5; IList prevList = EmployeeMoneyLogic.FindAll(crit); DateTime startTime = DateUtility.ZeroTime(DateTime.Now); if (prevList != null && prevList.Count > 0) { // update end time of nearest 5 timeline for sure transparency EmployeeMoney fixEmpMoney = (EmployeeMoney)prevList[0]; DateTime lastSubmitEndTime = fixEmpMoney.EmployeeMoneyPK.WorkingDay; // get days which customer do not submit period TimeSpan timeSpan = DateUtility.ZeroTime(DateTime.Now).Subtract(DateUtility.ZeroTime(lastSubmitEndTime)); // fix those days in order we can sync for today. //startTime = lastSubmitEndTime.AddSeconds(1); for (int i = 0; i < timeSpan.Days - 1; i++) { DateTime nextDateTime = lastSubmitEndTime.AddDays(i + 1); EmployeeMoney fixEmplMoney = new EmployeeMoney(); fixEmplMoney.WorkingDay = DateUtility.DateOnly(nextDateTime); fixEmplMoney.CreateDate = DateUtility.MaxTime(nextDateTime); fixEmplMoney.UpdateDate = DateUtility.MaxTime(nextDateTime); fixEmplMoney.CreateId = ClientInfo.getInstance().LoggedUser.Name; fixEmplMoney.UpdateId = ClientInfo.getInstance().LoggedUser.Name; fixEmplMoney.DateLogin = DateUtility.MaxTime(nextDateTime); fixEmplMoney.DateLogout = DateUtility.MaxTime(nextDateTime); fixEmplMoney.InMoney = 0; fixEmplMoney.OutMoney = 0; EmployeeMoneyPK fixTimelinePK = new EmployeeMoneyPK { DepartmentId = CurrentDepartment.Get().DepartmentId, EmployeeId = ClientInfo.getInstance().LoggedUser.Name, WorkingDay = DateUtility.DateOnly(nextDateTime) }; fixEmplMoney.EmployeeMoneyPK = fixTimelinePK; EmployeeMoneyLogic.Add(fixEmplMoney); //startTime = fixEmplMoney.EndTime.AddSeconds(1); } } #region unused code // If submit period ( ket so ) then we ' ket so ' /*DepartmentTimeline timeline = null; if (isSubmitPeriod) { timeline = new DepartmentTimeline(); timeline.WorkingDay = DateUtility.ZeroTime(DateTime.Now); timeline.CreateDate = DateTime.Now; timeline.UpdateDate = DateTime.Now; timeline.CreateId = ClientInfo.getInstance().LoggedUser.Name; timeline.UpdateId = ClientInfo.getInstance().LoggedUser.Name; timeline.StartTime = startTime; timeline.EndTime = DateTime.Now; DepartmentTimelinePK timelinePK = new DepartmentTimelinePK { DepartmentId = CurrentDepartment.Get().DepartmentId, Period = DateTime.Now.DayOfYear }; var dbTimeline = DepartmentTimelineDAO.FindById(timelinePK); if (dbTimeline != null) { throw new BusinessException("Ngày hôm nay đã kết sổ"); } timeline.DepartmentTimelinePK = timelinePK; DepartmentTimelineDAO.Add(timeline); //departmentTimelineList.Add(timeline); }*/ #endregion DateTime toDay = DateUtility.DateOnly(DateTime.Now); EmployeeMoney employeeMoney = new EmployeeMoney(); employeeMoney.EmployeeMoneyPK = new EmployeeMoneyPK { DepartmentId = CurrentDepartment.Get().DepartmentId, EmployeeId = ClientInfo.getInstance().LoggedUser.Name, WorkingDay = toDay }; employeeMoney.WorkingDay = toDay; employeeMoney.CreateDate = DateTime.Now; employeeMoney.UpdateDate = DateTime.Now; employeeMoney.CreateId = ClientInfo.getInstance().LoggedUser.Name; employeeMoney.UpdateId = ClientInfo.getInstance().LoggedUser.Name; employeeMoney.DateLogin = DateTime.Now; employeeMoney.DateLogout = DateTime.Now; employeeMoney.InMoney = 0; DateTime nextDay = toDay.AddDays(1); EmployeeMoney nextMoney = new EmployeeMoney(); nextMoney.EmployeeMoneyPK = new EmployeeMoneyPK { DepartmentId = CurrentDepartment.Get().DepartmentId, EmployeeId = ClientInfo.getInstance().LoggedUser.Name, WorkingDay = nextDay }; nextMoney.WorkingDay = nextDay; nextMoney.CreateDate = nextDay; nextMoney.UpdateDate = nextDay; nextMoney.CreateId = ClientInfo.getInstance().LoggedUser.Name; nextMoney.UpdateId = ClientInfo.getInstance().LoggedUser.Name; nextMoney.DateLogin = DateTime.Now; nextMoney.DateLogout = DateTime.Now; employeeMoney.InMoney = e.OutMoney; EmployeeMoney nextMoneyInDB = EmployeeMoneyLogic.FindById(employeeMoney.EmployeeMoneyPK); if (nextMoneyInDB != null) { throw new BusinessException("Ngày hôm nay đã kết sổ !"); } ObjectCriteria objectCriteria = new ObjectCriteria(); objectCriteria.AddEqCriteria("EmployeeMoneyPK.WorkingDay", toDay); objectCriteria.AddEqCriteria("EmployeeMoneyPK.DepartmentId", CurrentDepartment.Get().DepartmentId); IList list = EmployeeMoneyLogic.FindAll(objectCriteria); if(list!=null && list.Count == 1) { employeeMoney = (EmployeeMoney)list[0]; // count out money employeeMoney.OutMoney = e.OutMoney; employeeMoney.UpdateDate = DateTime.Now; employeeMoney.UpdateId = ClientInfo.getInstance().LoggedUser.Name; EmployeeMoneyLogic.Update(employeeMoney); } else { employeeMoney.OutMoney = e.OutMoney; EmployeeMoneyLogic.Add(employeeMoney); } EmployeeMoneyLogic.Add(nextMoney); e.EventResult = "Success"; }
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; } }
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; }