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)); }
public MainMenu(Account account, ATM atm, Login login) { InitializeComponent(); this.accountList = atm.GetDatabase(); this.instanceAccount = account; this.login = login; this.atm = atm; userNameLabel.Text = this.instanceAccount.CardNum; WithdrawPanel.Hide(); depositPanel.Hide(); checkBalancePanel.Hide(); numToWithdraw = 0; disableWithdrawButtons(); }
/* 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"); } }
public ATM(string jsonFilename) { bill20sLeft = 500; accounts = new AccountList(jsonFilename); }