private void button7_Click(object sender, System.EventArgs e)
 {
     Category category = new Category()
     {
         CategoryName = newCategoryName.Text
     };
     _baseWorker.AddNewCategory(category);
     RefreshCategories();
 }
 private void button6_Click(object sender, System.EventArgs e)
 {
     Category oldCategory = categoryesListBox.SelectedItem as Category;
     if (oldCategory != null)
     {
         Category newCategory = new Category()
         {
             CategoryName = categoryNameTextBox.Text
         };
         _baseWorker.ChangeCategory(oldCategory, newCategory);
         RefreshCategories();
     }
 }
        public void DeleteCategory(Category category)
        {
            using (SqlCommand sqlCommand = new SqlCommand(RemoveCategory, _sqlConnection))
            {
                sqlCommand.Parameters.AddWithValue("@categoryId", category.Id);

                if (sqlCommand.ExecuteNonQuery() > 0)
                {
                    MessageBox.Show("Категория удалена");
                }
                else
                {
                    MessageBox.Show("Ошибка при удалении");
                }
            }
        }
        public void ChangeCategory(Category oldCategory, Category newCategory)
        {
            using (SqlCommand sqlCommand = new SqlCommand(UpdateCategory, _sqlConnection))
            {
                sqlCommand.Parameters.AddWithValue("@categoryName", newCategory.CategoryName);
                sqlCommand.Parameters.AddWithValue("@categoryId", oldCategory.Id);

                if (sqlCommand.ExecuteNonQuery() > 0)
                {
                    MessageBox.Show("Категория изменена");
                }
                else
                {
                    MessageBox.Show("Ошибка при изменении");
                }
            }
        }
 public List<Attack> Attacks(Category category)
 {
     List<Attack> attacks = new List<Attack>();
     using (SqlCommand sqlCommand = new SqlCommand(SelectattacksCategory, _sqlConnection))
     {
         sqlCommand.Parameters.AddWithValue("@id", category.Id);
         using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
         {
             if (sqlDataReader.HasRows)
             {
                 while (sqlDataReader.Read())
                 {
                     attacks.Add(new Attack()
                     {
                         Id = int.Parse(sqlDataReader["Id"].ToString()),
                         AttackName = sqlDataReader["Attack_Name"].ToString(),
                         AttackClass = int.Parse(sqlDataReader["Attack_Class"].ToString())
                     });
                 }
                 return attacks;
             }
             return attacks;
         }
     }
 }
        public void AddNewCategory(Category category)
        {
            using (SqlCommand sqlCommand = new SqlCommand(AddCategoty, _sqlConnection))
            {
                sqlCommand.Parameters.AddWithValue("@categoryName", category.CategoryName);

                if (sqlCommand.ExecuteNonQuery() > 0)
                {
                    //  MessageBox.Show("Добвленно");
                }
                else
                {
                    MessageBox.Show("Ошибка при добавлении");
                }
            }
        }