Exemple #1
0
        /* submit the user input to the system */
        private void Submit()
        {
            // get the account number and pin from the user input
            String acctNum = this.AcctNumBox.Text;
            String pin     = this.PinBox.Text;

            // load the user from the database that matches the account number
            AccountList db   = atm.GetDatabase();
            Account     user = db.FindAcct(acctNum);

            // check if the account pin is correct
            if (user != null)
            {
                if (IsValidLogin(user, pin))
                {
                    // open the user's main menu screen
                    user.ClearLoginAttempts();
                    db.UpdateAcct(user);
                    OpenMainMenu(user);
                }
                else
                {
                    // Check # login attempts
                    if (user.LoginAttempts >= 2)
                    {
                        // lock the user account and update in database
                        user.Lock();
                        db.UpdateAcct(user);
                        MessageBox.Show("Please contact your bank.", "Account Locked", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Console.WriteLine("Your account has been locked due to too many failed login attempts. Please contact your bank");
                    }
                    else
                    {
                        user.AddLoginAttempt();
                        db.UpdateAcct(user);
                        MessageBox.Show("This account has " + user.LoginAttempts + " failed login attempts. After 3 failed logins, your account will be locked.", "Invalid PIN", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Console.WriteLine("Invalid PIN");
                    }
                }
            }
            else
            {
                // the account does not exist
                MessageBox.Show("Please try again.", "Account not found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Console.WriteLine("Account not found");
            }
        }
Exemple #2
0
        static void Main()
        {
            //Application.EnableVisualStyles();
            //Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());
            AccountList a = new AccountList("accounts.json");

            //Account acct = a.FindAcct("123456781234");

            a.UpdateAcct(new Account("123456781234", "1234", 5, false, 25.5));
        }
Exemple #3
0
        public void Withdraw(int numberOf20s, Account account)
        {
            accountList.UpdateAcct(account);

            int toWithdraw = (numberOf20s * 20);

            if (!this.atm.TakeOut(numberOf20s))
            {
                return;
            }

            if (account.Balance - toWithdraw >= 0)
            {
                account.Balance -= toWithdraw;
                DispenseCash(numberOf20s);
                accountList.UpdateAcct(account);
                System.Windows.Forms.MessageBox.Show("Withdrawal of: $" + toWithdraw.ToString() + " Successful");
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Insufficient acount funds");
            }
        }