Ejemplo n.º 1
0
        public Historicos()
        {
            try
            {
                InitializeComponent();
                rvm   = new RecargasViewModel();
                Title = "Histórico de recargas";
                NavigationPage.SetBackButtonTitle(this, "");

                lsr = rvm.SelRecargas().Where(x => x.err == 0 && !String.IsNullOrEmpty(x.rsauthorization) && !String.IsNullOrEmpty(x.rstransactionid)).OrderByDescending(x => x.fecha).ToList();
                lvHistoricos.ItemSelected += async(sender, e) =>
                {
                    if (e.SelectedItem == null)
                    {
                        return;
                    }

                    Recarga h      = e.SelectedItem as Recarga;
                    var     action = await DisplayActionSheet("Opción", "Cerrar", null, "Recargar a este número");

                    if (action == "Recargar a este número")
                    {
                        CargarSaldo p = new CargarSaldo(h);
                        await App.Nav.PushAsync(p);
                    }

                    ((ListView)sender).SelectedItem = null;
                };
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 2
0
        public Automaticas()
        {
            InitializeComponent();
            Title = "Recargas automaticas";
            rvm   = new RecargasViewModel();
            NavigationPage.SetBackButtonTitle(this, "");

            lvAutomaticas.ItemSelected += async(sender, e) => {
                if (e.SelectedItem == null)
                {
                    return;
                }
                var action = await DisplayActionSheet("Opcion", "Cerrar", null, "Modificar");

                if (action == "Modificar")
                {
                    CargarSaldo p = new CargarSaldo(e.SelectedItem as RecargaProg);
                    await App.Nav.PushAsync(p);
                }
                ((ListView)sender).SelectedItem = null;
            };
        }
Ejemplo n.º 3
0
        private async Task MuestraContactos()
        {
            List <RecargaFrecuente> lrf;
            List <char>             letras = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".ToList();

            try
            {
                Groups.Clear();
                lrf = rvm.SelRecargasFrecuentes();
                IEnumerable <Contacto> lsrf = lrf.Select(x => new Contacto {
                    Name = x.contactorecarga, Number = x.numerorecarga, Photo = null
                });
                Groups.Add(new letragrupo("Frecuentes", lsrf));
                foreach (char c in letras)
                {
                    Groups.Add(new letragrupo(c.ToString(), ls.Where(x => x.Name.StartsWith(c.ToString())).ToList()));
                }
                lvContactos.ItemSelected += async(sender, e) =>
                {
                    if (e.SelectedItem == null)
                    {
                        return;
                    }
                    var              cs = App.Nav.NavigationStack.OfType <CargarSaldo>().FirstOrDefault();
                    Contacto         c  = (e.SelectedItem as Contacto);
                    RecargaFrecuente rf = lrf.Where(x => x.numerorecarga == c.Number).FirstOrDefault();                     //App.db.SelRecargaFrecuente(c.Number);
                    if (cs == null)
                    {
                        if (rf == null)
                        {
                            cs = new CargarSaldo(new Recarga {
                                numerorecarga = c.Number, contactorecarga = c.Name
                            });
                        }
                        else
                        {
                            cs = new CargarSaldo(rf);
                        }
                        await App.Nav.PopAsync(Constantes.animated);

                        await App.Nav.PushAsync(cs, Constantes.animated);
                    }
                    else
                    {
                        if (rf == null)
                        {
                            cs.CargaDeAgenda(new Recarga {
                                numerorecarga = c.Number, contactorecarga = c.Name
                            });
                        }
                        else
                        {
                            cs.CargaDeAgenda(rf);
                        }
                        await App.Nav.PopAsync(Constantes.animated);
                    }

                    ((ListView)sender).SelectedItem = null;
                };
                lvContactos.BeginRefresh();
                lvContactos.IsGroupingEnabled = true;
                lvContactos.ItemsSource       = null;
                lvContactos.ItemsSource       = Groups;
                lvContactos.EndRefresh();

                srcBuscar.TextChanged += (object sender, TextChangedEventArgs e) =>
                {
                    string filtro = e.NewTextValue;
                    lvContactos.BeginRefresh();
                    if (String.IsNullOrEmpty(filtro))
                    {
                        lvContactos.ItemsSource = Groups;
                    }
                    else
                    {
                        if (filtro.Length == 1)
                        {
                            List <letragrupo> llg = Groups.Where(x => x.letra.ToUpper() == filtro.ToUpper()).ToList();
                            lvContactos.ItemsSource = llg;
                        }
                        else
                        {
                            List <letragrupo>      lg;
                            IEnumerable <Contacto> iec = ls.Where(x => (x.Name.ToUpper().Contains(filtro.ToUpper()) || (x.Number.Contains(filtro.ToUpper()))));
                            if (iec.Count() > 0)
                            {
                                lg = new List <letragrupo>()
                                {
                                    new letragrupo("", iec)
                                };
                                lvContactos.ItemsSource = lg;
                            }
                            else
                            {
                                if (Regex.IsMatch(filtro, phoneRegex, RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250)))
                                {
                                    List <Contacto> lc = new List <Contacto>()
                                    {
                                        new Contacto()
                                        {
                                            Id = "99999", Name = "Nuevo contacto", Number = filtro, Photo = null
                                        }
                                    };
                                    lg = new List <letragrupo>()
                                    {
                                        new letragrupo("Nuevo contacto", lc.AsEnumerable())
                                    };
                                    lvContactos.ItemsSource = lg;
                                }
                            }
                        }
                    }
                    lvContactos.EndRefresh();
                };
            }
            catch (Exception e)
            {
            }
            finally
            {
                UserDialogs.Instance.HideLoading();
            }
        }