private void GetDataForQuote() { var dt = new ObjectParameter("TranDT", typeof(DateTime)); var res = new ObjectParameter("Result", typeof(int)); lvwLightingData.Items.Clear(); try { var query = _context.usp_QT_LightingStudy_QuoteNumbers_GetQuoteData(QuoteNumber, dt, res).ToList(); if (!query.Any()) { return; } foreach (usp_QT_LightingStudy_QuoteNumbers_GetQuoteData_Result item in query) { // Add to listview var lvi = new ListViewItem(QuoteNumber); lvi.SubItems.Add(item.Application); lvi.SubItems.Add(item.Program); lvi.SubItems.Add(item.LEDHarness); lvi.SubItems.Add(item.Sop.ToString()); lvi.SubItems.Add(item.LightingStudyId.ToString()); lvi.SubItems.Add(item.RowID.ToString()); lvwLightingData.Items.Add(lvi); } } catch (Exception ex) { string error = (ex.InnerException != null) ? ex.InnerException.Message : ex.Message; MessageBox.Show(string.Format("Failure when attempting to find lighting data for this quote. Try refreshing. {0}", error), "Error at GetDataForQuote()"); } }