Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            long lIDSelector     = 0;
            long lsavingsDeposit = 0;

            if (txtsavingsDeposit.Text != "")
            {
                lsavingsDeposit = long.Parse(txtsavingsDeposit.Text);
            }
            if (txtID.Text != "")
            {
                lIDSelector = long.Parse(txtID.Text);
            }
            else
            {
                MessageBox.Show("Please enter your Account ID");
            }


            if (radioButton2.Checked)
            {
                try
                {
                    SavingsAccount savingsAccount = new SavingsAccount();
                    //currentAccount.openCurrentAccount(lIDSelector);
                    if (lsavingsDeposit > 999)
                    {
                        savingsAccount.openSavingsAccount(lIDSelector, lsavingsDeposit);
                    }
                    else
                    {
                        MessageBox.Show("Your savings account requires a deposit of R1000 to access your account");
                    }
                }
                catch
                {
                    MessageBox.Show("Error trying to open your account");
                }
            }

            if (radioButton1.Checked)
            {
                txtsavingsDeposit.Enabled = false;
                try
                {
                    CurrentAccount currentAccount = new CurrentAccount();
                    currentAccount.openCurrentAccount(lIDSelector);
                }
                catch
                {
                    MessageBox.Show("No such account exists");
                }
            }
            if (radioButton1.Checked == false && radioButton2.Checked == false)
            {
                MessageBox.Show("Please choose an account type");
            }
        }
 private void btnCurrentDeposit_Click(object sender, EventArgs e)
 {
     try
     {
         int            amountToDeposit = Convert.ToInt32(txtCurrentDepositAmount.Text);
         CurrentAccount currentAccount  = new CurrentAccount();
         currentAccount.deposit(ID, amountToDeposit);
         this.Close();
         int balance = Balance;
         txtAvailableBalance.Text = (Overdraft + Balance).ToString();
         txtCurrentBalance.Text   = Balance.ToString();
     }
     catch
     {
         MessageBox.Show("Please try again");
     }
 }