///// <summary> ///// Get ///// Calls [usp_select_PurchaseRequest] ///// </summary> public override POQuoteDetails Get(System.Int32?poQuoteId) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_select_PurchaseRequest", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cmd.Parameters.Add("@PurchaseRequestId", SqlDbType.Int).Value = poQuoteId; cn.Open(); DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow); if (reader.Read()) { //return GetQuoteFromReader(reader); POQuoteDetails obj = new POQuoteDetails(); obj.POQuoteId = GetReaderValue_Int32(reader, "PurchaseRequestId", 0); obj.ClientNo = GetReaderValue_Int32(reader, "ClientNo", 0); obj.POQuoteNumber = GetReaderValue_Int32(reader, "PurchaseRequestNumber", 0); obj.Notes = GetReaderValue_String(reader, "Notes", ""); // obj.CurrencyNo = GetReaderValue_Int32(reader, "CurrencyNo", 0); obj.Closed = GetReaderValue_NullableBoolean(reader, "Closed", null); obj.UpdatedBy = GetReaderValue_NullableInt32(reader, "UpdatedBy", null); obj.DLUP = GetReaderValue_DateTime(reader, "DLUP", DateTime.MinValue); obj.ContactName = GetReaderValue_String(reader, "ContactName", ""); //obj.CurrencyCode = GetReaderValue_String(reader, "CurrencyCode", ""); //obj.CurrencyDescription = GetReaderValue_String(reader, "CurrencyDescription", ""); obj.CompanyName = GetReaderValue_String(reader, "CompanyName", ""); obj.SalesPersonNo = GetReaderValue_Int32(reader, "Buyer", 0); obj.SalesPersonName = GetReaderValue_String(reader, "EmployeeName", ""); obj.DivisionNo = GetReaderValue_Int32(reader, "DivisionNo", 0); obj.DivisionName = GetReaderValue_String(reader, "DivisionName", ""); obj.PQStatus = GetReaderValue_Int32(reader, "PQStatus", 0); return(obj); } else { return(null); } } catch (SqlException sqlex) { //LogException(sqlex); throw new Exception("Failed to get Price Request", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }
/// <summary> /// GetForPage /// Calls [usp_select_PurchaseRequest_for_Page] /// </summary> public override POQuoteDetails GetForPage(System.Int32?poQuoteId) { SqlConnection cn = null; SqlCommand cmd = null; try { cn = new SqlConnection(this.ConnectionString); cmd = new SqlCommand("usp_select_PurchaseRequest_for_Page", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.CommandTimeout = 30; cmd.Parameters.Add("@PurchaseRequestId", SqlDbType.Int).Value = poQuoteId; cn.Open(); DbDataReader reader = ExecuteReader(cmd, CommandBehavior.SingleRow); if (reader.Read()) { POQuoteDetails obj = new POQuoteDetails(); obj.POQuoteId = GetReaderValue_Int32(reader, "PurchaseRequestId", 0); obj.ClientNo = GetReaderValue_Int32(reader, "ClientNo", 0); obj.POQuoteNumber = GetReaderValue_Int32(reader, "PurchaseRequestNumber", 0); obj.Closed = GetReaderValue_NullableBoolean(reader, "Closed", null); obj.PRStatus = GetReaderValue_String(reader, "PRStatus", ""); return(obj); } else { return(null); } } catch (SqlException sqlex) { throw new Exception("Failed to get Price Request", sqlex); } finally { cmd.Dispose(); cn.Close(); cn.Dispose(); } }