private void btOk_Click(object sender, EventArgs e) { if (IsValid()) { decimal amount = Decimal.Parse(tbAmount.Text); string target = tbTarget.Text.Substring(4, 4); if (index == Checking) { customer.Checking.Amount -= amount; } if (index == Savings) { customer.Savings.Amount -= amount; } foreach (Customer c in frmLogIn.userList) { if (String.Compare(tbTarget.Text, c.Checking.AccountNumber.ToString()) == 0) { c.Checking.Amount += amount; } if (String.Compare(tbTarget.Text, c.Savings.AccountNumber.ToString()) == 0) { c.Savings.Amount += amount; } } frmReceipt receipt = new frmReceipt(customer, 2, amount, index, target); this.Close(); receipt.ShowDialog(); } }
private void btOk_Click(object sender, EventArgs e) { if (IsValid()) { decimal amount = Decimal.Parse(tbAmount.Text); frmReceipt receipt = new frmReceipt(customer, mode, amount, index); switch (mode) { case Deposit: if (index == Checking) { customer.Checking.Amount += amount; } if (index == Savings) { customer.Savings.Amount += amount; } this.Close(); receipt.ShowDialog(); break; case Withdraw: // validate error message and confirmation if (index == Checking) { if (amount > customer.Checking.Amount) { MessageBox.Show("Insufficient Funds", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); break; } customer.Checking.Amount -= amount; } if (index == Savings) { customer.Savings.Amount -= amount; } this.Close(); receipt.ShowDialog(); break; } } }