コード例 #1
0
        public void SaveTranaction(decimal amount, Account account)
        {
            AccountType accountType = AccountType.None;
            TransactionType transactionType = TransactionType.None;

            if (account is CheckingAccount)
            {
                accountType = AccountType.Checking;
            }
            else if (account is SavingsAccount)
            {
                accountType = AccountType.Savings;
            }

            if (amount > 0)
            {
                transactionType = TransactionType.Credit;
            }
            else if (amount < 0)
            {
                transactionType = TransactionType.Debit;
                amount *= -1;
            }

            if ((amount != 0) && (account != null))
            {
                TranactionAdapter.Insert(
                            account.AccountNumber,
                            (short)accountType,
                            DateTime.Now,
                            amount,
                            (short)transactionType);
            }
        }
コード例 #2
0
        private void withdraw_button_Click(object sender, EventArgs e)
        {
            decimal amount = 0;
            try
            {
                amount = decimal.Parse(this.amount_withdraw_box.Text);
            }
            catch (Exception err)
            { this.errorProvider1.SetError(this.amount_withdraw_box, "Invalid amount set"); return; }
            String type = this.account_type_dropdown.Text;
            Account a = new Account();
            if (type.Equals("Checking"))
                a = this.owner.CAccount;
            else if (type.Equals("Savings"))
                a = this.owner.SAccount;
            a.Balance -= amount;
            this.errorProvider1.Clear();
            this.owner.UpdateAccounts();

            MessageBox.Show("Withdrawal completed successfully!");
        }
コード例 #3
0
ファイル: Account.cs プロジェクト: rckclmbr/Joshs-School
 public Account(Account copy)
     : base(copy)
 {
     this.accountNumber = copy.AccountNumber;
     this.balance = copy.Balance;
 }