private int ValidateData(out string id) { id = ""; var dt = new ObjectParameter("TranDT", typeof(DateTime)); var res = new ObjectParameter("Result", typeof(int)); var dtSop = Convert.ToDateTime(Sop); try { var query = _context.usp_QT_LightingStudy_QuoteNumbers_Validate(QuoteNumber, Application, Program, LedHarness, dtSop, dt, res).ToList(); foreach (usp_QT_LightingStudy_QuoteNumbers_Validate_Result item in query) { id = item.ID.ToString(); } } catch (Exception ex) { string error = (ex.InnerException != null) ? ex.InnerException.Message : ex.Message; MessageBox.Show(error, "Error at ValidateData()"); return(0); } return(1); }