Beispiel #1
0
        private void SpCopias_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            lista = new CopysBookWS();

            lista.ISBN        = listasp[e.Position].ISBN;
            lista.LibroId     = listasp[e.Position].LibroId;
            lista.Portada     = listasp[e.Position].Portada;
            lista.CopyId      = listasp[e.Position].CopyId;
            lista.NumeroCopia = listasp[e.Position].NumeroCopia;
            lista.Titulo      = listasp[e.Position].Titulo;

            //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();
            //    }
            //}
        }
Beispiel #2
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();
        }