protected void btnAddToCart_Click(object sender, EventArgs e) { if (_APFStatus == 1) // due in 3 months { if (_apfsInCart >= 1) { DisplayData(); return; } } MyHLShoppingCart cart = (Page as ProductsBase).ShoppingCart; //Add the APF amount to cart if (HLConfigManager.Configurations.APFConfiguration.DistributorSku != null) { try { if (_quantityToAdd > 0) { var apfSku = new List <ShoppingCartItem_V01>(); apfSku.Add(new ShoppingCartItem_V01(0, APFDueProvider.GetAPFSku(), _quantityToAdd, DateTime.Now)); if (ShoppingCart.DeliveryInfo == null) { lblAPFMessage.Text = PlatformResources.GetGlobalResourceString("ErrorMessage", "CantVisitWithNoDeliveryInfo"); return; } if (CatalogProvider.IsPreordering(ShoppingCart.CartItems, ShoppingCart.DeliveryInfo.WarehouseCode)) { lblAPFMessage.Text = String.Format( PlatformResources.GetGlobalResourceString("ErrorMessage", "PreOrderingSku")); } else { ProductsBase.AddItemsToCart(apfSku); } // Verify if any validation rule fails to show the error in the APF module IEnumerable <string> ruleResultMessages = from r in ShoppingCart.RuleResults where r.Result == RulesResult.Failure select r.Messages[0]; if (null != ruleResultMessages && ruleResultMessages.Count() > 0) { lblError.Text = ruleResultMessages.FirstOrDefault(); lblError.Visible = true; return; } } } catch (Exception ex) { LoggerHelper.Error("APF Could not be added to cart!\n" + ex); } DisplayData(); } }
protected void btnAddToCart_Click(object sender, EventArgs e) { if (_apfDueWithinOneYear) { if (_quantityToAdd != 1) { DisplayData(); return; } } else { if (_quantityToAdd == 0 || _quantityToAdd > (_apfsDue - _apfsInCart)) { if (_apfsDue - _apfsInCart == 1) { lblError.Text = GetLocalResourceObject("QuantityMustBeOne") as string; } else { lblError.Text = string.Format((GetLocalResourceObject("InvalidQuantity") as string), 1, (_apfsDue - _apfsInCart)); } lblError.Visible = true; return; } } MyHLShoppingCart cart = (Page as ProductsBase).ShoppingCart; //Add the APF amount to cart if (HLConfigManager.Configurations.APFConfiguration.DistributorSku != null) { try { if (_quantityToAdd > 0) { var apfSku = new List <ShoppingCartItem_V01>(); apfSku.Add(new ShoppingCartItem_V01(0, APFDueProvider.GetAPFSku(), _quantityToAdd, DateTime.Now)); if (Locale == "en-IN" && cart.CartItems.Count > 0) { lblError.Text = GetLocalResourceObject("AAFWithOtherProducts") as string; lblError.Visible = true; return; } else { ProductsBase.AddItemsToCart(apfSku); } // Verify if any validation rule fails to show the error in the APF module IEnumerable <string> ruleResultMessages = from r in ShoppingCart.RuleResults where r.Result == RulesResult.Failure select r.Messages[0]; if (null != ruleResultMessages && ruleResultMessages.Count() > 0) { lblError.Text = ruleResultMessages.FirstOrDefault(); lblError.Visible = true; return; } } } catch (Exception ex) { LoggerHelper.Error("APF Could not be added to cart!\n" + ex); } DisplayData(); } }