private void BindTotals() { decimal earnBase = 0.00M; var lstShoppingCartItems = (Page as ProductsBase).ShoppingCart.ShoppingCartItems; try { if (lstShoppingCartItems.Count > 0 && _shoppingCart.Totals != null) { OrderTotals_V01 totals = _shoppingCart.Totals as OrderTotals_V01; foreach (DistributorShoppingCartItem shoppingCartItem in lstShoppingCartItems) { earnBase += shoppingCartItem.EarnBase; } lblDiscountRate.Text = _shoppingCart.Totals == null ? "0%" : (totals.DiscountPercentage).ToString() + "%"; lblEarnBase.Text = getAmountString(CheckoutTotalsDetailed.GetTotalEarnBase(lstShoppingCartItems)); lblOrderMonthVolume.Text = (Page as ProductsBase).CurrentMonthVolume; lblRetailPrice.Text = getAmountString(totals.ItemsTotal); lblSubtotal.Text = getAmountString(totals.DiscountedItemsTotal); lblVolumePoints.Text = totals.VolumePoints.ToString("N2"); } else { DisplayEmptyTotals(); } } catch (Exception ex) { //Log Exception LoggerHelper.Error("Exception while displaying totals - " + ex); DisplayEmptyTotals(); } }
private void BindTotals() { //init etosku InitEtoPanel(); try { if (ShoppingCart != null) { var lstShoppingCartItems = ShoppingCart.ShoppingCartItems; if (lstShoppingCartItems.Count > 0 && ShoppingCart.Totals != null) { MyHLShoppingCart shoppingCart = ProductsBase.ShoppingCart; OrderTotals_V01 totals = shoppingCart.Totals as OrderTotals_V01; lblDiscountRate.Text = HLConfigManager.Configurations.CheckoutConfiguration.ShowVolumePointRange ? HLRulesManager.Manager.PerformDiscountRangeRules(shoppingCart, Locale, ProductsBase.DistributorDiscount) : (totals.DiscountPercentage).ToString() + "%"; trDiscountRate.Visible = !string.IsNullOrEmpty(lblDiscountRate.Text); if (HLConfigManager.Configurations.DOConfiguration.IsChina) { if (ShoppingCart.OrderCategory == OrderCategoryType.ETO && SessionInfo != null && !SessionInfo.IsReplacedPcOrder) { GetEligibleUseETOPoints(); } else { GetEligibleUsePoint(); } if (shoppingCart != null && shoppingCart.pcLearningPointOffSet > 0) { txtPCLearningPoint.Text = shoppingCart.pcLearningPointOffSet.ToString(); } else { txtPCLearningPoint.Text = "0"; } // added for China DO if (HLConfigManager.Configurations.CheckoutConfiguration.HasDiscountAmount) { OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02; if (totals_V02 != null) { HLRulesManager.Manager.PerformDiscountRules(ShoppingCart, null, Locale, ShoppingCartRuleReason.CartCalculated); trDiscountTotal.Visible = totals_V02.DiscountAmount > 0; lblDiscountTotal.Text = getAmountString(totals_V02.DiscountAmount); trDiscountRate.Visible = false; } } if ((HLConfigManager.Configurations.DOConfiguration.CalculateWithoutItems && ShoppingCart.Totals != null && (ShoppingCart.Totals as OrderTotals_V01).AmountDue != decimal.Zero) || (ShoppingCart.CartItems.Count > 0 && ShoppingCart.Totals != null)) { if (HLConfigManager.Configurations.CheckoutConfiguration.ConvertAmountDue) { decimal amountDue = OrderProvider.GetConvertedAmount(totals.AmountDue, CountryCode); if (HLConfigManager.Configurations.PaymentsConfiguration.RoundAmountDue == "Standard") { amountDue = Math.Round(amountDue); } if (DistributorOrderingProfile.IsPC) { if (HttpContext.Current.Request.UrlReferrer != null && HttpContext.Current.Request.UrlReferrer.ToString().Contains("Checkout.aspx")) { totals.AmountDue = ShoppingCart.AmountduepriorpcLearningoffset; lblGrandTotal.Text = getAmountString(shoppingCart.AmountduepriorpcLearningoffset, true); } else { lblGrandTotal.Text = getAmountString(amountDue, true); } } else { lblGrandTotal.Text = getAmountString(amountDue, true); } } else { if (HLConfigManager.Configurations.PaymentsConfiguration.RoundAmountDue == "Standard") { totals.AmountDue = Math.Round(totals.AmountDue); } if (DistributorOrderingProfile.IsPC) { if (HttpContext.Current.Request.UrlReferrer != null && HttpContext.Current.Request.UrlReferrer.ToString().Contains("Checkout.aspx")) { totals.AmountDue = ShoppingCart.AmountduepriorpcLearningoffset; lblGrandTotal.Text = getAmountString(ShoppingCart.AmountduepriorpcLearningoffset); } else { lblGrandTotal.Text = getAmountString(ShoppingCart.Totals != null ? totals.AmountDue : (decimal)0.00); } } else { lblGrandTotal.Text = getAmountString(ShoppingCart.Totals != null ? totals.AmountDue : (decimal)0.00); } } } if (IsReturnFromCheckout && ShoppingCart.OrderCategory == OrderCategoryType.ETO) { lblGrandTotal.Text = getAmountString(totals != null ? totals.ItemsTotal : 0M); lblDisplayPCLearningPoint.ForeColor = System.Drawing.Color.Green; lblDisplayPCLearningPoint.Font.Bold = true; } } else { if (lblDiscountTotal != null) { lblDiscountTotal.Text = getAmountString(CheckoutTotalsDetailed.GetDiscountTotal(lstShoppingCartItems)); } } lblEarnBase.Text = getAmountString(CheckoutTotalsDetailed.GetTotalEarnBase(lstShoppingCartItems)); decimal currentMonthVolume = 0.00M; if (HLConfigManager.Configurations.CheckoutConfiguration.DisplayFormatNeedsDecimal) { lblOrderMonthVolume.Text = decimal.TryParse(ProductsBase.CurrentMonthVolume, NumberStyles.Any, CultureInfo.InstalledUICulture, out currentMonthVolume) ? ProductsBase.GetVolumePointsFormat(currentMonthVolume) : (Page as ProductsBase).CurrentMonthVolume; } else { lblOrderMonthVolume.Text = (Page as ProductsBase).CurrentMonthVolume; } lblRetailPrice.Text = getAmountString(totals.ItemsTotal); lblSubtotal.Text = getAmountString(totals.DiscountedItemsTotal); lblVolumePoints.Text = ProductsBase.GetVolumePointsFormat(totals.VolumePoints); if (HLConfigManager.Configurations.DOConfiguration.IsChina) { if (totals.ChargeList != null) { Charge_V01 otherCharges = totals.ChargeList.Find( delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.OTHER); }) as Charge_V01 ?? new Charge_V01(ChargeTypes.OTHER, (decimal)0.0); Charge_V01 pHCharge = totals.ChargeList.Find( delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.PH); }) as Charge_V01 ?? new Charge_V01(ChargeTypes.PH, (decimal)0.0); Charge_V01 freightCharge = totals.ChargeList.Find( delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.FREIGHT); }) as Charge_V01 ?? new Charge_V01(ChargeTypes.FREIGHT, (decimal)0.0); Charge_V01 localTaxCharge = totals.ChargeList.Find( delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.LOCALTAX); }) as Charge_V01 ?? new Charge_V01(ChargeTypes.LOCALTAX, (decimal)0.0); lblOtherCharges.Text = getAmountString(otherCharges.Amount); lblLocalTax.Text = getAmountString(localTaxCharge.Amount); Charge_V01 logisticCharge = totals.ChargeList.Find( delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.LOGISTICS_CHARGE); }) as Charge_V01 ?? new Charge_V01(ChargeTypes.LOGISTICS_CHARGE, (decimal)0.0); lblLogisticCharges.Text = getAmountString(logisticCharge.Amount); lblPackageHandling.Text = getAmountString(pHCharge.Amount); lblShippingCharges.Text = getAmountString(freightCharge.Amount); //added for HR if (HLConfigManager.Configurations.CheckoutConfiguration.MergePHAndShippingCharges) { decimal phShippingCharges = pHCharge.Amount + freightCharge.Amount; lblPackageHandling.Text = getAmountString(phShippingCharges); } } lblTaxVAT.Text = getAmountString(totals.TaxAmount); } else { lblRetailPrice.Text = getAmountString((ShoppingCart.Totals as OrderTotals_V01).ItemsTotal); lblSubtotal.Text = getAmountString(OrderProvider.GetDistributorSubTotal(ShoppingCart.Totals as OrderTotals_V01)); } if (HLConfigManager.Configurations.DOConfiguration.ShowFreightChrageonCOP1) { if (totals.ChargeList != null) { Charge_V01 freightCharge = totals.ChargeList.Find( delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.FREIGHT); }) as Charge_V01 ?? new Charge_V01(ChargeTypes.FREIGHT, (decimal)0.0); lblShippingCharges.Text = getAmountString(freightCharge.Amount); trShippingCharge.Visible = !string.IsNullOrEmpty(lblShippingCharges.Text) && HLConfigManager.Configurations.DOConfiguration.ShowFreightChrageonCOP1 && shoppingCart.DeliveryInfo != null && shoppingCart.DeliveryInfo.Option == DeliveryOptionType.Shipping; } } if (HLConfigManager.Configurations.CheckoutConfiguration.DisplayWeight && !SessionInfo.IsEventTicketMode && lblWeight != null) { lblWeight.Text = ShoppingCartProvider.GetWeight(ShoppingCart); } } else { if (HLConfigManager.Configurations.DOConfiguration.IsChina) { if ((ShoppingCart.Totals == null || (ShoppingCart.Totals as OrderTotals_V01).AmountDue == 0.0M) && !(ShoppingCart.OrderCategory == OrderCategoryType.ETO && HLConfigManager.Configurations.DOConfiguration.AllowZeroPricingEventTicket) && (ShoppingCart.ShoppingCartItems != null && ShoppingCart.ShoppingCartItems.Any())) { OnQuoteError(null, null); } if (trDonationTotal != null) { trDonationTotal.Visible = true; OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02; if (totals_V02 != null) { lblDonationTotal.Text = getAmountString(totals_V02.Donation); } } //trDiscountRate.Visible = false; lblGrandTotal.Text = getAmountString(ShoppingCart.Totals != null ? (ShoppingCart.Totals as OrderTotals_V01).AmountDue : (decimal)0.00); } DisplayEmptyTotals(); } if (ShoppingCart.Totals != null && HLConfigManager.Configurations.DOConfiguration.DonationWithoutSKU) { if (trDonationTotal != null) { trDonationTotal.Visible = true; OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02; if (totals_V02 != null) { lblDonationTotal.Text = getAmountString(totals_V02.Donation); } } } } else { if (trDonationTotal != null) { trDonationTotal.Visible = true; OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02; if (totals_V02 != null) { lblDonationTotal.Text = getAmountString(totals_V02.Donation); } } lblGrandTotal.Text = getAmountString(ShoppingCart.Totals != null ? (ShoppingCart.Totals as OrderTotals_V01).AmountDue : (decimal)0.00); DisplayEmptyTotals(); } } catch (Exception ex) { //Log Exception LoggerHelper.Error(string.Format("Exception while displaying totals. Message: {0}, StackTrace: {1}, TargetSite:{2}, DistributorID: {3}", ex.Message, ex.StackTrace, ex.TargetSite, DistributorID)); if (HLConfigManager.Configurations.DOConfiguration.IsChina) { if (trDonationTotal != null) { trDonationTotal.Visible = true; OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02; if (totals_V02 != null) { lblDonationTotal.Text = getAmountString(totals_V02.Donation); } } } DisplayEmptyTotals(); } }