static bool IsSymbology2D(BarCodeSymbology symbology) { return(symbology == BarCodeSymbology.QRCode || symbology == BarCodeSymbology.DataMatrix || symbology == BarCodeSymbology.DataMatrixGS1 || symbology == BarCodeSymbology.PDF417); }
private void scan_callback(object sender, DataEventArgs e) { Scanner s = (Scanner)sender; BarCodeSymbology t = s.ScanDataType; string l = Encoding.Default.GetString(s.ScanDataLabel); Debug.WriteLine("Scan: {0}: " + l, t); try { SqlCommand com = new SqlCommand(string.Format("select * from products " + "inner join sale_listings " + "on products.id = sale_listings.product_id " + "where (barcode = '{0}');", l), con); List <Plu> plus = new List <Plu>(); using (SqlDataReader r = com.ExecuteReader()) { while (r.Read()) { plus.Add(new Plu((int)r[0], (string)r[1], (string)r[2], (string)r[3], (decimal)r[6], (byte)r[7])); } foreach (Plu plu in plus) { Debug.WriteLine(string.Format("{0}, {1}, {2}, {3}, {4}, {5}", plu.Id, plu.Sku, plu.Barcode, plu.Description, plu.UnitPrice, vat_decode(plu.Vat))); } } if (plus.Count == 0) { MessageBox.Show(string.Format("The barcode \"{0}\" does not have an associated sale listing.\n" + "Please contact the cash register database maintainer to solve the problem.", l)); } else if (plus.Count > 1) { // Allow user to pick specific product from list of matches in a dialog window. ProductDiscrimination pd = new ProductDiscrimination(plus); var result = pd.ShowDialog(); if (result == DialogResult.OK) { dataGridView1.Rows.Add(plus[pd.return_index].Sku, plus[pd.return_index].Barcode, plus[pd.return_index].Description, 1, plus[pd.return_index].UnitPrice, plus[pd.return_index].UnitPrice, vat_decode(plus[pd.return_index].Vat)); } } else { // Automatically add the first and only match. dataGridView1.Rows.Add(plus[0].Sku, plus[0].Barcode, plus[0].Description, 1, plus[0].UnitPrice, plus[0].UnitPrice, vat_decode(plus[0].Vat)); } } catch { MessageBox.Show("Failed to complete database query.\nPlease contact the cash register database maintainer to solve the problem."); } s.DataEventEnabled = true; }
private void GoodScan_Click(object sender, System.EventArgs e) { // Queue up a data event BarCodeSymbology type = (BarCodeSymbology)Enum.Parse(typeof(BarCodeSymbology), Symbology.SelectedItem.ToString()); ScannerSimulator Sim = ServiceObjectReference.Target as ScannerSimulator; if (Sim != null) { Sim.InputDataEvent(BarCode.Text, type); } }
/// <summary> /// A good scan event occurred: queue it and update the GoodScanCount statistic /// </summary> /// <param name="d">Scan event arguments</param> public void InputDataEvent(string data, BarCodeSymbology type) { if (data == null) { return; } byte[] b = new byte[data.Length]; for (int i = 0; i < data.Length; i++) { b[i] = (byte)data[i]; } Logger.Info("Scanner", "Scan event: " + DataToHex(b) + ", type=" + type); GoodScan(b, type, b); }
public override void PrintBarCode(PrinterStation station, string data, BarCodeSymbology symbology, int height, int width, int alignment, BarCodeTextPosition textPosition) { VerifyResult(_cco.PrintBarCode((int)station, data, (int)symbology, height, width, alignment, (int)textPosition)); }
private void ScanCallback(object sender, DataEventArgs e) { Scanner s = (Scanner)sender; BarCodeSymbology t = s.ScanDataType; string l = Encoding.Default.GetString(s.ScanDataLabel); Debug.WriteLine("Scan: {0}: " + l, t); SqlCommand com = new SqlCommand(string.Format("select * from products inner join sale_listings on products.id =" + "sale_listings.product_id where (barcode = '{0}');", l), Connection); SqlDataReader r = com.ExecuteReader(); List <ProductListingLookUp> plus = new List <ProductListingLookUp>(); while (r.Read()) { plus.Add(new ProductListingLookUp() { Id = (int)r[0], SKU = (string)r[1], Barcode = (string)r[2], Description = (string)r[3], UnitPrice = (decimal)r[6], VAT = DecodeVAT((byte)r[7]) }); } r.Close(); Debug.WriteLine("plus.Count: {0}", plus.Count); if (plus.Count == 0) { MessageBox.Show(string.Format("Barcode \"{0}\" does not have an associated product listing in the database.", l)); } else if (plus.Count == 1) { Debug.WriteLine("Adding new ReceiptLine."); AddReceiptLine( new ReceiptLine() { SKU = plus[0].SKU, Barcode = plus[0].Barcode, Description = plus[0].Description, UnitPrice = plus[0].UnitPrice, VAT = plus[0].VAT } ); } else { ChooseProductListingWindow w = new ChooseProductListingWindow(); w.ProductListingDataGrid.ItemsSource = plus; w.ShowDialog(); Debug.WriteLine("ReturnIndex: {0}", w.ReturnIndex); if (w.ReturnIndex != -1) { AddReceiptLine( new ReceiptLine() { SKU = plus[w.ReturnIndex].SKU, Barcode = plus[w.ReturnIndex].Barcode, Description = plus[w.ReturnIndex].Description, UnitPrice = plus[w.ReturnIndex].UnitPrice, VAT = plus[w.ReturnIndex].VAT } ); } } s.DataEventEnabled = true; }
/// <summary> /// A good scan event occurred: queue it and update the GoodScanCount statistic /// </summary> /// <param name="d">Scan event arguments</param> public void InputDataEvent(string data, BarCodeSymbology type) { if (data == null) return; byte[] b = new byte[data.Length]; for (int i=0; i< data.Length; i++) b[i] = (byte) data[i]; Logger.Info("Scanner", "Scan event: " + DataToHex(b) + ", type=" + type); GoodScan(b, type, b); }