コード例 #1
0
        public override decimal ApplyChanges(decimal item)
        {
            decimal val = 0;

            if (decimal.TryParse(MonetaryTextBox.Text, out val))
            {
                if (MonetaryDropDownList.SelectedIndex == (int)Modes.SetTo)
                {
                    return(val);
                }
                if (MonetaryDropDownList.SelectedIndex == (int)Modes.IncreaseByAmount)
                {
                    return(Money.ApplyIncreasedAmount(item, val));
                }
                if (MonetaryDropDownList.SelectedIndex == (int)Modes.DecreaseByAmount)
                {
                    return(Money.ApplyDiscountAmount(item, val));
                }
                if (MonetaryDropDownList.SelectedIndex == (int)Modes.IncreaseByPercent)
                {
                    return(Money.ApplyIncreasedPercent(item, val));
                }
                if (MonetaryDropDownList.SelectedIndex == (int)Modes.DecreaseByPercent)
                {
                    return(Money.ApplyDiscountPercent(item, val));
                }
            }
            else
            {
                return(item);
            }

            return(item);
        }
コード例 #2
0
        /// <summary>
        ///     This method returns the correct price for the customer based upon the specified PricingType
        /// </summary>
        /// <param name="price">Price of the product</param>
        /// <param name="msrp">The suggested retail price of the product</param>
        /// <param name="cost">The cost of the product</param>
        /// <returns>Decimal - the adjusted price</returns>
        public decimal GetAdjustedPriceForThisGroup(decimal price, decimal msrp, decimal cost)
        {
            var result = price;

            switch (PricingType)
            {
            case PricingTypes.AmountAboveCost:
                result = Money.ApplyIncreasedAmount(cost, AdjustmentAmount);
                break;

            case PricingTypes.AmountOffListPrice:
                result = Money.ApplyDiscountAmount(msrp, AdjustmentAmount);
                break;

            case PricingTypes.AmountOffSitePrice:
                result = Money.ApplyDiscountAmount(price, AdjustmentAmount);
                break;

            case PricingTypes.PercentageAboveCost:
                result = Money.ApplyIncreasedPercent(cost, AdjustmentAmount);
                break;

            case PricingTypes.PercentageOffListPrice:
                result = Money.ApplyDiscountPercent(msrp, AdjustmentAmount);
                break;

            case PricingTypes.PercentageOffSitePrice:
                result = Money.ApplyDiscountPercent(price, AdjustmentAmount);
                break;
            }

            return(result);
        }