예제 #1
0
 void HandleScanResult(ZXing.Result result)
 {
     if (result != null && !string.IsNullOrEmpty(result.Text))
     {
         if (result.Text.Length == 13)
         {
             libro = Service.SearchBook(result.Text);
             if (libro != null)
             {
                 edtISBN.Text   = libro.ISBN;
                 edtTitulo.Text = libro.Titulo;
             }
             else
             {
                 Toast.MakeText(this, "El libro no existe", ToastLength.Long).Show();
             }
         }
         else
         {
             Toast.MakeText(this, "Error en los datos", ToastLength.Long).Show();
         }
     }
     else
     {
         Toast.MakeText(this, "Vuelva a escanear", ToastLength.Long).Show();
     }
 }
예제 #2
0
        public void BuscarLibro()
        {
            var libro = Service.SearchBook(edtISBN.Text);

            if (libro != null)
            {
                edtISBN.Text    = libro.ISBN;
                edtTitle.Text   = libro.Titulo;
                edtCod.Text     = libro.Codigo;
                edtPreview.Text = libro.Descripcion;
                edtAutor.Text   = libro.Autor;
                Bitmap bitmap = BitmapFactory.DecodeByteArray(libro.Portada, 0, libro.Portada.Length);

                Img.SetImageBitmap(bitmap);

                edtTitle.Enabled    = false;
                edtPreview.Enabled  = false;
                edtAutor.Enabled    = false;
                edtCod.Enabled      = false;
                sp_Materias.Enabled = false;

                sp_Materias.SetSelection(libro.MateriaId);

                Toast.MakeText(this, "Ya existe un libro con ese ISBN", ToastLength.Long).Show();
            }
            else
            {
                edtISBN.Enabled     = true;
                edtTitle.Enabled    = true;
                edtCod.Enabled      = false;
                edtPreview.Enabled  = true;
                edtAutor.Enabled    = true;
                sp_Materias.Enabled = true;
            }
        }
예제 #3
0
        /// <summary>
        /// EVENTO PARA SCANEAR EL CODIGO Y SUS ACCIONES
        /// </summary>
        /// <param name="result"></param>
        void HandleScanResult(ZXing.Result result)
        {
            if (result != null && !string.IsNullOrEmpty(result.Text))
            {
                //LONGITUD DE CEDULA CLIENTE
                if (result.Text.Length == 14)
                {
                    //BUSCAR EL CLIENTE
                    var cliente = Service.GetCustomerData(result.Text);
                    if (cliente != null)
                    {
                        idCliente = cliente.Id;
                        //LLENAR EL ENCABEZADO
                        edtCedula.Text  = cliente.Codigo;
                        edtNombres.Text = cliente.Nombres + " " + cliente.Apellidos;
                    }
                    else
                    if (cliente == null)
                    {
                        edtCode.Text = result.Text;
                    }
                }
                else//LONGITUD DE ISBN LIBRO
                if (result.Text.Length == 13)
                {
                    var libro = Service.SearchBook(result.Text);
                    if (libro != null)
                    {
                        //LLENO LOS EDITEXT
                        edtisbn.Text   = libro.ISBN;
                        edttitulo.Text = libro.Titulo;

                        //BUSCO LAS COPIAS DISPONIBLES DEL LIBRO ENCONTRADO
                        listasp = Service.CopiesByBook(libro.ISBN);
                        //LLENAR EL ADAPTER CON LA LISTA DEL SERVICIO
                        spCopias.Adapter = new AdapterSpCopias((Activity)rootView.Context, listasp);
                        //spCopias.SetSelection(0,true);
                        spCopias.ItemSelected += SpCopias_ItemSelected;
                    }
                    else
                    {
                        Toast.MakeText(rootView.Context, "No se encontro el libro", ToastLength.Long).Show();
                    }
                }
                else
                {
                    Toast.MakeText(rootView.Context, "Error en los datos", ToastLength.Long).Show();
                }
            }
            else
            {
                Toast.MakeText(rootView.Context, "Vuelva a escanear", ToastLength.Long).Show();
            }
        }
