示例#1
0
        private void txt_scan_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                if (txt_scan.Text.Trim() == "")
                {
                    return;
                }

                //如果是采购入仓单功能进入的扫码
                if (Procur != null)
                {
                    Procur.GetQr(txt_scan.Text.Trim());
                }
                else if (IInspection != null)//如果是来料质检单功能进入的扫码
                {
                    IInspection.GetQr(txt_scan.Text.Trim());
                }
                else if (Chooseform != null)
                {
                    Chooseform.GetQr(txt_scan.Text.Trim());
                }
                else if (PickOut != null)//领料出仓
                {
                    PickOut.GetQr(txt_scan.Text.Trim());
                }
                this.Close();
            }
        }
示例#2
0
 void timer1_Tick(object sender, EventArgs e)
 {
     if (img == null)
     {
         return;
     }
     #region 将图片转换成byte数组
     MemoryStream ms = new MemoryStream();
     Dictionary <DecodeHintType, object> dic = new Dictionary <DecodeHintType, object>();
     dic.Add(DecodeHintType.CHARACTER_SET, "UTF-8");//GB2312
     img.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
     byte[] bt = ms.GetBuffer();
     ms.Close();
     #endregion
     LuminanceSource source = new RGBLuminanceSource(bt, img.Width, img.Height);
     BinaryBitmap    bitmap = new BinaryBitmap(new ZXing.Common.HybridBinarizer(source));
     Result          result;
     try
     {
         result = new MultiFormatReader().decode(bitmap, dic);
     }
     catch (ReaderException re)
     {
         return;
     }
     if (result != null)
     {
         //如果是采购入仓单功能进入的扫码
         if (Procur != null)
         {
             Procur.GetQr(result.Text);
         }
         else if (IInspection != null)//如果是来料质检单功能进入的扫码
         {
             IInspection.GetQr(result.Text);
         }
         else if (Chooseform != null)
         {
             Chooseform.GetQr(result.Text);
         }
         else if (PickOut != null)//领料出仓
         {
             PickOut.GetQr(result.Text);
         }
         this.Close();
     }
 }