From 4f4dad18c51c0720173f478cdf440160390b87a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=91=D0=B0=D0=BA=D0=B0?= =?UTF-8?q?=D0=BB=D1=8C=D1=81=D0=BA=D0=B0=D1=8F?= Date: Sun, 19 May 2024 18:11:43 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=BE=D0=B4=D0=BA=D0=BE=D1=80=D1=80?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BB=D0=B0=20?= =?UTF-8?q?=D0=BA=D1=80=D0=B0=D1=81=D0=BE=D1=82=D1=83=20=D0=B2=D1=8B=D0=B2?= =?UTF-8?q?=D0=BE=D0=B4=D0=B0=20=D0=BA=D0=BE=D0=BB=D0=BE=D0=BD=D0=BE=D0=BA?= =?UTF-8?q?,=20=D0=BD=D1=83=20=D0=B8=20=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=BB=D0=B0=20=D0=B4=D0=BE=20=D0=BA=D0=BE=D0=BD=D1=86?= =?UTF-8?q?=D0=B0=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=81=D0=B5=D1=80=D0=B2=D0=B8=D1=81?= =?UTF-8?q?=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B0=D0=B9=D0=B4=D0=B5=D1=80=D0=B0?= =?UTF-8?q?=20=D0=BD=D0=B0=20=D0=BC=D0=B5=D0=BD=D0=B5=D0=B4=D0=B6=D0=B5?= =?UTF-8?q?=D1=80=20=D0=B7=D0=B0=D0=B2=D0=B8=D1=81=D0=B8=D0=BC=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=B5=D0=B9=20=D0=BD=D0=B0=D1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SushiBar/FormMain.cs | 2 +- SushiBar/Program.cs | 4 -- SushiBar/Sushis/FormSushi.cs | 65 +++++++++---------- .../ViewModels/ClientViewModel.cs | 4 +- .../ViewModels/ComponentViewModel.cs | 4 +- .../ViewModels/ImplementerViewModel.cs | 8 +-- .../ViewModels/MessageInfoViewModel.cs | 2 +- .../ViewModels/OrderViewModel.cs | 11 ++-- .../ViewModels/SushiViewModel.cs | 2 +- 9 files changed, 47 insertions(+), 55 deletions(-) diff --git a/SushiBar/FormMain.cs b/SushiBar/FormMain.cs index b292116..88a5ea0 100644 --- a/SushiBar/FormMain.cs +++ b/SushiBar/FormMain.cs @@ -135,7 +135,7 @@ namespace SushiBarView private void запускРаботToolStripMenuItem_Click(object sender, EventArgs e) { - _workProcess.DoWork((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic); + _workProcess.DoWork((DependencyManager.Instance.Resolve() as IImplementerLogic)!, _orderLogic); MessageBox.Show("Процесс обработки запущен", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); } diff --git a/SushiBar/Program.cs b/SushiBar/Program.cs index 586074b..4cb6faa 100644 --- a/SushiBar/Program.cs +++ b/SushiBar/Program.cs @@ -16,10 +16,6 @@ namespace SushiBar { internal static class Program { - - private static ServiceProvider? _serviceProvider; - public static ServiceProvider? ServiceProvider => _serviceProvider; - /// /// The main entry point for the application. /// diff --git a/SushiBar/Sushis/FormSushi.cs b/SushiBar/Sushis/FormSushi.cs index 44be721..749c622 100644 --- a/SushiBar/Sushis/FormSushi.cs +++ b/SushiBar/Sushis/FormSushi.cs @@ -2,6 +2,7 @@ using SushiBar; using SushiBarContracts.BindingModel; using SushiBarContracts.BusinessLogicsContracts; +using SushiBarContracts.DI; using SushiBarContracts.SearchModel; using SushiBarDataModels.Models; @@ -29,7 +30,7 @@ namespace SushiBarView _logger.LogInformation("Загрузка изделия"); try { - var view = _logic.ReadElement(new SushiSearchModel{ Id = _id.Value }); + var view = _logic.ReadElement(new SushiSearchModel { Id = _id.Value }); if (view != null) { textBoxName.Text = view.SushiName; @@ -68,50 +69,46 @@ namespace SushiBarView } private void ButtonAdd_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormSushiComponent)); - if (service is FormSushiComponent form) + var form = DependencyManager.Instance.Resolve(); + + if (form.ShowDialog() == DialogResult.OK) { - if (form.ShowDialog() == DialogResult.OK) + if (form.ComponentModel == null) { - if (form.ComponentModel == null) - { - return; - } - _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", - form.ComponentModel.ComponentName, form.Count); - if (_sushiComponents.ContainsKey(form.Id)) - { - _sushiComponents[form.Id] = (form.ComponentModel, form.Count); - } - else - { - _sushiComponents.Add(form.Id, (form.ComponentModel, form.Count)); - } - LoadData(); + return; } + _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", + form.ComponentModel.ComponentName, form.Count); + if (_sushiComponents.ContainsKey(form.Id)) + { + _sushiComponents[form.Id] = (form.ComponentModel, form.Count); + } + else + { + _sushiComponents.Add(form.Id, (form.ComponentModel, form.Count)); + } + LoadData(); } } private void ButtonUpd_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) { - var service = Program.ServiceProvider?.GetService(typeof(FormSushiComponent)); - if (service is FormSushiComponent form) + var form = DependencyManager.Instance.Resolve(); + + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + form.Count = _sushiComponents[id].Item2; + if (form.ShowDialog() == DialogResult.OK) { - int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); - form.Id = id; - form.Count = _sushiComponents[id].Item2; - if (form.ShowDialog() == DialogResult.OK) + if (form.ComponentModel == null) { - if (form.ComponentModel == null) - { - return; - } - _logger.LogInformation("Изменение компонента: { ComponentName} - { Count} ", - form.ComponentModel.ComponentName, form.Count); - _sushiComponents[form.Id] = (form.ComponentModel, form.Count); - LoadData(); + return; } + _logger.LogInformation("Изменение компонента: { ComponentName} - { Count} ", + form.ComponentModel.ComponentName, form.Count); + _sushiComponents[form.Id] = (form.ComponentModel, form.Count); + LoadData(); } } } @@ -124,7 +121,7 @@ namespace SushiBarView { try { - _logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", + _logger.LogInformation("Удаление компонента: {ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value); _sushiComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); } diff --git a/SushiBarContracts/ViewModels/ClientViewModel.cs b/SushiBarContracts/ViewModels/ClientViewModel.cs index afdf47c..d101c1c 100644 --- a/SushiBarContracts/ViewModels/ClientViewModel.cs +++ b/SushiBarContracts/ViewModels/ClientViewModel.cs @@ -14,13 +14,13 @@ namespace SushiBarContracts.ViewModels [Column(visible: false)] public int Id { get; set; } - [Column(title: "ФИО клиента", width: 200)] + [Column(title: "ФИО клиента", width: 250)] public string ClientFIO { get; set; } = string.Empty; [Column(title: "Логин (эл. почта)", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string Email { get; set; } = string.Empty; - [Column(title: "Пароль", width: 50)] + [Column(title: "Пароль", width: 100)] public string Password { get; set; } = string.Empty; } } diff --git a/SushiBarContracts/ViewModels/ComponentViewModel.cs b/SushiBarContracts/ViewModels/ComponentViewModel.cs index 4e34d8d..9a6f2a8 100644 --- a/SushiBarContracts/ViewModels/ComponentViewModel.cs +++ b/SushiBarContracts/ViewModels/ComponentViewModel.cs @@ -9,11 +9,11 @@ namespace SushiBarContracts.ViewModels [Column(visible: false)] public int Id { get; set; } - [Column(title: "Компонент", width: 50)] + [Column(title: "Компонент", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ComponentName { get; set; } = string.Empty; [DisplayName("Цена")] - [Column(title: "Цена", width: 30)] + [Column(title: "Цена", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public double Cost { get; set; } } } diff --git a/SushiBarContracts/ViewModels/ImplementerViewModel.cs b/SushiBarContracts/ViewModels/ImplementerViewModel.cs index e8020fc..62e9f44 100644 --- a/SushiBarContracts/ViewModels/ImplementerViewModel.cs +++ b/SushiBarContracts/ViewModels/ImplementerViewModel.cs @@ -14,16 +14,16 @@ namespace SushiBarContracts.ViewModels [Column(visible: false)] public int Id { get; set; } - [Column(title: "Исполнитель ФИО", width: 150)] + [Column(title: "Исполнитель ФИО", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string ImplementerFIO { get; set; } = string.Empty; - [Column(title: "Пароль", width: 50)] + [Column(title: "Пароль", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string Password { get; set; } = string.Empty; - [Column(title: "Опыт работы", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] + [Column(title: "Опыт работы", width: 130)] public int WorkExperience { get; set; } - [Column(title: "Квалификация", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] + [Column(title: "Квалификация", width: 130)] public int Qualification { get; set; } } } diff --git a/SushiBarContracts/ViewModels/MessageInfoViewModel.cs b/SushiBarContracts/ViewModels/MessageInfoViewModel.cs index 8b9626d..9b5ce0b 100644 --- a/SushiBarContracts/ViewModels/MessageInfoViewModel.cs +++ b/SushiBarContracts/ViewModels/MessageInfoViewModel.cs @@ -6,7 +6,7 @@ namespace SushiBarContracts.ViewModels public class MessageInfoViewModel : IMessageInfoModel { [Column(visible: false)] - public int Id => throw new NotImplementedException(); + public int Id { get; set; } [Column(visible: false)] public string MessageId { get; set; } = string.Empty; diff --git a/SushiBarContracts/ViewModels/OrderViewModel.cs b/SushiBarContracts/ViewModels/OrderViewModel.cs index f972a2e..8c12235 100644 --- a/SushiBarContracts/ViewModels/OrderViewModel.cs +++ b/SushiBarContracts/ViewModels/OrderViewModel.cs @@ -8,7 +8,7 @@ namespace SushiBarContracts.ViewModels { public class OrderViewModel : IOrderModel { - [Column(title: "Номер", width: 10)] + [Column(title: "Номер", width: 30)] public int Id { get; set; } [Column(visible: false)] @@ -20,24 +20,23 @@ namespace SushiBarContracts.ViewModels [Column(visible: false)] public int? ImplementerId { get; set; } - [Column(title: "Имя клиента", width: 150)] + [Column(title: "Имя клиента", width: 250)] public string ClientFIO { get; set; } = string.Empty; [Column(title: "Имя исполнителя", width: 150)] public string? ImplementerFIO { get; set; } - [Column(title: "Суши", width: 50)] + [Column(title: "Суши", width: 100)] public string SushiName { get; set; } = string.Empty; - [Column(title: "Количество", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] + [Column(title: "Количество", width: 60)] public int Count { get; set; } - [Column(title: "Сумма", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public double Sum { get; set; } - [Column(title: "Статус", width: 30)] + [Column(title: "Статус", width: 80)] public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; diff --git a/SushiBarContracts/ViewModels/SushiViewModel.cs b/SushiBarContracts/ViewModels/SushiViewModel.cs index 8e79d30..30b54cd 100644 --- a/SushiBarContracts/ViewModels/SushiViewModel.cs +++ b/SushiBarContracts/ViewModels/SushiViewModel.cs @@ -9,7 +9,7 @@ namespace SushiBarContracts.ViewModels [Column(visible: false)] public int Id { get; set; } - [Column(title: "Название изделия", width: 50)] + [Column(title: "Название изделия", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)] public string SushiName { get; set; } = string.Empty; [Column(title: "Цена", gridViewAutoSize: GridViewAutoSize.Fill, isUseAutoSize: true)]