예제 #4
0
        void HandleScanResult(ZXing.Result result)
        {
            if (result != null && !string.IsNullOrEmpty(result.Text))
            {
                if (result.Text.Length == 13)
                {
                    var libro = Service.SearchBook(result.Text);
                    if (libro != null)
                    {
                        edtISBN.Text    = libro.ISBN;
                        edtTitle.Text   = libro.Titulo;
                        edtCod.Text     = libro.Codigo;
                        edtPreview.Text = libro.Descripcion;
                        edtAutor.Text   = libro.Autor;
                        Bitmap bitmap = BitmapFactory.DecodeByteArray(libro.Portada, 0, libro.Portada.Length);

                        Img.SetImageBitmap(bitmap);

                        edtTitle.Enabled    = false;
                        edtPreview.Enabled  = false;
                        edtAutor.Enabled    = false;
                        edtCod.Enabled      = false;
                        Img.Enabled         = false;
                        sp_Materias.Enabled = false;

                        sp_Materias.SetSelection(libro.MateriaId);

                        Toast.MakeText(this, "Ya existe un libro con ese ISBN", ToastLength.Long).Show();
                    }
                    else
                    {
                        edtISBN.Enabled     = true;
                        edtISBN.Text        = result.Text;
                        edtTitle.Enabled    = true;
                        edtCod.Enabled      = false;
                        edtPreview.Enabled  = true;
                        edtAutor.Enabled    = true;
                        sp_Materias.Enabled = true;
                    }
                }
                else
                {
                    Toast.MakeText(this, "Error en los datos", ToastLength.Long).Show();
                }
            }
            else
            {
                Toast.MakeText(this, "Vuelva a escanear", ToastLength.Long).Show();
            }
        }
예제 #5
0
 private void BtnCheck_Click(object sender, EventArgs e)
 {
     if (edtISBN.Text != "")
     {
         libro = Service.SearchBook(edtISBN.Text);
         if (libro != null)
         {
             edtISBN.Text   = libro.ISBN;
             edtTitulo.Text = libro.Titulo;
         }
         else
         {
             Toast.MakeText(this, "El libro no existe", ToastLength.Long).Show();
         }
     }
     Toast.MakeText(this, "Ingrese un código ISBN", ToastLength.Long).Show();
 }
