From 29f130ecd43b3e3d07e780a4f677a60f8c7748e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9E=D0=BB=D0=B5=D0=B3=20=D0=9A=D1=83=D0=B4=D1=80=D0=B8?= =?UTF-8?q?=D0=BD=D1=81=D0=BA=D0=B8=D0=B9?= Date: Wed, 18 Dec 2024 22:37:58 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Forms/FormAssemblerShifts.Designer.cs | 44 ++++++------ .../Forms/FormAssemblerShifts.cs | 2 +- .../Forms/FormAssemblers.Designer.cs | 44 ++++++------ .../ProjectWorkshop/Forms/FormAssemblers.cs | 6 +- .../Forms/FormAssemblies.Designer.cs | 44 ++++++------ .../ProjectWorkshop/Forms/FormAssemblies.cs | 6 +- .../Forms/FormProducts.Designer.cs | 68 +++++++++---------- .../ProjectWorkshop/Forms/FormProducts.cs | 6 +- .../Forms/FormShifts.Designer.cs | 29 ++++++++ .../ProjectWorkshop/Forms/FormShifts.cs | 55 +++++++++++++++ 10 files changed, 194 insertions(+), 110 deletions(-) diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.Designer.cs index de46933..103e3e5 100644 --- a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.Designer.cs +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.Designer.cs @@ -30,9 +30,9 @@ { panel = new Panel(); buttonAdd = new Button(); - dataGridView = new DataGridView(); + dataGridViewAssemblerShifts = new DataGridView(); panel.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dataGridViewAssemblerShifts).BeginInit(); SuspendLayout(); // // panel @@ -55,37 +55,37 @@ buttonAdd.UseVisualStyleBackColor = true; buttonAdd.Click += ButtonAdd_Click; // - // dataGridView + // dataGridViewAssemblerShifts // - dataGridView.AllowUserToAddRows = false; - dataGridView.AllowUserToDeleteRows = false; - dataGridView.AllowUserToResizeColumns = false; - dataGridView.AllowUserToResizeRows = false; - dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Dock = DockStyle.Fill; - dataGridView.Location = new Point(0, 0); - dataGridView.MultiSelect = false; - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersVisible = false; - dataGridView.RowHeadersWidth = 82; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(1081, 783); - dataGridView.TabIndex = 1; + dataGridViewAssemblerShifts.AllowUserToAddRows = false; + dataGridViewAssemblerShifts.AllowUserToDeleteRows = false; + dataGridViewAssemblerShifts.AllowUserToResizeColumns = false; + dataGridViewAssemblerShifts.AllowUserToResizeRows = false; + dataGridViewAssemblerShifts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewAssemblerShifts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewAssemblerShifts.Dock = DockStyle.Fill; + dataGridViewAssemblerShifts.Location = new Point(0, 0); + dataGridViewAssemblerShifts.MultiSelect = false; + dataGridViewAssemblerShifts.Name = "dataGridViewAssemblerShifts"; + dataGridViewAssemblerShifts.ReadOnly = true; + dataGridViewAssemblerShifts.RowHeadersVisible = false; + dataGridViewAssemblerShifts.RowHeadersWidth = 82; + dataGridViewAssemblerShifts.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewAssemblerShifts.Size = new Size(1081, 783); + dataGridViewAssemblerShifts.TabIndex = 1; // // FormAssemblerShifts // AutoScaleDimensions = new SizeF(13F, 32F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(1346, 783); - Controls.Add(dataGridView); + Controls.Add(dataGridViewAssemblerShifts); Controls.Add(panel); Name = "FormAssemblerShifts"; Text = "Выходы на смену"; Load += FormAssemblerShifts_Load; panel.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ((System.ComponentModel.ISupportInitialize)dataGridViewAssemblerShifts).EndInit(); ResumeLayout(false); } @@ -93,6 +93,6 @@ private Panel panel; private Button buttonAdd; - private DataGridView dataGridView; + private DataGridView dataGridViewAssemblerShifts; } } \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.cs index f8eb37c..03c4eaa 100644 --- a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.cs +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblerShifts.cs @@ -49,6 +49,6 @@ namespace ProjectWorkshop.Forms MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - private void LoadList() => dataGridView.DataSource = _assemblerShiftRepository.ReadAssemblerShifts(); + private void LoadList() => dataGridViewAssemblerShifts.DataSource = _assemblerShiftRepository.ReadAssemblerShifts(); } } diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.Designer.cs index 103c281..1abef80 100644 --- a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.Designer.cs +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.Designer.cs @@ -32,9 +32,9 @@ buttonDel = new Button(); buttonUpd = new Button(); buttonAdd = new Button(); - dataGridView = new DataGridView(); + dataGridViewAssemblers = new DataGridView(); panel.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dataGridViewAssemblers).BeginInit(); SuspendLayout(); // // panel @@ -81,38 +81,38 @@ buttonAdd.UseVisualStyleBackColor = true; buttonAdd.Click += ButtonAdd_Click; // - // dataGridView + // dataGridViewAssemblers // - dataGridView.AllowUserToAddRows = false; - dataGridView.AllowUserToDeleteRows = false; - dataGridView.AllowUserToResizeColumns = false; - dataGridView.AllowUserToResizeRows = false; - dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Dock = DockStyle.Fill; - dataGridView.Location = new Point(0, 0); - dataGridView.MultiSelect = false; - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersVisible = false; - dataGridView.RowHeadersWidth = 82; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(1279, 850); - dataGridView.TabIndex = 1; + dataGridViewAssemblers.AllowUserToAddRows = false; + dataGridViewAssemblers.AllowUserToDeleteRows = false; + dataGridViewAssemblers.AllowUserToResizeColumns = false; + dataGridViewAssemblers.AllowUserToResizeRows = false; + dataGridViewAssemblers.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewAssemblers.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewAssemblers.Dock = DockStyle.Fill; + dataGridViewAssemblers.Location = new Point(0, 0); + dataGridViewAssemblers.MultiSelect = false; + dataGridViewAssemblers.Name = "dataGridViewAssemblers"; + dataGridViewAssemblers.ReadOnly = true; + dataGridViewAssemblers.RowHeadersVisible = false; + dataGridViewAssemblers.RowHeadersWidth = 82; + dataGridViewAssemblers.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewAssemblers.Size = new Size(1279, 850); + dataGridViewAssemblers.TabIndex = 1; // // FormAssemblers // AutoScaleDimensions = new SizeF(13F, 32F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(1592, 850); - Controls.Add(dataGridView); + Controls.Add(dataGridViewAssemblers); Controls.Add(panel); Name = "FormAssemblers"; StartPosition = FormStartPosition.CenterParent; Text = "Сборщики"; Load += FormAssemblers_Load; panel.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ((System.ComponentModel.ISupportInitialize)dataGridViewAssemblers).EndInit(); ResumeLayout(false); } @@ -122,6 +122,6 @@ private Button buttonDel; private Button buttonUpd; private Button buttonAdd; - private DataGridView dataGridView; + private DataGridView dataGridViewAssemblers; } } \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.cs index a4ad521..75509fd 100644 --- a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.cs +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblers.cs @@ -96,19 +96,19 @@ namespace ProjectWorkshop.Forms } } - private void LoadList() => dataGridView.DataSource = _assemblerRepository.ReadAssemblers(); + private void LoadList() => dataGridViewAssemblers.DataSource = _assemblerRepository.ReadAssemblers(); private bool TryGetIdentifierFromSelectedRow(out int id) { id = 0; - if (dataGridView.SelectedRows.Count < 1) + if (dataGridViewAssemblers.SelectedRows.Count < 1) { MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } - id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value); + id = Convert.ToInt32(dataGridViewAssemblers.SelectedRows[0].Cells["ID"].Value); return true; } } diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.Designer.cs index a321a64..2da87a3 100644 --- a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.Designer.cs +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.Designer.cs @@ -31,9 +31,9 @@ panel = new Panel(); buttonDel = new Button(); buttonAdd = new Button(); - dataGridView = new DataGridView(); + dataGridViewAssemblies = new DataGridView(); panel.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dataGridViewAssemblies).BeginInit(); SuspendLayout(); // // panel @@ -68,37 +68,37 @@ buttonAdd.UseVisualStyleBackColor = true; buttonAdd.Click += ButtonAdd_Click; // - // dataGridView + // dataGridViewAssemblies // - dataGridView.AllowUserToAddRows = false; - dataGridView.AllowUserToDeleteRows = false; - dataGridView.AllowUserToResizeColumns = false; - dataGridView.AllowUserToResizeRows = false; - dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Dock = DockStyle.Fill; - dataGridView.Location = new Point(0, 0); - dataGridView.MultiSelect = false; - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersVisible = false; - dataGridView.RowHeadersWidth = 82; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(1062, 798); - dataGridView.TabIndex = 1; + dataGridViewAssemblies.AllowUserToAddRows = false; + dataGridViewAssemblies.AllowUserToDeleteRows = false; + dataGridViewAssemblies.AllowUserToResizeColumns = false; + dataGridViewAssemblies.AllowUserToResizeRows = false; + dataGridViewAssemblies.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewAssemblies.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewAssemblies.Dock = DockStyle.Fill; + dataGridViewAssemblies.Location = new Point(0, 0); + dataGridViewAssemblies.MultiSelect = false; + dataGridViewAssemblies.Name = "dataGridViewAssemblies"; + dataGridViewAssemblies.ReadOnly = true; + dataGridViewAssemblies.RowHeadersVisible = false; + dataGridViewAssemblies.RowHeadersWidth = 82; + dataGridViewAssemblies.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewAssemblies.Size = new Size(1062, 798); + dataGridViewAssemblies.TabIndex = 1; // // FormAssemblies // AutoScaleDimensions = new SizeF(13F, 32F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(1341, 798); - Controls.Add(dataGridView); + Controls.Add(dataGridViewAssemblies); Controls.Add(panel); Name = "FormAssemblies"; Text = "Сборки"; Load += FormAssemblies_Load; panel.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ((System.ComponentModel.ISupportInitialize)dataGridViewAssemblies).EndInit(); ResumeLayout(false); } @@ -107,6 +107,6 @@ private Panel panel; private Button buttonDel; private Button buttonAdd; - private DataGridView dataGridView; + private DataGridView dataGridViewAssemblies; } } \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.cs index ea78441..766d9ba 100644 --- a/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.cs +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormAssemblies.cs @@ -74,18 +74,18 @@ namespace ProjectWorkshop.Forms } } - private void LoadList() => dataGridView.DataSource = _assemblyRepository.ReadAssemblies(); + private void LoadList() => dataGridViewAssemblies.DataSource = _assemblyRepository.ReadAssemblies(); private bool TryGetIdentifierFromSelectedRow(out int id) { id = 0; - if (dataGridView.SelectedRows.Count < 1) + if (dataGridViewAssemblies.SelectedRows.Count < 1) { MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } - id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value); + id = Convert.ToInt32(dataGridViewAssemblies.SelectedRows[0].Cells["ID"].Value); return true; } diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.Designer.cs index c41838c..9e2e13a 100644 --- a/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.Designer.cs +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.Designer.cs @@ -29,12 +29,12 @@ private void InitializeComponent() { panel = new Panel(); + buttonDel = new Button(); buttonUpd = new Button(); buttonAdd = new Button(); - dataGridView = new DataGridView(); - buttonDel = new Button(); + dataGridViewProducts = new DataGridView(); panel.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + ((System.ComponentModel.ISupportInitialize)dataGridViewProducts).BeginInit(); SuspendLayout(); // // panel @@ -48,6 +48,17 @@ panel.Size = new Size(257, 757); panel.TabIndex = 0; // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.minus; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(53, 535); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(150, 151); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // // buttonUpd // buttonUpd.BackgroundImage = Properties.Resources.pencil; @@ -70,48 +81,37 @@ buttonAdd.UseVisualStyleBackColor = true; buttonAdd.Click += ButtonAdd_Click; // - // dataGridView + // dataGridViewProducts // - dataGridView.AllowUserToAddRows = false; - dataGridView.AllowUserToDeleteRows = false; - dataGridView.AllowUserToResizeColumns = false; - dataGridView.AllowUserToResizeRows = false; - dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Dock = DockStyle.Fill; - dataGridView.Location = new Point(0, 0); - dataGridView.MultiSelect = false; - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersVisible = false; - dataGridView.RowHeadersWidth = 82; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(903, 757); - dataGridView.TabIndex = 1; - // - // buttonDel - // - buttonDel.BackgroundImage = Properties.Resources.pencil; - buttonDel.BackgroundImageLayout = ImageLayout.Stretch; - buttonDel.Location = new Point(53, 535); - buttonDel.Name = "buttonDel"; - buttonDel.Size = new Size(150, 151); - buttonDel.TabIndex = 2; - buttonDel.UseVisualStyleBackColor = true; - buttonDel.Click += ButtonDel_Click; + dataGridViewProducts.AllowUserToAddRows = false; + dataGridViewProducts.AllowUserToDeleteRows = false; + dataGridViewProducts.AllowUserToResizeColumns = false; + dataGridViewProducts.AllowUserToResizeRows = false; + dataGridViewProducts.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridViewProducts.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridViewProducts.Dock = DockStyle.Fill; + dataGridViewProducts.Location = new Point(0, 0); + dataGridViewProducts.MultiSelect = false; + dataGridViewProducts.Name = "dataGridViewProducts"; + dataGridViewProducts.ReadOnly = true; + dataGridViewProducts.RowHeadersVisible = false; + dataGridViewProducts.RowHeadersWidth = 82; + dataGridViewProducts.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridViewProducts.Size = new Size(903, 757); + dataGridViewProducts.TabIndex = 1; // // FormProducts // AutoScaleDimensions = new SizeF(13F, 32F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(1160, 757); - Controls.Add(dataGridView); + Controls.Add(dataGridViewProducts); Controls.Add(panel); Name = "FormProducts"; Text = "Изделия"; Load += FormProducts_Load; panel.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ((System.ComponentModel.ISupportInitialize)dataGridViewProducts).EndInit(); ResumeLayout(false); } @@ -120,7 +120,7 @@ private Panel panel; private Button buttonUpd; private Button buttonAdd; - private DataGridView dataGridView; + private DataGridView dataGridViewProducts; private Button buttonDel; } } \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.cs index 14aea98..3e6eecd 100644 --- a/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.cs +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormProducts.cs @@ -93,18 +93,18 @@ namespace ProjectWorkshop.Forms } } - private void LoadList() => dataGridView.DataSource = _productRepository.ReadProducts(); + private void LoadList() => dataGridViewProducts.DataSource = _productRepository.ReadProducts(); private bool TryGetIdentifierFromSelectedRow(out int id) { id = 0; - if (dataGridView.SelectedRows.Count < 1) + if (dataGridViewProducts.SelectedRows.Count < 1) { MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return false; } id = - Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value); + Convert.ToInt32(dataGridViewProducts.SelectedRows[0].Cells["ID"].Value); return true; } } diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.Designer.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.Designer.cs index 527039e..9ca333a 100644 --- a/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.Designer.cs +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.Designer.cs @@ -29,6 +29,8 @@ private void InitializeComponent() { panel = new Panel(); + buttonDel = new Button(); + buttonUpd = new Button(); buttonAdd = new Button(); dataGridViewShifts = new DataGridView(); panel.SuspendLayout(); @@ -37,6 +39,8 @@ // // panel // + panel.Controls.Add(buttonDel); + panel.Controls.Add(buttonUpd); panel.Controls.Add(buttonAdd); panel.Dock = DockStyle.Right; panel.Location = new Point(962, 0); @@ -44,6 +48,28 @@ panel.Size = new Size(326, 768); panel.TabIndex = 0; // + // buttonDel + // + buttonDel.BackgroundImage = Properties.Resources.minus; + buttonDel.BackgroundImageLayout = ImageLayout.Stretch; + buttonDel.Location = new Point(93, 551); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(150, 151); + buttonDel.TabIndex = 2; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += ButtonDel_Click; + // + // buttonUpd + // + buttonUpd.BackgroundImage = Properties.Resources.pencil; + buttonUpd.BackgroundImageLayout = ImageLayout.Stretch; + buttonUpd.Location = new Point(93, 295); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(150, 151); + buttonUpd.TabIndex = 1; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += ButtonUpd_Click; + // // buttonAdd // buttonAdd.BackgroundImage = Properties.Resources.plus; @@ -68,6 +94,7 @@ dataGridViewShifts.ReadOnly = true; dataGridViewShifts.RowHeadersVisible = false; dataGridViewShifts.RowHeadersWidth = 82; + dataGridViewShifts.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridViewShifts.Size = new Size(962, 768); dataGridViewShifts.TabIndex = 1; // @@ -91,5 +118,7 @@ private Panel panel; private Button buttonAdd; private DataGridView dataGridViewShifts; + private Button buttonDel; + private Button buttonUpd; } } \ No newline at end of file diff --git a/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.cs b/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.cs index 4e46211..4a2f278 100644 --- a/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.cs +++ b/ProjectWorkshop/ProjectWorkshop/Forms/FormShifts.cs @@ -49,6 +49,61 @@ namespace ProjectWorkshop.Forms } } + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findID)) + { + return; + } + try + { + var form = _container.Resolve(); + form.Id = findID; + form.ShowDialog(); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (!TryGetIdentifierFromSelectedRow(out var findId)) + { + return; + } + if (MessageBox.Show("Удалить запись?", "Удаление", + MessageBoxButtons.YesNo) != DialogResult.Yes) + { + return; + } + try + { + _shiftRepository.DeleteShift(findId); + LoadList(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка при удалении", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void LoadList() => dataGridViewShifts.DataSource = _shiftRepository.ReadShifts(); + + private bool TryGetIdentifierFromSelectedRow(out int id) + { + id = 0; + if (dataGridViewShifts.SelectedRows.Count < 1) + { + MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return false; + } + id = + Convert.ToInt32(dataGridViewShifts.SelectedRows[0].Cells["ID"].Value); + return true; + } } }