diff --git a/AutoWorkshop/AutoWorkshopView.csproj b/AutoWorkshop/AutoWorkshopView.csproj
index fc1b320..3a78229 100644
--- a/AutoWorkshop/AutoWorkshopView.csproj
+++ b/AutoWorkshop/AutoWorkshopView.csproj
@@ -9,8 +9,11 @@
-
+
+
+
+
\ No newline at end of file
diff --git a/AutoWorkshop/Forms/FormRepairs.Designer.cs b/AutoWorkshop/Forms/FormRepairs.Designer.cs
new file mode 100644
index 0000000..d530879
--- /dev/null
+++ b/AutoWorkshop/Forms/FormRepairs.Designer.cs
@@ -0,0 +1,113 @@
+namespace AutoWorkshopView.Forms
+{
+ partial class FormRepairs
+ {
+ ///
+ /// 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();
+ AddButton = new Button();
+ UpdateButton = new Button();
+ DeleteButton = new Button();
+ RefreshButton = new Button();
+ ((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // DataGridView
+ //
+ DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ DataGridView.Location = new Point(12, 12);
+ DataGridView.Name = "DataGridView";
+ DataGridView.RowHeadersWidth = 51;
+ DataGridView.Size = new Size(379, 426);
+ DataGridView.TabIndex = 0;
+ //
+ // AddButton
+ //
+ AddButton.Location = new Point(397, 12);
+ AddButton.Name = "AddButton";
+ AddButton.Size = new Size(148, 29);
+ AddButton.TabIndex = 1;
+ AddButton.Text = "Добавить";
+ AddButton.UseVisualStyleBackColor = true;
+ AddButton.Click += AddButton_Click;
+ //
+ // UpdateButton
+ //
+ UpdateButton.Location = new Point(397, 47);
+ UpdateButton.Name = "UpdateButton";
+ UpdateButton.Size = new Size(148, 29);
+ UpdateButton.TabIndex = 2;
+ UpdateButton.Text = "Изменить";
+ UpdateButton.UseVisualStyleBackColor = true;
+ UpdateButton.Click += UpdateButton_Click;
+ //
+ // DeleteButton
+ //
+ DeleteButton.Location = new Point(397, 82);
+ DeleteButton.Name = "DeleteButton";
+ DeleteButton.Size = new Size(148, 29);
+ DeleteButton.TabIndex = 3;
+ DeleteButton.Text = "Удалить";
+ DeleteButton.UseVisualStyleBackColor = true;
+ DeleteButton.Click += DeleteButton_Click;
+ //
+ // RefreshButton
+ //
+ RefreshButton.Location = new Point(397, 117);
+ RefreshButton.Name = "RefreshButton";
+ RefreshButton.Size = new Size(148, 29);
+ RefreshButton.TabIndex = 4;
+ RefreshButton.Text = "Обновить";
+ RefreshButton.UseVisualStyleBackColor = true;
+ RefreshButton.Click += RefreshButton_Click;
+ //
+ // FormRepairs
+ //
+ AutoScaleDimensions = new SizeF(8F, 20F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(557, 450);
+ Controls.Add(RefreshButton);
+ Controls.Add(DeleteButton);
+ Controls.Add(UpdateButton);
+ Controls.Add(AddButton);
+ Controls.Add(DataGridView);
+ Name = "FormRepairs";
+ Text = "FormRepairs";
+ Load += FormRepairs_Load;
+ ((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private DataGridView DataGridView;
+ private Button AddButton;
+ private Button UpdateButton;
+ private Button DeleteButton;
+ private Button RefreshButton;
+ }
+}
\ No newline at end of file
diff --git a/AutoWorkshop/Forms/FormRepairs.cs b/AutoWorkshop/Forms/FormRepairs.cs
new file mode 100644
index 0000000..1032f63
--- /dev/null
+++ b/AutoWorkshop/Forms/FormRepairs.cs
@@ -0,0 +1,114 @@
+using AutoWorkshopContracts.BindingModels;
+using AutoWorkshopContracts.BusinessLogicContracts;
+using Microsoft.Extensions.Logging;
+
+namespace AutoWorkshopView.Forms
+{
+ public partial class FormRepairs : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IRepairLogic _logic;
+
+ public FormRepairs(ILogger Logger, IRepairLogic Logic)
+ {
+ InitializeComponent();
+
+ _logger = Logger;
+ _logic = Logic;
+ }
+
+ private void FormRepairs_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ try
+ {
+ var List = _logic.ReadList(null);
+
+ if (List != null)
+ {
+ DataGridView.DataSource = List;
+ DataGridView.Columns["Id"].Visible = false;
+ DataGridView.Columns["RepairName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ DataGridView.Columns["RepairComponents"].Visible = false;
+ }
+
+ _logger.LogInformation("Загрузка ремонта");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки ремонта");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void AddButton_Click(object sender, EventArgs e)
+ {
+ var Service = Program.ServiceProvider?.GetService(typeof(FormRepair));
+
+ if (Service is FormRepair Form)
+ {
+ if (Form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+
+ private void UpdateButton_Click(object sender, EventArgs e)
+ {
+ if (DataGridView.SelectedRows.Count == 1)
+ {
+ var Service = Program.ServiceProvider?.GetService(typeof(FormRepair));
+
+ if (Service is FormRepair Form)
+ {
+ var Temp = 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 DeleteButton_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 RepairBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+
+ 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/MainForm.cs b/AutoWorkshop/MainForm.cs
index 3a14f92..0df3bc2 100644
--- a/AutoWorkshop/MainForm.cs
+++ b/AutoWorkshop/MainForm.cs
@@ -59,11 +59,9 @@ namespace AutoWorkshopView
private void МороженноеStripMenuItem_Click(object sender, EventArgs e)
{
- var Service = Program.ServiceProvider?.GetService(typeof(FormRepair));
+ var Service = Program.ServiceProvider?.GetService(typeof(FormRepairs));
- //// FORMREPAIRS??
-
- if (Service is FormRepair Form)
+ if (Service is FormRepairs Form)
{
Form.ShowDialog();
}
diff --git a/AutoWorkshop/Program.cs b/AutoWorkshop/Program.cs
index f160524..60e854b 100644
--- a/AutoWorkshop/Program.cs
+++ b/AutoWorkshop/Program.cs
@@ -1,8 +1,11 @@
+using AutoWorkshopBusinessLogic.BusinessLogics;
using AutoWorkshopContracts.BusinessLogicContracts;
using AutoWorkshopContracts.StoragesContracts;
+using AutoWorkshopListImplement.Implements;
using AutoWorkshopView.Forms;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
namespace AutoWorkshopView
{
@@ -14,11 +17,12 @@ namespace AutoWorkshopView
[STAThread]
static void Main()
{
+ ApplicationConfiguration.Initialize();
+
var Services = new ServiceCollection();
ConfigureServices(Services);
- _serviceProvider = Services.BuildServiceProvider();
-
+ _serviceProvider = Services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService());
}
@@ -32,17 +36,17 @@ namespace AutoWorkshopView
Services.AddTransient();
Services.AddTransient();
- Services.AddTransient();
+ Services.AddTransient();
Services.AddTransient();
Services.AddTransient();
- Services.AddTransient();
+ Services.AddTransient();
Services.AddTransient();
- Services.AddTransient();
- Services.AddTransient();
- Services.AddTransient();
- Services.AddTransient();
- Services.AddTransient();
- Services.AddTransient();
+ Services.AddTransient();
+ Services.AddTransient();
+ Services.AddTransient();
+ Services.AddTransient();
+ Services.AddTransient();
+ Services.AddTransient();
}
}
}