This commit is contained in:
the 2024-06-25 23:02:50 +04:00
parent 49853d94de
commit 2f1866659c
3 changed files with 113 additions and 21 deletions

View File

@ -32,57 +32,85 @@
buttonSave = new Button(); buttonSave = new Button();
comboBoxProduct = new ComboBox(); comboBoxProduct = new ComboBox();
numericUpDownCount = new NumericUpDown(); numericUpDownCount = new NumericUpDown();
label2 = new Label();
label1 = new Label();
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit(); ((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// buttonCancel // buttonCancel
// //
buttonCancel.Location = new Point(179, 77); buttonCancel.BackColor = Color.FromArgb(255, 192, 192);
buttonCancel.Location = new Point(167, 106);
buttonCancel.Name = "buttonCancel"; buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23); buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 8; buttonCancel.TabIndex = 8;
buttonCancel.Text = "Отмена"; buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true; buttonCancel.UseVisualStyleBackColor = false;
buttonCancel.Click += ButtonCancel_Click; buttonCancel.Click += ButtonCancel_Click;
// //
// buttonSave // buttonSave
// //
buttonSave.Location = new Point(179, 53); buttonSave.BackColor = Color.FromArgb(192, 255, 192);
buttonSave.Location = new Point(86, 106);
buttonSave.Name = "buttonSave"; buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23); buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 7; buttonSave.TabIndex = 7;
buttonSave.Text = "Сохранить"; buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true; buttonSave.UseVisualStyleBackColor = false;
buttonSave.Click += ButtonSave_Click; buttonSave.Click += ButtonSave_Click;
// //
// comboBoxProduct // comboBoxProduct
// //
comboBoxProduct.FormattingEnabled = true; comboBoxProduct.FormattingEnabled = true;
comboBoxProduct.Location = new Point(12, 12); comboBoxProduct.Location = new Point(86, 24);
comboBoxProduct.Name = "comboBoxProduct"; comboBoxProduct.Name = "comboBoxProduct";
comboBoxProduct.Size = new Size(121, 23); comboBoxProduct.Size = new Size(156, 23);
comboBoxProduct.TabIndex = 6; comboBoxProduct.TabIndex = 6;
// //
// numericUpDownCount // numericUpDownCount
// //
numericUpDownCount.Location = new Point(13, 55); numericUpDownCount.Location = new Point(87, 71);
numericUpDownCount.Name = "numericUpDownCount"; numericUpDownCount.Name = "numericUpDownCount";
numericUpDownCount.Size = new Size(120, 23); numericUpDownCount.Size = new Size(155, 23);
numericUpDownCount.TabIndex = 5; 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 // FormSupplierProduct
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; 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(buttonCancel);
Controls.Add(buttonSave); Controls.Add(buttonSave);
Controls.Add(comboBoxProduct); Controls.Add(comboBoxProduct);
Controls.Add(numericUpDownCount); Controls.Add(numericUpDownCount);
Name = "FormSupplierProduct"; Name = "FormSupplierProduct";
Text = "FormSupplierProduct"; Text = "+ Товар поставщика";
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit(); ((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
ResumeLayout(false); ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion
@ -91,5 +119,7 @@
private Button buttonSave; private Button buttonSave;
private ComboBox comboBoxProduct; private ComboBox comboBoxProduct;
private NumericUpDown numericUpDownCount; private NumericUpDown numericUpDownCount;
private Label label2;
private Label label1;
} }
} }

View File

@ -31,50 +31,85 @@
dataGridView = new DataGridView(); dataGridView = new DataGridView();
buttonAdd = new Button(); buttonAdd = new Button();
buttonEdit = new Button(); buttonEdit = new Button();
groupBox1 = new GroupBox();
buttonDelete = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
groupBox1.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
// dataGridView // dataGridView
// //
dataGridView.BackgroundColor = Color.AliceBlue;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Left; dataGridView.Location = new Point(553, 12);
dataGridView.Location = new Point(0, 0);
dataGridView.Name = "dataGridView"; dataGridView.Name = "dataGridView";
dataGridView.Size = new Size(615, 637); dataGridView.Size = new Size(354, 488);
dataGridView.TabIndex = 4; dataGridView.TabIndex = 4;
// //
// buttonAdd // 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.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 23); buttonAdd.Size = new Size(109, 41);
buttonAdd.TabIndex = 5; buttonAdd.TabIndex = 5;
buttonAdd.Text = "Добавить"; buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true; buttonAdd.UseVisualStyleBackColor = false;
buttonAdd.Click += buttonAdd_Click; buttonAdd.Click += buttonAdd_Click;
// //
// buttonEdit // buttonEdit
// //
buttonEdit.Location = new Point(648, 115); buttonEdit.ForeColor = SystemColors.ActiveCaptionText;
buttonEdit.Location = new Point(242, 50);
buttonEdit.Name = "buttonEdit"; buttonEdit.Name = "buttonEdit";
buttonEdit.Size = new Size(122, 23); buttonEdit.Size = new Size(124, 41);
buttonEdit.TabIndex = 6; buttonEdit.TabIndex = 6;
buttonEdit.Text = "Редактировать"; buttonEdit.Text = "Редактировать";
buttonEdit.UseVisualStyleBackColor = true; buttonEdit.UseVisualStyleBackColor = true;
buttonEdit.Click += buttonEdit_Click; 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 // FormSuppliers
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources._9AZKH1_1911594361;
ClientSize = new Size(919, 637); ClientSize = new Size(919, 637);
Controls.Add(buttonEdit); Controls.Add(groupBox1);
Controls.Add(buttonAdd);
Controls.Add(dataGridView); Controls.Add(dataGridView);
Name = "FormSuppliers"; Name = "FormSuppliers";
Text = "FormSuppliers"; Text = "Поставщики";
Load += FormSuppliers_Load; Load += FormSuppliers_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
groupBox1.ResumeLayout(false);
ResumeLayout(false); ResumeLayout(false);
} }
@ -82,5 +117,7 @@
private DataGridView dataGridView; private DataGridView dataGridView;
private Button buttonAdd; private Button buttonAdd;
private Button buttonEdit; private Button buttonEdit;
private GroupBox groupBox1;
private Button buttonDelete;
} }
} }

View File

@ -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);
}
}
}
} }
} }