Beispiel #1
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            double interestRate;

            if (!double.TryParse(tbxInterestRate.Text, out interestRate))
            {
                MessageBox.Show("Illegal interest rate", Text);
                return;
            }

            double credit;

            if (!double.TryParse(tbxCredit.Text, out credit))
            {
                MessageBox.Show("Illegal credit amount", Text);
                return;
            }

            BankAccount newAccount;

            if (credit == 0)
            {
                newAccount = new SavingsAccount(tbxAccountNr.Text, interestRate);
            }
            else
            {
                newAccount = new CreditAccount(tbxAccountNr.Text, interestRate, credit);
            }

            bank.Accounts.Add(newAccount);
            lbxAccounts.Items.Add(newAccount);

            foreach (Control control in gbxOpenAccount.Controls)
            {
                if (control is TextBox)
                {
                    (control as TextBox).Clear();
                }
            }
        }
Beispiel #2
0
        public Account CreateAccount(Client client, double?limit, DateTime?dateTime)
        {
            Decorator decorator = new Decorator();
            Account   resultAccount;

            if (limit != null)
            {
                resultAccount = new CreditAccount(client, (double)limit, creditLimit);
            }
            else
            {
                if (dateTime != null)
                {
                    resultAccount = new DepositAccount(client, (DateTime)dateTime, depositPercent);
                }
                else
                {
                    resultAccount = new CurrentAccount(client, currentPercent);
                }
            }

            return(resultAccount);
        }