public SalesTaxRateCollection GetAllSalesTaxRatesCollection() { IDBManager dbm = new DBManager(); SalesTaxRateCollection cols = new SalesTaxRateCollection(); try { IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectSalesTaxRateAll"); while (reader.Read()) { SalesTaxRate STR = new SalesTaxRate(); STR.SalesTaxRateID = Int32.Parse(reader["SalesTaxRateID"].ToString()); STR.StateProvinceID = reader["StateProvinceID"].ToString(); STR.TaxType = Byte.Parse(reader["TaxType"].ToString()); STR.TaxRate = Decimal.Parse(reader["TaxRate"].ToString()); STR.Name = reader["Name"].ToString(); STR.ModifiedDate = DateTime.Parse(reader["ModifiedDate"].ToString()); cols.Add(STR); } } catch (Exception ex) { log.Write(ex.Message, "GetAllSalesTaxRatesCollection"); throw (ex); } finally { dbm.Dispose(); } return(cols); }
public SalesTaxRateCollection GetAllSalesTaxRatesDynamicCollection(string whereExpression, string orderBy) { IDBManager dbm = new DBManager(); SalesTaxRateCollection cols = new SalesTaxRateCollection(); try { dbm.CreateParameters(2); dbm.AddParameters(0, "@WhereCondition", whereExpression); dbm.AddParameters(1, "@OrderByExpression", orderBy); IDataReader reader = dbm.ExecuteReader(CommandType.StoredProcedure, "SelectSalesTaxRatesDynamic"); while (reader.Read()) { SalesTaxRate STR = new SalesTaxRate(); STR.SalesTaxRateID = Int32.Parse(reader["SalesTaxRateID"].ToString()); STR.StateProvinceID = reader["StateProvinceID"].ToString(); STR.TaxType = Byte.Parse(reader["TaxType"].ToString()); STR.TaxRate = Decimal.Parse(reader["TaxRate"].ToString()); STR.Name = reader["Name"].ToString(); STR.ModifiedDate = DateTime.Parse(reader["ModifiedDate"].ToString()); cols.Add(STR); } } catch (Exception ex) { log.Write(ex.Message, "GetAllSalesTaxRatesDynamicCollection"); throw (ex); } finally { dbm.Dispose(); } return(cols); }
/// <summary> /// Read function for table salesTax /// </summary> public static SalesTaxRateCollection GetTaxRates() { using (SqlConnection connection = new SqlConnection(connectionString)) { string query = @"SELECT taxId, taxCode, taxRate FROM salesTaxRates"; SalesTaxRateCollection salesTaxes = new SalesTaxRateCollection(); int taxId; string taxCode; decimal taxRate; using (SqlCommand command = new SqlCommand()) { command.CommandType = CommandType.Text; command.CommandText = query; command.Connection = connection; connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { taxId = (int)reader["taxId"]; taxCode = reader["taxCode"] as string; taxRate = (decimal)reader["taxRate"]; salesTaxes.Add(new SalesTaxRate { TaxId = taxId, TaxCode = taxCode, TaxRate = taxRate }); } } } return(salesTaxes); } }