예제 #1
0
        /* Выполняем запрос к БД и заносим полученные данные в List<SemCoreModel> */
        private bool Execute_SELECT_Command(SqlCommand _command)
        {
            kcList = new List <KeywordCategoryModel> {
            };
            try
            {
                connection.Open();

                SqlDataReader reader = _command.ExecuteReader();

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        SetDataToList((IDataRecord)reader);
                    }
                }
                else
                {
                    Console.WriteLine("No rows found.");
                }
                reader.Close();
                connection.Close();

                if (controlFormKeywordCategoryView != null)                       //вызывает нужный метод в зависимости, из какой формы нас вызывают
                {
                    controlFormKeywordCategoryView.GetCategoriesFromDB(kcList);
                }
                else if (controlFormSemCoreView != null)
                {
                    controlFormSemCoreView.GetCategoriesFromDB(kcList);
                }
                else if (controlFormFullSemCoreView != null)
                {
                    controlFormFullSemCoreView.GetCategoriesFromDB(kcList);
                }
                else if (controlFormSemCoreRebuildView != null)
                {
                    controlFormSemCoreRebuildView.GetCategoriesFromDB(kcList);
                }
                else if (controlSemanticsView != null)
                {
                    controlSemanticsView.GetCategoriesFromDB(kcList);
                }
                else if (controlSemCoreArchiveView != null)
                {
                    controlSemCoreArchiveView.GetCategoriesFromDB(kcList);
                }
                return(true);
            }
            catch (Exception ex)
            {
                connection.Close();
                return(false);
            }
        }