Example #1
0
        /// <summary>
        /// método usado para consumir al servicio de modificar un correo electrónico
        /// </summary>
        void conectar()
        {
            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)
            {
                DisplayAlert("Advertencia", "Introduzca un correo electrónico valido", "OK");
            }
            else
            {
                ClienteRest cliente = new ClienteRest();
                Email       email   = new Email();
                email.id      = ID;
                email.correoe = enCorreo.Text;
                email.tipo    = enTipo.Text;

                cliente.PUT(Constantes.URL_USUARIOS + "/email/actualizar-email", email);
                MessagingCenter.Subscribe <ClienteRest>(this, "OK", (sender) =>
                {
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                    DisplayAlert("Guardado", "¡Correo Modificado con Exito!", "OK");
                    Navigation.PopAsync();
                });

                MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) =>
                {
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                    DisplayAlert("Error", "¡No fué posible modifcar el correo!", "OK");
                });
            }
        }
        /// <summary>
        /// Este evento corresponde al boton modificar cuando se hace click al boton
        /// primero valida que todos los campos añadidos sean validos y una vez que todo sea correcto
        /// consume al servicio para modificar la información de facturacion.
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        void Modificar_Clicked(object sender, System.EventArgs e)
        {
            facturacion.rfc            = enRFC.Text;
            facturacion.nomrazonSocial = enRazon.Text;

            facturacion.direccion = new Modelos.Direccion
            {
                id          = IDDIR,
                catalogoDir = new CatalogoDir {
                    id = IDCATDIR
                }
            };
            ClienteRest client = new ClienteRest();


            if (!(string.IsNullOrEmpty(enRFC.Text)) && !(string.IsNullOrEmpty(enRazon.Text)) && pkCorreo.SelectedIndex > -1 && pkDireccion.SelectedIndex > -1)
            {
                if (!Regex.Match(enRFC.Text, "[A-Z,Ñ,&]{3,4}[0-9]{2}[0-1][0-9][0-3][0-9][A-Z,0-9]?[A-Z,0-9]?[0-9,A-Z]?").Success || enRFC.Text.Length < 12 || enRFC.Text.Length > 13)
                {
                    DisplayAlert("Advertencia", "Introduzca un RFC valido", "OK");
                }
                else
                {
                    client.PUT(Constantes.URL_USUARIOS + "/datos-facturacion/actualizar", facturacion);
                }
            }
            else
            {
                DisplayAlert("Advertencia", "¡Seleccione el resto de campos!", "OK");
            }



            MessagingCenter.Subscribe <ClienteRest>(this, "OK", (Sender) => {
                MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                DisplayAlert("Modificado", "¡Información de facturación modificada con exito!", "OK");
                Navigation.PopAsync();
            });

            MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) => {
                MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                DisplayAlert("Error", "¡No fue posible modificar la información actual!", "OK");
                Navigation.PopAsync();
            });
        }
        /// <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");
                        });
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// evento click al presionar el boton guardar, verifica que los campos añadidos sean correctos antes de
        /// consumir el servicio para modificarlos
        /// </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>
        void modificar_Clicked(object sender, System.EventArgs e)
        {
            Boolean a1 = false, a2 = false, a3 = false;

            if (string.IsNullOrEmpty(enCurp.Text) || !Regex.Match(enCurp.Text, "[A-Z][A,E,I,O,U,X][A-Z]{2}[0-9]{2}[0-1][0-9][0-3][0-9][M,H][A-Z]{2}[B,C,D,F,G,H,J,K,L,M,N,Ñ,P,Q,R,S,T,V,W,X,Y,Z]{3}[0-9,A-Z][0-9]").Success)
            {
                DisplayAlert("Campo incorrecto", "Introduzca un CURP valido", "ok");
                a1 = false;
            }
            else
            {
                a1 = true;
            }


            if (string.IsNullOrEmpty(enNombre.Text) || !Regex.Match(enNombre.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚ\s]+$").Success)
            {
                DisplayAlert("Campo incorrecto", "Introduzca un nombre valido", "ok");
                a2 = false;
            }
            else
            {
                a2 = true;
            }
            if (string.IsNullOrEmpty(enPaterno.Text) || !Regex.Match(enPaterno.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚ\s]+$").Success)
            {
                DisplayAlert("Campo incorrecto", "Introduzca un apellido valido", "ok");
                a3 = false;
            }
            else
            {
                a3 = true;
            }



            if (a1 && a2 && a3)
            {
                ClienteRest client = new ClienteRest();

                persona.nombre   = enNombre.Text;
                persona.apaterno = enPaterno.Text;
                persona.amaterno = enMaterno.Text;
                persona.curp     = enCurp.Text;
                persona.sexo     = pkSexo.Items[pkSexo.SelectedIndex];
                persona.edoCivil = pkEstCvl.Items[pkEstCvl.SelectedIndex];
                persona.fechanac = dtFecha.Date.ToString("yyyy-MM-dd");

                enNombre.IsEnabled  = false;
                enPaterno.IsEnabled = false;
                enMaterno.IsEnabled = false;
                enCurp.IsEnabled    = false;
                dtFecha.IsEnabled   = false;
                pkSexo.IsEnabled    = false;
                pkEstCvl.IsEnabled  = false;



                client.PUT(Constantes.URL_USUARIOS + "/personas/actualizar", persona);

                MessagingCenter.Subscribe <ClienteRest>(this, "OK", (send) =>
                {
                    DisplayAlert("Guardado", "¡Datos Modificados con Exito!", "OK");
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                    btnGuardar.IsEnabled          = false;
                    btnModificar.IsEnabled        = true;
                    btnModificar.BackgroundColor  = Color.FromHex("#5CB85C");
                    btnContraseña.IsEnabled       = true;
                    btnContraseña.BackgroundColor = Color.FromHex("#3f85bd");

                    btnGuardar.BackgroundColor = Color.Silver;
                });

                MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) => {
                    DisplayAlert("Error", "¡No fue posible modifcar los datos!", "OK");
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                    btnGuardar.IsEnabled          = false;
                    btnModificar.IsEnabled        = true;
                    btnModificar.BackgroundColor  = Color.FromHex("#5CB85C");
                    btnGuardar.BackgroundColor    = Color.Silver;
                    btnContraseña.IsEnabled       = true;
                    btnContraseña.BackgroundColor = Color.FromHex("#3f85bd");
                });
            }
            else
            {
                btnGuardar.IsEnabled          = true;
                btnModificar.IsEnabled        = false;
                btnGuardar.BackgroundColor    = Color.FromHex("#5CB85C");
                btnModificar.BackgroundColor  = Color.Silver;
                btnContraseña.IsEnabled       = true;
                btnContraseña.BackgroundColor = Color.FromHex("#3f85bd");
            }
        }
