From c2a8a8318e67b0767a2d45b1ed6b283281f64ab9 Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:36:33 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Monorail/Monorail/FormMonorailCollection.cs | 28 +++++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Monorail/Monorail/FormMonorailCollection.cs b/Monorail/Monorail/FormMonorailCollection.cs index 49edb49..1861389 100644 --- a/Monorail/Monorail/FormMonorailCollection.cs +++ b/Monorail/Monorail/FormMonorailCollection.cs @@ -24,7 +24,7 @@ namespace Monorail private readonly ILogger _logger; - readonly int countPlace = 21; + readonly int countPlace = 35; public FormMonorailCollection(ILogger logger) { InitializeComponent(); @@ -153,20 +153,26 @@ EventArgs e) { return; } - int pos = Convert.ToInt32(maskedTextBoxNumber.Text); + int pos = 0; try { - if (obj - pos != null) - { - MessageBox.Show("Объект удален"); - pictureBoxCollection.Image = obj.ShowMonorails(); - _logger.LogInformation("Объект удален"); - } + pos = Convert.ToInt32(maskedTextBoxNumber.Text); } - catch (MonorailNotFoundException ex) + catch (Exception) { + MessageBox.Show("Введите позицию монорельса", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (obj - pos != null) { - MessageBox.Show(ex.Message); - _logger.LogWarning($"Не удалось удалить объект. Исключение: {ex}"); + MessageBox.Show("Объект удален"); + pictureBoxCollection.Image = obj.ShowMonorails(); + _logger.LogInformation("Объект удален"); + } + else + { + _logger.LogWarning($"Не удалось удалить объект по позиции {pos}"); + throw new MonorailNotFoundException(pos); } } private void ButtonRefreshCollection_Click(object sender, EventArgs e)