コード例 #1
0
        /// <summary>
        /// Consume al servicio que obtiene la información del usuario mediante una instancia de la clase CLienteRest
        /// y llena los campos correspondientes
        /// </summary>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                ClienteRest cliente = new ClienteRest();
                var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                if (inf != null)
                {
                    enNombre.Text  = inf.persona.nombre;
                    enPaterno.Text = inf.persona.apaterno;
                    enMaterno.Text = inf.persona.amaterno;
                    enCurp.Text    = inf.persona.curp;
                    persona.id     = inf.persona.id;
                    dtFecha.Date   = DateTime.ParseExact(inf.persona.fechanac, "yyyy-MM-dd", null);
                    for (var i = 0; i < pkEstCvl.Items.Count; i++)
                    {
                        if (pkEstCvl.Items[i].Equals(inf.persona.edoCivil))
                        {
                            pkEstCvl.SelectedIndex = i;
                        }
                    }
                    for (var i = 0; i < pkSexo.Items.Count; i++)
                    {
                        if (pkSexo.Items[i].Equals(inf.persona.sexo))
                        {
                            pkSexo.SelectedIndex = i;
                        }
                    }
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// llama al servicio para mostrar todos los teléfonos ingresados por el usuario y añadirlos a una lista.
        /// </summary>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                ClienteRest cliente = new ClienteRest();
                var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                list = new List <Telefono>();
                if (inf != null)
                {
                    foreach (var dato in inf.telefonos)
                    {
                        //catdir.cp = dato.catalogoDir.cp;
                        list.Add(new Telefono
                        {
                            id       = dato.id,
                            telefono = dato.telefono,
                            lada     = dato.lada,
                            tipo     = dato.tipo
                        });
                    }


                    BindingContext       = list;
                    listView.ItemsSource = list;
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Consume al servicio infoContribuyente para mostrar el nombre en la barra lateral
        /// </summary>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                TOKEN = Application.Current.Properties["token"] as string;

                ClienteRest cliente = new ClienteRest();
                var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                if (inf != null)
                {
                    lblNomre.Text = inf.persona.nombre;
                }
            }
        }
コード例 #4
0
ファイル: HomePage.xaml.cs プロジェクト: urielnat/PagoEnLinea
        /// <summary>
        /// Método asincrono que consume al servicio InfoContribuyente para obtener el nombre del usuario logueado
        /// a su vez muestra en el carrito los items que han sido añadidos al carrito al obtener la cantidad de la
        /// base de datos interna
        /// </summary>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                ClienteRest cliente = new ClienteRest();
                var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                if (inf != null)
                {
                    Nombre.Text = "Bienvenido(a): " + inf.persona.nombre;
                }
            }

            ((App)Application.Current).ResumeAtTodoId = -1;
            var list = await App.Database.GetItemsAsync();

            itemsCarrito.Text = list.Count.ToString();
        }
コード例 #5
0
        /// <summary>
        /// llama al servicio para mostrar todas las direcciones ingresadas por el usuario y añadirlos a una lista.
        /// </summary>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                var cont = 1;

                ClienteRest cliente = new ClienteRest();
                var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                list = new List <Modelos.infodir>();

                if (inf != null)
                {
                    foreach (var dato in inf.direcciones)
                    {
                        list.Add(new Modelos.infodir
                        {
                            NumerodeDireccion = "Dirección " + cont + ":",
                            id             = dato.id,
                            calle          = dato.calle,
                            numero         = dato.numero,
                            numeroInterior = dato.numeroInterior,
                            tipo           = dato.tipo,

                            cp               = dato.catalogoDir.cp,
                            asentamiento     = dato.catalogoDir.asentamiento,
                            municipio        = dato.catalogoDir.municipio,
                            estado           = dato.catalogoDir.estado,
                            pais             = dato.catalogoDir.pais,
                            tipoasentamiento = dato.catalogoDir.tipoasentamiento,
                            ciudad           = dato.catalogoDir.ciudad,
                            idCat            = dato.catalogoDir.id
                        });
                        cont++;
                        System.Diagnostics.Debug.WriteLine(dato.catalogoDir.municipio);
                    }


                    BindingContext       = list;
                    listView.ItemsSource = list;
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// evento que permite seleccionar una direccion de la lista y elegir la opcion de modificarlo o eliminarlo
        /// unicamente en android se hará uso del cuadro de diálogo personalizado ya que en iOS
        /// sus configuraciones nativas no lo requieren. Así mismo consume los servicios correspondientes.
        /// </summary>
        /// <param name="sender">objeto que hace referencia al evento</param>
        /// <param name="e">argumentos que son posibles de obtener apartir del objeto que hace llamada al evento</param>
        async void Agregar_Clicked(object sender, System.EventArgs e)
        {
            if (string.IsNullOrEmpty(enCorreo.Text) || !Regex.Match(enCorreo.Text, "^(?(\")(\".+?(?<!\\\\)\"@)|(([0-9A-Za-z]((\\.(?!\\.))|[-!#\\$%&'\\*\\+/=\\?\\^`\\{\\}\\|~\\w])*)(?<=[0-9A-Za-z])@))(?(\\[)(\\[(\\d{1,3}\\.){3}\\d{1,3}\\])|(([0-9a-z][-\\w]*[0-9a-z]*\\.)+[a-z0-9][\\-a-z0-9]{0,22}[a-z0-9]))$").Success)
            {
                await DisplayAlert("Advertencia", "Introduzca un correo electrónico valido", "OK");
            }
            else
            {
                if (Application.Current.Properties.ContainsKey("token"))
                {
                    ClienteRest cliente = new ClienteRest();
                    var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                    if (inf != null)
                    {
                        AgregarCorreo addemail = new AgregarCorreo();
                        addemail.persona = inf.persona;
                        addemail.email   = new Email
                        {
                            correoe = enCorreo.Text,
                            tipo    = "PERSONAL"
                        };
                        ClienteRest client = new ClienteRest();



                        client.POST(Constantes.URL_USUARIOS + "/email/agregar", addemail, 1);
                        MessagingCenter.Subscribe <ClienteRest>(this, "OK", (Sender) =>
                        {
                            DisplayAlert("Guardado", "¡Correo añadido con exito!", "OK");
                            Navigation.PopAsync();
                            MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                        });

                        MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) =>
                        {
                            DisplayAlert("Error", "¡No fué posible añadir el correo actual", "OK");
                            MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                        });
                    }
                }
            }
        }
コード例 #7
0
        /// <summary>
        /// llama al servicio para mostrar todos los datos de facturacíon ingresadas por el usuario y añadirlos a una lista.
        /// </summary>>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                ClienteRest cliente = new ClienteRest();



                var inf = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                //list = new List<DatosFacturacion>();

                lista = new List <MostrarDatosFacturacion>();



                if (inf != null)
                {
                    foreach (var dato in inf.datosFacturacion)
                    {
                        lista.Add(new MostrarDatosFacturacion
                        {
                            id             = dato.id,
                            rfc            = dato.rfc,
                            email          = dato.email.correoe,
                            nomrazonSocial = dato.nomrazonSocial,
                            direccion      = dato.direccion.catalogoDir.tipoasentamiento + " " + dato.direccion.catalogoDir.asentamiento + ", " + dato.direccion.calle + " " + dato.direccion.numero,
                            idDireccion    = dato.direccion.id,
                            idCatDir       = dato.direccion.catalogoDir.id,
                            calle          = dato.direccion.calle
                        });
                    }
                    BindingContext       = lista;
                    listView.ItemsSource = lista;
                }
            }
        }
