From 3db34978e2e6f8d4893e7c729075ceac18864025 Mon Sep 17 00:00:00 2001 From: "leonteva.v" Date: Wed, 27 Mar 2024 05:18:40 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B2=D0=BE=D1=82=20=D1=82=D0=B5=D0=BF=D0=B5?= =?UTF-8?q?=D1=80=D1=8C=20=D1=82=D0=BE=D1=87=D0=BD=D0=BE=20=D0=B2=D1=81?= =?UTF-8?q?=D1=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Typography/FormComponent.Designer.cs | 1 + Typography/Typography/FormComponent.cs | 43 +++++++++---------- .../Typography/FormComponents.Designer.cs | 1 + Typography/Typography/FormComponents.cs | 8 ++-- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Typography/Typography/FormComponent.Designer.cs b/Typography/Typography/FormComponent.Designer.cs index 3ed07c9..a04cc5b 100644 --- a/Typography/Typography/FormComponent.Designer.cs +++ b/Typography/Typography/FormComponent.Designer.cs @@ -101,6 +101,7 @@ Controls.Add(textBoxName); Name = "FormComponent"; Text = "Компонент"; + Load += FormComponent_Load; ResumeLayout(false); PerformLayout(); } diff --git a/Typography/Typography/FormComponent.cs b/Typography/Typography/FormComponent.cs index dc6b30c..326ec09 100644 --- a/Typography/Typography/FormComponent.cs +++ b/Typography/Typography/FormComponent.cs @@ -17,27 +17,6 @@ namespace TypographyView _logger = logger; _logic = logic; } - private void FormComponent_Load(object sender, EventArgs e) - { - if (_id.HasValue) - { - try - { - _logger.LogInformation("Получение компонента"); - var view = _logic.ReadElement(new ComponentSearchModel { Id = _id.Value }); - if (view != null) - { - textBoxName.Text = view.ComponentName; - textBoxCost.Text = view.Cost.ToString(); - } - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка получения компонента"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } private void buttonSave_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBoxName.Text)) @@ -69,11 +48,31 @@ namespace TypographyView MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private void buttonCancel_Click(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; Close(); } + private void FormComponent_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation("Получение компонента"); + var view = _logic.ReadElement(new ComponentSearchModel { Id = _id.Value }); + if (view != null) + { + textBoxName.Text = view.ComponentName; + textBoxCost.Text = view.Cost.ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения компонента"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } } } diff --git a/Typography/Typography/FormComponents.Designer.cs b/Typography/Typography/FormComponents.Designer.cs index b090a4d..225fabb 100644 --- a/Typography/Typography/FormComponents.Designer.cs +++ b/Typography/Typography/FormComponents.Designer.cs @@ -101,6 +101,7 @@ Controls.Add(dataGridViewComponents); Name = "FormComponents"; Text = "Компоненты"; + Load += FormComponents_Load; ((System.ComponentModel.ISupportInitialize)dataGridViewComponents).EndInit(); ResumeLayout(false); } diff --git a/Typography/Typography/FormComponents.cs b/Typography/Typography/FormComponents.cs index 6d31fe7..4671fc1 100644 --- a/Typography/Typography/FormComponents.cs +++ b/Typography/Typography/FormComponents.cs @@ -14,10 +14,6 @@ namespace TypographyView _logger = logger; _logic = logic; } - private void FormComponents_Load(object sender, EventArgs e) - { - LoadData(); - } private void LoadData() { try @@ -92,5 +88,9 @@ namespace TypographyView { LoadData(); } + private void FormComponents_Load(object sender, EventArgs e) + { + LoadData(); + } } }