Imam neku aplikaciju u C#-u koja je povezana sa access-ovom bazom,
u jednoj celiji u tabeli se nalaze neki brojevi od 13 karaktera.
Kada procitam jedan broj iz tabele, pomocu odredjenih funkcija taj broj konvertujem u EAN13 barkod i prikazem u PictureBox kontroli na formi.
Meni treba, ako se u bazi nalazi npr. 20 rekorda, da procitam jedan po jedan, konvertujem u barkod i smjestim ga na papir A4 formata koristeci CrystalReports.
Velicina barkoda sa jos nekim informacijama, naziv, cijena, trebala bi da bude tolika da kada se poredaju u 4 kolone sa 5 redova zauzme tacno A4 format. Sve preko 20, 40, 60 ... da se stampaju na novim listovima.
Evo i djelovi koda kojim ubacujem u PictureBox:
Code:
private Ean13 ean13 = null;
private void button1_Click(object sender, EventArgs e)
{
System.Drawing.Graphics g = this.picBarcode.CreateGraphics();
g.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.SystemColors.Control),
new Rectangle(0, 0, picBarcode.Width, picBarcode.Height));
CreateEan13();
ean13.Scale = (float)Convert.ToDecimal(cboScale.Items[cboScale.SelectedIndex]);
ean13.DrawEan13Barcode(g, new System.Drawing.Point(0, 0));
tbChecksumDigit.Text = ean13.ChecksumDigit;
g.Dispose();
}
...
...
...
private void CreateEan13()
{
string CountryCode = "";
string ManufacturerCode = "";
string ProductCode = "";
string barkod = tbBarkod.Text;
CountryCode = barkod.Substring(0, 2);
ManufacturerCode = barkod.Substring(2, 5);
ProductCode = barkod.Substring(7, 5);
ean13 = new Ean13();
ean13.CountryCode = CountryCode;
ean13.ManufacturerCode = ManufacturerCode;
ean13.ProductCode = ProductCode;
if (tbChecksumDigit.Text.Length > 0)
ean13.ChecksumDigit = tbChecksumDigit.Text;
}
....
....
....
private Ean13 ean13 = null;
private void button1_Click(object sender, EventArgs e)
{
System.Drawing.Graphics g = this.picBarcode.CreateGraphics();
g.FillRectangle(new System.Drawing.SolidBrush(System.Drawing.SystemColors.Control),
new Rectangle(0, 0, picBarcode.Width, picBarcode.Height));
CreateEan13();
ean13.Scale = (float)Convert.ToDecimal(cboScale.Items[cboScale.SelectedIndex]);
ean13.DrawEan13Barcode(g, new System.Drawing.Point(0, 0));
tbChecksumDigit.Text = ean13.ChecksumDigit;
g.Dispose();
}
...
...
...
private void CreateEan13()
{
string CountryCode = "";
string ManufacturerCode = "";
string ProductCode = "";
string barkod = tbBarkod.Text;
CountryCode = barkod.Substring(0, 2);
ManufacturerCode = barkod.Substring(2, 5);
ProductCode = barkod.Substring(7, 5);
ean13 = new Ean13();
ean13.CountryCode = CountryCode;
ean13.ManufacturerCode = ManufacturerCode;
ean13.ProductCode = ProductCode;
if (tbChecksumDigit.Text.Length > 0)
ean13.ChecksumDigit = tbChecksumDigit.Text;
}
....
....
....
Na ovom primjeru broj uzimam iz TextBox-a, mislim da je slicno i kada koristim bazu.
Ima li ko kakvu ideju, ne trazim da mi uradite zadatak, samo me uputite u pravom smjeru ...
HVALA UNAPRIJED ...