コード例 #1
0
        protected virtual void BindTotals()
        {
            List <DistributorShoppingCartItem> lstShoppingCartItems =
                (Page as ProductsBase).ShoppingCart.ShoppingCartItems;

            try
            {
                if ((HLConfigManager.Configurations.DOConfiguration.CalculateWithoutItems &&
                     _shoppingCart.Totals != null &&
                     (_shoppingCart.Totals as OrderTotals_V01).AmountDue != decimal.Zero) || (lstShoppingCartItems.Count > 0 && ShoppingCart.Totals != null))
                {
                    OrderTotals_V01 totals = ShoppingCart.Totals as OrderTotals_V01;

                    lblDiscountRate.Text = _shoppingCart.Totals == null
                                               ? "0%"
                                               : ((_shoppingCart.Totals as OrderTotals_V01).DiscountPercentage).ToString() + "%";
                    _shoppingCart.EmailValues.DistributorSubTotal          = OrderProvider.GetDistributorSubTotal(_shoppingCart.Totals as OrderTotals_V01);
                    _shoppingCart.EmailValues.DistributorSubTotalFormatted = getAmountString(_shoppingCart.EmailValues.DistributorSubTotal);
                    lblDistributorSubtotal.Text = _shoppingCart.EmailValues.DistributorSubTotalFormatted;
                    lblEarnBase.Text            = getAmountString(GetTotalEarnBase(lstShoppingCartItems));
                    if (lblDiscountTotal != null)
                    {
                        lblDiscountTotal.Text =
                            getAmountString(CheckoutTotalsDetailed.GetDiscountTotal(lstShoppingCartItems));
                    }
                    if (IsChina && (DistributorOrderingProfile.IsPC || (ShoppingCart.OrderCategory == OrderCategoryType.ETO && SessionInfo != null && !SessionInfo.IsReplacedPcOrder)))
                    {
                        lblPCLearningPointAmount.Text = getAmountString(_shoppingCart.pcLearningPointOffSet);
                    }
                    // 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);
                            lblDiscountAmount.Text = getAmountString(totals_V02.DiscountAmount);
                            trDiscountRate.Visible = false;
                        }
                    }
                    if (HLConfigManager.Configurations.DOConfiguration.DonationWithoutSKU)
                    {
                        if (trDonationAmount != null)
                        {
                            trDonationAmount.Visible = true;
                            OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02;
                            if (totals_V02 != null)
                            {
                                lblDonationAmount.Text = getAmountString(totals_V02.Donation);
                            }
                        }
                    }
                    if (ProductsBase.IsEventTicketMode)
                    {
                        var orderMonthShortString = string.Empty;
                        var ordermonth            = OrderMonth.DualOrderMonthForEventTicket(true, out orderMonthShortString); // dual ordermonth should be desable for ETO
                        lblOrderMonth.Text = string.IsNullOrWhiteSpace(ordermonth) ? GetOrderMonthString() : ordermonth;
                        var currentSession = SessionInfo;

                        if (null != currentSession && !string.IsNullOrWhiteSpace(orderMonthShortString))
                        {
                            currentSession.OrderMonthString      = ordermonth;
                            currentSession.OrderMonthShortString = orderMonthShortString;
                        }
                    }
                    else
                    {
                        lblOrderMonth.Text = GetOrderMonthString();
                    }

                    decimal currentMonthVolume = 0;
                    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;
                    }

                    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);
                    lblRetailPrice.Text     = getAmountString(totals.ItemsTotal);
                    lblTaxVAT.Text          = getAmountString(totals.TaxAmount);
                    if (lblSubtotal != null)
                    {
                        lblSubtotal.Text = getAmountString(logisticCharge.Amount);
                    }
                    if (lblAdditionalDiscount != null)
                    {
                        lblAdditionalDiscount.Text = getAmountString(otherCharges.Amount);
                    }
                    lblVolumePoints.Text = ProductsBase.GetVolumePointsFormat(totals.VolumePoints);

                    //added for HR
                    if (HLConfigManager.Configurations.CheckoutConfiguration.MergePHAndShippingCharges)
                    {
                        decimal phShippingCharges = pHCharge.Amount + freightCharge.Amount;
                        lblPackageHandling.Text = getAmountString(phShippingCharges);
                    }

                    if (HLConfigManager.Configurations.CheckoutConfiguration.DisplayWeight && !SessionInfo.IsEventTicketMode && lblWeight != null)
                    {
                        lblWeight.Text = ShoppingCartProvider.GetWeight(ShoppingCart);
                    }
                }
                else
                {
                    if (HLConfigManager.Configurations.DOConfiguration.DonationWithoutSKU)
                    {
                        if (trDonationAmount != null)
                        {
                            trDonationAmount.Visible = true;
                            OrderTotals_V02 totals_V02 = ShoppingCart.Totals as OrderTotals_V02;
                            if (totals_V02 != null)
                            {
                                lblDonationAmount.Text = getAmountString(totals_V02.Donation);
                            }
                        }
                    }

                    DisplayEmptyLabels();
                }
            }
            catch (Exception ex)
            {
                //Log Exception
                LoggerHelper.Error("Exception while displaying totals - " + ex);
                DisplayEmptyLabels();
            }
        }
コード例 #2
0
        protected override void BindTotals()
        {
            decimal earnBase = 0.00M;
            List <DistributorShoppingCartItem> 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() + "%";
                    lblDistributorSubtotal.Text = getAmountString(totals.DiscountedItemsTotal);
                    lblEarnBase.Text            = getAmountString(GetTotalEarnBase(lstShoppingCartItems));
                    if (ProductsBase.IsEventTicketMode)
                    {
                        var orderMonthShortString = string.Empty;
                        var ordermonth            = OrderMonth.DualOrderMonthForEventTicket(true, out orderMonthShortString); // dual ordermonth should be desable for ETO
                        lblOrderMonth.Text = string.IsNullOrWhiteSpace(ordermonth) ? GetOrderMonthString() : ordermonth;
                        var currentSession = SessionInfo;

                        if (null != currentSession && !string.IsNullOrWhiteSpace(orderMonthShortString))
                        {
                            currentSession.OrderMonthString      = ordermonth;
                            currentSession.OrderMonthShortString = orderMonthShortString;
                        }
                    }
                    else
                    {
                        lblOrderMonth.Text = GetOrderMonthString();
                    }

                    decimal currentMonthVolume = 0;
                    if (decimal.TryParse((Page as ProductsBase).CurrentMonthVolume, out currentMonthVolume))
                    {
                        lblOrderMonthVolume.Text =
                            HLConfigManager.Configurations.CheckoutConfiguration.UseUSPricesFormat
                                ? currentMonthVolume.ToString("N", CultureInfo.GetCultureInfo("en-US"))
                                : currentMonthVolume.ToString("N2");
                    }
                    else
                    {
                        lblOrderMonthVolume.Text = (Page as ProductsBase).CurrentMonthVolume;
                    }

                    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);
                    lblOtherCharges.Text = getAmountString(otherCharges.Amount);
                    Charge_V01 localTaxCharge = OrderProvider.GetLocalTax(_shoppingCart.Totals as OrderTotals_V01);
                    lblLocalTax.Text        = getAmountString(localTaxCharge.Amount);
                    lblPackageHandling.Text = getAmountString(pHCharge.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);
                    var amount = GetSubTotalValue(totals, CountryCode);
                    lblSubtotal.Text        = getAmountString(amount);
                    lblRetailPrice.Text     = getAmountString(totals.ItemsTotal);
                    lblShippingCharges.Text = getAmountString(freightCharge.Amount);
                    lblTaxVAT.Text          = getAmountString(OrderProvider.GetTaxAmount(_shoppingCart.Totals as OrderTotals_V01));

                    Charge_V01 taxedNet =
                        totals.ChargeList.Find(
                            delegate(Charge p) { return(((Charge_V01)p).ChargeType == ChargeTypes.TAXEDNET); }) as
                        Charge_V01 ?? new Charge_V01(ChargeTypes.TAXEDNET, (decimal)0.0);
                    lblTaxedNet.Text = getAmountString(taxedNet.Amount);


                    lblVolumePoints.Text = HLConfigManager.Configurations.CheckoutConfiguration.UseUSPricesFormat
                                               ? totals.VolumePoints.ToString("N",
                                                                              CultureInfo.GetCultureInfo(
                                                                                  "en-US"))
                                               : totals.VolumePoints.ToString("N2");

                    lblGrandTotal.Text = getAmountString(totals.AmountDue);
                }
                else
                {
                    DisplayEmptyLabels();
                }

                if (HLConfigManager.Configurations.CheckoutConfiguration.HasTotalTaxable)
                {
                    trTaxedNet.Visible = true;
                    trTax.Visible      = false;
                }

                if (_shoppingCart.Totals != null)
                {
                    OrderTotals_V01 totals = _shoppingCart.Totals as OrderTotals_V01;
                    if (HLConfigManager.Configurations.CheckoutConfiguration.HasTaxPercentage)
                    {
                        trTaxPercentage.Visible = true;
                        //lblPercentage.Text = HLConfigManager.Configurations.CheckoutConfiguration.TaxPercentage + "%";
                        lblPercentage.Text = _shoppingCart.Totals != null
                                                 ? getAmountString(OrderProvider.GetTaxAmount(_shoppingCart.Totals as OrderTotals_V01))
                                                 : string.Empty;
                    }

                    if (HLConfigManager.Configurations.CheckoutConfiguration.HasTotalDiscount)
                    {
                        trTotalDiscount.Visible = true;
                        lblTotalDiscount2.Text  = _shoppingCart.Totals != null
                                                     ? getAmountString(totals.TotalItemDiscount)
                                                     : string.Empty;
                    }
                    // hide this row if there is no local tax return
                    trLocalTax.Visible = OrderProvider.HasLocalTax(totals);
                }
            }
            catch (Exception ex)
            {
                //Log Exception
                LoggerHelper.Error("Exception while displaying totals - " + ex);
                DisplayEmptyLabels();
            }
        }
コード例 #3
0
        protected override void BindTotals()
        {
            var lstShoppingCartItems = (this.Page as ProductsBase).ShoppingCart.ShoppingCartItems;

            _shoppingCart = (this.Page as ProductsBase).ShoppingCart;
            try
            {
                if (lstShoppingCartItems.Count > 0 && _shoppingCart.Totals != null)
                {
                    OrderTotals_V01 totals = _shoppingCart.Totals as OrderTotals_V01;
                    lblDiscountRate.Text    = HLRulesManager.Manager.PerformDiscountRangeRules(_shoppingCart, Locale, ProductsBase.DistributorDiscount);
                    divDiscountRate.Visible = !string.IsNullOrEmpty(lblDiscountRate.Text);

                    if (ProductsBase.IsEventTicketMode)
                    {
                        var orderMonthShortString = string.Empty;
                        var ordermonth            = OrderMonth.DualOrderMonthForEventTicket(true, out orderMonthShortString); // dual ordermonth should be desable for ETO
                        lblOrderMonth.Text = string.IsNullOrWhiteSpace(ordermonth)?GetOrderMonthString():ordermonth;
                        var currentSession = SessionInfo;

                        if (null != currentSession && !string.IsNullOrWhiteSpace(orderMonthShortString))
                        {
                            currentSession.OrderMonthString      = ordermonth;
                            currentSession.OrderMonthShortString = orderMonthShortString;
                        }
                    }
                    else
                    {
                        lblOrderMonth.Text = GetOrderMonthString();
                    }
                    lblOrderMonthVolume.Text = (this.Page as ProductsBase).CurrentMonthVolume;
                    lblVolumePoints.Text     = totals.VolumePoints.ToString("N2");

                    Charge_V01 pHCharge = GetCharge(totals.ChargeList, ChargeTypes.PH);
                    lblPackageHandling.Text = getAmountString(pHCharge.Amount);
                    lblGrandTotal.Text      = getAmountString(totals.AmountDue);

                    // Brasil exclusive labels.
                    lblDiscountedProductRetail.Text    = getAmountString(totals.ProductRetailAmount);
                    lblDiscountedLiteratureRetail.Text = getAmountString(totals.LiteratureRetailAmount);
                    lblDiscountedPromoteRetail.Text    = getAmountString(totals.PromotionRetailAmount);

                    lblRetailPrice.Text = getAmountString(totals.ItemsTotal);

                    Charge_V01 freightCharge = GetCharge(totals.ChargeList, ChargeTypes.FREIGHT);
                    lblFreightCharges.Text = getAmountString(freightCharge.Amount);
                    lblICMS.Text           = getAmountString(totals.IcmsTax);
                    lblIPI.Text            = getAmountString(totals.IpiTax);
                    //lbSubtotal.Text = getAmountString(freightCharge.Amount + pHCharge.Amount+_shoppingCart.Totals.ProductRetailAmount + _shoppingCart.Totals.LiteratureRetailAmount + _shoppingCart.Totals.PromotionRetailAmount);
                }
                else
                {
                    DisplayEmptyLabels();
                }
            }
            catch (Exception ex)
            {
                //Log Exception
                LoggerHelper.Error("Exception while displaying totals - " + ex.ToString());
                DisplayEmptyLabels();
            }
        }