Ejemplo n.º 1
0
 private async void ScanAction(object obj)
 {
     try
     {
         var item          = (Product)obj;
         var barcodeScan   = new BarcodeScanner();
         var vmScanBarcode = new BarcodeScannerViewModel();
         barcodeScan.BindingContext         = vmScanBarcode;
         vmScanBarcode.OnResultScanHandler += async(x) => {
             if (item != null)
             {
                 if (_SourceItems.Where(prod => !string.IsNullOrEmpty(prod.CodeArticle) && prod.CodeArticle == x.ToString()).Count() > 0)
                 {
                     MessagingCenter.Send <MessageDataCenter>(new MessageDataCenter
                     {
                         Title   = "Error",
                         Message = $"Data {x} Sudah Ada",
                         Ok      = "Ya"
                     }, "message");
                 }
                 else
                 {
                     item.CodeArticle = x.ToString();
                     var aa = await Products.Update(item.Id, item);
                 }
             }
         };
         await Shell.Current.Navigation.PushModalAsync(barcodeScan);
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
     }
 }
Ejemplo n.º 2
0
        private async void Button_Clicked(object sender, EventArgs e)
        {
            var form = new BarcodeScanner();
            var vm   = new BarcodeScannerViewModel();

            form.BindingContext     = vm;
            vm.OnResultScanHandler += Vm_OnResultScanHandler;

            await Navigation.PushModalAsync(form);
        }
Ejemplo n.º 3
0
 public BarcodeScanner()
 {
     InitializeComponent();
     scanView.Options = new ZXing.Mobile.MobileBarcodeScanningOptions
     {
         TryHarder       = true,
         PossibleFormats = new List <ZXing.BarcodeFormat>
         {
             ZXing.BarcodeFormat.EAN_8, ZXing.BarcodeFormat.EAN_13, ZXing.BarcodeFormat.UPC_A, ZXing.BarcodeFormat.UPC_E
         },
         DelayBetweenContinuousScans = 100,
         AutoRotate = true
     };
     scanView.AutoFocus();
     BindingContext = new BarcodeScannerViewModel();
 }