//define event listener method protected virtual void OnOverdraft(OverdraftEventArgs e) { EventHandler<OverdraftEventArgs> handler = Overdraft; if(handler != null) { handler(this, e); } }
// The event handler with event args. private void SavingsOverdrawnHandler(object sender, OverdraftEventArgs args) { string message = "The savings account is overdrawn." + Environment.NewLine + "Current Balance: " + args.Balance.ToString("C") + Environment.NewLine + "Debit Amount: " + args.Debit.ToString("C"); MessageBox.Show(message); }
//define event listener method protected virtual void OnOverdraft(OverdraftEventArgs e) { EventHandler <OverdraftEventArgs> handler = Overdraft; if (handler != null) { handler(this, e); } }
// The event handler with event args. private void AccountOverdrawnHandler(object sender, OverdraftEventArgs args) { // Get the overdraft account. OverdraftAccount account = sender as OverdraftAccount; string message = "The account is overdrawn." + Environment.NewLine + "Current Balance: " + account.Balance.ToString("C") + Environment.NewLine + "Savings Balance: " + account.SavingsAccount.Balance.ToString("C") + Environment.NewLine + "Debit Amount: " + args.Debit.ToString("C"); MessageBox.Show(message); }