コード例 #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            // Use this to return your custom view for this Fragment
            // return inflater.Inflate(Resource.Layout.YourFragment, container, false);
            //return base.OnCreateView(inflater, container, savedInstanceState);

            rootView = inflater.Inflate(Resource.Layout.fragmentrental, container, false);
            //INICIALIZAR LOS OBJETOS
            MobileBarcodeScanner.Initialize(Activity.Application);

            scanner = new MobileBarcodeScanner();

            edtCedula    = rootView.FindViewById <EditText>(Resource.Id.editText1);
            edtNombres   = rootView.FindViewById <EditText>(Resource.Id.editText2);
            edtCodAlq    = rootView.FindViewById <EditText>(Resource.Id.editText3);
            edtFechaalq  = rootView.FindViewById <EditText>(Resource.Id.editText4);
            edtFechaDevo = rootView.FindViewById <EditText>(Resource.Id.editText5);

            //DESACTIVAR LOS EDITEXT DE FECHA Y OTROS
            edtFechaalq.Enabled  = false;
            edtFechaDevo.Enabled = false;
            edtCodAlq.Enabled    = false;
            edtNombres.Enabled   = false;

            int var = int.Parse(Service.RentalCode());

            edtCodAlq.Text   = var.ToString();
            edtFechaalq.Text = DateTime.Now.ToShortDateString();

            //ASIGNACION DE OBJETOS Y ELIMINACION DE FONDOS A IMAGEBOTTON
            btnScan = rootView.FindViewById <ImageButton>(Resource.Id.button1);
#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
            btnAgregar = rootView.FindViewById <ImageButton>(Resource.Id.button2);
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnAgregar.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            btnFecha = rootView.FindViewById <ImageButton>(Resource.Id.button3);
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnFecha.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            btnlibros = rootView.FindViewById <ImageButton>(Resource.Id.button4);
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnlibros.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            btnguardar = rootView.FindViewById <ImageButton>(Resource.Id.button5);
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnguardar.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos
            btnAceptar = rootView.FindViewById <ImageButton>(Resource.Id.button6);
#pragma warning disable CS0618 // El tipo o el miembro están obsoletos
            btnAceptar.SetBackgroundDrawable(null);
#pragma warning restore CS0618 // El tipo o el miembro están obsoletos

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

            btnlibros.Click  += Btnlibros_Click;
            btnFecha.Click   += BtnFecha_Click;
            btnAgregar.Click += BtnAgregar_Click;
            btnguardar.Click += Btnguardar_Click;
            btnAceptar.Click += BtnAceptar_Click;

            //ACTIVA EL ESCANEO
            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);
            };

            return(rootView);
        }
コード例 #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();
        }