private void SetFormula(string value)
        {
            if (formula == value)
            {
                return;
            }

            formula = value;
            values  = null;
            string stringValue;

            switch (Type)
            {
            case PriceRule.ActionType.Stop:
            case PriceRule.ActionType.Exit:
            case PriceRule.ActionType.Message:
                values = new object [] { PriceRule.GetStringValue(formula, ' ') };
                break;

            case PriceRule.ActionType.Email:
                stringValue = PriceRule.GetStringValue(formula, ' ');
                if (stringValue == null)
                {
                    break;
                }

                int lastIndexOf = stringValue.LastIndexOf('|');
                if (lastIndexOf < 0)
                {
                    break;
                }

                values = new object [] { stringValue.Substring(lastIndexOf + 1), stringValue.Substring(0, lastIndexOf) };
                break;

            case PriceRule.ActionType.AddGood:
            case PriceRule.ActionType.AddGlobalGood:
                List <SaleDetail> details = GetDetailsForPromotionalItems <SaleDetail> (formula);
                if (details != null)
                {
                    values = details.Cast <object> ().ToArray();
                }
                break;

            case PriceRule.ActionType.Price:
                PriceGroup priceGroup;
                string []  priceParts = GetPriceExpressionParts(formula, out priceGroup);
                if (priceParts == null || priceParts.Length == 0)
                {
                    break;
                }

                double price;
                if (priceParts.Length > 1)
                {
                    OperatorType operatorType;
                    switch (priceParts [1].ToLowerInvariant())
                    {
                    case "+":
                    case "plus":
                        operatorType = OperatorType.Plus;
                        break;

                    case "-":
                    case "minus":
                        operatorType = OperatorType.Minus;
                        break;

                    case "*":
                        operatorType = OperatorType.Multiply;
                        break;

                    case "/":
                        operatorType = OperatorType.Divide;
                        break;

                    default:
                        operatorType = OperatorType.Unknown;
                        break;
                    }
                    if (operatorType == OperatorType.Unknown)
                    {
                        break;
                    }

                    if (Double.TryParse(priceParts [2], NumberStyles.Any, CultureInfo.InvariantCulture, out price))
                    {
                        values = new object [] { priceGroup, operatorType, price }
                    }
                    ;
                }
                else
                if (Double.TryParse(priceParts [0], NumberStyles.Any, CultureInfo.InvariantCulture, out price))
                {
                    values = new object [] { price }
                }
                ;
                break;

            case PriceRule.ActionType.Discount:
                values = new object [] { PriceRule.GetDoubleValue(formula) };
                break;

            case PriceRule.ActionType.ServiceCharge:
                string [] itemWithPercent = formula.Split(';');
                if (itemWithPercent.Length < 2)
                {
                    break;
                }

                long?itemId = PriceRule.GetLongValue(itemWithPercent [0]);
                if (itemId == null)
                {
                    break;
                }

                Item item = Item.Cache.GetById(itemId.Value);
                if (item == null)
                {
                    break;
                }

                string s = PriceRule.GetStringValue(itemWithPercent [1]);
                if (s == null)
                {
                    break;
                }

                double result;
                values = new [] { item,
                                  Double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out result) ? (object)result : s };
                break;

            case PriceRule.ActionType.Payment:
            case PriceRule.ActionType.AskAdvancePayment:
                stringValue = PriceRule.GetStringValue(formula, ' ');
                if (stringValue == null)
                {
                    break;
                }

                try {
                    List <Token> tokens = RPNCalculator.ParseTokens(stringValue);
                    if (tokens.Count > 0)
                    {
                        values = new object [] { ((Operand)tokens [0]).Value }
                    }
                    ;
                } catch (Exception ex) {
                    ErrorHandling.LogException(ex);
                }
                break;
            }

            error = values == null || values.All(v => v == null);
        }