diff --git a/Confectionery/ConfectioneryView.csproj b/Confectionery/ConfectioneryView.csproj
index 13143a7..be2660d 100644
--- a/Confectionery/ConfectioneryView.csproj
+++ b/Confectionery/ConfectioneryView.csproj
@@ -26,6 +26,12 @@
+
+
+ Form
+
+
+
Always
diff --git a/Confectionery/FormMain.Designer.cs b/Confectionery/FormMain.Designer.cs
index f218479..4a45ec6 100644
--- a/Confectionery/FormMain.Designer.cs
+++ b/Confectionery/FormMain.Designer.cs
@@ -42,6 +42,7 @@
button2 = new Button();
button3 = new Button();
button4 = new Button();
+ clientsToolStripMenuItem = new ToolStripMenuItem();
menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
@@ -57,7 +58,7 @@
//
// справочникиToolStripMenuItem
//
- справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { pastryToolStripMenuItem, componentToolStripMenuItem });
+ справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { pastryToolStripMenuItem, componentToolStripMenuItem, clientsToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(94, 20);
справочникиToolStripMenuItem.Text = "Справочники";
@@ -65,14 +66,14 @@
// pastryToolStripMenuItem
//
pastryToolStripMenuItem.Name = "pastryToolStripMenuItem";
- pastryToolStripMenuItem.Size = new Size(145, 22);
+ pastryToolStripMenuItem.Size = new Size(180, 22);
pastryToolStripMenuItem.Text = "Изделия";
pastryToolStripMenuItem.Click += PastryToolStripMenuItem_Click;
//
// componentToolStripMenuItem
//
componentToolStripMenuItem.Name = "componentToolStripMenuItem";
- componentToolStripMenuItem.Size = new Size(145, 22);
+ componentToolStripMenuItem.Size = new Size(180, 22);
componentToolStripMenuItem.Text = "Компоненты";
componentToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
//
@@ -169,6 +170,13 @@
button4.UseVisualStyleBackColor = true;
button4.Click += ButtonRef_Click;
//
+ // clientsToolStripMenuItem
+ //
+ clientsToolStripMenuItem.Name = "clientsToolStripMenuItem";
+ clientsToolStripMenuItem.Size = new Size(180, 22);
+ clientsToolStripMenuItem.Text = "Клиенты";
+ clientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
+ //
// FormMain
//
AutoScaleDimensions = new SizeF(7F, 15F);
@@ -208,5 +216,6 @@
private ToolStripMenuItem pastriesToolStripMenuItem;
private ToolStripMenuItem pastryComponentsToolStripMenuItem;
private ToolStripMenuItem ordersToolStripMenuItem;
+ private ToolStripMenuItem clientsToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/Confectionery/FormMain.cs b/Confectionery/FormMain.cs
index 68e45e1..56e1b3a 100644
--- a/Confectionery/FormMain.cs
+++ b/Confectionery/FormMain.cs
@@ -34,8 +34,9 @@ namespace ConfectioneryView
dataGridView.DataSource = list;
dataGridView.Columns["Id"].HeaderText = " ";
dataGridView.Columns["PastryId"].Visible = false;
- dataGridView.Columns["PastryName"].AutoSizeMode =
- DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["ClientId"].Visible = false;
+ dataGridView.Columns["PastryName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+ dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation(" ");
}
@@ -184,5 +185,14 @@ namespace ConfectioneryView
form.ShowDialog();
}
}
+
+ private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormViewClients));
+ if (service is FormViewClients form)
+ {
+ form.ShowDialog();
+ }
+ }
}
}
\ No newline at end of file
diff --git a/Confectionery/FormViewClients.Designer.cs b/Confectionery/FormViewClients.Designer.cs
new file mode 100644
index 0000000..66b1efe
--- /dev/null
+++ b/Confectionery/FormViewClients.Designer.cs
@@ -0,0 +1,90 @@
+namespace ConfectioneryView
+{
+ partial class FormViewClients
+ {
+ ///
+ /// 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()
+ {
+ buttonRef = new Button();
+ buttonDel = new Button();
+ dataGridView = new DataGridView();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // buttonRef
+ //
+ buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ buttonRef.Location = new Point(626, 67);
+ buttonRef.Name = "buttonRef";
+ buttonRef.Size = new Size(90, 37);
+ buttonRef.TabIndex = 9;
+ buttonRef.Text = "Обновить";
+ buttonRef.UseVisualStyleBackColor = true;
+ buttonRef.Click += ButtonRef_Click;
+ //
+ // buttonDel
+ //
+ buttonDel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
+ buttonDel.Location = new Point(626, 12);
+ buttonDel.Name = "buttonDel";
+ buttonDel.Size = new Size(90, 33);
+ buttonDel.TabIndex = 8;
+ buttonDel.Text = "Удалить";
+ buttonDel.UseVisualStyleBackColor = true;
+ buttonDel.Click += ButtonDel_Click;
+ //
+ // dataGridView
+ //
+ dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(12, 12);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.Size = new Size(553, 302);
+ dataGridView.TabIndex = 5;
+ //
+ // FormViewClients
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(722, 319);
+ Controls.Add(buttonRef);
+ Controls.Add(buttonDel);
+ Controls.Add(dataGridView);
+ Name = "FormViewClients";
+ Text = "Просмотри и удаление клиентов";
+ Load += FormViewClients_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+
+ private Button buttonRef;
+ private Button buttonDel;
+ private DataGridView dataGridView;
+ }
+}
\ No newline at end of file
diff --git a/Confectionery/FormViewClients.cs b/Confectionery/FormViewClients.cs
new file mode 100644
index 0000000..0e522a5
--- /dev/null
+++ b/Confectionery/FormViewClients.cs
@@ -0,0 +1,84 @@
+using ConfectioneryContracts.BindingModels;
+using ConfectioneryContracts.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 ConfectioneryView
+{
+ public partial class FormViewClients : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IClientLogic _logic;
+ public FormViewClients(ILogger logger, IClientLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+ private void FormViewClients_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);
+ _logger.LogInformation("Удаление клиента");
+ try
+ {
+ if (!_logic.Delete(new ClientBindingModel
+ {
+ Id = id
+ }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления клиента");
+ MessageBox.Show(ex.Message, "Ошибка",
+ MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/Confectionery/FormViewClients.resx b/Confectionery/FormViewClients.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/Confectionery/FormViewClients.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/Confectionery/Program.cs b/Confectionery/Program.cs
index bd53f5f..6141356 100644
--- a/Confectionery/Program.cs
+++ b/Confectionery/Program.cs
@@ -40,10 +40,12 @@ namespace ConfectioneryView
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
@@ -58,6 +60,7 @@ namespace ConfectioneryView
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
}
}
}
\ No newline at end of file