Пример #1
0
        //event handler for when user clicks 'Yes - Process'
        //validates transaction, then updates customer object with the new information
        //Loads frmTransactionComplete after update
        private void btnYesProcess_Click(object sender, EventArgs e)
        {
            //inidcates whether or not to load frmTransactionComplete
            Boolean processed = false;

            //increment savingsBal with transactionAmount
            if (btnSavingsDeposit.BackColor == Color.Yellow)
            {
                savingsBal += transactionAmount;
                processed   = true;
            }
            //increment checkingBal with transactionAmount
            if (btnCheckingDeposit.BackColor == Color.Yellow)
            {
                checkingBal += transactionAmount;
                processed    = true;
            }
            //Load frmTransactionComplete so that user can view balance
            if (btnSavingsBalance.BackColor == Color.Yellow)
            {
                //MessageBox.Show("Your Savings Account Balance is : $" + savingsBal, "Savings Account Balance");
                processed = true;
            }
            //Load frmTransactionComplete so that user can view balance
            if (btnCheckingBalance.BackColor == Color.Yellow)
            {
                //MessageBox.Show("Your Checking Account Balance is : $" + checkingBal, "Checking Account Balance");
                processed = true;
            }

            if (btnCheckingWithdrawal.BackColor == Color.Yellow)
            {
                //if transactionAmount is greather than the withdrawal limit, user needs to enter a smaller amount
                if (GlobalData.ATMBank.underLimit(transactionAmount) == false)
                {
                    MessageBox.Show("Please enter a withdrawal amount less than 300", "Error");
                    transactionAmount = 0;
                    txtConfirmAmount.ResetText();
                    lblCorrectMarked.Visible = false;
                    lblYouSelected.Visible   = false;
                    txtConfirmAmount.Visible = false;
                    btnYesProcess.Visible    = false;
                    btnNoSelectAgain.Visible = false;
                    txtTransactionAmount.ResetText();
                    txtTransactionAmount.Focus();
                    txtTransactionAmount.Select();
                }
                //if transactionAmount is more than the current Balance, the user needs to enter a smaller amount
                else if (transactionAmount > checkingBal)
                {
                    MessageBox.Show("Insufficient Funds. Please type in a smaller amount", "Error");
                    transactionAmount = 0;
                    txtConfirmAmount.ResetText();
                    lblCorrectMarked.Visible = false;
                    lblYouSelected.Visible   = false;
                    txtConfirmAmount.Visible = false;
                    btnYesProcess.Visible    = false;
                    btnNoSelectAgain.Visible = false;

                    txtTransactionAmount.ResetText();
                    txtTransactionAmount.Focus();
                    txtTransactionAmount.Select();
                }
                //if transactionAmount is a valid amount, then the withdrawal transaction can be executed
                else
                {
                    checkingBal -= transactionAmount;
                    processed    = true;
                }
            }
            if (btnSavingsWithdrawal.BackColor == Color.Yellow)
            {
                //if transactionAmount is greather than the withdrawal limit, user needs to enter a smaller amount
                if (GlobalData.ATMBank.underLimit(transactionAmount) == false)
                {
                    MessageBox.Show("Amount Exceeds the Daily Limit. Please enter a withdrawal amount less than 300", "Invalid Amount");
                    transactionAmount = 0;
                    txtConfirmAmount.ResetText();
                    lblCorrectMarked.Visible = false;
                    lblYouSelected.Visible   = false;
                    txtConfirmAmount.Visible = false;
                    btnYesProcess.Visible    = false;
                    btnNoSelectAgain.Visible = false;

                    txtTransactionAmount.ResetText();
                    txtTransactionAmount.Focus();
                    txtTransactionAmount.Select();
                }
                //if transactionAmount is more than the current Balance, the user needs to enter a smaller amount
                else if (transactionAmount > savingsBal)
                {
                    MessageBox.Show("The amount you entered exceeds the current amount in this account. Please type in a smaller amount", "Insufficient Funds");
                    transactionAmount = 0;
                    txtConfirmAmount.ResetText();
                    lblCorrectMarked.Visible = false;
                    lblYouSelected.Visible   = false;
                    txtConfirmAmount.Visible = false;
                    btnYesProcess.Visible    = false;
                    btnNoSelectAgain.Visible = false;

                    txtTransactionAmount.ResetText();
                    txtTransactionAmount.Focus();
                    txtTransactionAmount.Select();
                }
                //if transactionAmount is a valid amount, then the withdrawal transaction can be executed
                else
                {
                    savingsBal -= transactionAmount;
                    processed   = true;
                }
            }
            if (btnTransferCheckingToSavings.BackColor == Color.Yellow)
            {
                //if transactionAmount is greather than the amount in the source account, user needs to enter a smaller amount
                if (transactionAmount > checkingBal)
                {
                    MessageBox.Show("The amount you entered exceeds the current amount in this account. Please type in a smaller amount.", "Insufficient Funds");
                    txtConfirmAmount.ResetText();
                    lblCorrectMarked.Visible = false;
                    lblYouSelected.Visible   = false;
                    txtConfirmAmount.Visible = false;
                    btnYesProcess.Visible    = false;
                    btnNoSelectAgain.Visible = false;

                    transactionAmount = 0;
                    txtTransactionAmount.ResetText();
                    txtTransactionAmount.Focus();
                }
                //if transactionAmount is a valid amount, then the trasnfer money transaction can be executed
                else
                {
                    checkingBal -= transactionAmount;
                    savingsBal  += transactionAmount;
                    processed    = true;
                }
            }
            if (btnTransferSavingsToChecking.BackColor == Color.Yellow)
            {
                //if transactionAmount is greather than the amount in the source account, user needs to enter a smaller amount
                if (transactionAmount > savingsBal)
                {
                    MessageBox.Show("The amount you entered exceeds the current amount in this account. Please type in a smaller amount.", "Insufficient Funds");
                    txtConfirmAmount.ResetText();
                    lblCorrectMarked.Visible = false;
                    lblYouSelected.Visible   = false;
                    txtConfirmAmount.Visible = false;
                    btnYesProcess.Visible    = false;
                    btnNoSelectAgain.Visible = false;

                    transactionAmount = 0;
                    txtTransactionAmount.ResetText();
                    txtTransactionAmount.Focus();
                }
                //if transactionAmount is a valid amount, then the trasnfer money transaction can be executed
                else
                {
                    savingsBal  -= transactionAmount;
                    checkingBal += transactionAmount;
                    processed    = true;
                }
            }
            //if true, then frmTransactionComplete can be loaded
            if (processed == true)
            {
                GlobalData.customer.updateAccounts(savingsBal, checkingBal);
                Form frmTransactionComplete = new frmTransactionComplete();
                frmTransactionComplete.Show();
                Close();
            }
        }
