private static ContactUserDefined PopulateFromDBDetailsObject(ContactUserDefinedDetails obj) { ContactUserDefined objNew = new ContactUserDefined(); objNew.ContactNo = obj.ContactNo; objNew.RowNo = obj.RowNo; objNew.UserDefinedHeading = obj.UserDefinedHeading; objNew.UserDefinedValue = obj.UserDefinedValue; objNew.Inactive = obj.Inactive; objNew.UpdatedBy = obj.UpdatedBy; objNew.DLUP = obj.DLUP; return(objNew); }
/// <summary> /// Get /// Calls [usp_select_ContactUserDefined] /// </summary> public override ContactUserDefinedDetails Get(System.Int32?contactNo, System.Int32?rowNo) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_select_ContactUserDefined", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cmd.Parameters.Add("@ContactNo", SqlDbType.Int).Value = contactNo; cmd.Parameters.Add("@RowNo", SqlDbType.Int).Value = rowNo; cn.Open(); DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow); if (reader.Read()) { //return GetContactUserDefinedFromReader(reader); ContactUserDefinedDetails obj = new ContactUserDefinedDetails(); obj.ContactNo = GetReaderValue_Int32(reader, "ContactNo", 0); obj.RowNo = GetReaderValue_Int32(reader, "RowNo", 0); obj.UserDefinedHeading = GetReaderValue_String(reader, "UserDefinedHeading", ""); obj.UserDefinedValue = GetReaderValue_String(reader, "UserDefinedValue", ""); obj.Inactive = GetReaderValue_Boolean(reader, "Inactive", false); 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 ContactUserDefined", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }
/// <summary> /// GetListForContact /// Calls [usp_selectAll_ContactUserDefined_for_Contact] /// </summary> public override List <ContactUserDefinedDetails> GetListForContact(System.Int32?contactNo) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_selectAll_ContactUserDefined_for_Contact", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cmd.Parameters.Add("@ContactNo", SqlDbType.Int).Value = contactNo; cn.Open(); DbDataReader reader = ExecuteReader(cmd); List <ContactUserDefinedDetails> lst = new List <ContactUserDefinedDetails>(); while (reader.Read()) { ContactUserDefinedDetails obj = new ContactUserDefinedDetails(); obj.ContactNo = GetReaderValue_Int32(reader, "ContactNo", 0); obj.RowNo = GetReaderValue_Int32(reader, "RowNo", 0); obj.UserDefinedHeading = GetReaderValue_String(reader, "UserDefinedHeading", ""); obj.UserDefinedValue = GetReaderValue_String(reader, "UserDefinedValue", ""); obj.Inactive = GetReaderValue_Boolean(reader, "Inactive", false); 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 ContactUserDefineds", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }