ещё больше автогенерации штрих кодов + их отображение в реальном времени

This commit is contained in:
the 2024-06-25 16:01:10 +04:00
parent 7776de448b
commit 5cf65ccdb2
2 changed files with 25 additions and 2 deletions

View File

@ -60,8 +60,11 @@
dataGridView.Dock = DockStyle.Left; dataGridView.Dock = DockStyle.Left;
dataGridView.Location = new Point(0, 24); dataGridView.Location = new Point(0, 24);
dataGridView.Name = "dataGridView"; dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(602, 622); dataGridView.Size = new Size(602, 622);
dataGridView.TabIndex = 0; dataGridView.TabIndex = 0;
dataGridView.SelectionChanged += dataGridView_SelectionChanged;
// //
// buttonCreateProduct // buttonCreateProduct
// //

View File

@ -123,9 +123,9 @@ namespace WinFormsApp
finally finally
{ {
LoadData(); LoadData();
groupBoxControls.Enabled = true; //groupBoxControls.Enabled = true;
groupBoxControls.Show(); groupBoxControls.Show();
groupBoxCreateProduct.Enabled = false; //groupBoxCreateProduct.Enabled = false;
groupBoxCreateProduct.Hide(); groupBoxCreateProduct.Hide();
textBoxName.Text = string.Empty; textBoxName.Text = string.Empty;
numericUpDownAmount.Value = 0; numericUpDownAmount.Value = 0;
@ -246,5 +246,25 @@ namespace WinFormsApp
form.ShowDialog(); form.ShowDialog();
} }
} }
private void dataGridView_SelectionChanged(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (!File.Exists($"product{dataGridView.SelectedRows[0].Cells["Id"].Value}.png"))
{
var barcode = _barcodeLogic.CreateBarcode(new ProductBindingModel()
{
Id = (Guid)dataGridView.SelectedRows[0].Cells["Id"].Value,
Name = Convert.ToString(dataGridView.SelectedRows[0].Cells["Name"].Value),
}, true);
pictureBox1.Image = barcode.Image;
}
else
{
pictureBox1.Image = new Bitmap($"product{dataGridView.SelectedRows[0].Cells["Id"].Value}.png");
}
}
}
} }
} }