private void DonationClicked(decimal donationAmount) { decimal quantity = donationAmount; //if (int.TryParse(tbQuantity.Text.Trim(), out quantity)) if (quantity > 0) { var myShoppingCart = (Page as ProductsBase).ShoppingCart; //Add the donation amount to cart if (!string.IsNullOrEmpty(HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeSku)) { try { if (quantity > 0) { int quantiti = Decimal.ToInt32(quantity); if (!ProductsBase.AddHFFSKU(quantiti)) { lblHFFMsg.Text = string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "AddHFFFailed")); divMsg.Visible = true; } else { lblHFFMsg.Text = string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "AddHFFSucceeded")); divMsg.Visible = true; } } //else //{ // lblHFFMsg.Text = // string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "AddHFFZero")); // divMsg.Visible = true; //} } catch (Exception ex) { LoggerHelper.Error("HFF Herbalife Can not be added to cart!\n" + ex); } } else if (HLConfigManager.Configurations.DOConfiguration.DonationWithoutSKU) { if (myShoppingCart.Totals == null) { myShoppingCart.Totals = new OrderTotals_V02(); } if (myShoppingCart.Totals != null) { OrderTotals_V02 totals = myShoppingCart.Totals as OrderTotals_V02; if (totals != null) { if (totals != null && totals.Donation > 0) { totals.Donation = totals.Donation + quantity; } else { totals.Donation = quantity; } myShoppingCart.Calculate(); OnQuoteRetrieved(null, null); lblHFFMsg.Text = string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "AddHFFSucceeded")); divMsg.Visible = true; ClearDonation.Visible = true; if (SessionInfo.CancelSelfDonation > 0) { ClearDonation2.Visible = true; } else { ClearDonation2.Visible = false; } if (SessionInfo.CancelBehalfOfDonation > 0) { ClearBehalfDonation2.Visible = true; } else { ClearBehalfDonation2.Visible = false; } } } //tbQuantity.Text = HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeDefaultValue.ToString(); } else { LoggerHelper.Error(string.Format("HFF SKU missing from Config for {0}.", Locale)); } } //else //{ // //tbQuantity.Text = string.Empty; // lblHFFMsg.Text = PlatformResources.GetGlobalResourceString("ErrorMessage", "AddHFFZero"); // divMsg.Visible = true; //} }
private void DonationClicked() { int quantity = 0; if (int.TryParse(tbQuantity.Text.Trim(), out quantity)) { var myShoppingCart = (Page as ProductsBase).ShoppingCart; //Add the donation amount to cart if (!string.IsNullOrEmpty(HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeSku) || (HLConfigManager.Configurations.DOConfiguration.HFFSkuList != null && HLConfigManager.Configurations.DOConfiguration.HFFSkuList.Count > 0)) { try { if (quantity > 0) { if (!ProductsBase.AddHFFSKU(quantity)) { lblHFFMsg.Text = string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "AddHFFFailed")); divMsg.Visible = true; } else { lblHFFMsg.Text = string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "AddHFFSucceeded")); divMsg.Visible = true; } } else { lblHFFMsg.Text = string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "AddHFFZero")); divMsg.Visible = true; } } catch (Exception ex) { LoggerHelper.Error("HFF Herbalife Can not be added to cart!\n" + ex); } } else if (HLConfigManager.Configurations.DOConfiguration.DonationWithoutSKU) { if (myShoppingCart.Totals == null) { myShoppingCart.Totals = new OrderTotals_V02(); } if (myShoppingCart.Totals != null) { OrderTotals_V02 totals = myShoppingCart.Totals as OrderTotals_V02; if (totals != null) { totals.Donation = decimal.Parse(quantity.ToString()); myShoppingCart.Calculate(); OnQuoteRetrieved(null, null); lblHFFMsg.Text = string.Format(PlatformResources.GetGlobalResourceString("ErrorMessage", "AddHFFSucceeded")); divMsg.Visible = true; ClearDonation.Visible = ClearDonation2.Visible = true; } } tbQuantity.Text = HLConfigManager.Configurations.DOConfiguration.HFFHerbalifeDefaultValue.ToString(); } else { LoggerHelper.Error(string.Format("HFF SKU missing from Config for {0}.", Locale)); } } else { tbQuantity.Text = string.Empty; lblHFFMsg.Text = PlatformResources.GetGlobalResourceString("ErrorMessage", "AddHFFZero"); divMsg.Visible = true; } }