Esempio n. 1
0
        // Transfers the specified of amount of money
        private void transfer_Click(object sender, RoutedEventArgs e)
        {
            if (transferAmount_TextBox.Text.Equals("$0.00"))
            {
                error_Label.Content = "Please input a value";
            }
            else if (transferAmount_TextBox.Text.Equals(string.Empty))
            {
                error_Label.Content = "Please input a value";
            }
            else if (Convert.ToDouble(transferAmount_TextBox.Text) <= 0)
            {
                error_Label.Content = "Please input a value greater than 0";
            }
            else if (accountSelect == 0 || accountSelect2 == 0)
            {
                error_Label.Content = "Please specify the accounts for the transaction";
            }
            else if (accountSelect == accountSelect2)
            {
                error_Label.Content = "You cannot transfer to the same account";
            }
            else if ((Convert.ToDouble(transferAmount_TextBox.Text) > MainWindow.savingBalance && accountSelect == 1) || (Convert.ToDouble(transferAmount_TextBox.Text) > MainWindow.chequingBalance && accountSelect == 2))
            {
                error_Label.Content = "You do not have enough funds";
            }
            else
            {
                error_Label.Content = "";
                // Rounds to the 2nd decimal place
                transferAmount = Math.Round(Convert.ToDouble(transferAmount_TextBox.Text), 2);

                // Transfers and updates balances
                if (accountSelect == 1 && accountSelect2 == 2)
                {
                    MainWindow.savingBalance   -= transferAmount;
                    MainWindow.chequingBalance += transferAmount;

                    updateBalance(MainWindow.savingBalance, 1);
                    updateBalance(MainWindow.chequingBalance, 2);

                    ErrorWindow success = new ErrorWindow("You have transferred $" + (transferAmount) + "\nfrom savings to chequing");
                    success.Show();
                }
                else if (accountSelect == 2 && accountSelect2 == 1)
                {
                    MainWindow.savingBalance   += transferAmount;
                    MainWindow.chequingBalance -= transferAmount;

                    updateBalance(MainWindow.savingBalance, 2);
                    updateBalance(MainWindow.chequingBalance, 1);

                    ErrorWindow success = new ErrorWindow("You have transferred $" + (transferAmount) + "\nfrom chequing to savings");
                    success.Show();
                }
            }
        }
Esempio n. 2
0
        private void balance_Click(object sender, RoutedEventArgs e)
        {
            BalanceWindow win2 = new BalanceWindow();

            win2.Show();

            ErrorWindow success = new ErrorWindow("Please collect your printed balance \nfrom the box below");

            success.Show();
        }
Esempio n. 3
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";
            }
        }
Esempio n. 4
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();
        }