Готово

This commit is contained in:
Allllen4a 2024-02-25 11:53:53 +04:00
parent 2d616bea4a
commit c9a37b6da2
3 changed files with 120 additions and 106 deletions

View File

@ -28,86 +28,103 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
dataGridView = new DataGridView(); this.ToolsPanel = new System.Windows.Forms.Panel();
buttonAdd = new Button(); this.buttonRef = new System.Windows.Forms.Button();
buttonEdit = new Button(); this.buttonDel = new System.Windows.Forms.Button();
buttonDelete = new Button(); this.buttonUpd = new System.Windows.Forms.Button();
buttonUpdate = new Button(); this.buttonAdd = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); this.dataGridView = new System.Windows.Forms.DataGridView();
SuspendLayout(); this.ToolsPanel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
// //
// dataGridView // ToolsPanel
// //
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.ToolsPanel.Controls.Add(this.buttonRef);
dataGridView.Location = new Point(29, 28); this.ToolsPanel.Controls.Add(this.buttonDel);
dataGridView.Name = "dataGridView"; this.ToolsPanel.Controls.Add(this.buttonUpd);
dataGridView.RowHeadersWidth = 62; this.ToolsPanel.Controls.Add(this.buttonAdd);
dataGridView.RowTemplate.Height = 33; this.ToolsPanel.Location = new System.Drawing.Point(608, 12);
dataGridView.Size = new Size(471, 383); this.ToolsPanel.Name = "ToolsPanel";
dataGridView.TabIndex = 0; this.ToolsPanel.Size = new System.Drawing.Size(180, 426);
this.ToolsPanel.TabIndex = 3;
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(31, 206);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(126, 36);
this.buttonRef.TabIndex = 3;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// buttonDel
//
this.buttonDel.Location = new System.Drawing.Point(31, 142);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(126, 36);
this.buttonDel.TabIndex = 2;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonUpd
//
this.buttonUpd.Location = new System.Drawing.Point(31, 76);
this.buttonUpd.Name = "buttonUpd";
this.buttonUpd.Size = new System.Drawing.Size(126, 36);
this.buttonUpd.TabIndex = 1;
this.buttonUpd.Text = "Изменить";
this.buttonUpd.UseVisualStyleBackColor = true;
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
// //
// buttonAdd // buttonAdd
// //
buttonAdd.Location = new Point(540, 58); this.buttonAdd.Location = new System.Drawing.Point(31, 16);
buttonAdd.Name = "buttonAdd"; this.buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(202, 71); this.buttonAdd.Size = new System.Drawing.Size(126, 36);
buttonAdd.TabIndex = 1; this.buttonAdd.TabIndex = 0;
buttonAdd.Text = "Добавить"; this.buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true; this.buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click; this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
// //
// buttonEdit // dataGridView
// //
buttonEdit.Location = new Point(540, 140); this.dataGridView.AllowUserToAddRows = false;
buttonEdit.Name = "buttonEdit"; this.dataGridView.AllowUserToDeleteRows = false;
buttonEdit.Size = new Size(202, 71); this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
buttonEdit.TabIndex = 2; this.dataGridView.Location = new System.Drawing.Point(12, 12);
buttonEdit.Text = "Изменить"; this.dataGridView.Name = "dataGridView";
buttonEdit.UseVisualStyleBackColor = true; this.dataGridView.ReadOnly = true;
buttonEdit.Click += buttonEdit_Click; this.dataGridView.RowHeadersWidth = 51;
// this.dataGridView.RowTemplate.Height = 29;
// buttonDelete this.dataGridView.Size = new System.Drawing.Size(590, 426);
// this.dataGridView.TabIndex = 2;
buttonDelete.Location = new Point(540, 231);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(202, 71);
buttonDelete.TabIndex = 3;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += buttonDelete_Click;
//
// buttonUpdate
//
buttonUpdate.Location = new Point(540, 328);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(202, 71);
buttonUpdate.TabIndex = 4;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += buttonUpdate_Click;
// //
// FormPizzas // FormPizzas
// //
AutoScaleDimensions = new SizeF(10F, 25F); this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
ClientSize = new Size(800, 450); this.ClientSize = new System.Drawing.Size(800, 450);
Controls.Add(buttonUpdate); this.Controls.Add(this.ToolsPanel);
Controls.Add(buttonDelete); this.Controls.Add(this.dataGridView);
Controls.Add(buttonEdit); this.Name = "FormPizzas";
Controls.Add(buttonAdd); this.Text = "Пицца";
Controls.Add(dataGridView); this.Load += new System.EventHandler(this.FormPizza_Load);
Name = "FormPizzas"; this.ToolsPanel.ResumeLayout(false);
Text = "Пицца"; ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); this.ResumeLayout(false);
ResumeLayout(false);
} }
#endregion #endregion
private DataGridView dataGridView; private Panel ToolsPanel;
private Button buttonRef;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd; private Button buttonAdd;
private Button buttonEdit; private DataGridView dataGridView;
private Button buttonDelete;
private Button buttonUpdate;
} }
} }

View File

@ -1,15 +1,7 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using PizzeriaView;
using PizzeriaContracts.BindingModels; using PizzeriaContracts.BindingModels;
using PizzeriaContracts.BusinessLogicsContracts; using PizzeriaContracts.BusinessLogicsContracts;
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 PizzeriaView namespace PizzeriaView
{ {
@ -25,6 +17,11 @@ namespace PizzeriaView
_logic = logic; _logic = logic;
} }
private void FormPizza_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData() private void LoadData()
{ {
try try
@ -46,7 +43,8 @@ namespace PizzeriaView
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }
private void buttonAdd_Click(object sender, EventArgs e)
private void ButtonAdd_Click(object sender, EventArgs e)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormPizza)); var service = Program.ServiceProvider?.GetService(typeof(FormPizza));
if (service is FormPizza form) if (service is FormPizza form)
@ -57,9 +55,9 @@ namespace PizzeriaView
} }
} }
} }
private void buttonEdit_Click(object sender, EventArgs e)
{
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
var service = Program.ServiceProvider?.GetService(typeof(FormPizza)); var service = Program.ServiceProvider?.GetService(typeof(FormPizza));
@ -72,10 +70,9 @@ namespace PizzeriaView
} }
} }
} }
} }
private void buttonDelete_Click(object sender, EventArgs e) private void ButtonDel_Click(object sender, EventArgs e)
{ {
if (dataGridView.SelectedRows.Count == 1) if (dataGridView.SelectedRows.Count == 1)
{ {
@ -103,7 +100,7 @@ namespace PizzeriaView
} }
} }
private void buttonUpdate_Click(object sender, EventArgs e) private void ButtonRef_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->