public IList <Transactions> GetTransactionsByAccountCode(int?id) { List <Transactions> transactionList = new List <Transactions>(); using (SqlConnection con = new SqlConnection(CS)) { SqlCommand cmd = new SqlCommand("pr_GetTransactionsByAccountCode", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@account_code", id); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { var transactionModel = new Transactions() { code = DataTypesConvertor.ConvertToInt(rdr["code"]), account_code = DataTypesConvertor.ConvertToInt(rdr["account_code"]), transaction_date = DataTypesConvertor.ConvertToDateTime(rdr["transaction_date"]), capture_date = DataTypesConvertor.ConvertToDateTime(rdr["capture_date"]), amount = DataTypesConvertor.ConvertToDecimal(rdr["amount"]), description = rdr["description"].ToString() }; transactionList.Add(transactionModel); } return(transactionList); } }
public IList <Accounts> GetAccountsByPersonCode(int?id) { List <Accounts> accountList = new List <Accounts>(); using (SqlConnection con = new SqlConnection(CS)) { SqlCommand cmd = new SqlCommand("pr_GetAccountsByPersonCode", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@person_code", id); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { var accountModel = new Accounts() { code = DataTypesConvertor.ConvertToInt(rdr["code"]), person_code = DataTypesConvertor.ConvertToInt(rdr["person_code"]), account_number = rdr["account_number"].ToString(), outstanding_balance = DataTypesConvertor.ConvertToDecimal(rdr["outstanding_balance"]) }; accountList.Add(accountModel); } return(accountList); } }
public IList <Persons> SearchPersons(string term) { List <Persons> personsList = new List <Persons>(); using (SqlConnection con = new SqlConnection(CS)) { SqlCommand cmd = new SqlCommand("pr_SearchPerson", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@term", term); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { var personModel = new Persons() { code = DataTypesConvertor.ConvertToInt(rdr["code"]), name = rdr["name"].ToString(), surname = rdr["surname"].ToString(), id_number = rdr["id_number"].ToString() }; personsList.Add(personModel); } return(personsList); } }
public Accounts GetAccountByCode(int?id) { Accounts accountModel = new Accounts(); using (SqlConnection con = new SqlConnection(CS)) { SqlCommand cmd = new SqlCommand("pr_GetAccountByCode", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@code", id); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { accountModel.code = DataTypesConvertor.ConvertToInt(rdr["code"]); accountModel.person_code = DataTypesConvertor.ConvertToInt(rdr["person_code"]); accountModel.account_number = rdr["account_number"].ToString(); accountModel.outstanding_balance = DataTypesConvertor.ConvertToDecimal(rdr["outstanding_balance"]); } return(accountModel); } }
public Persons GetPersonsById(int?id) { Persons personModel = new Persons(); using (SqlConnection con = new SqlConnection(CS)) { SqlCommand cmd = new SqlCommand("pr_GetPersonByCode", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@code", id); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { personModel.code = DataTypesConvertor.ConvertToInt(rdr["code"]); personModel.name = rdr["name"].ToString(); personModel.surname = rdr["surname"].ToString(); personModel.id_number = rdr["id_number"].ToString(); } return(personModel); } }
public Transactions GetTransactionByCode(int?id) { Transactions accountModel = new Transactions(); using (SqlConnection con = new SqlConnection(CS)) { SqlCommand cmd = new SqlCommand("pr_GetTransactionByCode", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@code", id); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { accountModel.code = DataTypesConvertor.ConvertToInt(rdr["code"]); accountModel.account_code = DataTypesConvertor.ConvertToInt(rdr["person_code"]); accountModel.transaction_date = DataTypesConvertor.ConvertToDateTime(rdr["transaction_date"]); accountModel.capture_date = DataTypesConvertor.ConvertToDateTime(rdr["capture_date"]); accountModel.amount = DataTypesConvertor.ConvertToDecimal(rdr["amount"]); accountModel.description = rdr["description"].ToString(); } return(accountModel); } }