private void StockSearchForm_Load(object sender, EventArgs e) { var eventArgs = new StockSearchEventArgs(); EventUtility.fireEvent(InitStockSearchEvent, this, eventArgs); productMasterControl.cbbProductType.DataSource = eventArgs.ProductTypeList; productMasterControl.cbbProductType.DisplayMember = "TypeName"; productMasterControl.cbbProductSize.DataSource = eventArgs.ProductSizeList; productMasterControl.cbbProductSize.DisplayMember = "SizeName"; productMasterControl.cbbProductColor.DataSource = eventArgs.ProductColorList; productMasterControl.cbbProductColor.DisplayMember = "ColorName"; productMasterControl.cbbCountry.DataSource = eventArgs.CountryList; productMasterControl.cbbCountry.DisplayMember = "CountryName"; productMasterControl.cbbPackager.DataSource = eventArgs.PackagerList; productMasterControl.cbbPackager.DisplayMember = "PackagerName"; productMasterControl.cbbDistributor.DataSource = eventArgs.DistributorList; productMasterControl.cbbDistributor.DisplayMember = "DistributorName"; productMasterControl.cbbManufacturer.DataSource = eventArgs.ManufacturerList; productMasterControl.cbbManufacturer.DisplayMember = "ManufacturerName"; }
private void btnSearch_Click(object sender, EventArgs e) { stockBindingSource.Clear(); var eventArgs = new StockSearchEventArgs { ProductMasterId = productMasterControl.txtProductMasterId.Text, ProductMasterName = productMasterControl.txtProductName.Text, ProductSize = productMasterControl.cbbProductSize.SelectedIndex > 0 ? ((ProductSize)productMasterControl.cbbProductSize.SelectedItem) : null, ProductType = productMasterControl.cbbProductType.SelectedIndex > 0 ? ((ProductType)productMasterControl.cbbProductType.SelectedItem) : null, ProductColor = productMasterControl.cbbProductColor.SelectedIndex > 0 ? ((ProductColor)productMasterControl.cbbProductColor.SelectedItem) : null, Country = productMasterControl.cbbCountry.SelectedIndex > 0 ? ((Country)productMasterControl.cbbCountry.SelectedItem) : null, Packager = productMasterControl.cbbPackager.SelectedIndex > 0 ? ((Packager)productMasterControl.cbbPackager.SelectedItem) : null, Manufacturer = productMasterControl.cbbManufacturer.SelectedIndex > 0 ? ((Manufacturer)productMasterControl.cbbManufacturer.SelectedItem) : null, Distributor = productMasterControl.cbbDistributor.SelectedIndex > 0 ? ((Distributor)productMasterControl.cbbDistributor.SelectedItem) : null, FromDate = dtpImportDateFrom.Value, ToDate = dtpImportDateTo.Value }; EventUtility.fireEvent(BarcodeSearchStockEvent, sender, eventArgs); if(eventArgs.StockList== null || eventArgs.StockList.Count == 0) { MessageBox.Show("Không tìm thấy sản phẩm nào."); return; } stockBindingSource.DataSource = eventArgs.StockList; }
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; }
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_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 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()); }
private void textBox1_TextChanged(object sender, EventArgs e) { if(!string.IsNullOrEmpty(txtProductId.Text)) { productMasterControl.Enabled = false; if(txtProductId.Text.Length == 12) { stockBindingSource.Clear(); StockSearchEventArgs eventArgs = null; if (eventArgs == null) { eventArgs = new StockSearchEventArgs(); } eventArgs.ProductId = txtProductId.Text.Trim(); eventArgs.Description = txtDescription.Text.Trim(); eventArgs.RelevantProductFinding = chkRelevant.Checked; EventUtility.fireEvent(BarcodeSearchStockEvent, sender, eventArgs); txtProductId.Text = ""; if (eventArgs.StockList == null || eventArgs.StockList.Count == 0) { MessageBox.Show("Không tìm thấy sản phẩm nào."); return; } stockBindingSource.DataSource = eventArgs.StockList; } } else { productMasterControl.Enabled = true; } }
private void btnSearch_Click(object sender, EventArgs e) { var eventArgs = new StockSearchEventArgs { ProductMasterId = productMasterControl.txtProductMasterId.Text, ProductMasterName = productMasterControl.txtProductName.Text, ProductSize = productMasterControl.cbbProductSize.SelectedIndex > 0 ? ((ProductSize)productMasterControl.cbbProductSize.SelectedItem) : null, ProductType = productMasterControl.cbbProductType.SelectedIndex > 0 ? ((ProductType)productMasterControl.cbbProductType.SelectedItem) : null, ProductColor = productMasterControl.cbbProductColor.SelectedIndex > 0 ? ((ProductColor)productMasterControl.cbbProductColor.SelectedItem) : null, Country = productMasterControl.cbbCountry.SelectedIndex > 0 ? ((Country)productMasterControl.cbbCountry.SelectedItem) : null, Packager = productMasterControl.cbbPackager.SelectedIndex > 0 ? ((Packager)productMasterControl.cbbPackager.SelectedItem) : null, Manufacturer = productMasterControl.cbbManufacturer.SelectedIndex > 0 ? ((Manufacturer)productMasterControl.cbbManufacturer.SelectedItem) : null, Distributor = productMasterControl.cbbDistributor.SelectedIndex > 0 ? ((Distributor)productMasterControl.cbbDistributor.SelectedItem) : null }; EventUtility.fireEvent(SearchStockEvent, sender, eventArgs); stockBindingSource.DataSource = eventArgs.StockList; long sumQty = 0; foreach (Stock stock in eventArgs.StockList) { sumQty += stock.Quantity; } txtSumQty.Text = sumQty.ToString(); }
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; }