private void button1_Click(object sender, EventArgs e) { String amountText = this.textBox1.Text; int val = 0; bool result = int.TryParse(amountText, out val); if (result) { int amount = Int32.Parse(amountText); Console.WriteLine("WithDrawing : " + amount); int currentBalance = myATM.getCurrentUserBalance(); if (currentBalance >= amount) { int lastBal = myATM.getCurrentUserBalance(); myATM.withdrawFunds(amount); Console.WriteLine(myATM.getCurrentUserBalance()); VanishingScreen vs = new VanishingScreen(lastBal, myATM); this.Hide(); vs.Show(); } else { MessageBox.Show("Invalid Withdraw Amount", "Invalid Withdraw Amount", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Please only input integers", "Invalid Withdraw Input", MessageBoxButtons.OK, MessageBoxIcon.Error); } return; }
public VanishingScreen(int lastBal, ATM_Object theATM) { InitializeComponent(); myATM = theATM; prevBal = lastBal; this.previous_balance.Text = lastBal.ToString(); this.current_balance.Text = theATM.getCurrentUserBalance().ToString(); }
public ShowBalance(ATM_Object theATM) { InitializeComponent(); myATM = theATM; balance = myATM.getCurrentUserBalance(); this.label2.Text = balance.ToString(); // Text = balance.ToString(); }
private void deposit__Click(object sender, EventArgs e) { Console.WriteLine("Depositing : " + this.textBox1.Text); String amount = this.textBox1.Text; int val = 0; bool result = int.TryParse(amount, out val); if (result) { int prevBal = myATM.getCurrentUserBalance(); myATM.depositFunds(Int32.Parse(amount)); Console.WriteLine(myATM.getCurrentUserBalance()); VanishingScreen vs = new VanishingScreen(prevBal, myATM); this.Hide(); vs.Show(); } else { MessageBox.Show("Invalid Deposit Amount", "Invalid Deposit Amount", MessageBoxButtons.OK, MessageBoxIcon.Error); } return; }
// Withdraw 20 quick button private void button1_Click(object sender, EventArgs e) { int amount = 20; Console.WriteLine("WithDrawing : " + amount); int currentBalance = myATM.getCurrentUserBalance(); if (currentBalance >= amount) { int lastBal = myATM.getCurrentUserBalance(); myATM.withdrawFunds(amount); Console.WriteLine(myATM.getCurrentUserBalance()); VanishingScreen vs = new VanishingScreen(lastBal, myATM); this.Hide(); vs.Show(); } else { MessageBox.Show("Invalid Withdraw Amount", "Invalid Withdraw Amount", MessageBoxButtons.OK, MessageBoxIcon.Error); } return; }