Пример #1
0
        // find the customer
        private void findaccount_Click(object sender, EventArgs e)
        {
            if (dirty)
            {
                return;
            }
            //			This is the BANK #
            string accno = AccountNumber.Text;

            Bank = DataArray.ArrayGetBank(Convert.ToInt32(AccountNumber.Text));
            if (Bank == null)
            {
                info.Text = "The Customer # " + AccountNumber.Text + " cannot be found ?. Please try again... ";
                MessageBox.Show("The Bank account # " + AccountNumber.Text + " for this Customer cannot be found ?. Please try a  different  value... ", "Customer deletion system");
                AccountNumber.Focus( );
                return;
            }

            Cust = Customer.GetCustomerAccount(Bank.CustAccountNumber.ToString( ));
            if (Cust == null)
            {
                MessageBox.Show("Unable to find the Customer Record from LinkedList", "Database system ERROR"); return;
            }
            else
            {
                DeleteButton.Enabled = true;
                command.Text         = "Account has been identified successfully";
                FirstName.Text       = Cust.FirstName;
                LastName.Text        = Cust.LastName;
                command.Text         = "Click <DELETE> to REMOVE PERMANENTLY";
            }
        }
Пример #2
0
        private void allbankaccounts_SelectedIndexChanged(object sender, EventArgs e)
        {
            // get bank account for selected bank
            if (!listupdateneeded)
            {
                return;
            }
            Int32  currsel = 0;
            string temp    = allbankaccounts.SelectedItem.ToString();

            char[]   ch = { '\t' };
            string[] x  = temp.Split(ch);
            currsel = Convert.ToInt32(x[0]);
            // call the Find click event directly
            BankAccount Bank = DataArray.ArrayGetBank(currsel);

            if (Bank == null)
            {
                MessageBox.Show("ERROR ENCOUNTERED - Bank account found does not match ", "Data Processing Error"); return;
            }
            // Display the bank data
            AccountBalance.Text = Bank.Balance.ToString();
            Interest.Text       = Bank.InterestRate.ToString();
            int indx = Convert.ToInt16(x[1]);

            AccountType.SelectedIndex = indx - 1;
        }
Пример #3
0
 private void accountnumber_Leave_1(object sender, EventArgs e)
 {         // loosing focus of Bank A/C #
     if (accountnumber.Text == "")
     {
         MessageBox.Show("You MUST enter a valid Bank  A/c #, Please try again... ", "Bank Account Deposit");
         accountnumber.Focus( );
         return;
     }
     Bank = DataArray.ArrayGetBank(Convert.ToInt32(accountnumber.Text));
     if (Bank == null)
     {
         info.Text = "The Customer # " + accountnumber.Text + " cannot be found ?. Please try again... ";
         MessageBox.Show("The Bank account # " + accountnumber.Text + " cannot be found ?. Please try a  different  value... ", "Bank Account Deposit");
         accountnumber.Focus( );
         return;
     }
     MakeDeposit.Enabled = true;
     //Customer C = new Customer ( );
     Cust = DataArray.ArrayGetCust(Convert.ToInt32(Bank.CustAccountNumber.ToString( )));
     if (Cust == null)
     {
         MessageBox.Show("Cannot identify the Customer A/c # for this bank account , Please try again... ", "Bank Account Deposit");
         return;
     }
     else
     {
         lastname.Text  = Cust.LastName;
         firstname.Text = Cust.FirstName;
         info.Text      = "Bank A/C found ! - Enter the amount to be deposited...";
         textBox2.Focus( );
     }
 }
Пример #4
0
        private void AccountNumber_Leave(object sender, EventArgs e)
        {
            if (AccountNumber.Text == "1234")
            {
                info.Text = "Please complete the Customer A/c # entry correctly";
                AccountNumber.Focus( );
                return;
            }
            if (dirty)
            {
                return;
            }
            if (AccountNumber.Text == "")
            {
                MessageBox.Show("You MUST enter a valid Cusotmer A/c #, Please try again... ", "Customer deletion system");
                AccountNumber.Focus( );
                return;
            }

            if (Bank == null)
            {
                Bank = DataArray.ArrayGetBank(Convert.ToInt32(AccountNumber.Text));
                if (Bank == null)
                {
                    info.Text = "The Customer # " + AccountNumber.Text + " cannot be found ?. Please try again... ";
                    MessageBox.Show("The Bank account # " + AccountNumber.Text + " for this Customer cannot be found ?. Please try a  different  value... ", "Customer deletion system");
                    AccountNumber.Focus( );
                    return;
                }
                bankno.Text = Bank.BankAccountNumber.ToString( );
            }
            DeleteButton.Enabled = true;
            //Customer C = new Customer ( );
            Cust = DataArray.ArrayGetCust(Convert.ToInt32(Bank.CustAccountNumber.ToString( )));
            if (Cust == null)
            {
                MessageBox.Show("Cannot identify the Customer A/c # , Please try again... ", "Customer deletion system");
                return;
            }
            else
            {
                LastName.Text  = Cust.LastName;
                FirstName.Text = Cust.FirstName;
                info.Text      = "Customer A/C found ! - Click the Delete button to remove this account...";
                DeleteButton.Focus( );
                MessageBox.Show("Customer A/c # Identified, press the Delete button to remove it... ", "Customer deletion system");
            }
        }
