diff --git a/ProjectCleaningCar/ProjectCleaningCar/FormTruckCollection.cs b/ProjectCleaningCar/ProjectCleaningCar/FormTruckCollection.cs index aa26597..0e6b955 100644 --- a/ProjectCleaningCar/ProjectCleaningCar/FormTruckCollection.cs +++ b/ProjectCleaningCar/ProjectCleaningCar/FormTruckCollection.cs @@ -219,7 +219,23 @@ public partial class FormTruckCollection : Form /// private void buttonCollectionDel_Click(object sender, EventArgs e) { + if (listBoxCollection.SelectedIndex < 0 || listBoxCollection.SelectedItem == null) + { + MessageBox.Show("Коллекция не выбрана", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + string selectedCollection = listBoxCollection.SelectedItem.ToString(); + + if (MessageBox.Show($"Удалить коллекцию {selectedCollection}?", "Удаление коллекции", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) + { + return; + } + + _storageCollection.DelCollection(selectedCollection); + RerfreshListBoxItems(); } /// /// Обновление списка в listBoxCollection