From c9a37b6da2f12a7f97a5178136bd4cd4f1746592 Mon Sep 17 00:00:00 2001 From: Allllen4a Date: Sun, 25 Feb 2024 11:53:53 +0400 Subject: [PATCH] =?UTF-8?q?=D0=93=D0=BE=D1=82=D0=BE=D0=B2=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Pizzeria/PizzeriaView/FormPizzas.Designer.cs | 149 +++++++++++-------- Pizzeria/PizzeriaView/FormPizzas.cs | 27 ++-- Pizzeria/PizzeriaView/FormPizzas.resx | 50 +++---- 3 files changed, 120 insertions(+), 106 deletions(-) diff --git a/Pizzeria/PizzeriaView/FormPizzas.Designer.cs b/Pizzeria/PizzeriaView/FormPizzas.Designer.cs index eaeb961..23f97ae 100644 --- a/Pizzeria/PizzeriaView/FormPizzas.Designer.cs +++ b/Pizzeria/PizzeriaView/FormPizzas.Designer.cs @@ -28,86 +28,103 @@ /// private void InitializeComponent() { - dataGridView = new DataGridView(); - buttonAdd = new Button(); - buttonEdit = new Button(); - buttonDelete = new Button(); - buttonUpdate = new Button(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); + this.ToolsPanel = new System.Windows.Forms.Panel(); + this.buttonRef = new System.Windows.Forms.Button(); + this.buttonDel = new System.Windows.Forms.Button(); + this.buttonUpd = new System.Windows.Forms.Button(); + this.buttonAdd = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ToolsPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); // - // dataGridView + // ToolsPanel // - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(29, 28); - dataGridView.Name = "dataGridView"; - dataGridView.RowHeadersWidth = 62; - dataGridView.RowTemplate.Height = 33; - dataGridView.Size = new Size(471, 383); - dataGridView.TabIndex = 0; + this.ToolsPanel.Controls.Add(this.buttonRef); + this.ToolsPanel.Controls.Add(this.buttonDel); + this.ToolsPanel.Controls.Add(this.buttonUpd); + this.ToolsPanel.Controls.Add(this.buttonAdd); + this.ToolsPanel.Location = new System.Drawing.Point(608, 12); + this.ToolsPanel.Name = "ToolsPanel"; + 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.Location = new Point(540, 58); - buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(202, 71); - buttonAdd.TabIndex = 1; - buttonAdd.Text = "Добавить"; - buttonAdd.UseVisualStyleBackColor = true; - buttonAdd.Click += buttonAdd_Click; + this.buttonAdd.Location = new System.Drawing.Point(31, 16); + this.buttonAdd.Name = "buttonAdd"; + this.buttonAdd.Size = new System.Drawing.Size(126, 36); + this.buttonAdd.TabIndex = 0; + this.buttonAdd.Text = "Добавить"; + this.buttonAdd.UseVisualStyleBackColor = true; + this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); // - // buttonEdit + // dataGridView // - buttonEdit.Location = new Point(540, 140); - buttonEdit.Name = "buttonEdit"; - buttonEdit.Size = new Size(202, 71); - buttonEdit.TabIndex = 2; - buttonEdit.Text = "Изменить"; - buttonEdit.UseVisualStyleBackColor = true; - buttonEdit.Click += buttonEdit_Click; - // - // buttonDelete - // - 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; + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(12, 12); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(590, 426); + this.dataGridView.TabIndex = 2; // // FormPizzas // - AutoScaleDimensions = new SizeF(10F, 25F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); - Controls.Add(buttonUpdate); - Controls.Add(buttonDelete); - Controls.Add(buttonEdit); - Controls.Add(buttonAdd); - Controls.Add(dataGridView); - Name = "FormPizzas"; - Text = "Пицца"; - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.ToolsPanel); + this.Controls.Add(this.dataGridView); + this.Name = "FormPizzas"; + this.Text = "Пицца"; + this.Load += new System.EventHandler(this.FormPizza_Load); + this.ToolsPanel.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + } #endregion - private DataGridView dataGridView; + private Panel ToolsPanel; + private Button buttonRef; + private Button buttonDel; + private Button buttonUpd; private Button buttonAdd; - private Button buttonEdit; - private Button buttonDelete; - private Button buttonUpdate; + private DataGridView dataGridView; } } \ No newline at end of file diff --git a/Pizzeria/PizzeriaView/FormPizzas.cs b/Pizzeria/PizzeriaView/FormPizzas.cs index 5c9a449..4b1a3f8 100644 --- a/Pizzeria/PizzeriaView/FormPizzas.cs +++ b/Pizzeria/PizzeriaView/FormPizzas.cs @@ -1,15 +1,7 @@ using Microsoft.Extensions.Logging; +using PizzeriaView; using PizzeriaContracts.BindingModels; 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 { @@ -25,6 +17,11 @@ namespace PizzeriaView _logic = logic; } + private void FormPizza_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() { try @@ -46,7 +43,8 @@ namespace PizzeriaView 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)); 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) { 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) { @@ -103,7 +100,7 @@ namespace PizzeriaView } } - private void buttonUpdate_Click(object sender, EventArgs e) + private void ButtonRef_Click(object sender, EventArgs e) { LoadData(); } diff --git a/Pizzeria/PizzeriaView/FormPizzas.resx b/Pizzeria/PizzeriaView/FormPizzas.resx index af32865..1af7de1 100644 --- a/Pizzeria/PizzeriaView/FormPizzas.resx +++ b/Pizzeria/PizzeriaView/FormPizzas.resx @@ -1,17 +1,17 @@  -