Пример #1
0
        public ResultWindow(Calculator calculator)
        {
            InitializeComponent();
            amountWithoutTerms.Text = calculator.Amount.ToString();
            TermsAmountTextBox.Text = calculator.TermsAmount.ToString();
            totalWithTermsTextBox.Text = (calculator.Amount + calculator.TermsAmount).ToString();
            vatAmountTextBox.Text = calculator.VatAmount.ToString();
            totalTextBox.Text = calculator.TotalAmount.ToString();

            if (calculator.IsDiscountChecked == true)
            {
                TermsAmountTextBlock.Text = String.Format("Discount Amount (-{0}%):", ((1 - calculator.TermsPercentageDecimal) * 100).ToString());
            }
            else
            {
                TermsAmountTextBlock.Text = String.Format("Service charge amount ({0}%):", ((calculator.TermsPercentageDecimal - 1) * 100).ToString());
            }

            if (calculator.VatAmount == 0)
            {
                vatAmountTextBlock.Visibility = Visibility.Hidden;
                vatAmountTextBox.Visibility = Visibility.Hidden;
                vatTotalTextBlock.Visibility = Visibility.Hidden;
                totalTextBox.Visibility = Visibility.Hidden;

            }
        }
 private void calculateButton_Click(object sender, RoutedEventArgs e)
 {
     Calculator calculator = new Calculator();
     bool useDiscount = (discountRadioButton.IsChecked == true);
     bool termsAreIncluded = (termsIncludedCheckBox.IsChecked == true);
     bool includeVATCalculations = (calculateVATCheckBox.IsChecked == true);
     bool vatAlreadyIncluded = (vatAlredyIncludedCheckBox.IsChecked == true);
     if (includeVATCalculations)
     {
         calculator.updateCalculator(amountBox.Text, termsPercentage.Text, vatPercentage.Text, useDiscount, termsAreIncluded, vatAlreadyIncluded);
     }
     else
     {
         calculator.updateCalculator(amountBox.Text, termsPercentage.Text, useDiscount, termsAreIncluded );
     }
     calculator.updateFigures();
     ResultWindow resultWindow = new ResultWindow(calculator);
     resultWindow.Show();
     //this.Close();
 }