/// <summary> /// GetList /// Calls [usp_selectAll_SaleType] /// </summary> public override List <SaleTypeDetails> GetList() { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_selectAll_SaleType", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cn.Open(); DbDataReader reader = ExecuteReader(cmd); List <SaleTypeDetails> lst = new List <SaleTypeDetails>(); while (reader.Read()) { SaleTypeDetails obj = new SaleTypeDetails(); obj.SaleTypeId = GetReaderValue_Int32(reader, "SaleTypeId", 0); obj.Name = GetReaderValue_String(reader, "Name", ""); lst.Add(obj); obj = null; } return(lst); } catch (SqlException sqlex) { //LogException(sqlex); throw new Exception("Failed to get SaleTypes", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }
/// <summary> /// Get /// Calls [usp_select_SaleType] /// </summary> public override SaleTypeDetails Get(System.Int32?saleTypeId) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_select_SaleType", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cmd.Parameters.Add("@SaleTypeId", SqlDbType.Int).Value = saleTypeId; cn.Open(); DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow); if (reader.Read()) { //return GetSaleTypeFromReader(reader); SaleTypeDetails obj = new SaleTypeDetails(); obj.SaleTypeId = GetReaderValue_Int32(reader, "SaleTypeId", 0); obj.Name = GetReaderValue_String(reader, "Name", ""); return(obj); } else { return(null); } } catch (SqlException sqlex) { //LogException(sqlex); throw new Exception("Failed to get SaleType", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }
private static SaleType PopulateFromDBDetailsObject(SaleTypeDetails obj) { SaleType objNew = new SaleType(); objNew.SaleTypeId = obj.SaleTypeId; objNew.Name = obj.Name; return(objNew); }