Пример #1
0
        private void btnCreateAccount_Click(object sender, EventArgs e)
        {
            decimal balance;

            if (Decimal.TryParse(tbxInitBalance.Text, out balance))
            {
                if (balance >= 0)
                {
                    if (tbxCreateAccount.Text == "")
                    {
                        MessageBox.Show("Please Enter Account Name", "Error", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                    else
                    {
                        var account = new Account(tbxCreateAccount.Text, accounts.Count, "Open", Math.Round(balance, 2));
                        accounts.Add(account);

                        cbxDeposit.Items.Add(account.GetName());
                        cbxWithdraw.Items.Add(account.GetName());
                        cbxClose.Items.Add(account.GetName());
                        cbxQuery.Items.Add(account.GetName());

                        MessageBox.Show("Account Created", "Account Created",
                                        MessageBoxButtons.OK, MessageBoxIcon.Information);

                        tbxCreateAccount.Text = "";
                        tbxInitBalance.Text   = "0.00";
                    }
                }
                else
                {
                    MessageBox.Show("Account Balance Must Be Positive", "Error", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Balance Must Be Number", "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }