diff --git a/WinFormsApp/FormSupplierProduct.Designer.cs b/WinFormsApp/FormSupplierProduct.Designer.cs index b171d7a..a99fa32 100644 --- a/WinFormsApp/FormSupplierProduct.Designer.cs +++ b/WinFormsApp/FormSupplierProduct.Designer.cs @@ -32,57 +32,85 @@ buttonSave = new Button(); comboBoxProduct = new ComboBox(); numericUpDownCount = new NumericUpDown(); + label2 = new Label(); + label1 = new Label(); ((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit(); SuspendLayout(); // // buttonCancel // - buttonCancel.Location = new Point(179, 77); + buttonCancel.BackColor = Color.FromArgb(255, 192, 192); + buttonCancel.Location = new Point(167, 106); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(75, 23); buttonCancel.TabIndex = 8; buttonCancel.Text = "Отмена"; - buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.UseVisualStyleBackColor = false; buttonCancel.Click += ButtonCancel_Click; // // buttonSave // - buttonSave.Location = new Point(179, 53); + buttonSave.BackColor = Color.FromArgb(192, 255, 192); + buttonSave.Location = new Point(86, 106); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(75, 23); buttonSave.TabIndex = 7; buttonSave.Text = "Сохранить"; - buttonSave.UseVisualStyleBackColor = true; + buttonSave.UseVisualStyleBackColor = false; buttonSave.Click += ButtonSave_Click; // // comboBoxProduct // comboBoxProduct.FormattingEnabled = true; - comboBoxProduct.Location = new Point(12, 12); + comboBoxProduct.Location = new Point(86, 24); comboBoxProduct.Name = "comboBoxProduct"; - comboBoxProduct.Size = new Size(121, 23); + comboBoxProduct.Size = new Size(156, 23); comboBoxProduct.TabIndex = 6; // // numericUpDownCount // - numericUpDownCount.Location = new Point(13, 55); + numericUpDownCount.Location = new Point(87, 71); numericUpDownCount.Name = "numericUpDownCount"; - numericUpDownCount.Size = new Size(120, 23); + numericUpDownCount.Size = new Size(155, 23); numericUpDownCount.TabIndex = 5; // + // label2 + // + label2.AutoSize = true; + label2.Font = new Font("Segoe UI", 12F, FontStyle.Bold); + label2.Location = new Point(12, 68); + label2.Name = "label2"; + label2.Size = new Size(69, 21); + label2.TabIndex = 10; + label2.Text = "Кол-во:"; + // + // label1 + // + label1.AutoSize = true; + label1.Font = new Font("Segoe UI", 12F, FontStyle.Bold); + label1.Location = new Point(12, 24); + label1.Name = "label1"; + label1.Size = new Size(60, 21); + label1.TabIndex = 9; + label1.Text = "Товар:"; + // // FormSupplierProduct // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(291, 123); + BackColor = Color.AliceBlue; + ClientSize = new Size(255, 141); + Controls.Add(label2); + Controls.Add(label1); Controls.Add(buttonCancel); Controls.Add(buttonSave); Controls.Add(comboBoxProduct); Controls.Add(numericUpDownCount); Name = "FormSupplierProduct"; - Text = "FormSupplierProduct"; + Text = "+ Товар поставщика"; ((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit(); ResumeLayout(false); + PerformLayout(); } #endregion @@ -91,5 +119,7 @@ private Button buttonSave; private ComboBox comboBoxProduct; private NumericUpDown numericUpDownCount; + private Label label2; + private Label label1; } } \ No newline at end of file diff --git a/WinFormsApp/FormSuppliers.Designer.cs b/WinFormsApp/FormSuppliers.Designer.cs index 0cb5fe8..d015c38 100644 --- a/WinFormsApp/FormSuppliers.Designer.cs +++ b/WinFormsApp/FormSuppliers.Designer.cs @@ -31,50 +31,85 @@ dataGridView = new DataGridView(); buttonAdd = new Button(); buttonEdit = new Button(); + groupBox1 = new GroupBox(); + buttonDelete = new Button(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + groupBox1.SuspendLayout(); SuspendLayout(); // // dataGridView // + dataGridView.BackgroundColor = Color.AliceBlue; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Dock = DockStyle.Left; - dataGridView.Location = new Point(0, 0); + dataGridView.Location = new Point(553, 12); dataGridView.Name = "dataGridView"; - dataGridView.Size = new Size(615, 637); + dataGridView.Size = new Size(354, 488); dataGridView.TabIndex = 4; // // buttonAdd // - buttonAdd.Location = new Point(635, 50); + buttonAdd.BackColor = Color.FromArgb(192, 255, 192); + buttonAdd.ForeColor = SystemColors.ActiveCaptionText; + buttonAdd.Location = new Point(12, 50); buttonAdd.Name = "buttonAdd"; - buttonAdd.Size = new Size(75, 23); + buttonAdd.Size = new Size(109, 41); buttonAdd.TabIndex = 5; buttonAdd.Text = "Добавить"; - buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.UseVisualStyleBackColor = false; buttonAdd.Click += buttonAdd_Click; // // buttonEdit // - buttonEdit.Location = new Point(648, 115); + buttonEdit.ForeColor = SystemColors.ActiveCaptionText; + buttonEdit.Location = new Point(242, 50); buttonEdit.Name = "buttonEdit"; - buttonEdit.Size = new Size(122, 23); + buttonEdit.Size = new Size(124, 41); buttonEdit.TabIndex = 6; buttonEdit.Text = "Редактировать"; buttonEdit.UseVisualStyleBackColor = true; buttonEdit.Click += buttonEdit_Click; // + // groupBox1 + // + groupBox1.BackColor = Color.Transparent; + groupBox1.Controls.Add(buttonDelete); + groupBox1.Controls.Add(buttonEdit); + groupBox1.Controls.Add(buttonAdd); + groupBox1.Dock = DockStyle.Bottom; + groupBox1.Font = new Font("Segoe UI", 10F, FontStyle.Bold); + groupBox1.ForeColor = SystemColors.ButtonHighlight; + groupBox1.Location = new Point(0, 506); + groupBox1.Name = "groupBox1"; + groupBox1.Size = new Size(919, 131); + groupBox1.TabIndex = 7; + groupBox1.TabStop = false; + groupBox1.Text = "Действия"; + // + // buttonDelete + // + buttonDelete.BackColor = Color.FromArgb(255, 192, 192); + buttonDelete.ForeColor = SystemColors.ActiveCaptionText; + buttonDelete.Location = new Point(127, 50); + buttonDelete.Name = "buttonDelete"; + buttonDelete.Size = new Size(109, 41); + buttonDelete.TabIndex = 7; + buttonDelete.Text = "Удалить"; + buttonDelete.UseVisualStyleBackColor = false; + buttonDelete.Click += buttonDelete_Click; + // // FormSuppliers // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; + BackgroundImage = Properties.Resources._9AZKH1_1911594361; ClientSize = new Size(919, 637); - Controls.Add(buttonEdit); - Controls.Add(buttonAdd); + Controls.Add(groupBox1); Controls.Add(dataGridView); Name = "FormSuppliers"; - Text = "FormSuppliers"; + Text = "Поставщики"; Load += FormSuppliers_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + groupBox1.ResumeLayout(false); ResumeLayout(false); } @@ -82,5 +117,7 @@ private DataGridView dataGridView; private Button buttonAdd; private Button buttonEdit; + private GroupBox groupBox1; + private Button buttonDelete; } } \ No newline at end of file diff --git a/WinFormsApp/FormSuppliers.cs b/WinFormsApp/FormSuppliers.cs index 9722f3e..941c5fa 100644 --- a/WinFormsApp/FormSuppliers.cs +++ b/WinFormsApp/FormSuppliers.cs @@ -84,5 +84,30 @@ namespace WinFormsApp } } } + + private void buttonDelete_Click(object sender, EventArgs e) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + Guid id = (Guid)dataGridView.SelectedRows[0].Cells["Id"].Value; + _logger.LogInformation("Удаление поставщика"); + try + { + if (!_supplierLogic.Delete(new SupplierBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления поставщика"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } } }