Exemple #1
0
        // The event handler with event args.
        private void OverdraftOverdrawnHandler(object sender, OverdrawnEventArgs 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.DebitAmount.ToString("C");

            MessageBox.Show(message);
        }
Exemple #2
0
        // Make the accounts.
        private void Form1_Load(object sender, EventArgs e)
        {
            TheAccount = new OverdraftAccount();
            TheAccount.SavingsAccount         = new BankAccount();
            TheAccount.Balance                = 50m;
            TheAccount.SavingsAccount.Balance = 50m;
            DisplayBalances();

            // Subscribe to the accounts' Overdrawn events.
            TheAccount.Overdrawn += OverdraftOverdrawnHandler;
            TheAccount.SavingsAccount.Overdrawn += SavingsOverdrawnHandler;
        }