From cc6a673f86dc5bdb0ec85c55ee12af62d215fba4 Mon Sep 17 00:00:00 2001 From: DanilaSm08 Date: Sun, 7 Apr 2024 13:54:56 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D1=82=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=BE=D0=B9=20=E2=84=964?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectCleaningCar/FormTruckCollection.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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