/// <summary> /// DropDown /// Calls [usp_dropdown_Reason] /// </summary> public override List <ReasonDetails> DropDown() { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_dropdown_Reason", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cn.Open(); DbDataReader reader = ExecuteReader(cmd); List <ReasonDetails> lst = new List <ReasonDetails>(); while (reader.Read()) { ReasonDetails obj = new ReasonDetails(); obj.ReasonId = GetReaderValue_Int32(reader, "ReasonId", 0); obj.Name = GetReaderValue_String(reader, "Name", ""); obj.Sold = GetReaderValue_Boolean(reader, "Sold", false); obj.NotQuoted = GetReaderValue_Boolean(reader, "NotQuoted", false); lst.Add(obj); obj = null; } return(lst); } catch (SqlException sqlex) { //LogException(sqlex); throw new Exception("Failed to get Reasons", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }
private static Reason PopulateFromDBDetailsObject(ReasonDetails obj) { Reason objNew = new Reason(); objNew.ReasonId = obj.ReasonId; objNew.Name = obj.Name; objNew.Locked = obj.Locked; objNew.Sold = obj.Sold; objNew.NotQuoted = obj.NotQuoted; return(objNew); }
/// <summary> /// DropDown /// Calls [usp_dropdown_StatusReason] /// </summary> public override List <ReasonDetails> DropDown(System.String strSection) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_dropdown_StatusReason", cn); cmd.Parameters.Add("@Section", SqlDbType.NVarChar).Value = strSection; cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cn.Open(); DbDataReader reader = ExecuteReader(cmd); List <ReasonDetails> lst = new List <ReasonDetails>(); while (reader.Read()) { ReasonDetails obj = new ReasonDetails(); obj.ReasonId = GetReaderValue_Int32(reader, "StatusReasonId", 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 Reasons", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }
/// <summary> /// Get /// Calls [usp_select_Reason] /// </summary> public override ReasonDetails Get(System.Int32?reasonId) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_select_Reason", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cmd.Parameters.Add("@ReasonId", SqlDbType.Int).Value = reasonId; cn.Open(); DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow); if (reader.Read()) { //return GetReasonFromReader(reader); ReasonDetails obj = new ReasonDetails(); obj.ReasonId = GetReaderValue_Int32(reader, "ReasonId", 0); obj.Name = GetReaderValue_String(reader, "Name", ""); obj.Locked = GetReaderValue_Boolean(reader, "Locked", false); obj.Sold = GetReaderValue_Boolean(reader, "Sold", false); obj.NotQuoted = GetReaderValue_Boolean(reader, "NotQuoted", false); return(obj); } else { return(null); } } catch (SqlException sqlex) { //LogException(sqlex); throw new Exception("Failed to get Reason", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }