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; } }
public void mainStockOutView_LoadStockStatusEvent(object sender, MainStockOutEventArgs 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("ProductMaster.ProductMasterId", productMasterIds); IList list = StockLogic.FindAll(criteria); if (list.Count == 0) { return; } e.StockList = new ArrayList(); e.FoundStockOutDetailList = new ArrayList(); foreach (Stock stock in list) { StockOutDetail detail = new StockOutDetail(); 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.StockList.Add(stock); e.FoundStockOutDetailList.Add(detail); } }
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); } }
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 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; } }
private void GetRemainStockNumber(IList departmentStockIns) { IList productMasterIds = new ArrayList(); foreach (DepartmentStockInDetail detail in departmentStockIns) { if (detail.Product != null && detail.Product.ProductMaster != null && detail.Product.ProductMaster.ProductMasterId != null) productMasterIds.Add(detail.Product.ProductMaster.ProductMasterId); } if (productMasterIds.Count == 0) { return; } var criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddSearchInCriteria("ProductMaster.ProductMasterId", productMasterIds); IList stockList = StockLogic.FindAll(criteria); criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddEqCriteria("DepartmentPricePK.DepartmentId", (long)0); criteria.AddSearchInCriteria("DepartmentPricePK.ProductMasterId", productMasterIds); IList priceList = DepartmentPriceLogic.FindAll(criteria); foreach (DepartmentStockInDetail detail in departmentStockIns) { detail.StockQuantity = 0; if (detail.Product != null && detail.Product.ProductMaster != null && detail.Product.ProductMaster.ProductMasterId != null) { foreach (Stock stock in stockList) { if (detail.Product.ProductMaster.ProductMasterId.Equals(stock.ProductMaster.ProductMasterId)) { detail.StockQuantity += stock.Quantity; } } foreach (DepartmentPrice price in priceList) { if (detail.Product.ProductMaster.ProductMasterId.Equals(price.DepartmentPricePK.ProductMasterId)) { detail.Price = price.Price; } } } } }
public override void departmentStockInView_SaveDepartmentStockInEvent(object sender, DepartmentStockInEventArgs e) { var stockIn = e.DepartmentStockIn; if (stockIn.StockInId == 0) { // if we are doing stock out to department if(e.ExportGoodsToDepartment) { // execute stock out saving StockOutLogic.Add(stockIn); if (!e.IsForSync) { ClientUtility.Log(logger, stockIn.ToString(), "Xuất hàng ra cửa hàng"); } else { ClientUtility.Log(logger, "Đồng bộ về cửa hàng.\r\n" + stockIn.ToString(), "Xuất hàng ra cửa hàng"); } } else { DepartmentStockInLogic.Add(stockIn); if (!e.IsForSync) { ClientUtility.Log(logger, stockIn.ToString(), "Nhập kho cửa hàng"); } else { ClientUtility.Log(logger, "Đồng bộ về cửa hàng.\r\n" + stockIn.ToString(), "Đồng bộ về cửa hàng"); } } } else { DepartmentStockInLogic.Update(stockIn); if (!e.IsForSync) { ClientUtility.Log(logger, stockIn.ToString(), "Nhập kho cửa hàng"); } else { ClientUtility.Log(logger, "Đồng bộ về cửa hàng.\r\n" + stockIn.ToString(), "Đồng bộ về cửa hàng"); } } if (stockIn.DepartmentStockInPK != null && e.IsForSync) { e.DepartmentStockIn = DepartmentStockInLogic.FindById(stockIn.DepartmentStockInPK); IList productMasterIds = new ArrayList(); foreach (DepartmentStockInDetail detail in e.DepartmentStockIn.DepartmentStockInDetails) { if (!productMasterIds.Contains(detail.Product.ProductMaster.ProductMasterId)) { productMasterIds.Add(detail.Product.ProductMaster.ProductMasterId); } } var criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddEqCriteria("DepartmentPricePK.DepartmentId", (long)0); criteria.AddSearchInCriteria("DepartmentPricePK.ProductMasterId", productMasterIds); IList priceList = DepartmentPriceLogic.FindAll(criteria); foreach (DepartmentStockInDetail detail in e.DepartmentStockIn.DepartmentStockInDetails) { foreach (DepartmentPrice price in priceList) { if (price.DepartmentPricePK.ProductMasterId.Equals(detail.Product.ProductMaster.ProductMasterId)) { detail.Price = price.Price; } } } // Department information e.DepartmentStockIn.Department = DepartmentLogic.FindById(stockIn.DepartmentStockInPK.DepartmentId); criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddEqCriteria("EmployeePK.DepartmentId", stockIn.DepartmentStockInPK.DepartmentId); e.DepartmentStockIn.Department.Employees = EmployeeLogic.FindAll(criteria); } e.EventResult = "Success"; }
public virtual void departmentStockInView_SaveDepartmentStockInEvent(object sender, DepartmentStockInEventArgs e) { var stockIn = e.DepartmentStockIn; IList masterIds = new ArrayList(); foreach (DepartmentStockInDetail detail in stockIn.DepartmentStockInDetails) { if (!masterIds.Contains(detail.Product.ProductMaster.ProductMasterId)) { masterIds.Add(detail.Product.ProductMaster.ProductMasterId); } } var cri2 = new ObjectCriteria(); cri2.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); cri2.AddEqCriteria("DepartmentPricePK.DepartmentId", (long)0); cri2.AddSearchInCriteria("DepartmentPricePK.ProductMasterId", masterIds); IList prices = DepartmentPriceLogic.FindAll(cri2); foreach (DepartmentStockInDetail detail in stockIn.DepartmentStockInDetails) { foreach (DepartmentPrice price in prices) { if (price.DepartmentPricePK.ProductMasterId.Equals(detail.Product.ProductMaster.ProductMasterId)) { detail.Price = price.Price; } if(price.Price <= 0) { throw new BusinessException(" Giá hàng của " + detail.Product.ProductMaster.ProductName + " bằng 0 hoặc âm. Đề nghị điều chỉnh trước khi xuất ra cửa hàng."); } } } if (stockIn.StockInId == 0) { //StockOutLogic.Add(stockIn); DepartmentStockInLogic.Add(stockIn); if (!e.IsForSync) { ClientUtility.Log(logger, stockIn.ToString(), "Nhập kho cửa hàng"); } else { ClientUtility.Log(logger, "Đồng bộ về cửa hàng.\r\n" + stockIn.ToString(), "Đồng bộ về cửa hàng"); } } else { //StockOutLogic.Update(stockIn); DepartmentStockInLogic.Update(stockIn); if (!e.IsForSync) { ClientUtility.Log(logger, "Chỉnh sửa " + stockIn.ToString(), "Chỉnh sửa Nhập kho cửa hàng"); } else { ClientUtility.Log(logger, "Đồng bộ về cửa hàng.\r\n" + stockIn.ToString(), "Đồng bộ về cửa hàng"); } } if (stockIn.DepartmentStockInPK != null && e.IsForSync) { e.DepartmentStockIn = DepartmentStockInLogic.FindById(stockIn.DepartmentStockInPK); IList productMasterIds = new ArrayList(); foreach (DepartmentStockInDetail detail in e.DepartmentStockIn.DepartmentStockInDetails) { if (!productMasterIds.Contains(detail.Product.ProductMaster.ProductMasterId)) { productMasterIds.Add(detail.Product.ProductMaster.ProductMasterId); } } var criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddEqCriteria("DepartmentPricePK.DepartmentId", (long)0); criteria.AddSearchInCriteria("DepartmentPricePK.ProductMasterId", productMasterIds); IList priceList = DepartmentPriceLogic.FindAll(criteria); foreach (DepartmentStockInDetail detail in e.DepartmentStockIn.DepartmentStockInDetails) { foreach (DepartmentPrice price in priceList) { if (price.DepartmentPricePK.ProductMasterId.Equals(detail.Product.ProductMaster.ProductMasterId)) { detail.Price = price.Price; } } } // Department information if (DepartmentLogic != null) { e.DepartmentStockIn.Department = DepartmentLogic.FindById(stockIn.DepartmentStockInPK.DepartmentId); criteria = new ObjectCriteria(); criteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); criteria.AddEqCriteria("EmployeePK.DepartmentId", stockIn.DepartmentStockInPK.DepartmentId); e.DepartmentStockIn.Department.Employees = EmployeeLogic.FindAll(criteria); } } e.EventResult = "Success"; }
void departmentStockInExtraView_LoadStockInByProductMaster(object sender, DepartmentStockInEventArgs e) { if(e.ProductMasterList == null || e.ProductMasterList.Count == 0 ) { return; } ObjectCriteria prdMasterCrit = new ObjectCriteria(); IList prdNames = new ArrayList(); foreach (ProductMaster list in e.ProductMasterList) { prdNames.Add(list.ProductName); } IList prdMasterList = new ArrayList(); foreach (ProductMaster master in e.ProductMasterList) { prdMasterList.Add(master); } /*prdMasterCrit.AddSearchInCriteria("ProductName", prdNames); prdMasterCrit.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); prdMasterList = ProductMasterLogic.FindAll(prdMasterCrit);*/ if (prdMasterList != null && prdMasterList.Count > 0) { IList prdMstIds = new ArrayList(); foreach (ProductMaster master in prdMasterList) { prdMstIds.Add(master.ProductMasterId); } IList stockOutList = new ArrayList(); ObjectCriteria stkCriteria = new ObjectCriteria(); stkCriteria.AddSearchInCriteria("ProductMaster.ProductMasterId", prdMstIds); stkCriteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); //stkCriteria.AddGreaterCriteria("GoodQuantity", (long)0); IList stockList = StockLogic.FindAll(stkCriteria); foreach (Stock inDetail in stockList) { DepartmentStockInDetail deptDetail = new DepartmentStockInDetail(); deptDetail.CreateDate = DateTime.Now; deptDetail.UpdateDate = DateTime.Now; deptDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name; deptDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name; deptDetail.DepartmentStockInDetailPK = new DepartmentStockInDetailPK(); deptDetail.Product = inDetail.Product; deptDetail.ProductMaster = inDetail.Product.ProductMaster; deptDetail.Quantity = inDetail.Quantity; stockOutList.Add(deptDetail); } GetRemainStockNumber(stockOutList); MinusConfirmStockOut(stockOutList); e.SelectedStockOutDetails = stockOutList; } }
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); } }