From a2bd2436b5813d03a022adc290e8d7d421da3d8f Mon Sep 17 00:00:00 2001 From: Yunusov_Niyaz Date: Tue, 13 Feb 2024 00:17:40 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CarRepairShop/FormMain.Designer.cs | 24 ++- CarRepairShop/CarRepairShop/FormMain.cs | 16 ++ .../CarRepairShop/FormShop.Designer.cs | 202 ++++++++++++++++++ CarRepairShop/CarRepairShop/FormShop.cs | 114 ++++++++++ CarRepairShop/CarRepairShop/FormShop.resx | 120 +++++++++++ .../CarRepairShop/FormShops.Designer.cs | 125 +++++++++++ CarRepairShop/CarRepairShop/FormShops.cs | 118 ++++++++++ CarRepairShop/CarRepairShop/FormShops.resx | 120 +++++++++++ .../CarRepairShop/FormSupply.Designer.cs | 149 +++++++++++++ CarRepairShop/CarRepairShop/FormSupply.cs | 142 ++++++++++++ CarRepairShop/CarRepairShop/FormSupply.resx | 120 +++++++++++ CarRepairShop/CarRepairShop/Program.cs | 5 + .../CarRepairShopBusinessLogic/ShopLogic.cs | 129 +++++++++++ .../BindingModels/ShopBindingModel.cs | 14 ++ .../BusinessLogicsContracts/IShopLogic.cs | 17 ++ .../SearchModels/ShopSearchModel.cs | 14 ++ .../StoragesContracts/IShopStorage.cs | 18 ++ .../ViewModels/ShopViewModel.cs | 18 ++ .../CarRepairShopDataModels/IShopModel.cs | 12 ++ .../DataListSingleton.cs | 2 + .../Implements/ShopStorage.cs | 135 ++++++++++++ .../CarRepairShopListImplement/Models/Shop.cs | 51 +++++ 22 files changed, 1662 insertions(+), 3 deletions(-) create mode 100644 CarRepairShop/CarRepairShop/FormShop.Designer.cs create mode 100644 CarRepairShop/CarRepairShop/FormShop.cs create mode 100644 CarRepairShop/CarRepairShop/FormShop.resx create mode 100644 CarRepairShop/CarRepairShop/FormShops.Designer.cs create mode 100644 CarRepairShop/CarRepairShop/FormShops.cs create mode 100644 CarRepairShop/CarRepairShop/FormShops.resx create mode 100644 CarRepairShop/CarRepairShop/FormSupply.Designer.cs create mode 100644 CarRepairShop/CarRepairShop/FormSupply.cs create mode 100644 CarRepairShop/CarRepairShop/FormSupply.resx create mode 100644 CarRepairShop/CarRepairShopBusinessLogic/ShopLogic.cs create mode 100644 CarRepairShop/CarRepairShopContracts/BindingModels/ShopBindingModel.cs create mode 100644 CarRepairShop/CarRepairShopContracts/BusinessLogicsContracts/IShopLogic.cs create mode 100644 CarRepairShop/CarRepairShopContracts/SearchModels/ShopSearchModel.cs create mode 100644 CarRepairShop/CarRepairShopContracts/StoragesContracts/IShopStorage.cs create mode 100644 CarRepairShop/CarRepairShopContracts/ViewModels/ShopViewModel.cs create mode 100644 CarRepairShop/CarRepairShopDataModels/IShopModel.cs create mode 100644 CarRepairShop/CarRepairShopListImplement/Implements/ShopStorage.cs create mode 100644 CarRepairShop/CarRepairShopListImplement/Models/Shop.cs diff --git a/CarRepairShop/CarRepairShop/FormMain.Designer.cs b/CarRepairShop/CarRepairShop/FormMain.Designer.cs index 8bf3995..8aae5b5 100644 --- a/CarRepairShop/CarRepairShop/FormMain.Designer.cs +++ b/CarRepairShop/CarRepairShop/FormMain.Designer.cs @@ -38,6 +38,8 @@ buttonOrderReady = new Button(); buttonIssuedOrder = new Button(); buttonRefresh = new Button(); + ShopsToolStripMenuItem = new ToolStripMenuItem(); + SupplyToolStripMenuItem = new ToolStripMenuItem(); menuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -54,7 +56,7 @@ // // справочникиToolStripMenuItem // - справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, ремонтToolStripMenuItem }); + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, ремонтToolStripMenuItem, ShopsToolStripMenuItem, SupplyToolStripMenuItem }); справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; справочникиToolStripMenuItem.Size = new Size(117, 24); справочникиToolStripMenuItem.Text = "Справочники"; @@ -62,14 +64,14 @@ // компонентыToolStripMenuItem // компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - компонентыToolStripMenuItem.Size = new Size(182, 26); + компонентыToolStripMenuItem.Size = new Size(224, 26); компонентыToolStripMenuItem.Text = "Компоненты"; компонентыToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click; // // ремонтToolStripMenuItem // ремонтToolStripMenuItem.Name = "ремонтToolStripMenuItem"; - ремонтToolStripMenuItem.Size = new Size(182, 26); + ремонтToolStripMenuItem.Size = new Size(224, 26); ремонтToolStripMenuItem.Text = "Ремонт"; ремонтToolStripMenuItem.Click += RepairToolStripMenuItem_Click; // @@ -135,6 +137,20 @@ buttonRefresh.UseVisualStyleBackColor = true; buttonRefresh.Click += ButtonRef_Click; // + // ShopsToolStripMenuItem + // + ShopsToolStripMenuItem.Name = "ShopsToolStripMenuItem"; + ShopsToolStripMenuItem.Size = new Size(224, 26); + ShopsToolStripMenuItem.Text = "Магазины"; + ShopsToolStripMenuItem.Click += ShopsToolStripMenuItem_Click; + // + // SupplyToolStripMenuItem + // + SupplyToolStripMenuItem.Name = "SupplyToolStripMenuItem"; + SupplyToolStripMenuItem.Size = new Size(224, 26); + SupplyToolStripMenuItem.Text = "Поставки"; + SupplyToolStripMenuItem.Click += SupplyToolStripMenuItem_Click; + // // FormMain // AutoScaleDimensions = new SizeF(8F, 20F); @@ -171,5 +187,7 @@ private Button buttonOrderReady; private Button buttonIssuedOrder; private Button buttonRefresh; + private ToolStripMenuItem ShopsToolStripMenuItem; + private ToolStripMenuItem SupplyToolStripMenuItem; } } \ No newline at end of file diff --git a/CarRepairShop/CarRepairShop/FormMain.cs b/CarRepairShop/CarRepairShop/FormMain.cs index c14d176..cd1c4ad 100644 --- a/CarRepairShop/CarRepairShop/FormMain.cs +++ b/CarRepairShop/CarRepairShop/FormMain.cs @@ -156,5 +156,21 @@ namespace CarRepairShop { LoadData(); } + private void ShopsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShops)); + if (service is FormShops form) + { + form.ShowDialog(); + } + } + private void SupplyToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSupply)); + if (service is FormSupply form) + { + form.ShowDialog(); + } + } } } diff --git a/CarRepairShop/CarRepairShop/FormShop.Designer.cs b/CarRepairShop/CarRepairShop/FormShop.Designer.cs new file mode 100644 index 0000000..1bee047 --- /dev/null +++ b/CarRepairShop/CarRepairShop/FormShop.Designer.cs @@ -0,0 +1,202 @@ +namespace CarRepairShop +{ + partial class FormShop + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dateTimePicker = new DateTimePicker(); + textBoxName = new TextBox(); + textBoxAdress = new TextBox(); + labelName = new Label(); + labelAdress = new Label(); + labelDate = new Label(); + buttonSave = new Button(); + buttonCancel = new Button(); + dataGridView = new DataGridView(); + Id = new DataGridViewTextBoxColumn(); + ShopName = new DataGridViewTextBoxColumn(); + Cost = new DataGridViewTextBoxColumn(); + Count = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dateTimePicker + // + dateTimePicker.Location = new Point(97, 93); + dateTimePicker.Margin = new Padding(3, 4, 3, 4); + dateTimePicker.Name = "dateTimePicker"; + dateTimePicker.Size = new Size(363, 27); + dateTimePicker.TabIndex = 0; + // + // textBoxName + // + textBoxName.Location = new Point(97, 16); + textBoxName.Margin = new Padding(3, 4, 3, 4); + textBoxName.Name = "textBoxName"; + textBoxName.Size = new Size(363, 27); + textBoxName.TabIndex = 1; + // + // textBoxAdress + // + textBoxAdress.Location = new Point(97, 55); + textBoxAdress.Margin = new Padding(3, 4, 3, 4); + textBoxAdress.Name = "textBoxAdress"; + textBoxAdress.Size = new Size(363, 27); + textBoxAdress.TabIndex = 2; + // + // labelName + // + labelName.AutoSize = true; + labelName.Location = new Point(14, 20); + labelName.Name = "labelName"; + labelName.Size = new Size(77, 20); + labelName.TabIndex = 3; + labelName.Text = "Название"; + // + // labelAdress + // + labelAdress.AutoSize = true; + labelAdress.Location = new Point(14, 59); + labelAdress.Name = "labelAdress"; + labelAdress.Size = new Size(51, 20); + labelAdress.TabIndex = 4; + labelAdress.Text = "Адрес"; + // + // labelDate + // + labelDate.AutoSize = true; + labelDate.Location = new Point(14, 101); + labelDate.Name = "labelDate"; + labelDate.Size = new Size(41, 20); + labelDate.TabIndex = 5; + labelDate.Text = "Дата"; + // + // buttonSave + // + buttonSave.Location = new Point(277, 340); + buttonSave.Margin = new Padding(3, 4, 3, 4); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(91, 31); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += SaveButton_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(375, 340); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(86, 31); + buttonCancel.TabIndex = 7; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += CancelButton_Click; + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { Id, ShopName, Cost, Count }); + dataGridView.Location = new Point(14, 132); + dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.Size = new Size(447, 200); + dataGridView.TabIndex = 8; + // + // Id + // + Id.HeaderText = "id"; + Id.MinimumWidth = 6; + Id.Name = "Id"; + Id.Visible = false; + Id.Width = 125; + // + // Name + // + ShopName.HeaderText = "Название"; + ShopName.MinimumWidth = 6; + ShopName.Name = "Name"; + ShopName.ReadOnly = true; + ShopName.Width = 150; + // + // Cost + // + Cost.HeaderText = "Цена"; + Cost.MinimumWidth = 6; + Cost.Name = "Cost"; + Cost.ReadOnly = true; + Cost.Width = 125; + // + // Count + // + Count.HeaderText = "Количество"; + Count.MinimumWidth = 6; + Count.Name = "Count"; + Count.ReadOnly = true; + Count.Width = 125; + // + // FormShop + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(470, 380); + Controls.Add(dataGridView); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(labelDate); + Controls.Add(labelAdress); + Controls.Add(labelName); + Controls.Add(textBoxAdress); + Controls.Add(textBoxName); + Controls.Add(dateTimePicker); + Margin = new Padding(3, 4, 3, 4); + Name = "FormShop"; + Text = "Магазин"; + Load += FormShop_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private DateTimePicker dateTimePicker; + private TextBox textBoxName; + private TextBox textBoxAdress; + private Label labelName; + private Label labelAdress; + private Label labelDate; + private Button buttonSave; + private Button buttonCancel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn Id; + private DataGridViewTextBoxColumn ShopName; + private DataGridViewTextBoxColumn Cost; + private DataGridViewTextBoxColumn Count; + } +} \ No newline at end of file diff --git a/CarRepairShop/CarRepairShop/FormShop.cs b/CarRepairShop/CarRepairShop/FormShop.cs new file mode 100644 index 0000000..ebe31b1 --- /dev/null +++ b/CarRepairShop/CarRepairShop/FormShop.cs @@ -0,0 +1,114 @@ +using CarRepairShopContracts.BindingModels; +using CarRepairShopContracts.BusinessLogicsContracts; +using CarRepairShopContracts.SearchModels; +using CarRepairShopDataModels.Models; +using Microsoft.Extensions.Logging; + +namespace CarRepairShop +{ + public partial class FormShop : Form + { + private readonly ILogger _logger; + private readonly IShopLogic _logic; + public int? _id; + private Dictionary _repairs; + public FormShop(ILogger logger, IShopLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormShop_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Загрузка магазина"); + try + { + var shop = _logic.ReadElement(new ShopSearchModel { Id = _id }); + if (shop != null) + { + textBoxName.Text = shop.ShopName; + textBoxAdress.Text = shop.Address; + dateTimePicker.Text = shop.DateOpen.ToString(); + _repairs = shop.ShopRepairs; + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + + private void LoadData() + { + _logger.LogInformation("Загрузка товаров магазина"); + try + { + if (_repairs != null) + { + foreach (var repair in _repairs) + { + dataGridView.Rows.Add(new object[] { repair.Key, repair.Value.Item1.RepairName, repair.Value.Item1.Price, repair.Value.Item2 }); + } + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки ремонтов магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + + private void CancelButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void SaveButton_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxAdress.Text)) + { + MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение магазина"); + try + { + var model = new ShopBindingModel + { + Id = _id ?? 0, + ShopName = textBoxName.Text, + Address = textBoxAdress.Text, + DateOpen = dateTimePicker.Value.Date, + ShopRepairs = _repairs + }; + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } +} diff --git a/CarRepairShop/CarRepairShop/FormShop.resx b/CarRepairShop/CarRepairShop/FormShop.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/CarRepairShop/CarRepairShop/FormShop.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/CarRepairShop/CarRepairShop/FormShops.Designer.cs b/CarRepairShop/CarRepairShop/FormShops.Designer.cs new file mode 100644 index 0000000..9b94d42 --- /dev/null +++ b/CarRepairShop/CarRepairShop/FormShops.Designer.cs @@ -0,0 +1,125 @@ +namespace CarRepairShop +{ + partial class FormShops + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + dataGridView = new DataGridView(); + buttonAdd = new Button(); + buttonUpdate = new Button(); + buttonRefresh = new Button(); + buttonDelete = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.BackgroundColor = Color.White; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(14, 16); + dataGridView.Margin = new Padding(3, 4, 3, 4); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.Size = new Size(449, 499); + dataGridView.TabIndex = 0; + // + // buttonAdd + // + buttonAdd.Location = new Point(470, 16); + buttonAdd.Margin = new Padding(3, 4, 3, 4); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(130, 31); + buttonAdd.TabIndex = 1; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += ButtonAdd_Click; + // + // buttonUpdate + // + buttonUpdate.Location = new Point(470, 55); + buttonUpdate.Margin = new Padding(3, 4, 3, 4); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(130, 31); + buttonUpdate.TabIndex = 2; + buttonUpdate.Text = "Изменить"; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonUpdate_Click; + // + // buttonRefresh + // + buttonRefresh.Location = new Point(470, 93); + buttonRefresh.Margin = new Padding(3, 4, 3, 4); + buttonRefresh.Name = "buttonRefresh"; + buttonRefresh.Size = new Size(130, 31); + buttonRefresh.TabIndex = 3; + buttonRefresh.Text = "Обновить"; + buttonRefresh.UseVisualStyleBackColor = true; + buttonRefresh.Click += ButtonRefresh_Click; + // + // buttonDelete + // + buttonDelete.Location = new Point(470, 132); + buttonDelete.Margin = new Padding(3, 4, 3, 4); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(130, 31); + buttonDelete.TabIndex = 4; + buttonDelete.Text = "Удалить"; + buttonDelete.UseVisualStyleBackColor = true; + buttonDelete.Click += ButtonDelete_Click; + // + // FormShops + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(616, 537); + Controls.Add(buttonDelete); + Controls.Add(buttonRefresh); + Controls.Add(buttonUpdate); + Controls.Add(buttonAdd); + Controls.Add(dataGridView); + Margin = new Padding(3, 4, 3, 4); + Name = "FormShops"; + Text = "Магазины"; + Load += FormShops_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Button buttonAdd; + private Button buttonUpdate; + private Button buttonRefresh; + private Button buttonDelete; + private DataGridViewTextBoxColumn Column1; + private DataGridViewTextBoxColumn Column2; + private DataGridViewTextBoxColumn Column3; + private DataGridViewTextBoxColumn Column4; + private DataGridViewTextBoxColumn Column5; + } +} \ No newline at end of file diff --git a/CarRepairShop/CarRepairShop/FormShops.cs b/CarRepairShop/CarRepairShop/FormShops.cs new file mode 100644 index 0000000..f4990c7 --- /dev/null +++ b/CarRepairShop/CarRepairShop/FormShops.cs @@ -0,0 +1,118 @@ +using CarRepairShopContracts.BindingModels; +using CarRepairShopContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace CarRepairShop +{ + public partial class FormShops : Form + { + private readonly ILogger _logger; + private readonly IShopLogic _logic; + public FormShops(ILogger logger, IShopLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["Address"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["DateOpen"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ShopRepairs"].Visible = false; + } + _logger.LogInformation("Загрузка магазинов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки магазинов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void FormShops_Load(object sender, EventArgs e) + { + LoadData(); + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShop)); + if (service is FormShop form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void ButtonUpdate_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShop)); + if (service is FormShop form) + { + var tmp = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + form._id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + + private void ButtonRefresh_Click(object sender, EventArgs e) + { + LoadData(); + } + + private void ButtonDelete_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление магазина"); + try + { + if (!_logic.Delete(new ShopBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + } +} diff --git a/CarRepairShop/CarRepairShop/FormShops.resx b/CarRepairShop/CarRepairShop/FormShops.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/CarRepairShop/CarRepairShop/FormShops.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/CarRepairShop/CarRepairShop/FormSupply.Designer.cs b/CarRepairShop/CarRepairShop/FormSupply.Designer.cs new file mode 100644 index 0000000..46504a5 --- /dev/null +++ b/CarRepairShop/CarRepairShop/FormSupply.Designer.cs @@ -0,0 +1,149 @@ +namespace CarRepairShop +{ + partial class FormSupply + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + comboBoxShop = new ComboBox(); + comboBoxRepair = new ComboBox(); + textBoxCount = new TextBox(); + buttonSave = new Button(); + buttonCancel = new Button(); + labelShop = new Label(); + labelRepair = new Label(); + labelCount = new Label(); + SuspendLayout(); + // + // comboBoxShop + // + comboBoxShop.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxShop.FormattingEnabled = true; + comboBoxShop.Location = new Point(110, 16); + comboBoxShop.Margin = new Padding(3, 4, 3, 4); + comboBoxShop.Name = "comboBoxShop"; + comboBoxShop.Size = new Size(282, 28); + comboBoxShop.TabIndex = 0; + // + // comboBoxRepair + // + comboBoxRepair.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxRepair.FormattingEnabled = true; + comboBoxRepair.Location = new Point(110, 55); + comboBoxRepair.Margin = new Padding(3, 4, 3, 4); + comboBoxRepair.Name = "comboBoxRepair"; + comboBoxRepair.Size = new Size(282, 28); + comboBoxRepair.TabIndex = 1; + // + // textBoxCount + // + textBoxCount.Location = new Point(110, 93); + textBoxCount.Margin = new Padding(3, 4, 3, 4); + textBoxCount.Name = "textBoxCount"; + textBoxCount.Size = new Size(282, 27); + textBoxCount.TabIndex = 2; + // + // buttonSave + // + buttonSave.Location = new Point(204, 132); + buttonSave.Margin = new Padding(3, 4, 3, 4); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(96, 31); + buttonSave.TabIndex = 3; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += SaveButton_Click; + // + // buttonCancel + // + buttonCancel.Location = new Point(306, 132); + buttonCancel.Margin = new Padding(3, 4, 3, 4); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(86, 31); + buttonCancel.TabIndex = 4; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += CancelButton_Click; + // + // labelShop + // + labelShop.AutoSize = true; + labelShop.Location = new Point(12, 16); + labelShop.Name = "labelShop"; + labelShop.Size = new Size(72, 20); + labelShop.TabIndex = 5; + labelShop.Text = "Магазин:"; + // + // labelRepair + // + labelRepair.AutoSize = true; + labelRepair.Location = new Point(12, 55); + labelRepair.Name = "labelRepair"; + labelRepair.Size = new Size(63, 20); + labelRepair.TabIndex = 6; + labelRepair.Text = "Ремонт:"; + // + // labelCount + // + labelCount.AutoSize = true; + labelCount.Location = new Point(12, 93); + labelCount.Name = "labelCount"; + labelCount.Size = new Size(93, 20); + labelCount.TabIndex = 7; + labelCount.Text = "Количество:"; + // + // FormSupply + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(406, 181); + Controls.Add(labelCount); + Controls.Add(labelRepair); + Controls.Add(labelShop); + Controls.Add(buttonCancel); + Controls.Add(buttonSave); + Controls.Add(textBoxCount); + Controls.Add(comboBoxRepair); + Controls.Add(comboBoxShop); + Margin = new Padding(3, 4, 3, 4); + Name = "FormSupply"; + Text = "Поставки"; + ResumeLayout(false); + PerformLayout(); + } + + #endregion + + private ComboBox comboBoxShop; + private ComboBox comboBoxRepair; + private TextBox textBoxCount; + private Button buttonSave; + private Button buttonCancel; + private Label labelShop; + private Label labelRepair; + private Label labelCount; + } +} \ No newline at end of file diff --git a/CarRepairShop/CarRepairShop/FormSupply.cs b/CarRepairShop/CarRepairShop/FormSupply.cs new file mode 100644 index 0000000..ce6aa68 --- /dev/null +++ b/CarRepairShop/CarRepairShop/FormSupply.cs @@ -0,0 +1,142 @@ +using CarRepairShopContracts.BusinessLogicsContracts; +using CarRepairShopContracts.SearchModels; +using CarRepairShopContracts.ViewModels; +using CarRepairShopDataModels.Models; + +namespace CarRepairShop +{ + public partial class FormSupply : Form + { + private readonly List? _repairList; + private readonly List? _shopsList; + IShopLogic _shopLogic; + IRepairLogic _repairLogic; + public int ShopId + { + get + { + return + Convert.ToInt32(comboBoxShop.SelectedValue); + } + set + { + comboBoxShop.SelectedValue = value; + } + } + public int RepairId + { + get + { + return + Convert.ToInt32(comboBoxRepair.SelectedValue); + } + set + { + comboBoxRepair.SelectedValue = value; + } + } + + public IRepairModel? RepairModel + { + get + { + if (_repairList == null) + { + return null; + } + foreach (var elem in _repairList) + { + if (elem.Id == RepairId) + { + return elem; + } + } + return null; + } + } + + + public int Count + { + get { return Convert.ToInt32(textBoxCount.Text); } + set + { textBoxCount.Text = value.ToString(); } + } + public FormSupply(IRepairLogic repairLogic, IShopLogic shopLogic) + { + InitializeComponent(); + _shopLogic = shopLogic; + _repairLogic = repairLogic; + _repairList = repairLogic.ReadList(null); + _shopsList = shopLogic.ReadList(null); + if (_repairList != null) + { + comboBoxRepair.DisplayMember = "RepairName"; + comboBoxRepair.ValueMember = "Id"; + comboBoxRepair.DataSource = _repairList; + comboBoxRepair.SelectedItem = null; + } + if (_shopsList != null) + { + comboBoxShop.DisplayMember = "ShopName"; + comboBoxShop.ValueMember = "Id"; + comboBoxShop.DataSource = _shopsList; + comboBoxShop.SelectedItem = null; + } + } + + private void SaveButton_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxRepair.SelectedValue == null) + { + MessageBox.Show("Выберите ремонт", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxShop.SelectedValue == null) + { + MessageBox.Show("Выберите магазин", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + try + { + int count = Convert.ToInt32(textBoxCount.Text); + + bool res = _shopLogic.MakeSupply( + new ShopSearchModel() { Id = Convert.ToInt32(comboBoxShop.SelectedValue) }, + _repairLogic.ReadElement(new() { Id = Convert.ToInt32(comboBoxRepair.SelectedValue) }), + count + ); + + if (!res) + { + throw new Exception("Ошибка при пополнении. Дополнительная информация в логах"); + } + + MessageBox.Show("Пополнение прошло успешно"); + DialogResult = DialogResult.OK; + Close(); + + } + catch (Exception err) + { + MessageBox.Show("Ошибка пополнения"); + return; + } + } + + private void CancelButton_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/CarRepairShop/CarRepairShop/FormSupply.resx b/CarRepairShop/CarRepairShop/FormSupply.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/CarRepairShop/CarRepairShop/FormSupply.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/CarRepairShop/CarRepairShop/Program.cs b/CarRepairShop/CarRepairShop/Program.cs index 28c4224..3c6e08a 100644 --- a/CarRepairShop/CarRepairShop/Program.cs +++ b/CarRepairShop/CarRepairShop/Program.cs @@ -34,6 +34,8 @@ namespace CarRepairShop option.AddNLog("nlog.config"); }); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -46,6 +48,9 @@ namespace CarRepairShop services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/CarRepairShop/CarRepairShopBusinessLogic/ShopLogic.cs b/CarRepairShop/CarRepairShopBusinessLogic/ShopLogic.cs new file mode 100644 index 0000000..d0b7201 --- /dev/null +++ b/CarRepairShop/CarRepairShopBusinessLogic/ShopLogic.cs @@ -0,0 +1,129 @@ +using CarRepairShopContracts.BindingModels; +using CarRepairShopContracts.BusinessLogicsContracts; +using CarRepairShopContracts.SearchModels; +using CarRepairShopContracts.StoragesContracts; +using CarRepairShopContracts.ViewModels; +using CarRepairShopDataModels.Models; +using Microsoft.Extensions.Logging; + +namespace CarRepairShopBusinessLogic +{ + public class ShopLogic : IShopLogic + { + private readonly ILogger _logger; + private readonly IShopStorage _shopStorage; + + public ShopLogic(ILogger logger, IShopStorage shopStorage) + { + _logger = logger; + _shopStorage = shopStorage; + } + + public List ReadList(ShopSearchModel model) + { + _logger.LogInformation("ReadList. ShopName:{Name}. Id:{ Id}", model?.Name, model?.Id); + var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + + } + + public bool MakeSupply(ShopSearchModel model, IRepairModel repair, int count) + { + if (model == null) + return false; + return _shopStorage.SupplyRepair(model, repair, count); + } + + public ShopViewModel ReadElement(ShopSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ShopName:{ShopName}.Id:{ Id}", model.Name, model.Id); + var element = _shopStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id:{Id}", element.Id); + return element; + } + + public bool Create(ShopBindingModel model) + { + CheckModel(model); + if (_shopStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool Update(ShopBindingModel model) + { + CheckModel(model); + if (_shopStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ShopBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_shopStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + + private void CheckModel(ShopBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ShopName)) + { + throw new ArgumentNullException("Нет названия магазина", + nameof(model.ShopName)); + } + if (string.IsNullOrEmpty(model.Address)) + { + throw new ArgumentNullException("Нет адресса магазина", + nameof(model.ShopName)); + } + if (model.DateOpen == null) + { + throw new ArgumentNullException("Нет даты открытия магазина", + nameof(model.ShopName)); + } + _logger.LogInformation("Shop. ShopName:{ShopName}.Address:{Address}. DateOpen:{DateOpen}. Id: { Id}", model.ShopName, model.Address, model.DateOpen, model.Id); + var element = _shopStorage.GetElement(new ShopSearchModel + { + Name = model.ShopName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Магазин с таким названием уже есть"); + } + } + } +} diff --git a/CarRepairShop/CarRepairShopContracts/BindingModels/ShopBindingModel.cs b/CarRepairShop/CarRepairShopContracts/BindingModels/ShopBindingModel.cs new file mode 100644 index 0000000..86f9df5 --- /dev/null +++ b/CarRepairShop/CarRepairShopContracts/BindingModels/ShopBindingModel.cs @@ -0,0 +1,14 @@ +using CarRepairShopDataModels; +using CarRepairShopDataModels.Models; + +namespace CarRepairShopContracts.BindingModels +{ + public class ShopBindingModel : IShopModel + { + public int Id { get; set; } + public string ShopName { get; set; } + public string Address { get; set; } + public DateTime DateOpen { get; set; } + public Dictionary ShopRepairs { get; set; } = new(); + } +} diff --git a/CarRepairShop/CarRepairShopContracts/BusinessLogicsContracts/IShopLogic.cs b/CarRepairShop/CarRepairShopContracts/BusinessLogicsContracts/IShopLogic.cs new file mode 100644 index 0000000..5103a83 --- /dev/null +++ b/CarRepairShop/CarRepairShopContracts/BusinessLogicsContracts/IShopLogic.cs @@ -0,0 +1,17 @@ +using CarRepairShopContracts.BindingModels; +using CarRepairShopContracts.SearchModels; +using CarRepairShopContracts.ViewModels; +using CarRepairShopDataModels.Models; + +namespace CarRepairShopContracts.BusinessLogicsContracts +{ + public interface IShopLogic + { + List? ReadList(ShopSearchModel? model); + ShopViewModel? ReadElement(ShopSearchModel model); + bool Create(ShopBindingModel model); + bool Update(ShopBindingModel model); + bool Delete(ShopBindingModel model); + bool MakeSupply(ShopSearchModel model, IRepairModel repair, int count); + } +} diff --git a/CarRepairShop/CarRepairShopContracts/SearchModels/ShopSearchModel.cs b/CarRepairShop/CarRepairShopContracts/SearchModels/ShopSearchModel.cs new file mode 100644 index 0000000..88aa7d5 --- /dev/null +++ b/CarRepairShop/CarRepairShopContracts/SearchModels/ShopSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CarRepairShopContracts.SearchModels +{ + public class ShopSearchModel + { + public int? Id { get; set; } + public string? Name { get; set; } + } +} diff --git a/CarRepairShop/CarRepairShopContracts/StoragesContracts/IShopStorage.cs b/CarRepairShop/CarRepairShopContracts/StoragesContracts/IShopStorage.cs new file mode 100644 index 0000000..91a81fc --- /dev/null +++ b/CarRepairShop/CarRepairShopContracts/StoragesContracts/IShopStorage.cs @@ -0,0 +1,18 @@ +using CarRepairShopContracts.BindingModels; +using CarRepairShopContracts.SearchModels; +using CarRepairShopContracts.ViewModels; +using CarRepairShopDataModels.Models; + +namespace CarRepairShopContracts.StoragesContracts +{ + public interface IShopStorage + { + List GetFullList(); + List GetFilteredList(ShopSearchModel model); + ShopViewModel? GetElement(ShopSearchModel model); + ShopViewModel? Insert(ShopBindingModel model); + ShopViewModel? Update(ShopBindingModel model); + ShopViewModel? Delete(ShopBindingModel model); + bool SupplyRepair(ShopSearchModel model, IRepairModel repair, int Count); + } +} diff --git a/CarRepairShop/CarRepairShopContracts/ViewModels/ShopViewModel.cs b/CarRepairShop/CarRepairShopContracts/ViewModels/ShopViewModel.cs new file mode 100644 index 0000000..f2a4430 --- /dev/null +++ b/CarRepairShop/CarRepairShopContracts/ViewModels/ShopViewModel.cs @@ -0,0 +1,18 @@ +using CarRepairShopDataModels; +using CarRepairShopDataModels.Models; +using System.ComponentModel; + +namespace CarRepairShopContracts.ViewModels +{ + public class ShopViewModel : IShopModel + { + public int Id { get; set; } + [DisplayName("Название магазина")] + public string ShopName { get; set; } + [DisplayName("Адрес магазина")] + public string Address { get; set; } + [DisplayName("Дата открытия")] + public DateTime DateOpen { get; set; } + public Dictionary ShopRepairs { get; set; } = new(); + } +} diff --git a/CarRepairShop/CarRepairShopDataModels/IShopModel.cs b/CarRepairShop/CarRepairShopDataModels/IShopModel.cs new file mode 100644 index 0000000..72636b7 --- /dev/null +++ b/CarRepairShop/CarRepairShopDataModels/IShopModel.cs @@ -0,0 +1,12 @@ +using CarRepairShopDataModels.Models; + +namespace CarRepairShopDataModels +{ + public interface IShopModel : IId + { + string ShopName { get; } + string Address { get; } + DateTime DateOpen { get; } + Dictionary ShopRepairs { get; } + } +} diff --git a/CarRepairShop/CarRepairShopListImplement/DataListSingleton.cs b/CarRepairShop/CarRepairShopListImplement/DataListSingleton.cs index d2f576d..d38839e 100644 --- a/CarRepairShop/CarRepairShopListImplement/DataListSingleton.cs +++ b/CarRepairShop/CarRepairShopListImplement/DataListSingleton.cs @@ -8,11 +8,13 @@ namespace CarRepairShopListImplement public List Components { get; set; } public List Orders { get; set; } public List Repairs { get; set; } + public List Shops { get; set; } private DataListSingleton() { Components = new List(); Orders = new List(); Repairs = new List(); + Shops = new List(); } public static DataListSingleton GetInstance() { diff --git a/CarRepairShop/CarRepairShopListImplement/Implements/ShopStorage.cs b/CarRepairShop/CarRepairShopListImplement/Implements/ShopStorage.cs new file mode 100644 index 0000000..825579a --- /dev/null +++ b/CarRepairShop/CarRepairShopListImplement/Implements/ShopStorage.cs @@ -0,0 +1,135 @@ +using CarRepairShopContracts.BindingModels; +using CarRepairShopContracts.SearchModels; +using CarRepairShopContracts.StoragesContracts; +using CarRepairShopContracts.ViewModels; +using CarRepairShopDataModels.Models; +using CarRepairShopListImplement.Models; + +namespace CarRepairShopListImplement.Implements +{ + public class ShopStorage : IShopStorage + { + private readonly DataListSingleton _source; + public ShopStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var shop in _source.Shops) + { + result.Add(shop.GetViewModel); + } + return result; + } + public List GetFilteredList(ShopSearchModel + model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.Name)) + { + return result; + } + foreach (var shop in _source.Shops) + { + if (shop.ShopName.Contains(model.Name)) + { + result.Add(shop.GetViewModel); + } + } + return result; + } + public ShopViewModel? GetElement(ShopSearchModel model) + { + if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue) + { + return null; + } + foreach (var shop in _source.Shops) + { + if ((!string.IsNullOrEmpty(model.Name) && + shop.ShopName == model.Name) || + (model.Id.HasValue && shop.Id == model.Id)) + { + return shop.GetViewModel; + } + } + return null; + } + public ShopViewModel? Insert(ShopBindingModel model) + { + model.Id = 1; + foreach (var shop in _source.Shops) + { + if (model.Id <= shop.Id) + { + model.Id = shop.Id + 1; + } + } + var newShop = Shop.Create(model); + if (newShop == null) + { + return null; + } + _source.Shops.Add(newShop); + return newShop.GetViewModel; + } + public ShopViewModel? Update(ShopBindingModel model) + { + foreach (var shop in _source.Shops) + { + if (shop.Id == model.Id) + { + shop.Update(model); + return shop.GetViewModel; + } + } + return null; + } + public ShopViewModel? Delete(ShopBindingModel model) + { + for (int i = 0; i < _source.Shops.Count; ++i) + { + if (_source.Shops[i].Id == model.Id) + { + var element = _source.Shops[i]; + _source.Shops.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + + public bool SupplyRepair(ShopSearchModel model, IRepairModel repair, int count) + { + if (model == null) + throw new ArgumentNullException(nameof(model)); + if (repair == null) + throw new ArgumentNullException(nameof(repair)); + if (count <= 0) + throw new ArgumentNullException("Количество должно быть положительным числом"); + + ShopViewModel curModel = GetElement(model); + if (curModel == null) + throw new ArgumentNullException(nameof(curModel)); + if (curModel.ShopRepairs.TryGetValue(repair.Id, out var pair)) + { + curModel.ShopRepairs[repair.Id] = (pair.Item1, pair.Item2 + count); + } + else + { + curModel.ShopRepairs.Add(repair.Id, (repair, count)); + } + Update(new() + { + Id = curModel.Id, + ShopName = curModel.ShopName, + DateOpen = curModel.DateOpen, + Address = curModel.Address, + ShopRepairs = curModel.ShopRepairs, + }); + return true; + } + } +} diff --git a/CarRepairShop/CarRepairShopListImplement/Models/Shop.cs b/CarRepairShop/CarRepairShopListImplement/Models/Shop.cs new file mode 100644 index 0000000..c31b36a --- /dev/null +++ b/CarRepairShop/CarRepairShopListImplement/Models/Shop.cs @@ -0,0 +1,51 @@ +using CarRepairShopContracts.BindingModels; +using CarRepairShopContracts.ViewModels; +using CarRepairShopDataModels; +using CarRepairShopDataModels.Models; + +namespace CarRepairShopListImplement.Models +{ + public class Shop : IShopModel + { + public int Id { get; private set; } + public string ShopName { get; private set; } + public string Address { get; private set; } + public DateTime DateOpen { get; private set; } + public Dictionary ShopRepairs { get; private set; } = new(); + + public static Shop? Create(ShopBindingModel model) + { + if (model == null) + return null; + return new Shop() + { + Id = model.Id, + ShopName = model.ShopName, + Address = model.Address, + DateOpen = model.DateOpen, + ShopRepairs = new() + }; + } + + public void Update(ShopBindingModel? model) + { + if (model == null) + { + return; + } + ShopName = model.ShopName; + Address = model.Address; + DateOpen = model.DateOpen; + ShopRepairs = model.ShopRepairs; + } + + public ShopViewModel GetViewModel => new() + { + Id = Id, + ShopName = ShopName, + Address = Address, + DateOpen = DateOpen, + ShopRepairs = ShopRepairs + }; + } +} From 5a3c0887430a5ec3b3098e60603f8f0d55460b1c Mon Sep 17 00:00:00 2001 From: Yunusov_Niyaz Date: Mon, 19 Feb 2024 21:19:00 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=BE(=D1=81?= =?UTF-8?q?=D0=B4=D0=B0=D0=BD=D0=BE)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CarRepairShop/CarRepairShop/FormShop.Designer.cs | 5 +++-- CarRepairShop/CarRepairShop/FormShops.Designer.cs | 1 + CarRepairShop/CarRepairShop/FormSupply.Designer.cs | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CarRepairShop/CarRepairShop/FormShop.Designer.cs b/CarRepairShop/CarRepairShop/FormShop.Designer.cs index 1bee047..121e3bd 100644 --- a/CarRepairShop/CarRepairShop/FormShop.Designer.cs +++ b/CarRepairShop/CarRepairShop/FormShop.Designer.cs @@ -136,11 +136,11 @@ Id.Visible = false; Id.Width = 125; // - // Name + // ShopName // ShopName.HeaderText = "Название"; ShopName.MinimumWidth = 6; - ShopName.Name = "Name"; + ShopName.Name = "ShopName"; ShopName.ReadOnly = true; ShopName.Width = 150; // @@ -176,6 +176,7 @@ Controls.Add(dateTimePicker); Margin = new Padding(3, 4, 3, 4); Name = "FormShop"; + StartPosition = FormStartPosition.CenterScreen; Text = "Магазин"; Load += FormShop_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); diff --git a/CarRepairShop/CarRepairShop/FormShops.Designer.cs b/CarRepairShop/CarRepairShop/FormShops.Designer.cs index 9b94d42..a98bfcd 100644 --- a/CarRepairShop/CarRepairShop/FormShops.Designer.cs +++ b/CarRepairShop/CarRepairShop/FormShops.Designer.cs @@ -103,6 +103,7 @@ Controls.Add(dataGridView); Margin = new Padding(3, 4, 3, 4); Name = "FormShops"; + StartPosition = FormStartPosition.CenterScreen; Text = "Магазины"; Load += FormShops_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); diff --git a/CarRepairShop/CarRepairShop/FormSupply.Designer.cs b/CarRepairShop/CarRepairShop/FormSupply.Designer.cs index 46504a5..2b20b8c 100644 --- a/CarRepairShop/CarRepairShop/FormSupply.Designer.cs +++ b/CarRepairShop/CarRepairShop/FormSupply.Designer.cs @@ -130,6 +130,7 @@ Controls.Add(comboBoxShop); Margin = new Padding(3, 4, 3, 4); Name = "FormSupply"; + StartPosition = FormStartPosition.CenterScreen; Text = "Поставки"; ResumeLayout(false); PerformLayout(); From 8ac1d44d0e5d4e7c828ce62fcb0294862d28dae1 Mon Sep 17 00:00:00 2001 From: Yunusov_Niyaz Date: Mon, 19 Feb 2024 21:54:30 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=BA=20=D0=BF=D1=83=D0=BB=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CarRepairShop/FormMain.Designer.cs | 38 ++++++------- .../CarRepairShop/FormRepair.Designer.cs | 54 +++++++++---------- CarRepairShop/CarRepairShop/FormRepair.resx | 2 +- .../CarRepairShop/FormShop.Designer.cs | 50 ++++++++--------- 4 files changed, 72 insertions(+), 72 deletions(-) diff --git a/CarRepairShop/CarRepairShop/FormMain.Designer.cs b/CarRepairShop/CarRepairShop/FormMain.Designer.cs index 8aae5b5..fd31f01 100644 --- a/CarRepairShop/CarRepairShop/FormMain.Designer.cs +++ b/CarRepairShop/CarRepairShop/FormMain.Designer.cs @@ -32,14 +32,14 @@ справочникиToolStripMenuItem = new ToolStripMenuItem(); компонентыToolStripMenuItem = new ToolStripMenuItem(); ремонтToolStripMenuItem = new ToolStripMenuItem(); + ShopsToolStripMenuItem = new ToolStripMenuItem(); + SupplyToolStripMenuItem = new ToolStripMenuItem(); dataGridView = new DataGridView(); buttonCreateOrder = new Button(); buttonTakeOrderInWork = new Button(); buttonOrderReady = new Button(); buttonIssuedOrder = new Button(); buttonRefresh = new Button(); - ShopsToolStripMenuItem = new ToolStripMenuItem(); - SupplyToolStripMenuItem = new ToolStripMenuItem(); menuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -52,7 +52,7 @@ menuStrip.Name = "menuStrip"; menuStrip.Size = new Size(1082, 28); menuStrip.TabIndex = 0; - menuStrip.Text = "menuStrip1"; + menuStrip.Text = "Меню справочников"; // // справочникиToolStripMenuItem // @@ -64,17 +64,31 @@ // компонентыToolStripMenuItem // компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - компонентыToolStripMenuItem.Size = new Size(224, 26); + компонентыToolStripMenuItem.Size = new Size(182, 26); компонентыToolStripMenuItem.Text = "Компоненты"; компонентыToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click; // // ремонтToolStripMenuItem // ремонтToolStripMenuItem.Name = "ремонтToolStripMenuItem"; - ремонтToolStripMenuItem.Size = new Size(224, 26); + ремонтToolStripMenuItem.Size = new Size(182, 26); ремонтToolStripMenuItem.Text = "Ремонт"; ремонтToolStripMenuItem.Click += RepairToolStripMenuItem_Click; // + // ShopsToolStripMenuItem + // + ShopsToolStripMenuItem.Name = "ShopsToolStripMenuItem"; + ShopsToolStripMenuItem.Size = new Size(182, 26); + ShopsToolStripMenuItem.Text = "Магазины"; + ShopsToolStripMenuItem.Click += ShopsToolStripMenuItem_Click; + // + // SupplyToolStripMenuItem + // + SupplyToolStripMenuItem.Name = "SupplyToolStripMenuItem"; + SupplyToolStripMenuItem.Size = new Size(182, 26); + SupplyToolStripMenuItem.Text = "Поставки"; + SupplyToolStripMenuItem.Click += SupplyToolStripMenuItem_Click; + // // dataGridView // dataGridView.AllowUserToAddRows = false; @@ -137,20 +151,6 @@ buttonRefresh.UseVisualStyleBackColor = true; buttonRefresh.Click += ButtonRef_Click; // - // ShopsToolStripMenuItem - // - ShopsToolStripMenuItem.Name = "ShopsToolStripMenuItem"; - ShopsToolStripMenuItem.Size = new Size(224, 26); - ShopsToolStripMenuItem.Text = "Магазины"; - ShopsToolStripMenuItem.Click += ShopsToolStripMenuItem_Click; - // - // SupplyToolStripMenuItem - // - SupplyToolStripMenuItem.Name = "SupplyToolStripMenuItem"; - SupplyToolStripMenuItem.Size = new Size(224, 26); - SupplyToolStripMenuItem.Text = "Поставки"; - SupplyToolStripMenuItem.Click += SupplyToolStripMenuItem_Click; - // // FormMain // AutoScaleDimensions = new SizeF(8F, 20F); diff --git a/CarRepairShop/CarRepairShop/FormRepair.Designer.cs b/CarRepairShop/CarRepairShop/FormRepair.Designer.cs index 2c252f7..14b77fc 100644 --- a/CarRepairShop/CarRepairShop/FormRepair.Designer.cs +++ b/CarRepairShop/CarRepairShop/FormRepair.Designer.cs @@ -36,13 +36,13 @@ buttonUpdate = new Button(); buttonAdd = new Button(); dataGridViewComponents = new DataGridView(); - id = new DataGridViewTextBoxColumn(); - ComponentNameColumn = new DataGridViewTextBoxColumn(); - CountColumn = new DataGridViewTextBoxColumn(); textBoxName = new TextBox(); textBoxCost = new TextBox(); buttonSave = new Button(); buttonCancel = new Button(); + ColumnId = new DataGridViewTextBoxColumn(); + ComponentNameColumn = new DataGridViewTextBoxColumn(); + CountColumn = new DataGridViewTextBoxColumn(); groupBoxComponents.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridViewComponents).BeginInit(); SuspendLayout(); @@ -123,7 +123,7 @@ // dataGridViewComponents.BackgroundColor = Color.White; dataGridViewComponents.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridViewComponents.Columns.AddRange(new DataGridViewColumn[] { id, ComponentNameColumn, CountColumn }); + dataGridViewComponents.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ComponentNameColumn, CountColumn }); dataGridViewComponents.Location = new Point(13, 23); dataGridViewComponents.Name = "dataGridViewComponents"; dataGridViewComponents.RowHeadersWidth = 51; @@ -131,28 +131,6 @@ dataGridViewComponents.Size = new Size(573, 274); dataGridViewComponents.TabIndex = 0; // - // id - // - id.HeaderText = ""; - id.MinimumWidth = 6; - id.Name = "id"; - id.Visible = false; - id.Width = 125; - // - // ComponentNameColumn - // - ComponentNameColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; - ComponentNameColumn.HeaderText = "Компонент"; - ComponentNameColumn.MinimumWidth = 320; - ComponentNameColumn.Name = "ComponentNameColumn"; - // - // CountColumn - // - CountColumn.HeaderText = "Количество"; - CountColumn.MinimumWidth = 6; - CountColumn.Name = "CountColumn"; - CountColumn.Width = 200; - // // textBoxName // textBoxName.Location = new Point(117, 18); @@ -188,6 +166,28 @@ buttonCancel.UseVisualStyleBackColor = true; buttonCancel.Click += ButtonCancel_Click; // + // ColumnId + // + ColumnId.HeaderText = "Идентификатор"; + ColumnId.MinimumWidth = 6; + ColumnId.Name = "ColumnId"; + ColumnId.Visible = false; + ColumnId.Width = 125; + // + // ComponentNameColumn + // + ComponentNameColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + ComponentNameColumn.HeaderText = "Компонент"; + ComponentNameColumn.MinimumWidth = 320; + ComponentNameColumn.Name = "ComponentNameColumn"; + // + // CountColumn + // + CountColumn.HeaderText = "Количество"; + CountColumn.MinimumWidth = 6; + CountColumn.Name = "CountColumn"; + CountColumn.Width = 200; + // // FormRepair // AutoScaleDimensions = new SizeF(8F, 20F); @@ -224,7 +224,7 @@ private TextBox textBoxCost; private Button buttonSave; private Button buttonCancel; - private DataGridViewTextBoxColumn id; + private DataGridViewTextBoxColumn ColumnId; private DataGridViewTextBoxColumn ComponentNameColumn; private DataGridViewTextBoxColumn CountColumn; } diff --git a/CarRepairShop/CarRepairShop/FormRepair.resx b/CarRepairShop/CarRepairShop/FormRepair.resx index 23f2d4a..16aedde 100644 --- a/CarRepairShop/CarRepairShop/FormRepair.resx +++ b/CarRepairShop/CarRepairShop/FormRepair.resx @@ -117,7 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + True diff --git a/CarRepairShop/CarRepairShop/FormShop.Designer.cs b/CarRepairShop/CarRepairShop/FormShop.Designer.cs index 121e3bd..c45f18f 100644 --- a/CarRepairShop/CarRepairShop/FormShop.Designer.cs +++ b/CarRepairShop/CarRepairShop/FormShop.Designer.cs @@ -37,10 +37,10 @@ buttonSave = new Button(); buttonCancel = new Button(); dataGridView = new DataGridView(); - Id = new DataGridViewTextBoxColumn(); + ColumnId = new DataGridViewTextBoxColumn(); ShopName = new DataGridViewTextBoxColumn(); - Cost = new DataGridViewTextBoxColumn(); - Count = new DataGridViewTextBoxColumn(); + ColumnCost = new DataGridViewTextBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); // @@ -120,7 +120,7 @@ // dataGridView // dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Columns.AddRange(new DataGridViewColumn[] { Id, ShopName, Cost, Count }); + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ShopName, ColumnCost, ColumnCount }); dataGridView.Location = new Point(14, 132); dataGridView.Margin = new Padding(3, 4, 3, 4); dataGridView.Name = "dataGridView"; @@ -128,13 +128,13 @@ dataGridView.Size = new Size(447, 200); dataGridView.TabIndex = 8; // - // Id + // ColumnId // - Id.HeaderText = "id"; - Id.MinimumWidth = 6; - Id.Name = "Id"; - Id.Visible = false; - Id.Width = 125; + ColumnId.HeaderText = "Идентификатор"; + ColumnId.MinimumWidth = 6; + ColumnId.Name = "ColumnId"; + ColumnId.Visible = false; + ColumnId.Width = 125; // // ShopName // @@ -144,21 +144,21 @@ ShopName.ReadOnly = true; ShopName.Width = 150; // - // Cost + // ColumnCost // - Cost.HeaderText = "Цена"; - Cost.MinimumWidth = 6; - Cost.Name = "Cost"; - Cost.ReadOnly = true; - Cost.Width = 125; + ColumnCost.HeaderText = "Цена"; + ColumnCost.MinimumWidth = 6; + ColumnCost.Name = "ColumnCost"; + ColumnCost.ReadOnly = true; + ColumnCost.Width = 125; // - // Count + // ColumnCount // - Count.HeaderText = "Количество"; - Count.MinimumWidth = 6; - Count.Name = "Count"; - Count.ReadOnly = true; - Count.Width = 125; + ColumnCount.HeaderText = "Количество"; + ColumnCount.MinimumWidth = 6; + ColumnCount.Name = "ColumnCount"; + ColumnCount.ReadOnly = true; + ColumnCount.Width = 125; // // FormShop // @@ -195,9 +195,9 @@ private Button buttonSave; private Button buttonCancel; private DataGridView dataGridView; - private DataGridViewTextBoxColumn Id; + private DataGridViewTextBoxColumn ColumnId; private DataGridViewTextBoxColumn ShopName; - private DataGridViewTextBoxColumn Cost; - private DataGridViewTextBoxColumn Count; + private DataGridViewTextBoxColumn ColumnCost; + private DataGridViewTextBoxColumn ColumnCount; } } \ No newline at end of file From 7f02b269a0bd6ec2bab9ddefc18703ae192e2655 Mon Sep 17 00:00:00 2001 From: Yunusov_Niyaz Date: Wed, 28 Feb 2024 17:04:10 +0400 Subject: [PATCH 4/5] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=BE,=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BD=D0=BE=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=BD=D0=BE=D1=81=D1=82=D1=8C=D1=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CarRepairShopBusinessLogic/ShopLogic.cs | 41 ++++++++++++++++++- .../StoragesContracts/IShopStorage.cs | 1 - .../Implements/ShopStorage.cs | 31 -------------- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/CarRepairShop/CarRepairShopBusinessLogic/ShopLogic.cs b/CarRepairShop/CarRepairShopBusinessLogic/ShopLogic.cs index d0b7201..877fd07 100644 --- a/CarRepairShop/CarRepairShopBusinessLogic/ShopLogic.cs +++ b/CarRepairShop/CarRepairShopBusinessLogic/ShopLogic.cs @@ -35,9 +35,46 @@ namespace CarRepairShopBusinessLogic public bool MakeSupply(ShopSearchModel model, IRepairModel repair, int count) { + _logger.LogInformation("Try to supply shop. ShopName:{ShopName}. Id:{Id}", model.Name, model.Id); if (model == null) - return false; - return _shopStorage.SupplyRepair(model, repair, count); + { + _logger.LogWarning("Read operation failed"); + throw new ArgumentNullException(nameof(model)); + } + if (repair == null) + { + _logger.LogWarning("Read operation failed"); + throw new ArgumentNullException(nameof(repair)); + } + if (count <= 0) + { + _logger.LogWarning("Read operation failed"); + throw new ArgumentNullException("Количество должно быть положительным числом"); + } + ShopViewModel curModel = ReadElement(model); + if (curModel == null) + { + _logger.LogWarning("Read operation failed"); + throw new ArgumentNullException(nameof(curModel)); + } + if (curModel.ShopRepairs.TryGetValue(repair.Id, out var pair)) + { + curModel.ShopRepairs[repair.Id] = (pair.Item1, pair.Item2 + count); + } + else + { + curModel.ShopRepairs.Add(repair.Id, (repair, count)); + } + Update(new() + { + Id = curModel.Id, + ShopName = curModel.ShopName, + DateOpen = curModel.DateOpen, + Address = curModel.Address, + ShopRepairs = curModel.ShopRepairs, + }); + _logger.LogInformation("Success. RepairName:{RepairName}. Id:{Id}. Supply:{count}", repair.RepairName, repair.Id, count); + return true; } public ShopViewModel ReadElement(ShopSearchModel model) diff --git a/CarRepairShop/CarRepairShopContracts/StoragesContracts/IShopStorage.cs b/CarRepairShop/CarRepairShopContracts/StoragesContracts/IShopStorage.cs index 91a81fc..18d5e95 100644 --- a/CarRepairShop/CarRepairShopContracts/StoragesContracts/IShopStorage.cs +++ b/CarRepairShop/CarRepairShopContracts/StoragesContracts/IShopStorage.cs @@ -13,6 +13,5 @@ namespace CarRepairShopContracts.StoragesContracts ShopViewModel? Insert(ShopBindingModel model); ShopViewModel? Update(ShopBindingModel model); ShopViewModel? Delete(ShopBindingModel model); - bool SupplyRepair(ShopSearchModel model, IRepairModel repair, int Count); } } diff --git a/CarRepairShop/CarRepairShopListImplement/Implements/ShopStorage.cs b/CarRepairShop/CarRepairShopListImplement/Implements/ShopStorage.cs index 825579a..470eba9 100644 --- a/CarRepairShop/CarRepairShopListImplement/Implements/ShopStorage.cs +++ b/CarRepairShop/CarRepairShopListImplement/Implements/ShopStorage.cs @@ -100,36 +100,5 @@ namespace CarRepairShopListImplement.Implements } return null; } - - public bool SupplyRepair(ShopSearchModel model, IRepairModel repair, int count) - { - if (model == null) - throw new ArgumentNullException(nameof(model)); - if (repair == null) - throw new ArgumentNullException(nameof(repair)); - if (count <= 0) - throw new ArgumentNullException("Количество должно быть положительным числом"); - - ShopViewModel curModel = GetElement(model); - if (curModel == null) - throw new ArgumentNullException(nameof(curModel)); - if (curModel.ShopRepairs.TryGetValue(repair.Id, out var pair)) - { - curModel.ShopRepairs[repair.Id] = (pair.Item1, pair.Item2 + count); - } - else - { - curModel.ShopRepairs.Add(repair.Id, (repair, count)); - } - Update(new() - { - Id = curModel.Id, - ShopName = curModel.ShopName, - DateOpen = curModel.DateOpen, - Address = curModel.Address, - ShopRepairs = curModel.ShopRepairs, - }); - return true; - } } } From c197ace73d5b559d22ce1c762333b973c47060e1 Mon Sep 17 00:00:00 2001 From: Yunusov_Niyaz Date: Sat, 2 Mar 2024 00:20:37 +0400 Subject: [PATCH 5/5] =?UTF-8?q?=D0=9F=D1=83=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CarRepairShop/CarRepairShop/FormMain.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CarRepairShop/CarRepairShop/FormMain.cs b/CarRepairShop/CarRepairShop/FormMain.cs index cd1c4ad..0aab82e 100644 --- a/CarRepairShop/CarRepairShop/FormMain.cs +++ b/CarRepairShop/CarRepairShop/FormMain.cs @@ -50,8 +50,8 @@ namespace CarRepairShop } private void RepairToolStripMenuItem_Click(object sender, EventArgs e) { - var service = Program.ServiceProvider?.GetService(typeof(FormRepair)); - if (service is FormRepair form) + var service = Program.ServiceProvider?.GetService(typeof(FormRepairs)); + if (service is FormRepairs form) { form.ShowDialog(); }