protected void BtnTopluYazdir_Click(object sender, EventArgs e) {
PrintDocument pd = new PrintDocument(); pd.PrinterSettings.PrinterName = "Argox A-200 PPLB"; pd.PrintPage += new PrintPageEventHandler(yazdirBarkodToplu); pd.Print();
}
public void yazdirBarkodToplu(object sender, PrintPageEventArgs e)
{
secilenId = int.Parse(DropUrunler.SelectedItem.Value);
var barkodlar = from i in db.Barkodlar.ToList() where i.StokKartId == secilenId select i;
foreach (var item in barkodlar) {
BarkodUrunAdi = DropUrunler.SelectedItem.Text;
var OzellikBul = from i in db.UrunOzellikleri.ToList() where i.id == item.UrunOzellikId select i;
foreach (var item2 in OzellikBul) {
BarodOzellikAdi = item2.VaryasyonOzellik1Adi + " " + item2.VaryasyonOzellik2Adi;
Int32 barcodeHeight = 40, barcodeWidth = 150; Bitmap bmpBarcode; bmpBarcode = new Bitmap(barcodeWidth, barcodeHeight); bmpBarcode.SetResolution(300, 100);
StringFormat stringFormat = new StringFormat(); stringFormat.Alignment = StringAlignment.Center; stringFormat.LineAlignment = StringAlignment.Center;
clsBarCode barcodeGenerator = new clsBarCode(); String barcodeReadyData = barcodeGenerator.Code128(item.Barkod.ToString(), false);
PrivateFontCollection myFonts; FontFamily family = LoadFontFamily(Server.MapPath("fonts/IDAUTOMATIONSC128XXL.TTF"), out myFonts); using (Font drawFont = new Font(family, 12), readableFont = new Font("Arial", 10, FontStyle.Regular)) { using (SolidBrush drawBrush = new SolidBrush(Color.Black)) {
e.Graphics.FillRectangle(new SolidBrush(Color.White), new RectangleF(0, 0, bmpBarcode.Width, bmpBarcode.Height)); e.Graphics.DrawString(BarkodUrunAdi, readableFont, drawBrush, new RectangleF(0, 0, barcodeWidth, 14), stringFormat); e.Graphics.DrawString(BarodOzellikAdi, readableFont, drawBrush, new RectangleF(0, 15, barcodeWidth, 20), stringFormat); e.Graphics.DrawString(barcodeReadyData, drawFont, drawBrush, new RectangleF(0, 50, barcodeWidth, barcodeHeight), stringFormat); e.Graphics.DrawString(BarkodEtiket, readableFont, drawBrush, new RectangleF(0, 85, barcodeWidth, barcodeHeight), stringFormat); e.Graphics.DrawString("Logo", readableFont, drawBrush, new RectangleF(150, 85, barcodeWidth, 20), stringFormat);
}
} } }
}
|