From 5de3202afc8e548d612b9253aeb05b74491aeef8 Mon Sep 17 00:00:00 2001 From: m1aksim1 Date: Mon, 6 Feb 2023 22:03:49 +0400 Subject: [PATCH] fix --- .../OrderLogic.cs | 7 ++++++- .../OrderStorage.cs | 15 ++++++++++++++- .../SoftwareInstallationView/FormComponents.cs | 12 ++++-------- .../SoftwareInstallationView/FormMain.cs | 6 +++--- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs index e27c78b..4b53c5f 100644 --- a/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OrderLogic.cs @@ -39,12 +39,13 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics public bool DeliveryOrder(OrderBindingModel model) { + model.DateImplement = DateTime.Now; return SetOrderStatus(model, OrderStatus.Выдан); } public bool FinishOrder(OrderBindingModel model) { - return SetOrderStatus(model, OrderStatus.Выполняется); + return SetOrderStatus(model, OrderStatus.Готов); } public List? ReadList(OrderSearchModel? model) @@ -101,6 +102,10 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics nameof(viewModel)); } model.Status = orderStatus; + model.Sum = viewModel.Sum; + model.Count = viewModel.Count; + model.DateCreate = viewModel.DateCreate; + model.PackageId = viewModel.PackageId; if (_orderStorage.Update(model) == null) { _logger.LogWarning("Ошибка операции обновления"); diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs b/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs index d146868..85f1ea4 100644 --- a/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs +++ b/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs @@ -62,7 +62,7 @@ namespace SoftwareInstallationListImplement.Implements var result = new List(); foreach (var order in _source.Orders) { - result.Add(order.GetViewModel); + result.Add(GetViewModel(order)); } return result; } @@ -96,5 +96,18 @@ namespace SoftwareInstallationListImplement.Implements } return null; } + private OrderViewModel GetViewModel(Order model) + { + var res = model.GetViewModel; + foreach (var package in _source.Packages) + { + if (package.Id == model.PackageId) + { + res.PackageName = package.PackageName; + break; + } + } + return res; + } } } \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/FormComponents.cs b/SoftwareInstallation/SoftwareInstallationView/FormComponents.cs index 6d54eb5..3648177 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormComponents.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormComponents.cs @@ -28,16 +28,14 @@ namespace SoftwareInstallationView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; - dataGridView.Columns["ComponentName"].AutoSizeMode = - DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ComponentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка компонентов"); } catch (Exception ex) { _logger.LogError(ex, "Ошибка загрузки компонентов"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } private void ButtonAdd_Click(object sender, EventArgs e) @@ -73,11 +71,9 @@ namespace SoftwareInstallationView { if (dataGridView.SelectedRows.Count == 1) { - if (MessageBox.Show("Удалить запись?", "Вопрос", - MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - int id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Удаление компонента"); try { diff --git a/SoftwareInstallation/SoftwareInstallationView/FormMain.cs b/SoftwareInstallation/SoftwareInstallationView/FormMain.cs index 70f93ed..c44068a 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormMain.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormMain.cs @@ -27,6 +27,7 @@ namespace SoftwareInstallationView { dataGridView.DataSource = list; dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["PackageName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка заказов"); } @@ -54,8 +55,7 @@ namespace SoftwareInstallationView } private void ButtonCreateOrder_Click(object sender, EventArgs e) { - var service = - Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); if (service is FormCreateOrder form) { form.ShowDialog(); @@ -68,7 +68,7 @@ namespace SoftwareInstallationView { int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); - try + try { var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id }); if (!operationResult)