public bool IsValidStock(int mainProductQuantity) { if ((!ProductKitGroup.IsRequired) && (uxKitItemDrop.SelectedValue == "")) { return(true); } int productQty; bool isNum = int.TryParse(Quantity, out productQty); if (isNum == false) { uxMessageLabel.Text = GetLanguageText("ProductKitInputInvalid"); return(false); } int purchaseQuantity = productQty * mainProductQuantity; if (purchaseQuantity <= 0) { return(true); } ProductKitItem kitItem = GetSelectedProductKitItem(); Product product = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, kitItem.ProductID, new StoreRetriever().GetCurrentStoreID()); int currentStock = product.GetPurchasableStock( StoreContext.ShoppingCart.GetNumberOfItems(kitItem.ProductID) + PromotionSelectedItem.FindSubProductAmountInPromotion(StoreContext.ShoppingCart, kitItem.ProductID)); if (product.IsOutOfStock( purchaseQuantity, StoreContext.ShoppingCart.GetNumberOfItems(kitItem.ProductID) + PromotionSelectedItem.FindSubProductAmountInPromotion(StoreContext.ShoppingCart, kitItem.ProductID))) { uxMessageDiv.Visible = true; uxMessageLabel.Text = String.Format(GetLanguageText("CheckStockMessage")); return(false); } return(true); }
public bool IsValidStock(int mainProductQuantity) { if ((!ProductKitGroup.IsRequired) && (!isCheckedItem())) { return(true); } ArrayList selectedList = new ArrayList(); CreateProductKitItems(selectedList); foreach (ProductKitItemValue item in selectedList) { int purchaseQuantity = item.Quantity * mainProductQuantity; if (purchaseQuantity <= 0) { continue; } Product product = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, item.ProductID, new StoreRetriever().GetCurrentStoreID()); int currentStock = product.GetPurchasableStock( StoreContext.ShoppingCart.GetNumberOfItems(item.ProductID) + PromotionSelectedItem.FindSubProductAmountInPromotion(StoreContext.ShoppingCart, item.ProductID)); if (product.IsOutOfStock( purchaseQuantity, StoreContext.ShoppingCart.GetNumberOfItems(item.ProductID) + PromotionSelectedItem.FindSubProductAmountInPromotion(StoreContext.ShoppingCart, item.ProductID))) { uxMessageDiv.Visible = true; uxMessageLabel.Text = String.Format(GetLanguageText("CheckStockMessage")); return(false); } } return(true); }
private bool IsOutOfStock(string productID, int purchaseQuantity, out int currentStock) { Product product = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, productID, new StoreRetriever().GetCurrentStoreID()); currentStock = product.GetPurchasableStock( StoreContext.ShoppingCart.GetNumberOfItems(productID) + PromotionSelectedItem.FindSubProductAmountInPromotion(StoreContext.ShoppingCart, productID)); return(product.IsOutOfStock( purchaseQuantity, StoreContext.ShoppingCart.GetNumberOfItems(productID) + PromotionSelectedItem.FindSubProductAmountInPromotion(StoreContext.ShoppingCart, productID))); }
protected string CheckValidStock() { int numberItemInSession = StoreContext.ShoppingCart.GetNumberOfItems(ProductID) + PromotionSelectedItem.FindSubProductAmountInPromotion(StoreContext.ShoppingCart, ProductID); int currentStock = 0; currentStock = CurrentProduct.GetStockForQuickReview() - numberItemInSession; bool isOutStock = CatalogUtilities.IsOutOfStock(Convert.ToInt32(currentStock), CurrentProduct.UseInventory); if (CurrentProduct.isProductOptionStock()) { return(""); } if (isOutStock) { return(GetLanguageText("OutStock")); } else { return(GetLanguageText("InStock") + " (" + RemainingStock(currentStock) + ")"); } }
private bool VerifyStockOption( string productID, ArrayList optionItemIDs, int qty, string name, out int currentStock, string storeID) { Product product = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, productID, storeID); if (optionItemIDs == null || optionItemIDs.Count == 0) { if (IsOutOfStock(productID, qty, out currentStock)) { return(false); } else { return(true); } } else { string[] optionIDsArray = optionItemIDs.ToArray(typeof(string)) as string[]; string combinationID = product.FindProductStock(optionIDsArray).OptionCombinationID; currentStock = product.GetPurchasableStock( StoreContext.ShoppingCart.GetNumberOfItems(productID, combinationID) + PromotionSelectedItem.FindSubProductAmountInPromotion(StoreContext.ShoppingCart, productID, combinationID), optionIDsArray); return(!product.IsOutOfStock( qty, StoreContext.ShoppingCart.GetNumberOfItems(productID, combinationID) + PromotionSelectedItem.FindSubProductAmountInPromotion(StoreContext.ShoppingCart, productID, combinationID), optionIDsArray )); } }