예제 #1
0
 private void MainMenu_Load(object sender, EventArgs e)
 {
     logInForm         = new FormMain();
     logInForm.Visible = false;
     bankUserM         = logInForm.GetBankUser(); //grab data from main form
     bankUserDB.Remove(bankUserM);
 }
예제 #2
0
        private void buttonLogIn_Click(object sender, EventArgs e)
        {
            try
            {
                if (IsValidData())                                      //Input validation
                {
                    if (userExist() && !bankUsers[currentIndex].Locked) //Makes sure the user exist.  Meaning if the login info match record
                    {
                        //mainMenu.Focus();
                        //this.Close();

                        bankUser = bankUsers[currentIndex];
                        Console.WriteLine(bankUser.AccountNumber + "  " + bankUser.CheckingBalance);
                        Console.WriteLine(bankUsers[currentIndex].AccountNumber + "  " + bankUsers[currentIndex].CheckingBalance);
                        mainMenu.Show();
                        this.Visible = false;
                        //BankUser customer=mainMenu.Get
                    }
                    else if (bankUsers[currentIndex].Locked) //if account locked, wait for admin to unlock
                    {
                        textBoxUD.Text      = "";
                        textBoxPassw.Text   = "";
                        buttonClear.Visible = false;
                        buttonLogIn.Visible = false;
                        textBoxMessage.Text = "PLEASE SEE BANK OFFICER - NO FURTHER LOGIN ATTEMPTS ALLOWED." +
                                              "\nAny further questions, call the bank. Bank number: 1-800-Big-Bucks";

                        buttonAdmin.Visible = true;

                        //adminUnlock();
                    }
                    else if (textBoxUD.Text == closeWindow[0] && textBoxPassw.Text == closeWindow[1]) //admin closing atm
                    {
                        string       message = "Are you sure you want to shut down ATM? ";
                        DialogResult button  =
                            MessageBox.Show(message, "ATM Shut Down!",
                                            MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                        if (button == DialogResult.Yes)
                        {
                            System.Environment.Exit(1); //Close whole application
                        }
                    }
                    else
                    {
                        textBoxUD.Focus();
                        textBoxMessage.Text = "The user ID entered does not match the password we have on record.\nPlease try again.";
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n\n" + ex.GetType().ToString() + "\n" +
                                ex.StackTrace, "Exception");
            }
        }
예제 #3
0
        public Balance(BankUser user)
        {
            bankUserB = user;
            InitializeComponent();

            var accntNum = bankUserB.CheckingAccountNum.ToString();
            var accnt    = "Ending in " + accntNum.Substring(accntNum.Length - 4, 4);

            comboBoxAccount.Items.Add(accnt);

            accntNum = bankUserB.SavingAccountNum.ToString();
            accnt    = "Ending in " + accntNum.Substring(accntNum.Length - 4, 4);

            comboBoxAccount.Items.Add(accnt);
            comboBoxAccount.SelectedIndex = 0;
        }
예제 #4
0
        public static List <BankUser> GetProducts()
        {
            // if the directory doesn't exist, create it
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            // create the object for the input stream for a text file
            StreamReader textIn =
                new StreamReader(
                    new FileStream(path, FileMode.OpenOrCreate, FileAccess.Read));

            // create the list
            List <BankUser> bankUser = new List <BankUser>();

            // read the data from the file and store it in the list
            while (textIn.Peek() != -1)
            {
                string   row     = textIn.ReadLine();
                string[] columns = row.Split('|');
                BankUser user    = new BankUser();
                user.UserID             = columns[0];
                user.Password           = Convert.ToInt32(columns[1]);
                user.SavingAccountNum   = Convert.ToInt32(columns[2]);
                user.CheckingAccountNum = Convert.ToInt32(columns[3]);
                user.CheckingBalance    = Convert.ToDecimal(columns[4]);
                user.SavingBalance      = Convert.ToDecimal(columns[5]);
                user.AccountNumber      = Convert.ToInt32(columns[6]);
                bankUser.Add(user);
            }

            // close the input stream for the text file
            textIn.Close();

            return(bankUser);
        }
예제 #5
0
        private void buttonSubmit_Click(object sender, EventArgs e)
        {
            //bankUserDB.Remove(bankUserM); //remove the data from file to rewrite latest changes on file

            if (radioButtonDeposit.Checked) //deposit
            {
                bankUserM.Deposit = true;
                depositForm       = new Deposit_Withdraw(bankUserM);
                depositForm.Text  = "Deposit";
                this.Visible      = false;

                bankUserM    = depositForm.getDep_WidthData(); //calls Deposit Form and after is done, it returns Class
                this.Visible = true;
            }
            else if (radioButtonWithdrawl.Checked)  //withdraw
            {
                bankUserM.Deposit = false;
                depositForm       = new Deposit_Withdraw(bankUserM);
                depositForm.Text  = "Withdraw";
                this.Visible      = false;

                bankUserM    = depositForm.getDep_WidthData(); //calls Deposit Form and after is done, it returns Class
                this.Visible = true;
            }
            else if (radioButtonBalance.Checked) //balance
            {
                Balance balanceForm = new Balance(bankUserM);
                this.Visible = false;
                balanceForm.ShowDialog();
                this.Visible = true;
            }
            else if (radioButtonTransfer.Checked)  //transfer
            {
                transferForm = new TransferForm(bankUserM);
                this.Visible = false;

                bankUserM    = transferForm.getTransferData(); //this calls method in transfer form which calls the showdialog form
                this.Visible = true;
            }
            else
            {
                string       message = "Are you sure you want to Logg Off? ";
                DialogResult button  =
                    MessageBox.Show(message, "Logg Off!",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                if (button == DialogResult.Yes)
                {
                    for (int x = 0; x < bankUserDB.Count; x++)  //Loop will save changes to list which will update the text file
                    {
                        if (bankUserM.AccountNumber == bankUserDB[x].AccountNumber)
                        {
                            bankUserDB[x].CheckingBalance = bankUserM.CheckingBalance;
                            bankUserDB[x].SavingBalance   = bankUserM.SavingBalance;

                            Console.WriteLine("Main loop.. " + bankUserDB[x].UserID + "  " + bankUserDB[x].SavingBalance + " " + bankUserDB[x].CheckingBalance);
                            break;
                        }
                    }

                    BankUserDB.SaveProducts(bankUserDB);

                    this.Visible = false;
                    logInForm.Show();
                }
            }
        }
예제 #6
0
 public TransferForm(BankUser t)
 {
     bankUserT = t;
     InitializeComponent();
 }
예제 #7
0
 public Deposit_Withdraw(BankUser user)
 {
     bankUserD = user;
     InitializeComponent();
 }