//-------------------------------МЕТОДЫ---------------------------------------- /* Выполняем запрос к БД и заносим полученные данные в List<SemCoreModel> */ private bool Execute_SELECT_Command(SqlCommand _command) { ptList = new List <ProductTypesModel> { }; try { connection.Open(); SqlDataReader reader = _command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { SetData((IDataRecord)reader); } } else { Console.WriteLine("No rows found."); } reader.Close(); connection.Close(); if (controlFormProductTypesView != null) //вызывает нужный метод в зависимости, из какой формы нас вызывают { controlFormProductTypesView.GetProductTypesFromDB(ptList); } else if (controlFormSemCoreView != null) { controlFormSemCoreView.GetProductTypesFromDB(ptList); } else if (controlFormProductsView != null) { controlFormProductsView.GetProductTypesFromDB(ptList); } else if (controlFormFullSemCoreView != null) { controlFormFullSemCoreView.GetProductTypesFromDB(ptList); } else if (controlFormSemCoreRebuildView != null) { controlFormSemCoreRebuildView.GetProductTypesFromDB(ptList); } else if (controlKeywordCategoryView != null) { controlKeywordCategoryView.GettFullProductTypesFromDB(ptList); } else if (controlSemCoreArchiveView != null) { controlSemCoreArchiveView.GetProductTypesFromDB(ptList); } return(true); } catch (Exception ex) { connection.Close(); return(false); } }