Передача штрих-кода из базы данных в другое barcodeimage
Привет, я хочу передать значение из моей базы данных[штрих-код] для обновления, я делаю передачу формы другой формы. Когда я нажимаю кнопку Обновить генератор штрих-кодов должен генерировать только штрих-код из базы данных, но когда я делаю некоторое обновление, чтобы показать форму, он генерирует другой штрих-код, а его нет в базе данных, как я могу сделать, чтобы остановить автоматическое генерирование штрих-кода и генерировать только штрих-код из базы данных?
Что я уже пробовал:
if (btn_add.Text == "UPDATE") { UserControls.AddItems frmupdate = new UserControls.AddItems(); DataGridViewRow row = this.dataGridView1.Rows[0]; var data = (Byte[])(row.Cells["Photo"].Value); var stream = new MemoryStream(data); frmupdate.pictureBox1.Image = Image.FromStream(stream); frmupdate.item_id.Text = this.dataGridView1.CurrentRow.Cells[1].Value.ToString(); frmupdate.txt_supplier.Text = this.dataGridView1.CurrentRow.Cells[2].Value.ToString(); // This line here.. frmupdate.barcode.Text = this.dataGridView1.CurrentRow.Cells[3].Value.ToString(); // end of line frmupdate.txt_cat.Text = this.dataGridView1.CurrentRow.Cells[4].Value.ToString(); frmupdate.txt_name.Text = this.dataGridView1.CurrentRow.Cells[5].Value.ToString(); frmupdate.txt_brand.Text = this.dataGridView1.CurrentRow.Cells[6].Value.ToString(); frmupdate.txt_description.Text = this.dataGridView1.CurrentRow.Cells[7].Value.ToString(); frmupdate.txt_price.Text = this.dataGridView1.CurrentRow.Cells[8].Value.ToString(); frmupdate.txt_sellprice.Text = this.dataGridView1.CurrentRow.Cells[9].Value.ToString(); frmupdate.txt_unit.Text = this.dataGridView1.CurrentRow.Cells[10].Value.ToString(); frmupdate.txt_quantity.Text = this.dataGridView1.CurrentRow.Cells[11].Value.ToString(); frmupdate.ShowDialog(); }
Вот мой штрих - код автогенератора из другой формы.
private void AddItems_Load(object sender, EventArgs e) { GetBarcode(); }
public void GetBarcode() { string barcodes = barcode.Text = RandomDigits(12); Bitmap bitmap = new Bitmap(barcode.Text.Length * 264, 82); using (Graphics graphics = Graphics.FromImage(bitmap)) { Font ofont = new System.Drawing.Font("IDAutomationHC39M", 14); PointF point = new PointF(2f, 2f); SolidBrush black = new SolidBrush(Color.Black); SolidBrush white = new SolidBrush(Color.White); graphics.FillRectangle(white, 0, 0, bitmap.Width, bitmap.Height); graphics.DrawString("*" + barcodes + "*", ofont, black, point); } using (MemoryStream ms = new MemoryStream()) { bitmap.Save(ms, ImageFormat.Png); pictureBox1.Image = bitmap; pictureBox1.Height = bitmap.Height; // pictureBox1.Width = bitmap.Width; } } public string RandomDigits(int length) { var random = new Random(); string s = string.Empty; for (int i = 0; i < length; i++) s = String.Concat(s, random.Next(10).ToString()); return s; }
Как я могу остановить этот автоматически генерируемый штрих-код? и передать эту переменную штрих-кода(перечисленную в базе данных MS access), чтобы показать изображение штрих-кода (из базы данных штрих-кода) в области picturebox?
Спасибо, что уделили мне время. Надеюсь, ты будешь направлять меня.