コード例 #8
0
        /// <summary>
        /// método usado para consumir al servicio de modificar un teléfono, primero valida si los campos ingresados sean correctos
        /// </summary>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                ClienteRest cliente = new ClienteRest();
                var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                if (inf != null)
                {
                    Telefono modtel;


                    // modtel.persona = inf.persona;
                    bool auth = false, auth2 = false;


                    modtel = new Telefono
                    {
                        id       = ID,
                        tipo     = pkTipo.Items[pkTipo.SelectedIndex],
                        telefono = enTelefono.Text,
                        lada     = enLada.Text
                    };

                    ClienteRest client = new ClienteRest();
                    if (!String.IsNullOrEmpty(enTelefono.Text) && !(enTelefono.Text.Length < 7) && !(enTelefono.Text.Length > 10))
                    {
                        auth = true;
                    }
                    else
                    {
                        auth = false;
                        await DisplayAlert("Error", "Teléfono Invalido", "ok");
                    }


                    if (!String.IsNullOrEmpty(enLada.Text) && !(enLada.Text.Length < 2))
                    {
                        auth2 = true;
                    }
                    else
                    {
                        auth2 = false;
                        await DisplayAlert("Error", "LADA incorrecta", "ok");
                    }

                    if (auth && auth2)
                    {
                        client.PUT(Constantes.URL_USUARIOS + "/telefonos/modificar", modtel);
                        MessagingCenter.Subscribe <ClienteRest>(this, "OK", (Sender) => {
                            DisplayAlert("Guardado", "¡Teléfono Modificado con Exito!", "OK");
                            MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                            Navigation.PopAsync();
                        });

                        MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) => {
                            DisplayAlert("Error", "¡No fué posible Modificar el Teléfono!", "OK");
                            MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                        });
                    }
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// evento click del botón agregar para consumir al servicio de agregar un nuevo teléfono
        /// </summary>
        /// <param name="sender">objeto que hace referencia al evento</param>
        /// <param name="e">argumentos que son posibles de obtener apartir del objeto que hace llamada al evento</param>
        async void Agregar_Clicked(object sender, System.EventArgs e)
        {
            ClienteRest cliente = new ClienteRest();
            var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

            if (inf != null)
            {
                Modelos.ModificarTelefono modtel = new Modelos.ModificarTelefono();


                modtel.persona = inf.persona;
                bool auth = false, auth2 = false, auth3 = false;


                modtel.telefono = new Telefono
                {
                    tipo     = pkTipo.Items[pkTipo.SelectedIndex],
                    telefono = enTelefono.Text,
                    lada     = enLada.Text
                };

                ClienteRest client = new ClienteRest();
                if (!String.IsNullOrEmpty(enTelefono.Text) && !(enTelefono.Text.Length < 7) && !(enTelefono.Text.Length > 10))
                {
                    auth = true;
                }
                else
                {
                    auth = false;
                    await DisplayAlert("Error", "Teléfono Invalido", "ok");
                }


                if (!String.IsNullOrEmpty(enLada.Text) && !(enTelefono.Text.Length < 2))
                {
                    auth2 = true;
                }
                else
                {
                    auth2 = false;
                    await DisplayAlert("Error", "LADA incorrecta", "ok");
                }


                if (pkTipo.SelectedIndex > -1)
                {
                    auth3 = true;
                }
                else
                {
                    auth3 = false;
                    await DisplayAlert("Error", "Seleccione el tipo de teléfono", "ok");
                }

                if (auth && auth2 && auth3)
                {
                    client.POST(Constantes.URL_USUARIOS + "/telefono/agregar", modtel, 1);
                    MessagingCenter.Subscribe <ClienteRest>(this, "OK", (Sender) => {
                        DisplayAlert("Guardado", "¡Teléfono Añadido con Exito!", "OK");
                        MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                        Navigation.PopAsync();
                    });

                    MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) => {
                        DisplayAlert("Error", "¡No fué posible añadir el Teléfono!", "OK");
                        MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                    });
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// consume al servicio que contiene la información del usuario para mostrarla y pueda ser seleccionada como datos de facturación
        /// entre este información se encuentra sus direcciones y correos añadidos
        /// </summary>
        async void conectar()
        {
            if (Application.Current.Properties.ContainsKey("token"))
            {
                var cont = 1;

                ClienteRest cliente = new ClienteRest();
                var         inf     = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                listDir   = new List <Modelos.infodir>();
                listEmail = new List <Email>();


                if (inf != null)
                {
                    foreach (var dato in inf.direcciones)
                    {
                        listDir.Add(new Modelos.infodir
                        {
                            NumerodeDireccion = "Dirección " + cont + ":",
                            id             = dato.id,
                            calle          = dato.calle,
                            numero         = dato.numero,
                            numeroInterior = dato.numeroInterior,
                            tipo           = dato.tipo,

                            cp               = dato.catalogoDir.cp,
                            asentamiento     = dato.catalogoDir.asentamiento,
                            municipio        = dato.catalogoDir.municipio,
                            estado           = dato.catalogoDir.estado,
                            pais             = dato.catalogoDir.pais,
                            tipoasentamiento = dato.catalogoDir.tipoasentamiento,
                            ciudad           = dato.catalogoDir.ciudad,
                            idCat            = dato.catalogoDir.id
                        });

                        cont++;
                    }



                    foreach (var dato in inf.email)
                    {
                        listEmail.Add(new Email
                        {
                            id      = dato.id,
                            correoe = dato.correoe,
                            tipo    = dato.tipo,
                        });
                    }

                    System.Diagnostics.Debug.WriteLine(listEmail.Count);
                    foreach (var corr in listEmail)
                    {
                        pkCorreo.Items.Add(corr.correoe);
                    }

                    //System.Diagnostics.Debug.WriteLine(listEmail[3].id);



                    foreach (var dir in listDir)
                    {
                        pkDireccion.Items.Add(dir.asentamiento + " " + dir.calle + " " + dir.numero);
                    }


                    facturacion.id      = ID;
                    facturacion.persona = inf.persona;


                    if (tipos == 0)
                    {
                        for (var i = 0; i < pkCorreo.Items.Count; i++)
                        {
                            if (pkCorreo.Items[i].Equals(email))
                            {
                                pkCorreo.SelectedIndex = i;
                            }
                        }


                        for (var i = 0; i < pkDireccion.Items.Count; i++)
                        {
                            if (pkDireccion.Items[i].Contains(direccion))
                            {
                                pkDireccion.SelectedIndex = i;
                            }
                        }
                    }
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// este método valida que los campos ingresados en las entradas sean correctos antes de consumir al servicio
        /// de añadir una nueva dirección, en caso contrario se notifica al usuario
        /// </summary>
        async void Añadir()
        {
            bool a1 = false, a2 = false, a3 = false, a4 = false, a5 = false, a6 = false, a7 = false;


            if (ValidarVacio(enCalle.Text) || !Regex.Match(enCalle.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚüÜ\s0-9]+$").Success)
            {
                await DisplayAlert("Campo no valida", "Introduza una calle válida", "Ok");

                a1 = false;
            }
            else
            {
                a1 = true;
            }

            if (ValidarVacio(enNumero.Text) || !Regex.Match(enNumero.Text, "^[a-zA-Z0-9/-]*$").Success)
            {
                await DisplayAlert("Campo no valido", "Introduza una número válido", "Ok");

                a2 = false;
            }
            else
            {
                a2 = true;
            }


            if (ValidarVacio(enCP.Text) || enCP.Text.Length < 5)
            {
                await  DisplayAlert("Campo no valido", "Introduza una código postal válido", "Ok");

                a3 = false;
            }
            else
            {
                a3 = true;
            }


            if (!(pkTipoAsentamiento.SelectedIndex > -1))
            {
                await DisplayAlert("Campo vacio", "selecciona un tipo de asentamiento", "ok");

                a4 = false;
            }
            else
            {
                a4 = true;
            }

            if (ValidarVacio(enMunicipio.Text) || !Regex.Match(enMunicipio.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚ\s0-9]+$").Success)
            {
                await  DisplayAlert("Campo incorrecto", "Introduzca un municipio valido", "ok");

                a5 = false;
            }
            else
            {
                a5 = true;
            }

            if (ValidarVacio(enEstado.Text) || !Regex.Match(enEstado.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚÜü\s0-9]+$").Success)
            {
                await DisplayAlert("Campo vacio", "Introduzca un estado valido", "ok");

                a6 = false;
            }
            else
            {
                a6 = true;
            }
            if (!(pkAsentamiento.SelectedIndex > -1))
            {
                await DisplayAlert("Campo vacio", "seleccione su asentamiento", "ok");

                a7 = false;
            }
            else
            {
                a7 = true;
            }

            if (a1 && a2 && a3 && a4 && a5 && a6 && a7)
            {
                ClienteRest cliente = new ClienteRest();
                Modelos.AgregarDireccion agredire = new Modelos.AgregarDireccion();
                var inf = await cliente.InfoUsuario <InfoUsuario>(Application.Current.Properties["token"] as string);

                if (inf != null)
                {
                    agredire.persona = new Persona
                    {
                        id       = inf.persona.id,
                        nombre   = inf.persona.nombre,
                        apaterno = inf.persona.apaterno,
                        amaterno = inf.persona.amaterno,
                        curp     = inf.persona.curp,
                        edoCivil = inf.persona.edoCivil,
                        sexo     = inf.persona.sexo,
                        fechanac = inf.persona.fechanac
                    };


                    agredire.direccion = new Modelos.Direccion()
                    {
                        calle          = enCalle.Text,
                        numero         = enNumero.Text,
                        numeroInterior = enNumeroInterior.Text,
                        catalogoDir    = new CatalogoDir()
                        {
                            id               = (cargaCP)?cargaID.ToString():null,
                            asentamiento     = pkAsentamiento.Items[pkAsentamiento.SelectedIndex],
                            tipoasentamiento = pkTipoAsentamiento.Items[pkTipoAsentamiento.SelectedIndex],
                            cp               = enCP.Text,
                            ciudad           = enCiudad.Text,
                            municipio        = enMunicipio.Text,
                            estado           = enEstado.Text,
                            pais             = pkpais.Items[pkpais.SelectedIndex]
                        }
                    };
                }



                cliente.POST(Constantes.URL_USUARIOS + "/direccion/agregar", agredire, 1);

                MessagingCenter.Subscribe <ClienteRest>(this, "OK", (Sender) =>
                {
                    DisplayAlert("Guardado", "¡Direccion Añadida con Exito!", "OK");
                    Navigation.PopAsync();
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                });
                MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) => {
                    DisplayAlert("Advertencia", "¡No fué posible añadir la dirección actual!", "error");
                    Navigation.PopAsync();
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                });
            }
        }