예제 #6
0
        private void Btnlibros_Click(object sender, EventArgs e)
        {
            View view = LayoutInflater.Inflate(Resource.Layout.copiasbybook, null);

            //SE CREA EL POP UP DEL LIBRO
            Android.App.AlertDialog builder = new Android.App.AlertDialog.Builder((Activity)rootView.Context)
                                              .SetTitle("Agregar Libro")
                                              .SetIcon(Android.Resource.Drawable.IcDialogInfo)
                                              .SetNegativeButton("Cerrar", (IDialogInterfaceOnClickListener)null)
                                              .SetPositiveButton("Agregar", delegate {
                if (Detalleranta.Count() == 0)
                {
                    Detalleranta.Add(lista);
                    Toast.MakeText(rootView.Context, "Se Agrego", ToastLength.Long).Show();
                }
                else
                {
                    CopysBookWS Copia = Detalleranta.DefaultIfEmpty(null).FirstOrDefault(x => x.CopyId == lista.CopyId);

                    if (Copia == null)
                    {
                        Detalleranta.Add(lista);
                        Toast.MakeText(rootView.Context, "Se Agrego", ToastLength.Long).Show();
                    }
                    else
                    {
                        Toast.MakeText(rootView.Context, "No se puede agregar por que ya existe", ToastLength.Long).Show();
                    }
                }

                listacopias         = rootView.FindViewById <ListView>(Resource.Id.listView1);
                listacopias.Adapter = new AdapterDetailRental((Activity)rootView.Context, Detalleranta);
            }).Create();
            //ASIGNACION DE TEXTOS
            edtisbn           = view.FindViewById <EditText>(Resource.Id.editText1);
            edttitulo         = view.FindViewById <EditText>(Resource.Id.editText2);
            edttitulo.Enabled = false;
            spCopias          = view.FindViewById <Spinner>(Resource.Id.spinner1);
            ImageButton btnISBN = view.FindViewById <ImageButton>(Resource.Id.button2);

#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnISBN.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            ImageButton btnScanner = view.FindViewById <ImageButton>(Resource.Id.button1);
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnScanner.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            btnISBN.Click += delegate
            {
                if (edtisbn.Text != null)
                {
                    var libro = Service.SearchBook(edtisbn.Text);
                    if (libro != null)
                    {
                        //LLENO LOS EDITEXT
                        edtisbn.Text   = libro.ISBN;
                        edttitulo.Text = libro.Titulo;

                        //BUSCO LAS COPIAS DISPONIBLES DEL LIBRO ENCONTRADO
                        listasp = Service.CopiesByBook(libro.ISBN);
                        //LLENAR EL ADAPTER CON LA LISTA DEL SERVICIO
                        spCopias.Adapter = new AdapterSpCopias((Activity)rootView.Context, listasp);
                        //spCopias.SetSelection(0,true);
                        spCopias.ItemSelected += SpCopias_ItemSelected;
                    }
                    else
                    {
                        Toast.MakeText(rootView.Context, "Dígite el código ISBN", ToastLength.Long).Show();
                    }
                }
            };
            btnScanner.Click += async delegate
            {
                //SCANEAR EL ISBN DEL LIBRO
                //Tell our scanner to use the default overlay
                scanner.UseCustomOverlay = false;

                //PERSONALIZAR LOS MENSAJES QUE SE MOSTRARAN EN LA CAMARA DEL SCANNER
                scanner.TopText    = "Por favor, no mueva el dispositivo móvil\nMantengalo al menos 10cm de distancia";
                scanner.BottomText = "Espere mientras el scanner lee el código de barra";

                //COMIENZO DEL SCANEO Y ALMACENO SU VALOR
                var result = await scanner.Scan();

                HandleScanResult(result);
            };

            //view.FindViewById<ImageButton>(Resource.Id.button2).Click += FragmentRental_Click;

            listacopias = view.FindViewById <ListView>(Resource.Id.listView1);

            //spCopias = view.FindViewById<Spinner>(Resource.Id.spinner1);

            builder.SetView(view);
            builder.Show();
        }
예제 #7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.AddCopy);
            // Create your application here

            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            SetActionBar(toolbar);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetHomeButtonEnabled(true);

            btnScan        = FindViewById <ImageButton>(Resource.Id.button1);
            btnCheck       = FindViewById <ImageButton>(Resource.Id.button2);
            btnSave        = FindViewById <Button>(Resource.Id.button3);
            edtISBN        = FindViewById <EditText>(Resource.Id.editText1);
            edtNumber      = FindViewById <EditText>(Resource.Id.editText3);
            edtTitulo      = FindViewById <EditText>(Resource.Id.editText2);
            btnSave.Click += BtnSave_Click;

            isbn = Intent.GetStringExtra("libroId");


            if (isbn != null)
            {
                edtISBN.Text = isbn;
                libro        = Service.SearchBook(edtISBN.Text);
                if (libro != null)
                {
                    edtISBN.Text   = libro.ISBN;
                    edtTitulo.Text = libro.Titulo;
                }
                else
                {
                    Toast.MakeText(this, "El libro no existe", ToastLength.Long).Show();
                }
            }


#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnScan.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnCheck.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos

            btnCheck.Click += BtnCheck_Click;

            MobileBarcodeScanner.Initialize(Application);
            scanner = new MobileBarcodeScanner();

            btnScan.Click += async delegate {
                //Tell our scanner to use the default overlay
                scanner.UseCustomOverlay = false;

                //PERSONALIZAR LOS MENSAJES QUE SE MOSTRARAN EN LA CAMARA DEL SCANNER
                scanner.TopText    = "Por favor, no mueva el dispositivo móvil\nMantengalo al menos 10cm de distancia";
                scanner.BottomText = "Espere mientras el scanner lee el código de barra";

                //COMIENZO DEL SCANEO
                var result = await scanner.Scan();

                HandleScanResult(result);
            };
        }