Пример #1
0
        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();
        }
Пример #2
0
 private void NewAccount_Added(object sender, NewAccountAddedEventArgs e)
 {
     if (e.NewAccount != null)
     {
         _year.RemoveAccount(e.NewAccount.Name);
         _year.AddAccount(e.NewAccount);
     }
     RefreshPage();
 }
Пример #3
0
 protected virtual void OnNewAccountAdded(NewAccountAddedEventArgs e)
 {
     NewAccountAdded?.Invoke(this, e);
 }