public static void Update(Account acc) { SqlParamsColl paramList = new SqlParamsColl(); paramList.Add("@AccountNumber", SqlDbType.Int, acc.AccountNumber); paramList.Add("AvailableBalance", SqlDbType.Money, acc.AvailableBalance); SqlTools.ExecuteReader("Account_Update", paramList, reader => { while (reader.Read()) { PopulateObjectFromReader(reader, acc); } }); }
public static void PopulateObjectFromReader(SqlDataReader reader, Account acc) { acc.AccountNumber = (int)reader["AccountNumber"]; acc.Type = (char)reader.GetString(reader.GetOrdinal("AccountType"))[0]; acc.AvailableBalance = (decimal)reader["AvailableBalance"]; acc.CustomerId = (int)reader["CustomerId"]; try { acc.LastUpdatedDate = Convert.ToDateTime(reader["LastUpdatedDate"]); } catch (Exception) { acc.LastUpdatedDate = null; } }
public static AccountList GetAccountsByCustomer(int Id) { AccountList list = new AccountList(); SqlParamsColl paramList = new SqlParamsColl(); paramList.Add("@CustomerId", SqlDbType.Int, Id); SqlTools.ExecuteReader("dbo.Accounts_RetrieveByCustomer", paramList, reader => { while (reader.Read()) { Account acc = new Account(); PopulateObjectFromReader(reader, acc); list.Add(acc); } }); return list; }
public static void Withdraw(Account Acc, decimal Amount, string Comment) { DBTransaction.Insert_WithdrawTransaction(Acc.AccountNumber, Amount, Comment); //DBAccount.Update(Acc); }
public static void Transfer(Account SourceAccount, int DestinationAccount, decimal Amount, string Comment) { DBTransaction.Insert_TransferTransaction(SourceAccount.AccountNumber, DestinationAccount, Amount, Comment); //DBAccount.Update(SourceAccount); }
public static void Deposit(Account Acc, decimal Amount, string Comment) { DBTransaction.Insert_DepositTransaction(Acc.AccountNumber, Amount, Comment); //DBAccount.Update(Acc); }