/// <summary> /// GetCurrentForProduct /// Calls [usp_select_DutyRate_Current_for_Product] /// </summary> public override DutyRateDetails GetCurrentForProduct(System.Int32?productNo, System.DateTime?datePoint) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_select_DutyRate_Current_for_Product", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cmd.Parameters.Add("@ProductNo", SqlDbType.Int).Value = productNo; cmd.Parameters.Add("@DatePoint", SqlDbType.DateTime).Value = datePoint; cn.Open(); DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow); if (reader.Read()) { //return GetDutyRateFromReader(reader); DutyRateDetails obj = new DutyRateDetails(); obj.DutyRateValue = GetReaderValue_NullableDouble(reader, "DutyRateValue", null); return(obj); } else { return(null); } } catch (SqlException sqlex) { //LogException(sqlex); throw new Exception("Failed to get DutyRate", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }
private static DutyRate PopulateFromDBDetailsObject(DutyRateDetails obj) { DutyRate objNew = new DutyRate(); objNew.DutyRateId = obj.DutyRateId; objNew.DutyDate = obj.DutyDate; objNew.DutyRateValue = obj.DutyRateValue; objNew.ProductNo = obj.ProductNo; objNew.UpdatedBy = obj.UpdatedBy; objNew.DLUP = obj.DLUP; return(objNew); }
/// <summary> /// GetListForGlobalProduct /// Calls [usp_selectAll_DutyRate_for_GlobalProduct] /// </summary> public override List <DutyRateDetails> GetListForGlobalProduct(System.Int32?productId) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_selectAll_DutyRate_for_GlobalProduct", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cmd.Parameters.Add("@GlobalProductId", SqlDbType.Int).Value = productId; cn.Open(); DbDataReader reader = ExecuteReader(cmd); List <DutyRateDetails> lst = new List <DutyRateDetails>(); while (reader.Read()) { DutyRateDetails obj = new DutyRateDetails(); obj.DutyRateId = GetReaderValue_Int32(reader, "GlobalDutyRateId", 0); obj.DutyDate = GetReaderValue_NullableDateTime(reader, "DutyDate", null); obj.DutyRateValue = GetReaderValue_NullableDouble(reader, "DutyRateValue", null); obj.ProductNo = GetReaderValue_Int32(reader, "ProductNo", 0); obj.UpdatedBy = GetReaderValue_NullableInt32(reader, "UpdatedBy", null); obj.DLUP = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue); lst.Add(obj); obj = null; } return(lst); } catch (SqlException sqlex) { //LogException(sqlex); throw new Exception("Failed to get DutyRates", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }
/// <summary> /// Get /// Calls [usp_select_DutyRate] /// </summary> public override DutyRateDetails Get(System.Int32?dutyRateId) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_select_DutyRate", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cmd.Parameters.Add("@DutyRateId", SqlDbType.Int).Value = dutyRateId; cn.Open(); DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow); if (reader.Read()) { //return GetDutyRateFromReader(reader); DutyRateDetails obj = new DutyRateDetails(); obj.DutyRateId = GetReaderValue_Int32(reader, "DutyRateId", 0); obj.DutyDate = GetReaderValue_NullableDateTime(reader, "DutyDate", null); obj.DutyRateValue = GetReaderValue_NullableDouble(reader, "DutyRateValue", null); obj.ProductNo = GetReaderValue_Int32(reader, "ProductNo", 0); obj.UpdatedBy = GetReaderValue_NullableInt32(reader, "UpdatedBy", null); obj.DLUP = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue); return(obj); } else { return(null); } } catch (SqlException sqlex) { //LogException(sqlex); throw new Exception("Failed to get DutyRate", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }