Exemplo n.º 1
0
 protected override void OnDisappearing()
 {
     if (barCodeString == "")
     {
         BarcodeRead?.Invoke(this, barCodeButton + ": Não foi possível ler o código.");
     }
     zXing.IsScanning = false;
     base.OnDisappearing();
 }
 public void Handle_OnScanResult(Result result)
 {
     //pega as informações do código lido e exibe
     Device.BeginInvokeOnMainThread(async() =>
     {
         if (!PopUp)
         {
             PopUp = true;
             BarcodeRead?.Invoke(this, result.BarcodeFormat + ": " + result.Text);
             btnResult.Text = result.BarcodeFormat + ": " + result.Text;
             await DisplayAlert("Código " + result.BarcodeFormat, result.BarcodeFormat + ": " + result.Text, "OK");
             PopUp = false;
         }
     });
 }
Exemplo n.º 3
0
        public TelaCodigoBarras(string op)
        {
            /*MobileBarcodeScanningOptions optionCode = this.optionCode;*/

            InitializeComponent();

            // Configuração da Leitura
            this.optionsEan8 = new MobileBarcodeScanningOptions
            {
                AutoRotate = false,
                UseFrontCameraIfAvailable = false,
                TryHarder = true,
                // Todos os formatos que códigos que serão aceitos
                PossibleFormats = new List <ZXing.BarcodeFormat> {
                    ZXing.BarcodeFormat.EAN_8
                }
            };

            this.optionsEan13 = new MobileBarcodeScanningOptions
            {
                AutoRotate = false,
                UseFrontCameraIfAvailable = false,
                TryHarder = true,
                // Todos os formatos que códigos que serão aceitos
                PossibleFormats = new List <ZXing.BarcodeFormat> {
                    ZXing.BarcodeFormat.EAN_13
                }
            };

            this.optionsEan14 = new MobileBarcodeScanningOptions
            {
                AutoRotate = false,
                UseFrontCameraIfAvailable = false,
                TryHarder = true,
                // Todos os formatos que códigos que serão aceitos
                PossibleFormats = new List <ZXing.BarcodeFormat> {
                    ZXing.BarcodeFormat.EAN_8,
                    ZXing.BarcodeFormat.CODE_128
                }
            };

            this.optionsQrCode = new MobileBarcodeScanningOptions
            {
                AutoRotate = false,
                UseFrontCameraIfAvailable = false,
                TryHarder = true,
                // Todos os formatos que códigos que serão aceitos
                PossibleFormats = new List <ZXing.BarcodeFormat> {
                    ZXing.BarcodeFormat.QR_CODE
                }
            };

            switch (op)
            {
            case "EAN_8":
                barCodeButton = op;
                zXing         = new ZXingScannerView
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    Options           = optionsEan8
                };
                break;

            case "EAN_13":
                barCodeButton = op;
                zXing         = new ZXingScannerView
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    Options           = optionsEan13
                };
                break;

            case "EAN_14":
                barCodeButton = op;
                zXing         = new ZXingScannerView
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    Options           = optionsEan14
                };
                break;

            case "QR_CODE":
                barCodeButton = op;
                zXing         = new ZXingScannerView
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand,
                    Options           = optionsQrCode
                };
                break;
            }

            zXing.OnScanResult += (result) =>
                                  Device.BeginInvokeOnMainThread(async() =>
            {
                // Finaliza a leitura
                zXing.IsAnalyzing = false;

                barCodeString = result.Text;
                // Pega as informações do código lido
                BarcodeRead?.Invoke(this, barCodeButton + ": " + barCodeString);
                await Navigation.PopModalAsync();
            });

            overlay = new ZXingDefaultOverlay
            {
                TopText         = "Aproxime do código para leitura",
                BottomText      = "O código será lido automaticamente",
                ShowFlashButton = zXing.HasTorch
            };

            var grid = new Grid
            {
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            grid.Children.Add(zXing);
            grid.Children.Add(overlay);

            Content = grid;
        }
Exemplo n.º 4
0
        public JsonResult PickDown()
        {
            int _userid = (int)Session["user_id"];
            var _ckid   = Request["ck"] ?? "";
            var _loc    = Request["loc"] ?? "";
            var _ph     = Request["ph"] ?? "";
            var _xl     = Request["xl"] ?? "";
            var _sl     = Request["sl"] ?? "";

            if (string.IsNullOrEmpty(_ckid) || string.IsNullOrEmpty(_loc))
            {
                return(Json(-1));
            }
            if (string.IsNullOrEmpty(_ph) && string.IsNullOrEmpty(_xl))
            {
                return(Json(-1));
            }
            if ((!string.IsNullOrEmpty(_ph)) && (!string.IsNullOrEmpty(_xl)))
            {
                return(Json(-1));
            }
            if (string.IsNullOrEmpty(_sl))
            {
                _sl = "1";
            }
            else
            {
                if (_sl == "0")
                {
                    return(Json(-1));
                }
            }
            var _cargoloc = ServiceFactory.wms_jianhuoservice.GetPickDetail(int.Parse(_ckid), p => p.Kuwei == _loc.Trim()).ToList <wms_pick_v>();

            if (_cargoloc == null)
            {
                return(Json(-2));
            }
            List <wms_pick_v> _cargo = null;

            if (!string.IsNullOrEmpty(_ph))
            {
                _ph    = BarcodeRead.BatchCode(_ph.Trim());
                _cargo = _cargoloc.Where(p => p.Pihao == _ph.Trim()).ToList <wms_pick_v>();
            }
            if (!string.IsNullOrEmpty(_xl))
            {
                _xl    = BarcodeRead.SerialNumber(_xl.Trim());
                _cargo = _cargoloc.Where(p => p.Xuliema == _xl.Trim()).ToList <wms_pick_v>();
            }
            if (_cargo == null)
            {
                return(Json(-2));
            }
            if (_cargo.Count == 1)
            {
                wms_jianhuo _jh = ServiceFactory.wms_jianhuoservice.GetEntityById(p => p.ID == _cargo[0].pickid);
                if (_jh != null)
                {
                    if (_jh.ShijianSL == null)
                    {
                        _jh.ShijianSL = 0;
                    }
                    if (_cargo[0].DaijianSL >= _jh.ShijianSL + float.Parse(_sl))
                    {
                        _jh.ShijianSL = _jh.ShijianSL + float.Parse(_sl);
                        ServiceFactory.wms_jianhuoservice.UpdateEntity(_jh);
                    }
                }
            }
            else
            {
                float _sjsl = float.Parse(_sl);
                foreach (var cargo in _cargo)
                {
                    if (cargo != null)
                    {
                        wms_jianhuo _jh = ServiceFactory.wms_jianhuoservice.GetEntityById(p => p.ID == cargo.pickid);
                        if (_jh != null)
                        {
                            if (_jh.ShijianSL == null)
                            {
                                _jh.ShijianSL = 0;
                            }
                            if (_jh.DaijianSL > _jh.ShijianSL && _sjsl > 0)
                            {
                                if (_jh.DaijianSL >= _jh.ShijianSL + _sjsl)
                                {
                                    _jh.ShijianSL = _jh.ShijianSL + _sjsl;
                                    _sjsl         = 0;
                                }
                                else
                                {
                                    _sjsl         = _sjsl - ((float)_jh.DaijianSL - (float)_jh.ShijianSL);
                                    _jh.ShijianSL = _jh.DaijianSL;
                                }
                                ServiceFactory.wms_jianhuoservice.UpdateEntity(_jh);
                            }
                        }
                    }
                }
            }
            return(Json(1));
        }
Exemplo n.º 5
0
        public ActionResult SaveRecieve()
        {
            int _userid = (int)Session["user_id"];
            var _rkd    = Request["rkid"] ?? "";
            var _sp     = Request["shangpin"] ?? "";
            var _spnum  = Request["spnum"] ?? "";
            var _ph     = Request["pihao"] ?? "";
            var _phnum  = Request["phnum"] ?? "";
            var _xl     = Request["xlm"] ?? "";
            var _xlnum  = Request["xlnum"] ?? "";

            if (string.IsNullOrEmpty(_rkd))
            {
                _rkd = "0";
            }
            var _rkmx = ServiceFactory.wms_rukumxservice.LoadEntities(p => p.RukuID == int.Parse(_rkd) && p.IsDelete == false).ToList <wms_rukumx>();

            if (_rkmx == null)
            {
                return(RedirectToAction("Index"));
            }

            if (string.IsNullOrEmpty(_sp))
            {
                _spnum = "0";
            }
            else
            {
                //var _mxsp = from u in _rkmx
                //            group u by u.ShangpinTM into tb
                //            select new
                //            {
                //                sptm = tb.Key,
                //                spcount = tb.Count()
                //            };
                var _mxsp = _rkmx.Where(p => p.ShangpinTM == _sp).ToList <wms_rukumx>();
                if (_mxsp != null)
                {
                    if (string.IsNullOrEmpty(_spnum))
                    {
                        _spnum = "1";
                    }
                    if (_mxsp.Count() == 1 && int.Parse(_spnum) > 0)
                    {
                        wms_shouhuomx _sh = AddRecieveRec(_mxsp[0], int.Parse(_spnum), _userid);
                        if (_sh == null)
                        {
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            return(RedirectToAction("Recieving", new { rkd = _rkd }));
                        }
                    }
                }
            }
            if (string.IsNullOrEmpty(_ph))
            {
                _phnum = "0";
            }
            else
            {
                _ph = BarcodeRead.BatchCode(_ph.Trim());
                var _mxph = _rkmx.Where(p => p.Pihao == _ph).ToList <wms_rukumx>();
                if (_mxph != null)
                {
                    if (string.IsNullOrEmpty(_phnum))
                    {
                        _phnum = "1";
                    }
                    if (_mxph.Count() == 1 && int.Parse(_phnum) > 0)
                    {
                        wms_shouhuomx _sh = AddRecieveRec(_mxph[0], int.Parse(_phnum), _userid);
                        if (_sh == null)
                        {
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            return(RedirectToAction("Recieving", new { rkd = _rkd }));
                        }
                    }
                }
            }
            if (string.IsNullOrEmpty(_xl))
            {
                _xlnum = "0";
            }
            else
            {
                _xl = BarcodeRead.SerialNumber(_xl.Trim());
                var _mxxl = _rkmx.Where(p => p.Xuliema == _xl).ToList <wms_rukumx>();
                if (_mxxl != null)
                {
                    if (string.IsNullOrEmpty(_xlnum))
                    {
                        _xlnum = "1";
                    }
                    if (_mxxl.Count() == 1 && int.Parse(_xlnum) > 0)
                    {
                        wms_shouhuomx _sh = AddRecieveRec(_mxxl[0], int.Parse(_xlnum), _userid);
                        if (_sh == null)
                        {
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            return(RedirectToAction("Recieving", new { rkd = _rkd }));
                        }
                    }
                }
            }
            return(RedirectToAction("Index"));
        }
Exemplo n.º 6
0
        public JsonResult SaveUpload()
        {
            int    _userid   = (int)Session["user_id"];
            string _username = (string)Session["user_name"];
            var    _rkid     = Request["rkd"] ?? "";
            var    _kuwei    = Request["kw"] ?? "";
            var    _kwid     = Request["kwid"] ?? "";
            var    _ph1      = Request["pihao1"] ?? "";
            var    _phnum1   = Request["phnum1"] ?? "";
            var    _ph2      = Request["pihao2"] ?? "";
            var    _phnum2   = Request["phnum2"] ?? "";
            var    _ph3      = Request["pihao3"] ?? "";
            var    _phnum3   = Request["phnum3"] ?? "";
            var    _xlm1     = Request["xlm1"] ?? "";
            var    _xlnum1   = Request["xlnum1"] ?? "";
            var    _xlm2     = Request["xlm2"] ?? "";
            var    _xlnum2   = Request["xlnum2"] ?? "";
            var    _xlm3     = Request["xlm3"] ?? "";
            var    _xlnum3   = Request["xlnum3"] ?? "";

            if (string.IsNullOrEmpty(_rkid) || string.IsNullOrEmpty(_kuwei))
            {
                return(Json(-1));
            }
            wms_kuwei _kw = ServiceFactory.wms_kuweiservice.GetEntityById(p => p.Mingcheng == _kuwei.Trim() && p.IsDelete == false);

            if (_kw == null)
            {
                return(Json(-3));
            }
            _kwid = _kw.ID.ToString();
            if (!string.IsNullOrEmpty(_ph1))
            {
                _ph1 = BarcodeRead.BatchCode(_ph1.Trim());
                if (string.IsNullOrEmpty(_phnum1))
                {
                    _phnum1 = "1";
                }
                var _sh = ServiceFactory.wms_shouhuomxservice.LoadEntities(p => p.Pihao == _ph1 && p.IsDelete == false).ToList <wms_shouhuomx>();
                if (_sh.Count == 1)
                {
                    wms_cunhuo _ch = AddUpload(_sh[0], int.Parse(_phnum1), _kuwei, int.Parse(_kwid), _userid, _username);
                    if (_ch == null)
                    {
                        return(Json(-2));
                    }
                }
                else
                {
                    foreach (var shmx in _sh)
                    {
                        if (shmx.Shuliang == float.Parse(_phnum1) && shmx.ShangjiaSL == 0)
                        {
                            wms_cunhuo _ch = AddUpload(shmx, int.Parse(_phnum1), _kuwei, int.Parse(_kwid), _userid, _username);
                            if (_ch == null)
                            {
                                return(Json(-2));
                            }
                            break;
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(_ph2))
            {
                _ph2 = BarcodeRead.BatchCode(_ph2.Trim());
                if (string.IsNullOrEmpty(_phnum2))
                {
                    _phnum2 = "1";
                }
                var _sh = ServiceFactory.wms_shouhuomxservice.LoadEntities(p => p.Pihao == _ph2 && p.IsDelete == false).ToList <wms_shouhuomx>();
                if (_sh.Count == 1)
                {
                    wms_cunhuo _ch = AddUpload(_sh[0], int.Parse(_phnum2), _kuwei, int.Parse(_kwid), _userid, _username);
                    if (_ch == null)
                    {
                        return(Json(-2));
                    }
                }
                else
                {
                    foreach (var shmx in _sh)
                    {
                        if (shmx.Shuliang == float.Parse(_phnum2) && shmx.ShangjiaSL == 0)
                        {
                            wms_cunhuo _ch = AddUpload(shmx, int.Parse(_phnum2), _kuwei, int.Parse(_kwid), _userid, _username);
                            if (_ch == null)
                            {
                                return(Json(-2));
                            }
                            break;
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(_ph3))
            {
                _ph3 = BarcodeRead.BatchCode(_ph3.Trim());
                if (string.IsNullOrEmpty(_phnum3))
                {
                    _phnum3 = "1";
                }
                var _sh = ServiceFactory.wms_shouhuomxservice.LoadEntities(p => p.Pihao == _ph3 && p.IsDelete == false).ToList <wms_shouhuomx>();
                if (_sh.Count == 1)
                {
                    wms_cunhuo _ch = AddUpload(_sh[0], int.Parse(_phnum3), _kuwei, int.Parse(_kwid), _userid, _username);
                    if (_ch == null)
                    {
                        return(Json(-2));
                    }
                }
                else
                {
                    foreach (var shmx in _sh)
                    {
                        if (shmx.Shuliang == float.Parse(_phnum3) && shmx.ShangjiaSL == 0)
                        {
                            wms_cunhuo _ch = AddUpload(shmx, int.Parse(_phnum3), _kuwei, int.Parse(_kwid), _userid, _username);
                            if (_ch == null)
                            {
                                return(Json(-2));
                            }
                            break;
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(_xlm1))
            {
                _xlm1 = BarcodeRead.SerialNumber(_xlm1.Trim());
                if (string.IsNullOrEmpty(_xlnum1))
                {
                    _xlnum1 = "1";
                }
                var _sh = ServiceFactory.wms_shouhuomxservice.LoadEntities(p => p.Xuliema == _xlm1 && p.IsDelete == false).ToList <wms_shouhuomx>();
                if (_sh.Count == 1 && int.Parse(_xlnum1) > 0)
                {
                    wms_cunhuo _ch = AddUpload(_sh[0], int.Parse(_xlnum1), _kuwei, int.Parse(_kwid), _userid, _username);
                    if (_ch == null)
                    {
                        return(Json(-2));
                    }
                }
            }
            if (!string.IsNullOrEmpty(_xlm2))
            {
                _xlm2 = BarcodeRead.SerialNumber(_xlm2.Trim());
                if (string.IsNullOrEmpty(_xlnum2))
                {
                    _xlnum2 = "1";
                }
                var _sh = ServiceFactory.wms_shouhuomxservice.LoadEntities(p => p.Xuliema == _xlm2 && p.IsDelete == false).ToList <wms_shouhuomx>();
                if (_sh.Count == 1 && int.Parse(_xlnum2) > 0)
                {
                    wms_cunhuo _ch = AddUpload(_sh[0], int.Parse(_xlnum2), _kuwei, int.Parse(_kwid), _userid, _username);
                    if (_ch == null)
                    {
                        return(Json(-2));
                    }
                }
            }
            if (!string.IsNullOrEmpty(_xlm3))
            {
                _xlm3 = BarcodeRead.SerialNumber(_xlm3.Trim());
                if (string.IsNullOrEmpty(_xlnum3))
                {
                    _xlnum3 = "1";
                }
                var _sh = ServiceFactory.wms_shouhuomxservice.LoadEntities(p => p.Xuliema == _xlm3 && p.IsDelete == false).ToList <wms_shouhuomx>();
                if (_sh.Count == 1 && int.Parse(_xlnum3) > 0)
                {
                    wms_cunhuo _ch = AddUpload(_sh[0], int.Parse(_xlnum3), _kuwei, int.Parse(_kwid), _userid, _username);
                    if (_ch == null)
                    {
                        return(Json(-2));
                    }
                }
            }
            return(Json(1));
        }