Ejemplo n.º 1
0
        private void SortOutPrice()
        {
            if (txtPayInput.Text == "")
            {
                return;
            }

            int intValue = (int)sldPrice.Value;

            double dblPriceInput;

            if (!double.TryParse(txtPayInput.Text, out dblPriceInput))
            {
                ErrorMessages(0);
                Clear();
                return;
            }

            //validation for the number going above or below a required parameter
            if (dblPriceInput < 0.00 || dblPriceInput > 10000.00)
            {
                ErrorMessages(1);
                Clear();
                return;
            }

            CheckCurrency();

            //shows the discount level
            txbPriceDiscount.Text = intValue.ToString("n0") + "%" + " off";

            //takes the percentage and shows what you pay with the discount
            double dblPrice = DiscountCalculations.DiscountPrice(dblPriceInput, intValue);

            txbYouPay.Text = string.Format("you pay: " + currency + dblPrice.ToString("n2"));
            //shows the price with tax
            txbPriceWithTax.Text = string.Format("price with tax: " + currency + DiscountCalculations.AddTax(dblPrice, _Settings.TaxSetting).ToString("n2"));
            //shows the total saving
            txbYouSave.Text = string.Format("you save: " + currency + DiscountCalculations.YouSave(dblPriceInput, intValue).ToString("n2"));
        }
Ejemplo n.º 2
0
        private void SortOutDiscount()
        {
            if (txtNewPriceInput.Text == "")
            {
                return;
            }

            int intValue = (int)sldDiscounts.Value;

            double dblNewPriceInput;

            if (!double.TryParse(txtNewPriceInput.Text, out dblNewPriceInput))
            {
                ErrorMessages(0);
                ClearDiscounts();
                return;
            }
            if (dblNewPriceInput < 0.00 || dblNewPriceInput > 10000.00)
            {
                ErrorMessages(1);
                ClearDiscounts();
                return;
            }
            CheckCurrency();

            //shows the discount level
            txbDiscounts.Text = intValue.ToString("n0") + "%" + " off";
            //shows the original price
            double dblOriginalPrice = DiscountCalculations.PaidToOriginal(dblNewPriceInput, intValue);

            txbOriginalPrice.Text = string.Format(currency + dblOriginalPrice.ToString("n2"));
            //takes the new price and adds on the tax
            txbYouPayDiscountsWithTax.Text        = string.Format("new price with tax");
            txbYouPayDiscountsWithTaxNumbers.Text = string.Format(currency + DiscountCalculations.AddTax(dblNewPriceInput, _Settings.TaxSetting).ToString("n2"));
            //takes the original price and adds on the tax
            txbYouPayOriginalWithTax.Text        = string.Format("original price with tax");
            txbYouPayOriginalWithTaxNumbers.Text = string.Format(currency + DiscountCalculations.AddTax(dblOriginalPrice, _Settings.TaxSetting).ToString("n2"));
        }