diff --git a/Pizzeria/PizzeriaView/DataGridViewExtension.cs b/Pizzeria/PizzeriaView/DataGridViewExtension.cs
index ce7d461..6ead3e6 100644
--- a/Pizzeria/PizzeriaView/DataGridViewExtension.cs
+++ b/Pizzeria/PizzeriaView/DataGridViewExtension.cs
@@ -1,7 +1,6 @@
using PizzeriaContracts.Attributes;
using System;
using System.Collections.Generic;
-
using System.Linq;
using System.Text;
using System.Threading.Tasks;
diff --git a/Pizzeria/PizzeriaView/FormClients.Designer.cs b/Pizzeria/PizzeriaView/FormClients.Designer.cs
index a195c27..1c033b5 100644
--- a/Pizzeria/PizzeriaView/FormClients.Designer.cs
+++ b/Pizzeria/PizzeriaView/FormClients.Designer.cs
@@ -1,33 +1,33 @@
-namespace Pizzeria
+namespace PizzeriaView
{
- partial class FormClients
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
+ 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);
- }
+ ///
+ /// 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
+ #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()
- {
+ ///
+ /// 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.buttonDel = new System.Windows.Forms.Button();
this.buttonRef = new System.Windows.Forms.Button();
@@ -36,59 +36,60 @@
//
// 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.Location = new System.Drawing.Point(1, 1);
- this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
+ this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Name = "dataGridView";
+ this.dataGridView.ReadOnly = true;
this.dataGridView.RowHeadersVisible = false;
- this.dataGridView.RowHeadersWidth = 51;
- this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
- this.dataGridView.Size = new System.Drawing.Size(569, 302);
+ this.dataGridView.Size = new System.Drawing.Size(350, 312);
this.dataGridView.TabIndex = 0;
//
// buttonDel
//
- this.buttonDel.Location = new System.Drawing.Point(584, 9);
- this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonDel.Location = new System.Drawing.Point(368, 12);
this.buttonDel.Name = "buttonDel";
- this.buttonDel.Size = new System.Drawing.Size(89, 22);
- this.buttonDel.TabIndex = 1;
+ this.buttonDel.Size = new System.Drawing.Size(75, 23);
+ this.buttonDel.TabIndex = 3;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
+ this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonRef
//
- this.buttonRef.Location = new System.Drawing.Point(584, 35);
- this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.buttonRef.Location = new System.Drawing.Point(368, 53);
this.buttonRef.Name = "buttonRef";
- this.buttonRef.Size = new System.Drawing.Size(89, 22);
- this.buttonRef.TabIndex = 2;
+ this.buttonRef.Size = new System.Drawing.Size(75, 23);
+ this.buttonRef.TabIndex = 4;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
+ this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// FormClients
//
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(684, 302);
+ this.ClientSize = new System.Drawing.Size(464, 312);
this.Controls.Add(this.buttonRef);
this.Controls.Add(this.buttonDel);
this.Controls.Add(this.dataGridView);
- this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormClients";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Клиенты";
+ this.Load += new System.EventHandler(this.FormClients_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
- }
+ }
- #endregion
+ #endregion
- private DataGridView dataGridView;
- private Button buttonDel;
- private Button buttonRef;
- }
+ private System.Windows.Forms.DataGridView dataGridView;
+ private System.Windows.Forms.Button buttonDel;
+ private System.Windows.Forms.Button buttonRef;
+ }
}
\ No newline at end of file
diff --git a/Pizzeria/PizzeriaView/FormClients.cs b/Pizzeria/PizzeriaView/FormClients.cs
index 681ff12..6f53349 100644
--- a/Pizzeria/PizzeriaView/FormClients.cs
+++ b/Pizzeria/PizzeriaView/FormClients.cs
@@ -1,70 +1,78 @@
-using PizzeriaContracts.BindingModels;
+using Microsoft.Extensions.Logging;
+using PizzeriaContracts.BindingModels;
using PizzeriaContracts.BusinessLogicsContracts;
-using Microsoft.Extensions.Logging;
-using PizzeriaView;
+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 Pizzeria
+namespace PizzeriaView
{
- public partial class FormClients : Form
- {
- private readonly ILogger _logger;
- private readonly IClientLogic _logic;
+ public partial class FormClients : Form
+ {
+ private readonly ILogger _logger;
- public FormClients(ILogger logger, IClientLogic logic)
- {
- InitializeComponent();
- _logger = logger;
- _logic = logic;
- }
+ private readonly IClientLogic _logic;
- private void FormClients_Load(object sender, EventArgs e)
- {
- LoadData();
- }
+ public FormClients(ILogger logger, IClientLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
- private void LoadData()
- {
- try
- {
+ private void FormClients_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+
+ private void LoadData()
+ {
+ try
+ {
dataGridView.FillAndConfigGrid(_logic.ReadList(null));
_logger.LogInformation("Загрузка клиентов");
- }
- catch (Exception ex)
- {
- _logger.LogError(ex, "Ошибка загрузки клиентов");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
- }
- }
+ }
+ 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 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();
- }
- }
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
}
diff --git a/Pizzeria/PizzeriaView/FormClients.resx b/Pizzeria/PizzeriaView/FormClients.resx
index f298a7b..1af7de1 100644
--- a/Pizzeria/PizzeriaView/FormClients.resx
+++ b/Pizzeria/PizzeriaView/FormClients.resx
@@ -1,4 +1,64 @@
-
+
+
+
diff --git a/Pizzeria/PizzeriaView/FormComponents.cs b/Pizzeria/PizzeriaView/FormComponents.cs
index bf8fbf7..d63eac1 100644
--- a/Pizzeria/PizzeriaView/FormComponents.cs
+++ b/Pizzeria/PizzeriaView/FormComponents.cs
@@ -32,15 +32,8 @@ namespace PizzeriaView
{
try
{
- var list = _logic.ReadList(null);
- if (list != null)
- {
- dataGridView.DataSource = list;
- dataGridView.Columns["Id"].Visible = false;
- dataGridView.Columns["ComponentName"].AutoSizeMode =
- DataGridViewAutoSizeColumnMode.Fill;
- }
- _logger.LogInformation("Загрузка ингридиентов");
+ dataGridView.FillAndConfigGrid(_logic.ReadList(null));
+ _logger.LogInformation("Загрузка компонентов");
}
catch (Exception ex)
{
diff --git a/Pizzeria/PizzeriaView/FormMessages.Designer.cs b/Pizzeria/PizzeriaView/FormMessages.Designer.cs
index 136b1f9..ae8c15c 100644
--- a/Pizzeria/PizzeriaView/FormMessages.Designer.cs
+++ b/Pizzeria/PizzeriaView/FormMessages.Designer.cs
@@ -55,6 +55,7 @@
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormMessages";
this.Text = "Входящие письма";
+ this.Load += new System.EventHandler(this.FormMessages_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);