diff --git a/LawFirm/LawFirm/FormBlanks.Designer.cs b/LawFirm/LawFirm/FormBlanks.Designer.cs
new file mode 100644
index 0000000..a56b183
--- /dev/null
+++ b/LawFirm/LawFirm/FormBlanks.Designer.cs
@@ -0,0 +1,114 @@
+namespace LawFirmView
+{
+ partial class FormBlanks
+ {
+ ///
+ /// 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.dataGridView = new System.Windows.Forms.DataGridView();
+ this.buttonAdd = new System.Windows.Forms.Button();
+ this.buttonEdit = new System.Windows.Forms.Button();
+ this.buttonDelete = new System.Windows.Forms.Button();
+ this.buttonUpdate = new System.Windows.Forms.Button();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(12, 12);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(507, 426);
+ this.dataGridView.TabIndex = 0;
+ //
+ // buttonAdd
+ //
+ this.buttonAdd.Location = new System.Drawing.Point(538, 12);
+ this.buttonAdd.Name = "buttonAdd";
+ this.buttonAdd.Size = new System.Drawing.Size(152, 29);
+ this.buttonAdd.TabIndex = 1;
+ this.buttonAdd.Text = "Добавить";
+ this.buttonAdd.UseVisualStyleBackColor = true;
+ this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
+ //
+ // buttonEdit
+ //
+ this.buttonEdit.Location = new System.Drawing.Point(538, 47);
+ this.buttonEdit.Name = "buttonEdit";
+ this.buttonEdit.Size = new System.Drawing.Size(152, 29);
+ this.buttonEdit.TabIndex = 2;
+ this.buttonEdit.Text = "Изменить";
+ this.buttonEdit.UseVisualStyleBackColor = true;
+ this.buttonEdit.Click += new System.EventHandler(this.buttonEdit_Click);
+ //
+ // buttonDelete
+ //
+ this.buttonDelete.Location = new System.Drawing.Point(538, 82);
+ this.buttonDelete.Name = "buttonDelete";
+ this.buttonDelete.Size = new System.Drawing.Size(152, 29);
+ this.buttonDelete.TabIndex = 3;
+ this.buttonDelete.Text = "Удалить";
+ this.buttonDelete.UseVisualStyleBackColor = true;
+ this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
+ //
+ // buttonUpdate
+ //
+ this.buttonUpdate.Location = new System.Drawing.Point(538, 409);
+ this.buttonUpdate.Name = "buttonUpdate";
+ this.buttonUpdate.Size = new System.Drawing.Size(152, 29);
+ this.buttonUpdate.TabIndex = 4;
+ this.buttonUpdate.Text = "Обновить";
+ this.buttonUpdate.UseVisualStyleBackColor = true;
+ this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
+ //
+ // FormBlanks
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(702, 450);
+ this.Controls.Add(this.buttonUpdate);
+ this.Controls.Add(this.buttonDelete);
+ this.Controls.Add(this.buttonEdit);
+ this.Controls.Add(this.buttonAdd);
+ this.Controls.Add(this.dataGridView);
+ this.Name = "FormBlanks";
+ this.Text = "Бланки";
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private DataGridView dataGridView;
+ private Button buttonAdd;
+ private Button buttonEdit;
+ private Button buttonDelete;
+ private Button buttonUpdate;
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirm/FormBlanks.cs b/LawFirm/LawFirm/FormBlanks.cs
new file mode 100644
index 0000000..4b9ed6e
--- /dev/null
+++ b/LawFirm/LawFirm/FormBlanks.cs
@@ -0,0 +1,114 @@
+using LawFirm;
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.BusinessLogicContracts;
+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 LawFirmView
+{
+ public partial class FormBlanks : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IBlankLogic _logic;
+
+ public FormBlanks(ILogger logger, IBlankLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormComponents_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["BlankName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ _logger.LogInformation("Загрузка бланков");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки бланков");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void buttonAdd_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormBlank));
+ if (service is FormBlank form)
+ {
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ private void buttonEdit_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormBlank));
+ if (service is FormBlank form)
+ {
+ form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ LoadData();
+ }
+ }
+ }
+ }
+
+ private void buttonUpdate_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 BlankBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления бланка");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+
+ }
+ }
+}
diff --git a/LawFirm/LawFirm/FormBlanks.resx b/LawFirm/LawFirm/FormBlanks.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/LawFirm/LawFirm/FormBlanks.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/LawFirm/LawFirm/FormMain.Designer.cs b/LawFirm/LawFirm/FormMain.Designer.cs
new file mode 100644
index 0000000..7289f5a
--- /dev/null
+++ b/LawFirm/LawFirm/FormMain.Designer.cs
@@ -0,0 +1,39 @@
+namespace LawFirmView
+{
+ partial class FormMain
+ {
+ ///
+ /// 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 = "FormMain";
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirm/FormMain.cs b/LawFirm/LawFirm/FormMain.cs
new file mode 100644
index 0000000..ed09cd4
--- /dev/null
+++ b/LawFirm/LawFirm/FormMain.cs
@@ -0,0 +1,20 @@
+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 LawFirmView
+{
+ public partial class FormMain : Form
+ {
+ public FormMain()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/LawFirm/LawFirm/LawFirmView.csproj b/LawFirm/LawFirm/LawFirmView.csproj
index b57c89e..cef0922 100644
--- a/LawFirm/LawFirm/LawFirmView.csproj
+++ b/LawFirm/LawFirm/LawFirmView.csproj
@@ -8,4 +8,12 @@
enable
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/LawFirm/LawFirm/Program.cs b/LawFirm/LawFirm/Program.cs
index 45182ca..837092a 100644
--- a/LawFirm/LawFirm/Program.cs
+++ b/LawFirm/LawFirm/Program.cs
@@ -1,7 +1,19 @@
+using LawFirmBusinessLogic.BusinessLogics;
+using LawFirmContracts.BusinessLogicContracts;
+using LawFirmContracts.StorageContracts;
+using LawFirmListImplements.Implements;
+using LawFirmView;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Logging;
+using NLog.Extensions.Logging;
+using System;
+
namespace LawFirm
{
internal static class Program
{
+ private static ServiceProvider? _serviceProvider;
+ public static ServiceProvider? ServiceProvider => _serviceProvider;
///
/// The main entry point for the application.
///
@@ -11,7 +23,35 @@ namespace LawFirm
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new Form1());
+
+ var services = new ServiceCollection();
+ ConfigureServices(services);
+ _serviceProvider = services.BuildServiceProvider();
+
+ Application.Run(_serviceProvider.GetRequiredService());
}
+
+ private static void ConfigureServices(ServiceCollection services)
+ {
+ services.AddLogging(option =>
+ {
+ option.SetMinimumLevel(LogLevel.Information);
+ option.AddNLog("nlog.config");
+ });
+ 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();
+ }
+
}
-}
\ No newline at end of file
+}
diff --git a/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs
index 2fc733b..1fc1e4c 100644
--- a/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs
+++ b/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs
@@ -13,7 +13,7 @@ using System.Threading.Tasks;
namespace LawFirmBusinessLogic.BusinessLogics
{
- internal class OrderLogic : IOrderLogic
+ public class OrderLogic : IOrderLogic
{
private readonly ILogger _logger;
private readonly IOrderStorage _orderStorage;
diff --git a/LawFirm/LawFirmBusinessLogic/LawFirmBusinessLogic.csproj b/LawFirm/LawFirmBusinessLogic/LawFirmBusinessLogic.csproj
index 426ab2e..8b32af9 100644
--- a/LawFirm/LawFirmBusinessLogic/LawFirmBusinessLogic.csproj
+++ b/LawFirm/LawFirmBusinessLogic/LawFirmBusinessLogic.csproj
@@ -8,6 +8,7 @@
+
diff --git a/LawFirm/LawFirmContracts/LawFirmContracts.csproj b/LawFirm/LawFirmContracts/LawFirmContracts.csproj
index 46ea406..89ab575 100644
--- a/LawFirm/LawFirmContracts/LawFirmContracts.csproj
+++ b/LawFirm/LawFirmContracts/LawFirmContracts.csproj
@@ -6,6 +6,10 @@
enable
+
+
+
+
diff --git a/LawFirm/LawFirmDataModels/LawFirmDataModels.csproj b/LawFirm/LawFirmDataModels/LawFirmDataModels.csproj
index 132c02c..da8492b 100644
--- a/LawFirm/LawFirmDataModels/LawFirmDataModels.csproj
+++ b/LawFirm/LawFirmDataModels/LawFirmDataModels.csproj
@@ -6,4 +6,8 @@
enable
+
+
+
+
diff --git a/LawFirm/LawFirmListImplements/LawFirmListImplements.csproj b/LawFirm/LawFirmListImplements/LawFirmListImplements.csproj
index 132c02c..77fe5b1 100644
--- a/LawFirm/LawFirmListImplements/LawFirmListImplements.csproj
+++ b/LawFirm/LawFirmListImplements/LawFirmListImplements.csproj
@@ -6,4 +6,9 @@
enable
+
+
+
+
+