Пример #5
0
        private void saveBank_Click(object sender, EventArgs e)
        {
            Bank.Balance      = Convert.ToDecimal(AccountBalance.Text);
            Bank.InterestRate = Convert.ToDecimal(Interest.Text);
            SerializeData.WriteBankAccountToDiskAndText(Bank, Bank.FullFileName);
            // update array data
            BankAccount B = DataArray.ArrayGetBank(Bank.BankAccountNumber);

            B.Balance      = Bank.Balance;
            B.InterestRate = Bank.InterestRate;
            // update LinkedList
            foreach (BankAccount Bk in BankAccount.BankAccountsLinkedList)
            {
                if (Bk.BankAccountNumber == Bank.BankAccountNumber)
                {
                    Bk.Balance      = Bank.Balance;
                    Bk.InterestRate = Bank.InterestRate;
                    break;
                }
            }
            MessageBox.Show("Bank Account [" + Bank.BankAccountNumber.ToString( ) + "] has been updated successfully..", "Data Maintenance");
            string msg = "Bank Account [" + Bank.BankAccountNumber.ToString( ) + " has been updated successfully...\r\n";
            //			Bank.form1. ShowText ( msg, null, -1 );//the method defined in Bank
        }
Пример #6
0
        // Go ahead and make bank account deposit
        //******************************************************************************************************************************
        private void MakeDeposit_Click_1(object sender, EventArgs e)
        //******************************************************************************************************************************
        {
            // Caution, this bank account may be one of several for this customer,
            // so make NO assumptions
            // Bank is already the correct record
            Int32 bankaccountno = 0;

            if (accountnumber.Text.Length == 0 || textBox2.Text.Length == 0)
            {
                info.Text = "Please complete both fields before pressing Go";
                MessageBox.Show("Please complete both fields before pressing Go", "Data Input Error");
                return;
            }
            if (notes.Text == "")
            {
                MessageBox.Show("You have not entered a reason for this deposit ?\nDo you want to continue without doing so ?",
                                "Data Input Error", MessageBoxButtons.YesNo);
                if (DialogResult == DialogResult.No)
                {
                    return;
                }
            }

            // This is the bank account #
            bankaccountno = Convert.ToInt32(accountnumber.Text);
            string acnostring = accountnumber.Text;
            string amountstr  = textBox2.Text.Trim( );

            if (!amountstr.Contains("."))
            {
                amountstr += ".00";
            }
            decimal amount = Convert.ToDecimal(amountstr);

            if (amount <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(amount), "Amount of Deposit [" + amount + "] must be positive");
            }

            // Update the Bank ArrayList
            Bank = DataArray.ArrayGetBank(bankaccountno);
            if (Bank == null)
            {
                MessageBox.Show("Unable to Find Bank  Account in LinkedList??..\nDeposit transaction aborted.", "Fatal Error"); return;
            }
            string custnostring = Bank.CustAccountNumber.ToString( );


            // This call updates BOTH  the Bank A/c and the entry in the LinkedList
            if (!BankAccount.UpdateBankLinkedList(bankaccountno, amount))
            {
                MessageBox.Show("Failed to update BankAccount Linked List for Account " + acnostring, "Bank Account Deposit");
            }
            // Also save the updated bank account back to disk
            SerializeData.WriteBankAccountToDiskAndText(Bank, Bank.FullFileName);
            // now add a new transaction for this operation
            BankTransaction Deposit = new BankTransaction( );

            Deposit.TransDate         = DateTime.Now;
            Deposit.AccountType       = Bank.AccountType;
            Deposit.CustAccountNumber = Bank.CustAccountNumber;
            Deposit.BankAccountNumber = Bank.BankAccountNumber;
            Deposit.Transamount       = amount;
            Deposit.Notes             = "New Deposit : " + notes.Text;
            Deposit.Status            = Bank.Status;
            BankTransaction.allBankTransactions.AddLast(Deposit);

            // update the Customer Balance Hash Table cos it holds the balance value
            CustomerBalanceHashTable.DeleteHashCustBalEntry(custnostring);
            CustomerBalanceHashTable.AddHashCustBalEntry(custnostring, Bank.Balance);

            MessageBox.Show("Deposit of " + amount.ToString( ) + " has been added to account  # " + custnostring + "\nThe new balance is £" + Bank.Balance.ToString( ), "Bank Account Deposit");
            textBox2.Text = "";
            notes.Text    = "";
            accountnumber.Focus( );
            return;
        }