diff --git a/SoftwareInstallation/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/ClientLogic.cs b/SoftwareInstallation/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/ClientLogic.cs
index 2805e0c..55d329d 100644
--- a/SoftwareInstallation/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/ClientLogic.cs
+++ b/SoftwareInstallation/AbstractSoftwareInstallationBusinessLogic/BusinessLogic/ClientLogic.cs
@@ -114,6 +114,10 @@ namespace AbstractSoftwareInstallationBusinessLogic.BusinessLogic
{
throw new InvalidOperationException("Такой клиент уже есть");
}
+ if (element != null && element.Email != model.Email)
+ {
+ throw new InvalidOperationException("Такой клиент уже есть");
+ }
}
}
}
diff --git a/SoftwareInstallation/SoftwareInstallation/FormClients.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormClients.Designer.cs
new file mode 100644
index 0000000..10a30f7
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormClients.Designer.cs
@@ -0,0 +1,94 @@
+namespace SoftwareInstallationView
+{
+ partial class FormClients
+ {
+ ///
+ /// 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.buttonRef = new System.Windows.Forms.Button();
+ this.buttonDel = new System.Windows.Forms.Button();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // buttonRef
+ //
+ this.buttonRef.Location = new System.Drawing.Point(429, 80);
+ this.buttonRef.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ this.buttonRef.Name = "buttonRef";
+ this.buttonRef.Size = new System.Drawing.Size(97, 27);
+ this.buttonRef.TabIndex = 7;
+ this.buttonRef.Text = "Обновить";
+ this.buttonRef.UseVisualStyleBackColor = true;
+ //
+ // buttonDel
+ //
+ this.buttonDel.Location = new System.Drawing.Point(429, 33);
+ this.buttonDel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ this.buttonDel.Name = "buttonDel";
+ this.buttonDel.Size = new System.Drawing.Size(97, 27);
+ this.buttonDel.TabIndex = 6;
+ this.buttonDel.Text = "Удалить";
+ this.buttonDel.UseVisualStyleBackColor = true;
+ //
+ // dataGridView
+ //
+ this.dataGridView.AllowUserToAddRows = false;
+ this.dataGridView.AllowUserToDeleteRows = false;
+ this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
+ this.dataGridView.Location = new System.Drawing.Point(0, 0);
+ this.dataGridView.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.ReadOnly = true;
+ this.dataGridView.RowHeadersVisible = false;
+ this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
+ this.dataGridView.Size = new System.Drawing.Size(408, 450);
+ this.dataGridView.TabIndex = 5;
+ //
+ // FormClients
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(543, 450);
+ this.Controls.Add(this.buttonRef);
+ this.Controls.Add(this.buttonDel);
+ this.Controls.Add(this.dataGridView);
+ this.Name = "FormClients";
+ this.Text = "FormClients";
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Button buttonRef;
+ private Button buttonDel;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/SoftwareInstallation/SoftwareInstallation/FormClients.cs b/SoftwareInstallation/SoftwareInstallation/FormClients.cs
new file mode 100644
index 0000000..f7a9ecb
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormClients.cs
@@ -0,0 +1,85 @@
+using AbstractSoftwareInstallationContracts.BindingModels;
+using AbstractSoftwareInstallationContracts.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 SoftwareInstallationView
+{
+ public partial class FormClients : Form
+ {
+ private readonly ILogger _logger;
+
+ private readonly IClientLogic _logic;
+
+ public FormClients(ILogger logger, IClientLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormClients_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["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ }
+ _logger.LogInformation("Загрузка клиентов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки клиентов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void ButtonDel_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);
+ try
+ {
+ if (!_logic.Delete(new ClientBindingModel { Id = id }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+ _logger.LogInformation("Удаление клиента");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления клиента");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ LoadData();
+ }
+ }
+ }
+
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ }
+}
diff --git a/SoftwareInstallation/SoftwareInstallation/FormClients.resx b/SoftwareInstallation/SoftwareInstallation/FormClients.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/SoftwareInstallation/SoftwareInstallation/FormClients.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/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs
index 0e71a19..c93deac 100644
--- a/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs
+++ b/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs
@@ -40,6 +40,7 @@ namespace SoftwareInstallationView
this.guideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.reportsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.packageToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
+ this.clientToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.storageToolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem();
this.packagesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.ordersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
@@ -124,7 +125,7 @@ namespace SoftwareInstallationView
//
this.guideToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.packageToolStripMenuItem2,
- this.storageToolStripMenuItem3});
+ this.storageToolStripMenuItem3, this.clientToolStripMenuItem});
this.guideToolStripMenuItem.Name = "guideToolStripMenuItem";
this.guideToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
this.guideToolStripMenuItem.Text = "Справочники";
@@ -167,6 +168,13 @@ namespace SoftwareInstallationView
this.packageToolStripMenuItem2.Text = "Пакеты";
this.packageToolStripMenuItem2.Click += new System.EventHandler(this.packageToolStripMenuItem_Click);
//
+ // clientToolStripMenuItem
+ //
+ this.clientToolStripMenuItem.Name = "clientToolStripMenuItem";
+ this.clientToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.clientToolStripMenuItem.Text = "Клиенты";
+ this.clientToolStripMenuItem.Click += new System.EventHandler(this.clientToolStripMenuItem_Click);
+ //
// storageToolStripMenuItem3
//
this.storageToolStripMenuItem3.Name = "storageToolStripMenuItem3";
@@ -208,6 +216,7 @@ namespace SoftwareInstallationView
private MenuStrip menuStrip1;
private ToolStripMenuItem guideToolStripMenuItem;
private ToolStripMenuItem packageToolStripMenuItem2;
+ private ToolStripMenuItem clientToolStripMenuItem;
private ToolStripMenuItem storageToolStripMenuItem3;
private ToolStripMenuItem reportsToolStripMenuItem;
private ToolStripMenuItem packagesToolStripMenuItem;
diff --git a/SoftwareInstallation/SoftwareInstallation/FormMain.cs b/SoftwareInstallation/SoftwareInstallation/FormMain.cs
index a73f022..18d4b0a 100644
--- a/SoftwareInstallation/SoftwareInstallation/FormMain.cs
+++ b/SoftwareInstallation/SoftwareInstallation/FormMain.cs
@@ -188,5 +188,14 @@ namespace SoftwareInstallationView
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
+
+ private void clientToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormClients));
+ if (service is FormClients form)
+ {
+ form.ShowDialog();
+ }
+ }
}
}
diff --git a/SoftwareInstallation/SoftwareInstallation/Program.cs b/SoftwareInstallation/SoftwareInstallation/Program.cs
index d7433f6..1ac1217 100644
--- a/SoftwareInstallation/SoftwareInstallation/Program.cs
+++ b/SoftwareInstallation/SoftwareInstallation/Program.cs
@@ -35,10 +35,12 @@ namespace SoftwareInstallation
option.SetMinimumLevel(LogLevel.Information);
option.AddNLog("nlog.config");
});
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
@@ -49,6 +51,7 @@ namespace SoftwareInstallation
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();