private static void Pdoc_PrintPage(object sender, PrintPageEventArgs e) { // Draw the serial as text on top of label Font font = new Font(_font_name, _font_size, FontStyle.Regular); SizeF fsize = e.Graphics.MeasureString(_board_serial, font); SolidBrush sb = new SolidBrush(Color.Black); int x = (int)((e.PageBounds.Width - fsize.Width) / 2) + _left_margin; int y = _top_margin; e.Graphics.DrawString(_board_serial, font, sb, x, y); // Draw barcode below it Code128BarcodeDraw barcode = BarcodeDrawFactory.Code128WithChecksum; int h = (int)(e.PageBounds.Height - fsize.Height - y - 5); Image bi = barcode.Draw(_board_serial, h); if (bi.Width > e.PageBounds.Width) { throw new Exception("Barcode too large to fit on selected paper"); } x = (e.PageBounds.Width - bi.Width) / 2 + _left_margin; y += (int)(fsize.Height); e.Graphics.DrawImage(bi, x, y); e.Graphics.Dispose(); }
Image drawBarcode(string value) { Code128BarcodeDraw code = BarcodeDrawFactory.Code128WithChecksum; Image img = code.Draw(value, 20); return(img); }
public byte[] Get([FromHeader] int id) { var metere = _context.altUnits .Include(p => p.MainUnitId) .FirstOrDefault(); var result = _context.orderDetails .Where(p => p.OrderId == id) .Include(p => p.Item) .FirstOrDefault(); string barkodTasarim = result.OrderId.ToString() + "_" + result.Item.Pattern.ToString() + result.Item.Rope.ToString() + result.Item.Strike.ToString(); var draw = new Code128BarcodeDraw(Code128Checksum.Instance); var image = draw.Draw(barkodTasarim, 70, 1); HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Unauthorized); byte[] arr; using (var memStream = new MemoryStream()) { image.Save(memStream, ImageFormat.Png); arr = memStream.ToArray(); } response.Content = new StreamContent(new MemoryStream(arr)); response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png"); return(arr); }
/// <summary> /// A helper method used to render a Code 128 barcode using the Barcode /// Rendering Framework. /// </summary> /// <param name="text">A string containing the text information to encode into the barcode.</param> /// <returns>A BitmapImage containing the rendered barcode image.</returns> public static BitmapImage renderCode128(string text) { BitmapImage bitmap; //create barcode image Code128BarcodeDraw barcode = BarcodeDrawFactory.Code128WithChecksum; //draw barcode image DrawImage image = barcode.Draw(text, 40, 2); //create memory stream for barcode conversion MemoryStream ms = new MemoryStream(); //save barcode image to memory stream as PNG image.Save(ms, ImageFormat.Png); //---debug render to file //FileStream fStream = new FileStream("barcode.png", FileMode.Create); //image.Save(fStream, ImageFormat.Png); //set memory stream position back to the beginning ms.Position = 0; //create bitmap image bitmap = new BitmapImage(); //prep bitmap for memory stream bitmap.BeginInit(); //set memory stream bitmap.StreamSource = ms; //end stream prep bitmap.EndInit(); return bitmap; }
public bool GenerateLotBarCodeImage(string data) { try { //context.Response.ContentType = "image/jpeg"; string Code = data.ToString(); //txtLotNmber.Text; Code128BarcodeDraw br = BarcodeDrawFactory.Code128WithChecksum; int size = 100; System.Drawing.Image img = br.Draw((data), size, 2); Font stringFont = new Font("Arial", 16); SizeF textsize = new SizeF(); System.Drawing.Image imgText = DrawText(data, stringFont, Color.Black, Color.White, img.Width, img.Height, out textsize); Bitmap bitmap = new Bitmap(img.Width, img.Height + imgText.Height); using (Graphics g = Graphics.FromImage(bitmap)) { g.DrawImage(img, 0, 0); g.DrawImage(imgText, 0, img.Height); } string strPath = HttpContext.Current.Server.MapPath("/images/temp"); System.IO.Directory.CreateDirectory(strPath); bitmap.Save(HttpContext.Current.Server.MapPath(String.Format("/images/temp/{0}.Gif", data)), System.Drawing.Imaging.ImageFormat.Gif); } catch (Exception ex) { new SqlLog().InsertSqlLog(0, "Utils GenerateLotBarCodeImage", ex); return(false); } return(true); }
private void dataBind(PrintInfo info) { //生成二维码 //CodeQrBarcodeDraw qrcode = BarcodeDrawFactory.CodeQr; //Image img = qrcode.Draw("Hello World", qrcode.GetDefaultMetrics(40)); //Code128BarcodeDraw barcode128 = BarcodeDrawFactory.Code128WithChecksum; //Image img = barcode128.Draw("12345678901234567", 40); //this.erweima.Image = img; if (info.Barcode != "") { //生成二维码 //MemoryStream ms = GetQRCode(info.Barcode); //this.erweima.Image = Image.FromStream(ms); //生成条码 Code128BarcodeDraw barcode128 = BarcodeDrawFactory.Code128WithChecksum; Image img = barcode128.Draw(info.Barcode, 40); this.erweima.Image = img; } this.Cxps.Text = info.OptionCode; this.Ljmc.Text = info.PartsName; this.Rjbb.Text = info.SoftWareVersion; this.tm.Text = "+" + info.Barcode; this.date.Text = DateTime.Now + ""; this.hm.Text = "NO." + info.Number; }
public static void gen_barcode(PictureBox pixBarcode, string str) { try { Code128BarcodeDraw _barcode = BarcodeDrawFactory.Code128WithChecksum; pixBarcode.Image = _barcode.Draw(str, 50); } catch { } }
private void CodeTB_TextChanged(object sender, EventArgs e) { Code128BarcodeDraw bdf = BarcodeDrawFactory.Code128WithChecksum; if (CodeTB.Text.Length > 0) { BarcodePB.Image = bdf.Draw(CodeTB.Text, 40); BarcodePB.Update(); } }
public Image getBarCodeImage(int scale) { if (img == null) { Code128BarcodeDraw x = BarcodeDrawFactory.Code128WithChecksum; img = x.Draw(_FNSKU, 30, scale); } return(img); }
public String Get128BarCode(String barcode) { String token = CreateUniqueToken(); String Route = string.Format("{0}\\{1}.{2}", Directorio, token, Tipo.jpg); int maxheight = 40; Code128BarcodeDraw barcode128 = BarcodeDrawFactory.Code128WithChecksum; Image img = barcode128.Draw(barcode, maxheight); img.Save(Route, System.Drawing.Imaging.ImageFormat.Jpeg); return(Route); }
private void genBarCode() { Code128BarcodeDraw barcode = BarcodeDrawFactory.Code128WithChecksum; picBarcode.Image = barcode.Draw(txtBarCode.Text, 60); string qr = "http://www.ppakorn.info/siam_summaryDoc/page/coding2/coding2-index.html?qrCode=" + txtBarCode.Text.Trim(); CodeQrBarcodeDraw qrcode = BarcodeDrawFactory.CodeQr; picQR.Image = qrcode.Draw(qr, 50); lblBarCodeImg.Text = txtBarCode.Text; }
public ActionResult PrintBarCode() { HallMovieViewModel hallMovieViewModel = (HallMovieViewModel)TempData["hallMovieViewModel"]; TempData["hallMovieViewModel"] = hallMovieViewModel; Code128BarcodeDraw bc128 = BarcodeDrawFactory.Code128WithChecksum; System.Drawing.Image img = bc128.Draw("" + hallMovieViewModel.order.PrintID, 40); img.Save(Server.MapPath("../Barcodes/") + hallMovieViewModel.order.PrintID.ToString(), ImageFormat.Jpeg); return(new ViewAsPdf("PrintBarCode", hallMovieViewModel)); }
void drawCode(string value, PictureBox pictureBox) { try { Code128BarcodeDraw code = BarcodeDrawFactory.Code128WithChecksum; System.Drawing.Image img = code.Draw(value, 40); pictureBox.Image = img; } catch (Exception) { pictureBox.Image = null; } }
void BarCode(string value, PictureBox image) { try { Code128BarcodeDraw code = BarcodeDrawFactory.Code128WithChecksum; System.Drawing.Image img = code.Draw(value, 40); image.Image = img; } catch (Exception) { image.Image = pictureBox1.Image; } }
private void prepair_Click(object sender, EventArgs e) { if (txt_product_name.Text == "") { MessageBox.Show("يجب كتابة اسم المنتج"); } else { int new_id = db.lastID(cbx_category_name.Text) + 1; lbl_product_id.Text = new_id.ToString(); Code128BarcodeDraw bar_code = BarcodeDrawFactory.Code128WithChecksum; picture_bar_code.Image = bar_code.Draw(lbl_product_id.Text, 50); } }
public ActionResult GetBarCodeImg(string txm) { Code128BarcodeDraw qrcode = BarcodeDrawFactory.Code128WithChecksum; //Code128BarcodeDraw qrcode = BarcodeDrawFactory.Code128WithChecksum; Image barcode = qrcode.Draw(txm, qrcode.GetDefaultMetrics(40)); System.IO.MemoryStream ms = new System.IO.MemoryStream(); barcode.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg); Response.ContentType = "image/jpeg"; Response.Clear(); Response.BinaryWrite(ms.ToArray()); return(new EmptyResult()); }
public ActionResult EmitirTktGuiche(bool checkResp) { var ticketOuLotado = f.guicheEmiteTicket(checkResp); if (ticketOuLotado.Equals("impossivel")) { return(View("~/Views/Guiche/Vazio.cshtml")); } else if (ticketOuLotado.Equals("cheio")) { return(View("~/Views/CancelaEntrada/Lotado.cshtml")); } else { var tkt = f.geTicket(ticketOuLotado); ViewBag.date = tkt.dt_hr_entrada; ViewBag.code = tkt.ticket; Code128BarcodeDraw bdf = BarcodeDrawFactory.Code128WithChecksum; ViewBag.codigoDeBarras = f.geraCodigoDeBarrasTM(bdf.Draw(tkt.ticket, 50)); return(View("~/Views/Guiche/TicketEmitidoGuiche.cshtml")); } }
public static Image drawBarCode128(string barcodeValues, int maxHeight, int scale) { int barCodeResHeight = 18, yCoordidate = 11; Code128BarcodeDraw code128 = BarcodeDrawFactory.Code128WithChecksum; Image barcodeImage = code128.Draw(barcodeValues, maxHeight, scale); Image res = (Image) new Bitmap(barcodeImage.Width, barcodeImage.Height + barCodeResHeight); using (var graphics = Graphics.FromImage(res)) using (var font = new Font("Times New Roman", 11)) // Any font you want using (var brush = new SolidBrush(Color.Black)) using (var format = new StringFormat() { LineAlignment = StringAlignment.Center }) // To align text above the specified point { // Print a string at the left bottom corner of image graphics.DrawImage(barcodeImage, new Rectangle(0, 0, barcodeImage.Width, barcodeImage.Height)); SizeF sizeF = graphics.MeasureString(barcodeValues, font); graphics.DrawString(barcodeValues, font, brush, barcodeImage.Width / 2 - sizeF.Width / 2, barcodeImage.Height + yCoordidate, format); } return(res); }
private void CreateMasterCoilPDFButton_Click(object sender, EventArgs e) { char[] delimiters = { ' ', ',' }; string COILID, TYPE = "", COLOR, GAUGE, WIDTH; int WEIGHT; if ((System.IO.File.Exists(@"C:\Coil master 28-02-2019.csv")) == true) { int pageNumber = 1; int fileNumber = 0; int i = 0; // number of columns int j = 0; // number of rows ArrayList lines = new ArrayList(); foreach (string line in System.IO.File.ReadLines(@"C:\Coil master 28-02-2019.csv")) { lines.Add(line); } int totalFiles = (int)Math.Ceiling((double)lines.Count / 50); for (; fileNumber < totalFiles; fileNumber++) { j = 0; // reset the number of rows for each new document string path = Application.StartupPath; var pgSize = new iTextSharp.text.Rectangle(2976, 4194); Document pdfdoc = new Document(pgSize); // Setting the page size for the PDF PdfWriter writer = PdfWriter.GetInstance(pdfdoc, new FileStream(path + "/MasterCoils/" + (1 + (50 * fileNumber)) + "-" + (50 + (fileNumber * 50)) + ".pdf", FileMode.Create)); //Using the PDF Writer class to generate the PDF pdfdoc.Open(); // Opening the PDF to write the data from the textbox int maxRows = 50; if (fileNumber == totalFiles - 1) { maxRows = lines.Count - (50 * fileNumber) - 1; } // cannot write into new pdf foreach (string line in lines.GetRange(1 + (fileNumber * 50), maxRows)) { try { string[] inputArray = line.Split(delimiters); // split the input string by using the delimiter ',' COILID = inputArray[0]; TYPE = inputArray[1]; COLOR = inputArray[2]; WEIGHT = Int32.Parse(inputArray[3]); GAUGE = inputArray[4]; WIDTH = inputArray[5]; CodeQrBarcodeDraw QRcode = BarcodeDrawFactory.CodeQr; // to generate QR code System.Drawing.Image QRcodeImage = QRcode.Draw(COILID + "+" + TYPE + "+" + COLOR + "+" + WEIGHT + "+" + GAUGE + "+" + WIDTH, 100); iTextSharp.text.Image pic = iTextSharp.text.Image.GetInstance(QRcodeImage, System.Drawing.Imaging.ImageFormat.Jpeg); pic.ScaleAbsolute(90, 90); pic.SetAbsolutePosition(20 + (595 * i), (419 * (9 - j)) + 300); Code128BarcodeDraw barcode128 = BarcodeDrawFactory.Code128WithChecksum; // to generate barcode System.Drawing.Image BarcodeImage = barcode128.Draw(COILID + "+" + TYPE + "+" + COLOR + "+" + WEIGHT + "+" + GAUGE + "+" + WIDTH, 100); iTextSharp.text.Image pic2 = iTextSharp.text.Image.GetInstance(BarcodeImage, System.Drawing.Imaging.ImageFormat.Jpeg); pic2.ScaleAbsolute(310, 90); pic2.SetAbsolutePosition(250 + (595 * i), (419 * (9 - j)) + 300); pdfdoc.Add(pic); pdfdoc.Add(pic2); PdfContentByte cb = writer.DirectContent; // we tell the ContentByte we're ready to draw text cb.BeginText(); // set up Font and Size for Content to be shown in PDF BaseFont mybf = BaseFont.CreateFont(BaseFont.HELVETICA_BOLD, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); cb.SetFontAndSize(mybf, 15); cb.SetTextMatrix(250 + (595 * i), (419 * (9 - j)) + 280); cb.ShowText(COILID + "+" + TYPE + "+" + COLOR + "+" + WEIGHT + "+" + GAUGE + "+" + WIDTH); cb.SetFontAndSize(mybf, 45); if (COLOR.Length == 4) { cb.SetTextMatrix(120 + (595 * i), (419 * (9 - j)) + 350); } else { cb.SetTextMatrix(135 + (595 * i), (419 * (9 - j)) + 350); } cb.ShowText(COLOR); cb.SetFontAndSize(mybf, 35); cb.SetTextMatrix(160 + (595 * i), (419 * (9 - j)) + 320); cb.ShowText(TYPE); cb.SetFontAndSize(mybf, 25); cb.SetTextMatrix(130 + (595 * i), (419 * (9 - j)) + 300); string month_year = DateTime.Now.ToString("MMM").ToUpper() + "_" + DateTime.Now.ToString("yy"); cb.ShowText(month_year); cb.SetFontAndSize(mybf, 150); cb.SetTextMatrix(120 + (595 * i), (419 * (9 - j)) + 150); cb.ShowText(COLOR); cb.SetFontAndSize(mybf, 100); cb.SetTextMatrix(140 + (595 * i), (419 * (9 - j)) + 50); cb.ShowText(TYPE); // we tell the contentByte, we've finished drawing text cb.EndText(); // A5 size: 21cm x 14.8cm, (595, 419) var A5Size = new iTextSharp.text.Rectangle(15 + (595 * i), (419 * (9 - j)) + 15, 580 + (595 * i), (419 * (9 - j)) + 404); iTextSharp.text.Rectangle pageBorderRect = new iTextSharp.text.Rectangle(A5Size); pageBorderRect.BorderWidth = 6; i++; if (i == 5) { j++; i = 0; } pageNumber++; cb.SetColorStroke(BaseColor.GRAY); cb.Rectangle(pageBorderRect.Left, pageBorderRect.Bottom, pageBorderRect.Width, pageBorderRect.Height); cb.Stroke(); } catch (Exception ex) { ErrMsg.Text = "Input format is not corrent!" + ex.Message; COILID = null; TYPE = null; COLOR = null; WEIGHT = 0; GAUGE = null; WIDTH = null; return; } } pdfdoc.Close(); } } }
private void button1_Click(object sender, EventArgs e) { DataTable sat = DALCadastro.VerificaSAT(Convert.ToInt32(Global.Margem.IdProdSAT)); if (sat.Rows.Count == 1) { label3.Text = ""; string message = "O Emulador precisa estar executando para o teste.\nPodemos continuar?"; string caption = "Emulador SAT"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; // Displays the MessageBox. result = MessageBox.Show(this, message, caption, buttons, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { string codativação = "123456789"; string sessao = ""; GeraSAT_EMU gera = new GeraSAT_EMU(); //IntPtr teste = SAT_Emulador_Funcoes.ConsultarSAT(numsess); //int num = Marshal.ReadInt32(teste); IntPtr recebe = SAT_Emulador_Funcoes.EnviarDadosVenda(numsess, codativação, gera.EnviaXML(Convert.ToInt32(Global.Margem.IdProdSAT), "emulador")); //IntPtr recebe = SAT_Emulador_Funcoes.EnviarDadosVenda(numsess, codativação, gera.EnviaXML(20, "produção", "44")); string stringB = Marshal.PtrToStringAnsi(recebe); using (StreamWriter writer = new StreamWriter("Cfe.txt")) { writer.Write(stringB.ToString()); } string time = ""; string chave = ""; string total = ""; string assinatura = ""; string sucesso = ""; int barra = 0; for (int i = 0; i < stringB.Length; i++) { if (stringB.Substring(i, 1) == "|") { barra++; } if (barra < 1) { label3.Text += stringB.Substring(i, 1); } if (barra <= 4) { sucesso += stringB.Substring(i, 1); } if (barra == 7) { time += stringB.Substring(i, 1); } if (barra == 8) { chave += stringB.Substring(i, 1); } if (barra == 9) { total += stringB.Substring(i, 1); } if (barra == 11) { assinatura += stringB.Substring(i, 1); } } string url = chave + time + total + assinatura; QRCodeEncoder qrencod = new QRCodeEncoder(); Bitmap qrcode = qrencod.Encode(url); pictureBox2.Image = qrcode as Image; chave = chave.Replace("|", ""); chave2 = chave; string caminho = chave; chave = chave.Replace("C", ""); chave = chave.Replace("F", ""); chave = chave.Replace("e", ""); Code128BarcodeDraw cod128 = new Code128BarcodeDraw(Code128Checksum.Instance); if (String.IsNullOrEmpty(chave) == false) { pictureBox1.Image = cod128.Draw(chave, 50, 1); } else { return; } if (Convert.ToString(numsess).Length == 1) { sessao = "00000" + Convert.ToString(numsess); } if (Convert.ToString(numsess).Length == 2) { sessao = "0000" + Convert.ToString(numsess); } if (Convert.ToString(numsess).Length == 3) { sessao = "000" + Convert.ToString(numsess); } if (Convert.ToString(numsess).Length == 4) { sessao = "00" + Convert.ToString(numsess); } if (Convert.ToString(numsess).Length == 5) { sessao = "0" + Convert.ToString(numsess); } if (Global.Margem.xProd.Length >= 15) { label18.Text = "001 7890000000001 " + Global.Margem.xProd.Substring(0, 15) + " 1 pcX0,00 T 18% 0,00"; } if (Global.Margem.xProd.Length < 15) { label18.Text = "001 7890000000001 " + Global.Margem.xProd.Substring(0, Global.Margem.xProd.Length) + " 1 pcX0,00 T 18% 0,00"; } label21.Text = chave; //System.Diagnostics.Process.Start("C:\\SAT\\CFes\\" + caminho + ".XML"); //webBrowser1.Navigate(new Uri("C:\\SAT\\CFes\\" + caminho + ".XML")); string caminho2 = caminho.Replace("C", "A"); caminho2 = caminho2.Replace("F", "D"); caminho2 = caminho2.Replace("e", ""); // caminho e nome atual do arquivo string antigo = "C:\\SAT\\CFes\\" + caminho + ".XML"; string path = Directory.GetCurrentDirectory(); // caminho e novo nome do arquivo string novo = path + "\\SAT_EMU\\copias_de_segurança\\Emitidos\\" + caminho2 + ".XML"; // vamos renomear o arquivo File.Move(antigo, novo); webBrowser1.Navigate(new Uri(novo)); numsess = numsess + 1; MessageBox.Show(sucesso + "\nCFe" + chave); button2.Visible = true; } } }
private void button2_Click(object sender, EventArgs e) { label3.Text = ""; geraSAT ger = new geraSAT(); MessageBox.Show(Convert.ToString(numsess) + " " + chave2); string cod = "#lecoteco1975#"; IntPtr rec = SAT_Emulador_Funcoes.CancelarUltimaVenda(numsess, cod, chave2, ger.CancelaVenda_XML(chave2, "emulador")); string stringB = Marshal.PtrToStringAnsi(rec); using (StreamWriter writer = new StreamWriter("CfeCancelado.txt")) { writer.Write(stringB.ToString()); } string time = ""; string chave = ""; string total = ""; string assinatura = ""; string sucesso = ""; int barra = 0; for (int i = 0; i < stringB.Length; i++) { if (stringB.Substring(i, 1) == "|") { barra++; } if (barra < 1) { label3.Text += stringB.Substring(i, 1); } if (barra <= 4) { sucesso += stringB.Substring(i, 1); } if (barra == 7) { time += stringB.Substring(i, 1); } if (barra == 8) { chave += stringB.Substring(i, 1); } if (barra == 9) { total += stringB.Substring(i, 1); } if (barra == 11) { assinatura += stringB.Substring(i, 1); } } string url = chave + time + total + assinatura; QRCodeEncoder qrencod = new QRCodeEncoder(); Bitmap qrcode = qrencod.Encode(url); pictureBox2.Image = qrcode as Image; chave = chave.Replace("|", ""); chave2 = chave; string caminho = chave; chave = chave.Replace("C", ""); chave = chave.Replace("F", ""); chave = chave.Replace("e", ""); Code128BarcodeDraw cod128 = new Code128BarcodeDraw(Code128Checksum.Instance); pictureBox1.Image = cod128.Draw(chave, 50, 1); string caminho2 = caminho.Replace("C", "A"); caminho2 = caminho2.Replace("F", "D"); caminho2 = caminho2.Replace("e", "C"); // caminho e nome atual do arquivo string antigo = "C:\\SAT\\CFesCancelados\\" + caminho + ".XML"; string path = Directory.GetCurrentDirectory(); // caminho e novo nome do arquivo string novo = path + "\\SAT_EMU\\copias_de_segurança\\Cancelados\\" + caminho2 + ".XML"; // vamos renomear o arquivo File.Move(antigo, novo); webBrowser1.Navigate(new Uri(novo)); label21.Text = chave; numsess = numsess + 1; MessageBox.Show(sucesso + "\nCFe" + chave); button2.Visible = false; numsess++; }
private void btn_print_Click(object sender, EventArgs e) { if (orderDetail.Rows.Count > 0) { List <OrderReceipt> list = new List <OrderReceipt>(); int sum_qty = 0; foreach (DataRow row in orderDetail.Rows) { sum_qty += Convert.ToInt16(row["item_qty"].ToString()); list.Add(new OrderReceipt() { item_id = row["item_id"].ToString(), item_name = row["item_name"].ToString(), item_discount = row["item_discount"].ToString(), item_total = row["total1"].ToString(), item_qty = row["item_qty"].ToString(), price = row["item_price"].ToString() } ); } Code128BarcodeDraw barcode = BarcodeDrawFactory.Code128WithChecksum; Image image = new Bitmap(barcode.Draw(orderDetail.Rows[0]["id"].ToString(), 100)); string barCodeImage = this.ImageToBase64(image, System.Drawing.Imaging.ImageFormat.Jpeg); //this.orders = new Orders(); //this.orderStatus = new OrderStatus(); //string order_status_id = this.orderStatus.getOrderStatus("completed"); //if (this.isPayByCash) //{ // this.orders.Id = orderDetail.Rows[0]["id"].ToString(); // this.orders.Order_status_id = order_status_id; // this.orders.Payment_method = "cash"; // this.orders.Payment_recieved = Convert.ToString(this.payment_received); // this.orders.Amount_returned = Convert.ToString(this.cash_back); // this.orders.completeOrder(); //} //else //{ // this.orders.Id = orderDetail.Rows[0]["id"].ToString(); // this.orders.Order_status_id = order_status_id; // this.orders.Payment_method = "debit_card"; // this.orders.completeOrder(false); //} Dictionary <string, string> item = new Dictionary <string, string>(); item.Add("total", this.total); item.Add("discount", this.discount); item.Add("payment_received", Convert.ToString(this.payment_received)); item.Add("cash_back", Convert.ToString(this.cash_back)); item.Add("order_type", this.order_type); item.Add("order_id", orderDetail.Rows[0]["id"].ToString()); item.Add("barcode_image", barCodeImage); item.Add("sum_qty", Convert.ToString(sum_qty)); using (OrderPaymentPrint orderPrePayment = new OrderPaymentPrint(list, item)) { if (orderPrePayment.ShowDialog() != DialogResult.OK) { // do some thing } } } }
private void Barcode_Click(object sender, EventArgs e) { Code128BarcodeDraw barcode = BarcodeDrawFactory.Code128WithChecksum; pictureBox1.Image = barcode.Draw(Mybarcode.Text, 2011111); }
public Form1() { InitializeComponent(); bdf = BarcodeDrawFactory.Code128WithChecksum; PrinterRobot = new PrintRobot(); }
/*private void xmlButton_Click(object sender, EventArgs e) * { * if (xmlOpenFileDialog.ShowDialog() == DialogResult.OK) * { * try * { * string xml = File.ReadAllText(xmlOpenFileDialog.FileName); * InvoiceModel invoice = _invoice.XmlDecode(xml); * try * { * _invoice.Add(invoice); * MessageBox.Show("Zapisano z XML'a do bazy"); * } * catch (Exception ex) * { * MessageBox.Show(ex.Message.ToString()); * } * * } * catch (Exception err) * { * MessageBox.Show(err.Message); * } * } * }*/ private void buttonKreskowe_Click(object sender, EventArgs e) { Cursor = Cursors.WaitCursor; Dict si = comboBoxKreskowe.SelectedItem as Dict; string text = textBoxBarcode.Text; Image barcodeImage = null; switch (si.Key) { case "qr": CodeQrBarcodeDraw bd = BarcodeDrawFactory.CodeQr; barcodeImage = bd.Draw(text, 2, 2); break; case "code_11": if (Barcode.isValidCode11(text)) { Code11BarcodeDraw bd_code11 = BarcodeDrawFactory.Code11WithoutChecksum; barcodeImage = bd_code11.Draw(text, 60, 1); } else { MessageBox.Show("Wprowadzona wartość nie może zostać wygenerowana.\nCode 11 zawiera cyfry od 0 do 9 oraz łącznik (-)."); } break; case "code_39": if (Barcode.isValidCode39(text)) { Code39BarcodeDraw bd_code39 = BarcodeDrawFactory.Code39WithoutChecksum; barcodeImage = bd_code39.Draw(text, 60, 1); } else { MessageBox.Show("Wprowadzona wartość nie może zostać wygenerowana.\n" + "Code 39 zawiera wszystkie litery, cyfry od 0 do 9, następujące znaki specjalne \"-.$/+%\" i spacje."); } break; case "code_128": if (Barcode.isValidCode128(text)) { Code128BarcodeDraw bd_code128 = BarcodeDrawFactory.Code128WithChecksum; barcodeImage = bd_code128.Draw(text, 60, 1); } else { MessageBox.Show("Wprowadzona wartość nie może zostać wygenerowana.\n" + ""); } break; case "ean8": if (Barcode.isValidEan8(text)) { CodeEan8BarcodeDraw bd_ean8 = BarcodeDrawFactory.CodeEan8WithChecksum; barcodeImage = bd_ean8.Draw(text, 60, 1); } else { MessageBox.Show("Wprowadzona wartość nie może zostać wygenerowana.\n" + "Kod ten zawiera 8 cyfr, ale ostatni znak jest sumą kontrolną, więc należy wprowadzić 7 znaków."); } break; case "ean13": if (Barcode.isValidEan13(text)) { CodeEan13BarcodeDraw bd_ean13 = BarcodeDrawFactory.CodeEan13WithChecksum; barcodeImage = bd_ean13.Draw(text, 60, 1); } else { MessageBox.Show("Wprowadzona wartość nie może zostać wygenerowana.\n" + "Kod ten zawiera 13 cyfr, ale ostatni znak jest sumą kontrolną, więc należy wprowadzić 12 znaków."); } break; } if (barcodeImage != null) { Print print = new Print(); print.printBarcode(barcodeImage, text); pictureBoxKreskowe.Image = barcodeImage; } Cursor = Cursors.Default; }
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { Code128BarcodeDraw barcode = BarcodeDrawFactory.Code128WithChecksum; string ash = "My name is ashfaque"; PictureBox pic1 = new PictureBox(); e.Graphics.DrawImage(pic1.Image = barcode.Draw(ash, 80), 550, 300, 250, 70); e.Graphics.DrawString("ALI CAFE Pvt LTD...", new Font("Century751 SeBd BT", 35, FontStyle.Bold), Brushes.Fuchsia, 150, 25); Pen pen = new Pen(Brushes.Black, 10); e.Graphics.DrawLine(pen, 110, 85, 720, 85); e.Graphics.DrawString("Address:- Master Colony Old Mehruun Raod Jalgaon 425001 ", new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 30, 100); e.Graphics.DrawString("Mobail Number 1: 7066367203", new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 30, 140); e.Graphics.DrawString("Mobail Number 2: 9175831706", new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 400, 140); e.Graphics.DrawString("Email:- [email protected]", new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 30, 180); e.Graphics.DrawString("WebSite:- www.abc.com", new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 400, 180); e.Graphics.DrawLine(pen, 10, 230, 810, 230); e.Graphics.DrawString("Client Name:- " + ClientNameTextBox.Text, new Font("Arial", 17, FontStyle.Bold), Brushes.Black, 30, 260); e.Graphics.DrawString("Date:- " + DateTime.Now, new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 30, 300); e.Graphics.DrawString("......................................................................................................................................", new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 25, 380); e.Graphics.DrawString("Item Description", new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 55, 410); e.Graphics.DrawString("Peice", new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 350, 410); e.Graphics.DrawString("Quantity", new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 500, 410); e.Graphics.DrawString("Total", new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 680, 410); e.Graphics.DrawString("......................................................................................................................................", new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 25, 440); Pen pen2 = new Pen(Brushes.Black, 3); e.Graphics.DrawLine(pen2, 25, 399, 25, 800); e.Graphics.DrawLine(pen2, 810, 399, 810, 800); //-------------------------- if (gsv1.Top != 0) { e.Graphics.DrawString(gsv1.SetItemName(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 55, 480); e.Graphics.DrawString(gsv1.SetIprice().ToString(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 360, 480); e.Graphics.DrawString(gsv1.SetQuantity().ToString(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 520, 480); e.Graphics.DrawString(gsv1.SetTotal().ToString(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 695, 480); gsv1.After_Uing(); // GrandTotal += int.Parse(TotalTextBox.Text); } if (gsv1.Top != 0) { e.Graphics.DrawString(gsv1.SetItemName(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 55, 530); e.Graphics.DrawString(gsv1.SetIprice().ToString(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 360, 530); e.Graphics.DrawString(gsv1.SetQuantity().ToString(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 520, 530); e.Graphics.DrawString(gsv1.SetTotal().ToString(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 695, 530); gsv1.After_Uing(); //GrandTotal += int.Parse(TotalTextBox.Text); } if (gsv1.Top != 0) { e.Graphics.DrawString(gsv1.SetItemName(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 55, 580); e.Graphics.DrawString(gsv1.SetIprice().ToString(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 360, 580); e.Graphics.DrawString(gsv1.SetQuantity().ToString(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 520, 580); e.Graphics.DrawString(gsv1.SetTotal().ToString(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 695, 580); gsv1.After_Uing(); //GrandTotal += int.Parse(TotalTextBox.Text); } if (gsv1.Top != 0) { e.Graphics.DrawString(gsv1.SetItemName(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 55, 630); e.Graphics.DrawString(gsv1.SetIprice().ToString(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 360, 630); e.Graphics.DrawString(gsv1.SetQuantity().ToString(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 520, 630); e.Graphics.DrawString(gsv1.SetTotal().ToString(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 695, 630); gsv1.After_Uing(); // GrandTotal += int.Parse(TotalTextBox.Text); } if (gsv1.Top != 0) { e.Graphics.DrawString(gsv1.SetItemName(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 55, 680); e.Graphics.DrawString(gsv1.SetIprice().ToString(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 360, 680); e.Graphics.DrawString(gsv1.SetQuantity().ToString(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 520, 680); e.Graphics.DrawString(gsv1.SetTotal().ToString(), new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 695, 680); gsv1.After_Uing(); //GrandTotal += int.Parse(TotalTextBox.Text); } e.Graphics.DrawString("......................................................................................................................................", new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 20, 730); e.Graphics.DrawString("Grand Total :-", new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 35, 760); e.Graphics.DrawString("RS. " + GrandTotal, new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 620, 760); e.Graphics.DrawString("......................................................................................................................................", new Font("Arial", 15, FontStyle.Bold), Brushes.Black, 20, 780); gsv1.After_Uing(); //GrandTotal += int.Parse(TotalTextBox.Text); }
public static Image Generate(string text, int maxBarHeight) { Code128BarcodeDraw barcode = BarcodeDrawFactory.Code128WithChecksum; return(barcode.Draw(text, maxBarHeight, 3)); }
public ActionResult Sliting(CoilSlits slits) { ViewBag.Title = "Coil Slit"; Session["CurrForm"] = "CoilSlit"; slits.errMsg = ""; if (slits.inputHidden != null) { //char[] delimiters = { ' ', '+' }; //string[] inputArray = slits.input.Split(delimiters); // split the input string by using the delimiter '+' if (slits.inputHidden.Length < 9) { slits.errMsg = "Wrong Coil ID."; return(View(slits)); } string coilID = slits.inputHidden.Substring(0, 9); int cover_width = 0; int base_width = 0; if (slits.slitWidth == 118) { cover_width = 51; base_width = 67; } if (slits.slitWidth == 150) { cover_width = 67; base_width = 83; } if (slits.slitWidth == 200) { cover_width = 92; base_width = 108; } CodeQrBarcodeDraw QRcode = BarcodeDrawFactory.CodeQr; // to generate QR code Code128BarcodeDraw barcode128 = BarcodeDrawFactory.Code128WithChecksum; // to generate barcode Image img_QRcode = null; Image img_Barcode = null; byte[] imgBytes; string imgString; var sql = "select * from GRAM_SYD_LIVE.dbo.X_COIL_MASTER where COILID = '" + coilID + "'"; try { using (var context = new DbContext(Global.ConnStr)) { slits.CoilDetails = context.Database.SqlQuery <CoilMaster>(sql).ToList <CoilMaster>(); } } catch (Exception e) { slits.errMsg = "SQL Exception: " + e + ";"; } if (slits.CoilDetails.Count == 0) { slits.errMsg = "No information found in the database."; return(View(slits)); } string M_color = ""; string S_color = ""; int uniqueLocation = 0; if (slits.CoilDetails[0].COLOR.Length == 4) { M_color = slits.CoilDetails[0].COLOR.Substring(0, 2); S_color = slits.CoilDetails[0].COLOR.Substring(2, 2); } switch (slits.CoilDetails[0].TYPE) { case "RA": slits.slitNumber = 4; slits.slitWidth = 170; cover_width = slits.slitWidth; base_width = slits.slitWidth; break; case "SM": break; case "PO": slits.slitNumber = 8; slits.slitWidth = 135; cover_width = slits.slitWidth; base_width = slits.slitWidth; break; case "PL": slits.slitNumber = 4; slits.slitWidth = 255; cover_width = slits.slitWidth; base_width = slits.slitWidth; break; case "IS": slits.slitNumber = 8; slits.slitWidth = 116; cover_width = slits.slitWidth; base_width = slits.slitWidth; break; default: slits.errMsg = "Type not exist."; break; } if (slits.slitNumber > 0 && slits.CoilDetails != null) { string[] slitIDs = new string[slits.slitNumber]; string[] slitLabels = new string[slits.slitNumber]; slits.QRcodes = new string[8]; slits.Barcodes = new string[8]; for (int i = 1; i < slitIDs.Length + 1; i++) { slitIDs[i - 1] = slits.CoilDetails[0].COILID + "_" + i; slits.slits.Add(new CoilSlit()); slits.slits[i - 1].COIL_SLIT_ID = slitIDs[i - 1]; slits.slits[i - 1].TYPE = slits.CoilDetails[0].TYPE; slits.slits[i - 1].COLOR = slits.CoilDetails[0].COLOR; slits.slits[i - 1].M_COLOR = M_color; slits.slits[i - 1].S_COLOR = S_color; slits.slits[i - 1].WEIGHT = (int)(slits.CoilDetails[0].WEIGHT / slits.slitNumber); slits.slits[i - 1].GAUGE = slits.CoilDetails[0].GAUGE; slits.slits[i - 1].LENGTH = slits.CoilDetails[0].CLENGTH; slits.slits[i - 1].UNIQUELOCATION = uniqueLocation; if (i % 2 != 0) { slits.slits[i - 1].WIDTH = cover_width; } else { slits.slits[i - 1].WIDTH = base_width; } slits.slits[i - 1].STATUS = 0; // new -> 0, used -> 1 slitLabels[i - 1] = slits.CoilDetails[0].COILID + "_" + i + "+" + slits.CoilDetails[0].TYPE + "+" + slits.CoilDetails[0].COLOR + "+" + (int)(slits.CoilDetails[0].WEIGHT / slits.slitNumber) + "+" + slits.CoilDetails[0].GAUGE + "+" + slits.slits[i - 1].WIDTH; BarcodeMetrics barcodeMetrics = QRcode.GetDefaultMetrics(150); barcodeMetrics.Scale = 3; //qrcode size img_QRcode = QRcode.Draw(slitLabels[i - 1], barcodeMetrics); imgBytes = turnImageToByteArray(img_QRcode); imgString = Convert.ToBase64String(imgBytes); slits.QRcodes[i - 1] = String.Format("<img src=\"data:image/png;base64,{0}\"/>", imgString); img_Barcode = barcode128.Draw(slitLabels[i - 1], 100); imgBytes = turnImageToByteArray(img_Barcode); imgString = Convert.ToBase64String(imgBytes); slits.Barcodes[i - 1] = String.Format("<img src=\"data:image/png;base64,{0}\"/>", imgString); } slits.CoilSlitIDs = slitIDs; slits.CoilSlitLabels = slitLabels; if (slits.printFlag == "print") { for (int i = 0; i < slits.CoilSlitIDs.Count; i++) { var coilID_sql = new SqlParameter("@coilID", slits.CoilDetails[0].COILID); var coilSlitID_sql = new SqlParameter("@coilSlitID", slits.slits[i].COIL_SLIT_ID); var type_sql = new SqlParameter("@type", slits.slits[i].TYPE); var color_sql = new SqlParameter("@color", slits.slits[i].COLOR); var m_color_sql = new SqlParameter("@m_color", slits.slits[i].M_COLOR); var s_color_sql = new SqlParameter("@s_color", slits.slits[i].S_COLOR); var weight_sql = new SqlParameter("@weight", slits.slits[i].WEIGHT); var gauge_sql = new SqlParameter("@gauge", slits.slits[i].GAUGE); var width_sql = new SqlParameter("@width", slits.slits[i].WIDTH); var status_sql = new SqlParameter("@status", slits.slits[i].STATUS); var userID_sql = new SqlParameter("@userID", ((Scanner.Models.User)Session["User"]).UserName); var length_sql = new SqlParameter("@length", DBNull.Value); var uniqueLocation_sql = new SqlParameter("@uniqueLocation", slits.slits[i].UNIQUELOCATION); if (slits.slits[i].LENGTH != null) { length_sql = new SqlParameter("@length", slits.slits[i].LENGTH); } else { length_sql = new SqlParameter("@length", DBNull.Value); } var sql_update = "exec GramOnline.dbo.proc_Y_AddCoilSlit " + "@coilID, " + "@coilSlitID, " + "@type, " + "@color, " + "@m_color, " + "@s_color, " + "@weight, " + "@gauge, " + "@width, " + "@status, " + "@userID, " + "@length, " + "@uniqueLocation "; try { using (var context = new DbContext(Global.ConnStr)) { context.Database.ExecuteSqlCommand(sql_update, coilID_sql, coilSlitID_sql, type_sql, color_sql, m_color_sql, s_color_sql, weight_sql, gauge_sql, width_sql, status_sql, userID_sql, length_sql, uniqueLocation_sql); } } catch (Exception e) { slits.errMsg = "SQL Exception: " + e.Message + ";"; } } } } } return(View(slits)); }