Exemplo n.º 1
0
        // Withdraws specified amount within reasonable limits
        public void withdraw(double amount)
        {
            if (accountSelect == 1)
            {
                if (amount > MainWindow.savingBalance)
                {
                    error_Label.Content = "You do not have enough funds";
                }
                else
                {
                    MainWindow.savingBalance -= amount;
                    updateBalance(MainWindow.savingBalance);

                    ErrorWindow success = new ErrorWindow("You have withdrawn $" + (amount) + "\nfrom your savings account");
                    success.Show();

                    error_Label.Content = "";
                }
            }
            else if (accountSelect == 2)
            {
                if (amount > MainWindow.chequingBalance)
                {
                    error_Label.Content = "You do not have enough funds";
                }
                else
                {
                    MainWindow.chequingBalance -= amount;
                    updateBalance(MainWindow.chequingBalance);

                    ErrorWindow success = new ErrorWindow("You have withdrawn $" + (amount) + "\nfrom your chequing account");
                    success.Show();

                    error_Label.Content = "";
                }
            }
            else if (accountSelect == 0)
            {
                error_Label.Content = "Please select an Account";
            }
        }
Exemplo n.º 2
0
        // Performs deposit and displays result
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            input2 = Convert.ToDouble(label1.Text);
            temp   = Math.Round((input + input2), 2);
            if (DepositPage.accountSelect == 1)
            {
                WithdrawPage.withdraw(-(temp), DepositPage.accountSelect);

                ErrorWindow success = new ErrorWindow("You have deposited $" + (temp) + "\ninto your savings account");
                success.Show();
            }
            else if (DepositPage.accountSelect == 2)
            {
                WithdrawPage.withdraw(-(temp), DepositPage.accountSelect);
                ErrorWindow success = new ErrorWindow("You have deposited $" + (temp) + "\ninto your chequing account");
                success.Show();
            }
            input       = 0;
            input2      = 0;
            label1.Text = "0.00";
            updateText();
        }