private void saveBtn_Click(object sender, EventArgs e)
        {
            decimal startingAmount = 0;

            if (!decimal.TryParse(balanceTb.Text, out startingAmount))
            {
                balanceTb.Text = 0.ToString();
                MessageBox.Show("Invalid amount!");
                return;
            }

            DateTime startingDate = startingDateDtp.Value.Date;

            string name = nameTb.Text;

            AccountBase account = null;
            string      type    = typeCb.SelectedItem.ToString();

            switch (type)
            {
            case "CheckingAccount":
                account = new CheckingAccount(name, startingAmount, startingDate);
                break;

            case "CreditCard":
                account = new CreditCard(name, startingAmount, startingDate);
                break;
            }
            NewAccountAddedEventArgs args = new NewAccountAddedEventArgs();

            args.NewAccount = account;
            OnNewAccountAdded(args);

            this.Close();
        }
 private void NewAccount_Added(object sender, NewAccountAddedEventArgs e)
 {
     if (e.NewAccount != null)
     {
         _year.RemoveAccount(e.NewAccount.Name);
         _year.AddAccount(e.NewAccount);
     }
     RefreshPage();
 }
 protected virtual void OnNewAccountAdded(NewAccountAddedEventArgs e)
 {
     NewAccountAdded?.Invoke(this, e);
 }