コード例 #1
0
ファイル: FragmentRental.cs プロジェクト: lcd97/ManoAmigaApp
        /// <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();
            }
        }
コード例 #2
0
ファイル: FragmentRental.cs プロジェクト: lcd97/ManoAmigaApp
        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();
        }