Example #5
0
        /// <summary>
        /// Este método permite verificar que el texto introducido en las entradas sea correcto antes de consumir el servicio para
        /// modificar los datos de facturación. enc aso contrario notifica al usuario
        /// </summary>
        void Modificar()
        {
            bool a1 = false, a2 = false, a3 = false, a4 = false, a5 = false, a6 = false, a7 = false, a8 = true;


            if (ValidarVacio(enCalle.Text) || !Regex.Match(enCalle.Text, @"^[a-zA-ZñÑáéíóúÁÉÍÓÚüÜ\s0-9]+$").Success)
            {
                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)
            {
                DisplayAlert("Campo no valido", "Introduza una número valido", "Ok");
                a2 = false;
            }
            else
            {
                a2 = true;
            }


            if (ValidarVacio(enCP.Text) || enCP.Text.Length < 5)
            {
                DisplayAlert("Campo no valido", "Introduza una código postal valido", "Ok");
                a3 = false;
            }
            else
            {
                a3 = true;
            }


            if (!(pkTipoAsentamiento.SelectedIndex > -1))
            {
                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)
            {
                DisplayAlert("Campo vacio", "Introduzca un municipio valido", "ok");
                a5 = false;
            }
            else
            {
                a5 = true;
            }

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

            if (ValidarVacio(enAsentamiento.Text))
            {
                DisplayAlert("Campo vacio", "Introduzaca un asentamiento", "ok");
                a7 = false;
            }
            else
            {
                a7 = true;
            }

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

            if (a1 && a2 && a3 && a4 && a5 && a6 && a7 && a8)
            {
                ClienteRest client = new ClienteRest();

                Modelos.Direccion dir = new Modelos.Direccion();

                dir.id             = ID;
                dir.calle          = enCalle.Text;
                dir.numero         = enNumero.Text;
                dir.numeroInterior = enNumeroInterior.Text;
                dir.catalogoDir    = new CatalogoDir()
                {
                    id               = catID,
                    asentamiento     = (cargaCP)?pkAsentamiento.Items[pkAsentamiento.SelectedIndex]:enAsentamiento.Text,
                    tipoasentamiento = pkTipoAsentamiento.Items[pkTipoAsentamiento.SelectedIndex],
                    cp               = enCP.Text,
                    ciudad           = enCiudad.Text,
                    municipio        = enMunicipio.Text,
                    estado           = enEstado.Text,
                    pais             = pkpais.Items[pkpais.SelectedIndex]
                };


                client.PUT(Constantes.URL_USUARIOS + "/direccion/actualizar", dir);

                MessagingCenter.Subscribe <ClienteRest>(this, "OK", (Sender) => {
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "OK");
                    DisplayAlert("Guardado", "¡Direccion Modificada con Exito!", "OK");
                    Navigation.PopAsync();
                });


                MessagingCenter.Subscribe <ClienteRest>(this, "error", (Sender) => {
                    MessagingCenter.Unsubscribe <ClienteRest>(this, "error");
                    DisplayAlert("Advertencia", "¡No fue posible modificar la dirección actual!", "OK");
                    Navigation.PopAsync();
                });
            }
        }