diff --git a/AutoWorkshop/Form1.Designer.cs b/AutoWorkshop/Form1.Designer.cs
deleted file mode 100644
index 3c9cb85..0000000
--- a/AutoWorkshop/Form1.Designer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-namespace AutoWorkshopView
-{
- partial class Form1
- {
- ///
- /// 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()
- {
- this.components = new System.ComponentModel.Container();
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Text = "Form1";
- }
-
- #endregion
- }
-}
diff --git a/AutoWorkshop/Form1.cs b/AutoWorkshop/Form1.cs
deleted file mode 100644
index d447399..0000000
--- a/AutoWorkshop/Form1.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace AutoWorkshopView
-{
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- }
-}
diff --git a/AutoWorkshop/MainForm.Designer.cs b/AutoWorkshop/MainForm.Designer.cs
new file mode 100644
index 0000000..88a9258
--- /dev/null
+++ b/AutoWorkshop/MainForm.Designer.cs
@@ -0,0 +1,179 @@
+namespace AutoWorkshopView
+{
+ partial class MainForm
+ {
+ ///
+ /// 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()
+ {
+ MenuStrip = new MenuStrip();
+ ToolStripMenu = new ToolStripMenuItem();
+ ComponentsStripMenuItem = new ToolStripMenuItem();
+ RepairStripMenuItem = new ToolStripMenuItem();
+ DataGridView = new DataGridView();
+ CreateOrderButton = new Button();
+ TakeInWorkButton = new Button();
+ ReadyButton = new Button();
+ IssuedButton = new Button();
+ RefreshButton = new Button();
+ MenuStrip.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // MenuStrip
+ //
+ MenuStrip.ImageScalingSize = new Size(20, 20);
+ MenuStrip.Items.AddRange(new ToolStripItem[] { ToolStripMenu });
+ MenuStrip.Location = new Point(0, 0);
+ MenuStrip.Name = "MenuStrip";
+ MenuStrip.Padding = new Padding(5, 2, 0, 2);
+ MenuStrip.Size = new Size(1134, 24);
+ MenuStrip.TabIndex = 0;
+ MenuStrip.Text = "menuStrip1";
+ //
+ // ToolStripMenu
+ //
+ ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { ComponentsStripMenuItem, RepairStripMenuItem });
+ ToolStripMenu.Name = "ToolStripMenu";
+ ToolStripMenu.Size = new Size(94, 20);
+ ToolStripMenu.Text = "Справочники";
+ //
+ // ComponentsStripMenuItem
+ //
+ ComponentsStripMenuItem.Name = "ComponentsStripMenuItem";
+ ComponentsStripMenuItem.Size = new Size(180, 22);
+ ComponentsStripMenuItem.Text = "Компоненты";
+ ComponentsStripMenuItem.Click += КомпонентыStripMenuItem_Click;
+ //
+ // RepairStripMenuItem
+ //
+ RepairStripMenuItem.Name = "RepairStripMenuItem";
+ RepairStripMenuItem.Size = new Size(180, 22);
+ RepairStripMenuItem.Text = "Мороженное";
+ RepairStripMenuItem.Click += МороженноеStripMenuItem_Click;
+ //
+ // DataGridView
+ //
+ DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ DataGridView.Location = new Point(10, 23);
+ DataGridView.Margin = new Padding(3, 2, 3, 2);
+ DataGridView.Name = "DataGridView";
+ DataGridView.RowHeadersWidth = 51;
+ DataGridView.Size = new Size(881, 305);
+ DataGridView.TabIndex = 1;
+ //
+ // CreateOrderButton
+ //
+ CreateOrderButton.Location = new Point(897, 23);
+ CreateOrderButton.Margin = new Padding(3, 2, 3, 2);
+ CreateOrderButton.Name = "CreateOrderButton";
+ CreateOrderButton.Size = new Size(227, 30);
+ CreateOrderButton.TabIndex = 2;
+ CreateOrderButton.Text = "Создать заказ";
+ CreateOrderButton.UseVisualStyleBackColor = true;
+ CreateOrderButton.Click += CreateOrderButton_Click;
+ //
+ // TakeInWorkButton
+ //
+ TakeInWorkButton.Location = new Point(897, 57);
+ TakeInWorkButton.Margin = new Padding(3, 2, 3, 2);
+ TakeInWorkButton.Name = "TakeInWorkButton";
+ TakeInWorkButton.Size = new Size(227, 30);
+ TakeInWorkButton.TabIndex = 3;
+ TakeInWorkButton.Text = "Отдать заказ в работу";
+ TakeInWorkButton.UseVisualStyleBackColor = true;
+ TakeInWorkButton.Click += TakeInWorkButton_Click;
+ //
+ // ReadyButton
+ //
+ ReadyButton.Location = new Point(897, 91);
+ ReadyButton.Margin = new Padding(3, 2, 3, 2);
+ ReadyButton.Name = "ReadyButton";
+ ReadyButton.Size = new Size(227, 30);
+ ReadyButton.TabIndex = 4;
+ ReadyButton.Text = "Заказ готов";
+ ReadyButton.UseVisualStyleBackColor = true;
+ ReadyButton.Click += ReadyButton_Click;
+ //
+ // IssuedButton
+ //
+ IssuedButton.Location = new Point(897, 125);
+ IssuedButton.Margin = new Padding(3, 2, 3, 2);
+ IssuedButton.Name = "IssuedButton";
+ IssuedButton.Size = new Size(227, 30);
+ IssuedButton.TabIndex = 5;
+ IssuedButton.Text = "Заказ выдан";
+ IssuedButton.UseVisualStyleBackColor = true;
+ IssuedButton.Click += IssuedButton_Click;
+ //
+ // RefreshButton
+ //
+ RefreshButton.Location = new Point(897, 159);
+ RefreshButton.Margin = new Padding(3, 2, 3, 2);
+ RefreshButton.Name = "RefreshButton";
+ RefreshButton.Size = new Size(227, 30);
+ RefreshButton.TabIndex = 6;
+ RefreshButton.Text = "Обновить";
+ RefreshButton.UseVisualStyleBackColor = true;
+ RefreshButton.Click += RefreshButton_Click;
+ //
+ // MainForm
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(1134, 338);
+ Controls.Add(RefreshButton);
+ Controls.Add(IssuedButton);
+ Controls.Add(ReadyButton);
+ Controls.Add(TakeInWorkButton);
+ Controls.Add(CreateOrderButton);
+ Controls.Add(DataGridView);
+ Controls.Add(MenuStrip);
+ MainMenuStrip = MenuStrip;
+ Margin = new Padding(3, 2, 3, 2);
+ Name = "MainForm";
+ Text = "MainForm";
+ Load += MainForm_Load;
+ MenuStrip.ResumeLayout(false);
+ MenuStrip.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private MenuStrip MenuStrip;
+ private ToolStripMenuItem ToolStripMenu;
+ private ToolStripMenuItem ComponentsStripMenuItem;
+ private ToolStripMenuItem RepairStripMenuItem;
+ private DataGridView DataGridView;
+ private Button CreateOrderButton;
+ private Button TakeInWorkButton;
+ private Button ReadyButton;
+ private Button IssuedButton;
+ private Button RefreshButton;
+ }
+}
\ No newline at end of file
diff --git a/AutoWorkshop/MainForm.cs b/AutoWorkshop/MainForm.cs
new file mode 100644
index 0000000..3a14f92
--- /dev/null
+++ b/AutoWorkshop/MainForm.cs
@@ -0,0 +1,184 @@
+using AutoWorkshopContracts.BindingModels;
+using AutoWorkshopContracts.BusinessLogicContracts;
+using AutoWorkshopDataModels.Enums;
+using AutoWorkshopView.Forms;
+using Microsoft.Extensions.Logging;
+
+namespace AutoWorkshopView
+{
+ public partial class MainForm : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderLogic _orderLogic;
+ public MainForm(ILogger Logger, IOrderLogic OrderLogic)
+ {
+ InitializeComponent();
+
+ _logger = Logger;
+ _orderLogic = OrderLogic;
+ }
+
+ private void КомпонентыStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var Service = Program.ServiceProvider?.GetService(typeof(FormComponents));
+
+ if (Service is FormComponents Form)
+ {
+ Form.ShowDialog();
+ }
+ }
+
+ private void MainForm_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка заказов");
+
+ try
+ {
+ var List = _orderLogic.ReadList(null);
+
+ if (List != null)
+ {
+ DataGridView.DataSource = List;
+ DataGridView.Columns["RepairId"].Visible = false;
+ DataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+
+ _logger.LogInformation("Загрузка заказов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки заказов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void МороженноеStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var Service = Program.ServiceProvider?.GetService(typeof(FormRepair));
+
+ //// FORMREPAIRS??
+
+ if (Service is FormRepair Form)
+ {
+ Form.ShowDialog();
+ }
+ }
+
+ private void CreateOrderButton_Click(object sender, EventArgs e)
+ {
+ var Service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
+
+ if (Service is FormCreateOrder Form)
+ {
+ Form.ShowDialog();
+ LoadData();
+ }
+ }
+
+ private OrderBindingModel CreateBindingModel(int id, bool isDone = false)
+ {
+ return new OrderBindingModel
+ {
+ Id = id,
+ RepairId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["RepairId"].Value),
+ Status = Enum.Parse(DataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
+ Count = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Count"].Value),
+ Sum = double.Parse(DataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
+ DateCreate = DateTime.Parse(DataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
+ };
+ }
+
+ private void TakeInWorkButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
+
+ try
+ {
+ var OperationResult = _orderLogic.TakeOrderInWork(CreateBindingModel(id));
+
+ if (!OperationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка передачи заказа в работу");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ }
+
+ private void ReadyButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
+
+ try
+ {
+ var OperationResult = _orderLogic.FinishOrder(CreateBindingModel(id));
+
+ if (!OperationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о готовности заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void IssuedButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
+
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
+
+ try
+ {
+ var OperationResult = _orderLogic.DeliveryOrder(CreateBindingModel(id));
+
+ if (!OperationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+
+ _logger.LogInformation("Заказ №{id} выдан", id);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о выдачи заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ private void RefreshButton_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/AutoWorkshop/Form1.resx b/AutoWorkshop/MainForm.resx
similarity index 91%
rename from AutoWorkshop/Form1.resx
rename to AutoWorkshop/MainForm.resx
index 1af7de1..cae68fc 100644
--- a/AutoWorkshop/Form1.resx
+++ b/AutoWorkshop/MainForm.resx
@@ -1,17 +1,17 @@
-
@@ -117,4 +117,7 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 17, 17
+
\ No newline at end of file