public List <Account> GetAccounts(int customerNumber) { List <Account> accounts = new List <Account>(); ATM.AccountDataTable accountTable = AccountAdapter.GetAccountsByCustomerNumber(customerNumber); foreach (ATM.AccountRow row in accountTable) { accounts.AddRange(createAccount(row)); } return(accounts); }
protected Customer createCustomer(ATM.CustomerRow customerRow) { Customer customer = new Customer(customerRow.CustomerNumber, customerRow.FirstName, customerRow.LastName); customer.Status = ObjectStatus.Clean; ATM.AccountDataTable accountTable = AccountAdapter.GetAccountsByCustomerNumber(customer.CustomerNumber); foreach (ATM.AccountRow row in accountTable) { customer.Accounts.AddRange(createAccount(row)); } return(customer); }
public void SaveAccount(Account account) { if (account != null) { ATM.AccountDataTable accountDataTable = AccountAdapter.GetAccountByAccountNumber(account.AccountNumber); ATM.AccountRow accountRow = (ATM.AccountRow)accountDataTable.Rows[0]; if (account is SavingsAccount) { accountRow.SavingsBalance = account.Balance; } else if (account is CheckingAccount) { accountRow.Checking_Balance = account.Balance; } AccountAdapter.Update(accountDataTable); } }
public virtual ATM.AccountDataTable GetAccountByAccountNumber(int AccountNumber) { this.Adapter.SelectCommand = this.CommandCollection[1]; this.Adapter.SelectCommand.Parameters[0].Value = ((int)(AccountNumber)); ATM.AccountDataTable dataTable = new ATM.AccountDataTable(); this.Adapter.Fill(dataTable); return dataTable; }
public virtual ATM.AccountDataTable GetAccountsByCustomerNumber(System.Nullable<int> CustomerNumber) { this.Adapter.SelectCommand = this.CommandCollection[0]; if ((CustomerNumber.HasValue == true)) { this.Adapter.SelectCommand.Parameters[0].Value = ((int)(CustomerNumber.Value)); } else { this.Adapter.SelectCommand.Parameters[0].Value = System.DBNull.Value; } ATM.AccountDataTable dataTable = new ATM.AccountDataTable(); this.Adapter.Fill(dataTable); return dataTable; }