Пример #2
0
        // Calculates changes to accounts based on transaction information. Validates some transaction rules.
        // Updates customer object with new information and opens frmTransactionComplete.
        // Closes transaction entry form.
        private void btnTransactionGo_Click(object sender, EventArgs e)
        {
            bool transactionHappened = false;

            if (selectedTransaction == 1)
            {
                savingsBalance     += transactionAmount;
                transactionHappened = true;
            }
            if (selectedTransaction == 2)
            {
                if (GlobalData.ATMBank.meetsLimit(transactionAmount))
                {
                    if (transactionAmount > savingsBalance)
                    {
                        MessageBox.Show("You are withdrawing more money than you have in your account. Please widthdraw less.", "Overdraft Warning");
                        transactionAmount         = 0;
                        txtTransactionAmount.Text = "";
                        txtTransactionAmount.Focus();
                    }
                    else
                    {
                        savingsBalance     -= transactionAmount;
                        transactionHappened = true;
                    }
                }
                else
                {
                    MessageBox.Show("Please enter a withdrawal amount less than 300.", "Error");
                    transactionAmount         = 0;
                    txtTransactionAmount.Text = "";
                    txtTransactionAmount.Focus();
                }
            }
            if (selectedTransaction == 4)
            {
                if (transactionAmount > savingsBalance)
                {
                    MessageBox.Show("You are transfering more money than you have in your account. Please transfer less.", "Overdraft Warning");
                    transactionAmount         = 0;
                    txtTransactionAmount.Text = "";
                    txtTransactionAmount.Focus();
                }
                else
                {
                    savingsBalance     -= transactionAmount;
                    checkingBalance    += transactionAmount;
                    transactionHappened = true;
                }
            }
            if (selectedTransaction == 5)
            {
                checkingBalance    += transactionAmount;
                transactionHappened = true;
            }
            if (selectedTransaction == 6)
            {
                if (transactionAmount > 300)
                {
                    MessageBox.Show("Please enter a withdrawal amount less than 300.", "Error");
                    transactionAmount         = 0;
                    txtTransactionAmount.Text = "";
                    txtTransactionAmount.Focus();
                }
                else
                {
                    if (transactionAmount > checkingBalance)
                    {
                        MessageBox.Show("You are withdrawing more money than you have in your account. Please widthdraw less.", "Overdraft Warning");
                        transactionAmount         = 0;
                        txtTransactionAmount.Text = "";
                        txtTransactionAmount.Focus();
                    }
                    else
                    {
                        checkingBalance    += transactionAmount;
                        transactionHappened = true;
                    }
                }
            }
            if (selectedTransaction == 8)
            {
                if (transactionAmount > savingsBalance)
                {
                    MessageBox.Show("You are transfering more money than you have in your account. Please transfer less.", "Overdraft Warning");
                    transactionAmount         = 0;
                    txtTransactionAmount.Text = "";
                    txtTransactionAmount.Focus();
                }
                else
                {
                    checkingBalance    -= transactionAmount;
                    savingsBalance     += transactionAmount;
                    transactionHappened = true;
                }
            }
            if (selectedTransaction == 3 || selectedTransaction == 7)
            {
                transactionHappened = true;
            }
            if (transactionHappened)
            {
                GlobalData.customer.updateSavingsCheckings(savingsBalance, checkingBalance);
                Form frmTransactionComplete = new frmTransactionComplete();
                frmTransactionComplete.Show();
                Close();
            }
        }