From 2026569f00d9fefdc3ed3d5b05b4f552959099e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=BB=D0=B5=D0=BD=D0=B0=20=D0=91=D0=B0=D0=BA=D0=B0?= =?UTF-8?q?=D0=BB=D1=8C=D1=81=D0=BA=D0=B0=D1=8F?= Date: Wed, 8 May 2024 12:37:48 +0400 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D1=8B=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D0=B8=D1=81=D0=B0=20=D0=B8=20=D1=87=D0=B0=D1=81?= =?UTF-8?q?=D1=82=D0=B8=D1=87=D0=BD=D0=BE=20=D1=84=D0=BE=D1=80=D0=BC=D1=8B?= =?UTF-8?q?=20=D0=B8=D0=B0=D1=81=D1=82=D0=B5=D1=80=D0=B0=20=D0=B8=20=D1=81?= =?UTF-8?q?=D0=BF=D0=B5=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D0=B8=20=D0=BF=D0=BE=D0=B4=D0=BA=D0=BE=D1=80=D1=80=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BB=D0=B0=20=D0=B8?= =?UTF-8?q?=20=D0=B4=D0=BE=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BeautySalon/BeautySalon/FormMaster.cs | 3 ++- .../BeautySalon/FormService.Designer.cs | 1 + BeautySalon/BeautySalon/FormService.cs | 1 - .../BeautySalon/FormServices.Designer.cs | 1 + BeautySalon/BeautySalon/FormServices.cs | 23 +++++++------------ .../BeautySalon/FormSpecialisations.cs | 10 -------- 6 files changed, 12 insertions(+), 27 deletions(-) diff --git a/BeautySalon/BeautySalon/FormMaster.cs b/BeautySalon/BeautySalon/FormMaster.cs index 059ab7a..eea7340 100644 --- a/BeautySalon/BeautySalon/FormMaster.cs +++ b/BeautySalon/BeautySalon/FormMaster.cs @@ -15,7 +15,8 @@ namespace BeautySalon private readonly AbstractWorkWithStorage specialisationStorage; private readonly List specialisations; - public FormMaster(AbstractWorkWithStorage masterStorage, AbstractWorkWithStorage specialisationStorage) + public FormMaster(AbstractWorkWithStorage masterStorage, + AbstractWorkWithStorage specialisationStorage) { this.masterStorage = masterStorage; this.specialisationStorage = specialisationStorage; diff --git a/BeautySalon/BeautySalon/FormService.Designer.cs b/BeautySalon/BeautySalon/FormService.Designer.cs index 45e21ee..6f22245 100644 --- a/BeautySalon/BeautySalon/FormService.Designer.cs +++ b/BeautySalon/BeautySalon/FormService.Designer.cs @@ -95,6 +95,7 @@ // numericUpDownPrice // numericUpDownPrice.Location = new Point(177, 140); + numericUpDownPrice.Maximum = new decimal(new int[] { 100000, 0, 0, 0 }); numericUpDownPrice.Name = "numericUpDownPrice"; numericUpDownPrice.Size = new Size(290, 27); numericUpDownPrice.TabIndex = 12; diff --git a/BeautySalon/BeautySalon/FormService.cs b/BeautySalon/BeautySalon/FormService.cs index 9f0a21d..2aecee7 100644 --- a/BeautySalon/BeautySalon/FormService.cs +++ b/BeautySalon/BeautySalon/FormService.cs @@ -77,7 +77,6 @@ namespace BeautySalon var serviceObject = serviceStorage.GetObject(_id.Value); if (serviceObject != null) { - comboBoxSpecialisation.SelectedItem = serviceObject; textBoxName.Text = serviceObject.ServiceName; numericUpDownPrice.Value = (decimal)serviceObject.Price; } diff --git a/BeautySalon/BeautySalon/FormServices.Designer.cs b/BeautySalon/BeautySalon/FormServices.Designer.cs index e95385a..e4aa452 100644 --- a/BeautySalon/BeautySalon/FormServices.Designer.cs +++ b/BeautySalon/BeautySalon/FormServices.Designer.cs @@ -37,6 +37,7 @@ // // dataGridView // + dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; dataGridView.BackgroundColor = SystemColors.ActiveCaption; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.Dock = DockStyle.Left; diff --git a/BeautySalon/BeautySalon/FormServices.cs b/BeautySalon/BeautySalon/FormServices.cs index 92850eb..c241036 100644 --- a/BeautySalon/BeautySalon/FormServices.cs +++ b/BeautySalon/BeautySalon/FormServices.cs @@ -1,14 +1,5 @@ using BeautySalonDBModels.Models; using BeautySalonDBModels; -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; using BeautySalonDBModels.Implements; namespace BeautySalon @@ -40,6 +31,7 @@ namespace BeautySalon if (dataGridView.ColumnCount == 0) { + dataGridView.Columns.Add("ServiceId", "ID"); dataGridView.Columns.Add("ServiceName", "Название"); dataGridView.Columns.Add("Specialisation", "Специализация"); dataGridView.Columns.Add("Price", "Цена"); @@ -48,8 +40,9 @@ namespace BeautySalon foreach (Service service in services) { string specialisationName = mdb.GetNameSpecialisation(service); - dataGridView.Rows.Add(service.ServiceName, specialisationName, service.Price); + dataGridView.Rows.Add(service.ServiceId, service.ServiceName, specialisationName, service.Price); } + dataGridView.Columns["ServiceId"].Visible = false; } private void buttonCreate_Click(object sender, EventArgs e) @@ -69,10 +62,10 @@ namespace BeautySalon var service = Program.ServiceProvider?.GetService(typeof(FormService)); if (service is FormService form) { + int rowIndex = dataGridView.CurrentCell.RowIndex; + form.Id = (int)dataGridView.Rows[rowIndex].Cells["ServiceId"].Value; if (form.ShowDialog() == DialogResult.OK) { - int rowIndex = dataGridView.CurrentCell.RowIndex; - form.Id = (int)dataGridView.Rows[rowIndex].Cells["ServiceId"].Value; LoadData(); } } @@ -80,10 +73,10 @@ namespace BeautySalon private void buttonDelete_Click(object sender, EventArgs e) { - if(dataGridView.SelectedRows.Count == 1) + if (dataGridView.SelectedRows.Count == 1) { - int rowIndex = dataGridView.CurrentCell.RowIndex; - serviceStorage.Remove(rowIndex); + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ServiceId"].Value); + serviceStorage.Remove(id); LoadData(); } } diff --git a/BeautySalon/BeautySalon/FormSpecialisations.cs b/BeautySalon/BeautySalon/FormSpecialisations.cs index 75d2a14..b1c51f1 100644 --- a/BeautySalon/BeautySalon/FormSpecialisations.cs +++ b/BeautySalon/BeautySalon/FormSpecialisations.cs @@ -1,15 +1,5 @@ using BeautySalonDBModels; -using BeautySalonDBModels.Implements; using BeautySalonDBModels.Models; -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 BeautySalon {