public void Delete(StockInDetail data) { StockInDetailDAO.Delete(data); }
private object[] AddBlockToDataGrid(StockInDetail stockInDetail, IList stockList, IList returnStockList, int rowIndex) { var obj = new object[MAX_COLUMN]; obj[BLOCK_ID_POS] = stockInDetail.Product.BlockInDetail.BlockInDetailPK.BlockDetailId; obj[PRODUCT_MASTER_ID_POS] = stockInDetail.Product.ProductMaster.ProductMasterId; obj[STOCK_IN_DATE_ID_POS] = stockInDetail.StockIn.StockInDate; obj[PRODUCT_MASTER_NAME_POS] = stockInDetail.Product.ProductMaster.ProductName; obj[PRODUCT_PRICE_POS] = stockInDetail.Price; obj[PRODUCT_QUANTITY_POS] = stockInDetail.Quantity; long stockQty = 0; if (stockList != null && stockList.Count > 0) { foreach (Stock stock in stockList) { if (stockInDetail.Product.ProductId == stock.Product.ProductId) { stockQty += stock.Quantity; } } } obj[STOCK_QUANTITY_POS] = stockQty; long returnQty = 0; if (returnStockList != null && returnStockList.Count > 0) { foreach (ReturnProduct returnProduct in returnStockList) { if (stockInDetail.Product.ProductId == returnProduct.ProductId) { returnQty += returnProduct.Quantity; } } } var remainQty = stockInDetail.Quantity - stockQty - returnQty; obj[REMAIN_QUANTITY_POS] = remainQty; obj[MAX_COLUMN - 1] = rowIndex; return obj; }
public void Update(StockInDetail data) { StockInDetailDAO.Update(data); }
public StockInDetail Add(StockInDetail data) { StockInDetailDAO.Add(data); return data; }
public BlockInDetail Add(BlockInDetail data) { var pk = new BlockInDetailPK {BlockId = 1}; var maxId = BlockInDetailDAO.SelectSpecificType(null, Projections.Max("BlockInDetailPK.BlockDetailId")); pk.BlockDetailId = maxId == null ? "1" : (Int64.Parse(maxId.ToString()) + 1).ToString(); data.BlockInDetailPK = pk; var maxProduct = ProductDAO.SelectSpecificType(null, Projections.Max("ProductId")); Int64 maxProductId = 1; if (maxProduct != null) { maxProductId = (Int64)maxProduct + 1; } var maxStockInId = StockInDAO.SelectSpecificType(null, Projections.Max("StockInId")); if (maxStockInId == null) { maxStockInId = (long) 1; } else { maxStockInId = (long)maxStockInId + 1; } var stockIn = new StockIn {StockInDate = data.ImportDate}; data.StockInId = (long)maxStockInId; BlockInDetailDAO.Add(data); StockInDAO.Add(stockIn); foreach (Product product in data.Products) { // TODO product.ProductId = maxProductId++; product.BlockInDetail = data; ProductDAO.Add(product); var stockInDetail = new StockInDetail { Product = product, ProductId = product.ProductId, StockIn = stockIn, Quantity = product.Quantity, Price = product.Price, StockInType = (Int64)StockInDetail.StockInStatus.IMPORTED, StockInDetailPK = new StockInDetailPK {StockInId = stockIn.StockInId, ProductId = product.ProductId} }; StockInDetailDAO.Add(stockInDetail); } return data; }
void _departmentStockAdhocProcessingView_ProcessAdhocStocksEvent(object sender, DepartmentStockAdhocProcessingEventArgs e) { try { long departmentId = -1; StockOut stockOut = null; StockIn stockIn = new StockIn(); stockIn.CreateDate = DateTime.Now; stockIn.UpdateDate = DateTime.Now; stockIn.CreateId = ClientInfo.getInstance().LoggedUser.Name; stockIn.UpdateId = ClientInfo.getInstance().LoggedUser.Name; stockIn.StockInDate = DateTime.Now; stockIn.StockInType = 2; // stock in for fixing department stock quantity stockIn.StockInId = StockInLogic.FindMaxId(); stockIn.StockInDetails = new ArrayList(); long stockOutDetailMaxId = StockOutDetailLogic.FindMaxId() + 1; long stockOutMaxId = StockOutLogic.FindMaxId()+1; for (int i=0; i< e.DeptStockProcessedList.Count;i++) { DepartmentStockTemp stockTemp = (DepartmentStockTemp) e.DeptStockProcessedList[i]; if(stockTemp.DepartmentStockTempPK.DepartmentId != departmentId) { departmentId = stockTemp.DepartmentStockTempPK.DepartmentId; if (stockOut != null) { StockOutLogic.AddFixedStockOut(stockOut); } stockOut = new StockOut(); stockOut.CreateDate = DateTime.Now; stockOut.UpdateDate = DateTime.Now; stockOut.CreateId = ClientInfo.getInstance().LoggedUser.Name; stockOut.UpdateId = ClientInfo.getInstance().LoggedUser.Name; stockOut.StockOutDate = DateTime.Now; stockOut.StockOutDetails = new ArrayList(); stockOut.DepartmentId = departmentId; stockOut.DefectStatus = new StockDefectStatus{ DefectStatusId = 0}; stockOut.StockoutId = stockOutMaxId++; } stockTemp.Fixed = 1; stockTemp.UpdateDate = DateTime.Now; stockTemp.UpdateId = ClientInfo.getInstance().LoggedUser.Name; DepartmentStockTempLogic.Update(stockTemp); long realQty = stockTemp.GoodQuantity + stockTemp.ErrorQuantity + stockTemp.DamageQuantity + stockTemp.LostQuantity + stockTemp.UnconfirmQuantity; if(stockTemp.Quantity < realQty) { long stockInQty = realQty - stockTemp.Quantity; StockOutDetail stockOutDetail = new StockOutDetail(); stockOutDetail.CreateDate = DateTime.Now; stockOutDetail.UpdateDate = DateTime.Now; stockOutDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name; stockOutDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name; stockOutDetail.Quantity = stockInQty; stockOutDetail.Product = stockTemp.Product; stockOutDetail.StockOutId = stockOut.StockoutId; stockOutDetail.StockOut = stockOut; stockOutDetail.DefectStatus = new StockDefectStatus{DefectStatusId = 0}; stockOutDetail.Description = "Export goods"; stockOutDetail.ProductMaster = stockTemp.ProductMaster; stockOutDetail.StockOutDetailId = stockOutDetailMaxId++; stockOut.StockOutDetails.Add(stockOutDetail); StockInDetail stockInDetail = new StockInDetail(); stockInDetail.CreateDate = DateTime.Now; stockInDetail.UpdateDate = DateTime.Now; stockInDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name; stockInDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name; stockInDetail.StockInType = 0; stockInDetail.StockIn = stockIn; stockInDetail.Quantity = stockInQty; stockInDetail.Product = stockTemp.Product; stockInDetail.ProductMaster = stockTemp.ProductMaster; stockInDetail.StockInDetailPK = new StockInDetailPK { ProductId = stockTemp.Product.ProductId, StockInId = stockIn.StockInId }; stockIn.StockInDetails.Add(stockInDetail); } if (i == e.DeptStockProcessedList.Count - 1) // last item { StockOutLogic.AddFixedStockOut(stockOut); } } StockInLogic.AddFixedStockIn(stockIn); } catch (Exception) { e.HasErrors = true; throw; } }
public void DeleteList(IList<BlockInDetail> deleteList) { foreach (var blockInDetail in deleteList) { // Delete Block blockInDetail.DelFlg = 1; BlockInDetailDAO.Update(blockInDetail); // Delete Stock In StockIn stockIn = null; if (blockInDetail.StockInId != 0) { stockIn = StockInDAO.FindById(blockInDetail.StockInId); if (stockIn != null) { stockIn.DelFlg = 1; StockInDAO.Update(stockIn); } } foreach (Product product in blockInDetail.Products) { product.DelFlg = 1; ProductDAO.Update(product); if (stockIn != null) { var stockInDetail = new StockInDetail { Product = product, StockIn = stockIn, DelFlg = 1, StockInDetailPK = new StockInDetailPK { StockInId = stockIn.StockInId, ProductId = product.ProductId } }; StockInDetailDAO.Update(stockInDetail); } } } }
public void Update(BlockInDetail data) { // Update block BlockInDetailDAO.Update(data); // Update Stock In StockIn stockIn = null; if (data.StockInId != 0) { stockIn = StockInDAO.FindById(data.StockInId); if (stockIn != null) { stockIn.StockInDate = data.ImportDate; StockInDAO.Update(stockIn); } } // Get the max id of product var maxProduct = ProductDAO.SelectSpecificType(null, Projections.Max("ProductId")); Int64 maxProductId = 1; if (maxProduct != null) { maxProductId = ((Int64)maxProduct) + 1; } foreach (Product product in data.Products) { // Add new Product if (string.IsNullOrEmpty(product.ProductId)) { // TODO product.ProductId = maxProductId++; ProductDAO.Add(product); if (stockIn != null) { var stockInDetail = new StockInDetail { Product = product, ProductId = product.ProductId, StockIn = stockIn, Quantity = product.Quantity, Price = product.Price, StockInDetailPK = new StockInDetailPK { StockInId = stockIn.StockInId, ProductId = product.ProductId } }; StockInDetailDAO.Add(stockInDetail); } } // Update Product else { ProductDAO.Update(product); if (stockIn != null) { var stockInDetail = new StockInDetail { Product = product, ProductId = product.ProductId, StockIn = stockIn, Quantity = product.Quantity, Price = product.Price, StockInDetailPK = new StockInDetailPK { StockInId = stockIn.StockInId, ProductId = product.ProductId } }; StockInDetailDAO.Update(stockInDetail); } } } }
public void mainStockInView_FindByBarcodeEvent(object sender, MainStockInEventArgs e) { var subCriteria = new SubObjectCriteria("StockOut"); subCriteria.AddEqCriteria("DefectStatus.DefectStatusId", (long)4); // tạm xuất là 4 var objectCriteria = new ObjectCriteria(); objectCriteria.AddEqCriteria("Product.ProductId", e.ProductId); objectCriteria.AddEqCriteria("DelFlg", CommonConstants.DEL_FLG_NO); objectCriteria.AddEqCriteria("DefectStatus.DefectStatusId", (long) 4); //objectCriteria.AddSubCriteria("StockOut", subCriteria); IList list = StockOutDetailLogic.FindAll(objectCriteria); if (list!=null && list.Count > 0) { var detail = new StockInDetail { Product = ((StockOutDetail)list[0]).Product }; foreach (StockOutDetail soDetail in list) { detail.StockOutQuantity += soDetail.Quantity; } e.StockInDetail = detail; } IList reStockInList = StockInLogic.FindReStockIn(e.ProductId); if(reStockInList!=null) { foreach (StockInDetail inDetail in reStockInList) { e.StockInDetail.ReStockQuantity += inDetail.Quantity; } } e.EventResult = "Success"; }
void inventoryCheckingView_SaveInventoryCheckingEvent(object sender, InventoryCheckingEventArgs e) { if(e.SaveStockList!=null && e.SaveStockList.Count > 0) { /*foreach (Stock stock in e.SaveStockList) { stock.CreateDate = DateTime.Now; stock.CreateId = ClientInfo.getInstance().LoggedUser.Name; stock.UpdateId = ClientInfo.getInstance().LoggedUser.Name; stock.UpdateDate = DateTime.Now; stock.DelFlg = 0; // calculate business StockLogic.Update(stock); e.HasErrors = false; }*/ // ++ AMEND FOR SHOES STOCK CHECKING 19/10/2009 StockIn stockIn = new StockIn(); stockIn.NotUpdateMainStock = false; stockIn.CreateDate = DateTime.Now; stockIn.UpdateDate = DateTime.Now; stockIn.StockInDate = DateTime.Now; stockIn.CreateId = ClientInfo.getInstance().LoggedUser.Name; stockIn.UpdateId = ClientInfo.getInstance().LoggedUser.Name; stockIn.DelFlg = 0; stockIn.Description = " NHẬP TỪ SỐ LƯỢNG KIỂM KÊ"; IList stockInDetailList = new ArrayList(); foreach (Stock stock in e.SaveStockList) { StockInDetail inDetail = new StockInDetail(); inDetail.CreateDate = DateTime.Now; inDetail.CreateId = ClientInfo.getInstance().LoggedUser.Name; inDetail.UpdateId = ClientInfo.getInstance().LoggedUser.Name; inDetail.UpdateDate = DateTime.Now; inDetail.DelFlg = 0; inDetail.Product = stock.Product; inDetail.Quantity = stock.GoodQuantity; inDetail.DelFlg = 0; inDetail.StockIn = stockIn; // calculate business inDetail.StockInDetailPK = new StockInDetailPK { ProductId = stock.Product.ProductId }; stockInDetailList.Add(inDetail); } stockIn.StockInDetails = stockInDetailList; StockInLogic.AddForStockOutToProducer(stockIn); e.HasErrors = false; // ++ AMEND FOR SHOES STOCK CHECKING 19/10/2009 } }
/// <summary> /// Delete StockInDetail from database. /// </summary> /// <param name="data"></param> /// <returns></returns> public void Delete(StockInDetail data) { HibernateTemplate.Delete(data); }
/// <summary> /// Add StockInDetail to database. /// </summary> /// <param name="data"></param> /// <returns></returns> public StockInDetail Add(StockInDetail data) { HibernateTemplate.Save(data); return data; }
/// <summary> /// Update StockInDetail to database. /// </summary> /// <param name="data"></param> /// <returns></returns> public void Update(StockInDetail data) { HibernateTemplate.Update(data); }