将条形码从数据库传递到另一个条形码图像 [英] Passing barcode from database to another barcodeimage

查看:135
本文介绍了将条形码从数据库传递到另一个条形码图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从我的数据库[条形码]传递一个值进行更新,我正在传递另一个表单。当我点击更新时,条形码生成器只应该从数据库中生成条形码,但是当我做一些更新以显示表单时它会生成另一个条形码而不是数据库,我该怎样才能停止自动生成条形码而只生成数据库中的条形码?



我尝试过:



  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 ]。的ToString();
frmupdate.txt_supplier.Text = this .dataGridView1.CurrentRow.Cells [ 2 ]。的ToString();

// 这一行......
frmupdate.barcode .Text = this .dataGridView1.CurrentRow.Cells [ 3 ]。Value.ToString();
// 行尾
frmupdate.txt_cat.Text = this .dataGridView1.CurrentRow.Cells [ 4 ]。Value.ToString();
frmupdate.txt_name.Text = this .dataGridView1.CurrentRow.Cells [ 5 ]。的ToString();
frmupdate.txt_brand.Text = this .dataGridView1.CurrentRow.Cells [ 6 ]。的ToString();
frmupdate.txt_description.Text = .dataGridView1.CurrentRow.Cells [ 7 ]。的ToString();
frmupdate.txt_price.Text = this .dataGridView1.CurrentRow.Cells [ 8 ]。的ToString();
frmupdate.txt_sellprice.Text = this .dataGridView1.CurrentRow.Cells [ 9 ]。的ToString();
frmupdate.txt_unit.Text = this .dataGridView1.CurrentRow.Cells [ 10 ]。的ToString();
frmupdate.txt_quantity.Text = this .dataGridView1.CurrentRow.Cells [ 11 ]。的ToString();
frmupdate.ShowDialog();

}





这是我的另一种形式的Autogenerator条形码。

< pre lang =c#> private void AddItems_Load( object sender,EventArgs e)
{
GetBarcode();

}





  public   void  GetBarcode()
{

string barcodes = barcode.Text = RandomDigits( 12 );

位图位图= 位图(barcode.Text.Length * 264 82 );
使用(图形图形= Graphics.FromImage(位图))
{
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(白色, 0 0 ,bitmap.Width,bitmap.Height) ;
graphics.DrawString( * + barcodes + *,ofont,black,point);
}

使用(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访问中列出)以显示图片框区域上的条形码图像(来自数据库条形码)?





谢谢你的时间。希望你能引导我。

解决方案

你是从随机数字生成条形码编号而不是从你的daytabase获取它。有点像你之前关于这个主题的问题。


Hi, I want to passing a value from my database[barcode] to update, Im doing passing form another form. When I click Update the barcode generator should only generate the barcode from the database, but when I do some Update to show the form it generate another barcode and its not on the database, how can I make to stop the auto generate barcode and only generate the barcode from the database?

What I have tried:

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



Here is my Autogenerator barcode from another form.

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



How can I stop this autogenerate barcode? and pass this barcode variable(listed on database MS access) to show the barcode image (from the database barcode) on the picturebox area?


Thank you for your time. Hope you will guide me.

解决方案

You are generating your barcode number from random digits instead of getting it from your daytabase. A bit like your previous question on this subject.


这篇关于将条形码从数据库传递到另一个条形码图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