Exemplo n.º 1
0
        async void Continuar_Clicked(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(codigo.Text))
            {
                await DisplayAlert("", "Por favor, ingrese el código enviado.", "Aceptar");

                codigo.Focus();
                return;
            }
            else
            {
                if (!String.IsNullOrEmpty(PwdReset_ID))
                {
                    if (codigo.Text.Equals(PwdReset_ID))
                    {
                        confirmacionCodigo.IsVisible = false;
                        cambioContrasenia.IsVisible  = true;
                    }
                    else
                    {
                        await DisplayAlert("", "El código ingresado no coincide con el enviado.", "Aceptar");

                        codigo.Focus();
                        return;
                    }
                }
                else
                {
                    ShowToast(ToastNotificationType.Error, "Recuperación de contraseña", "Servicio no disponible, intente más tarde.", 7);
                    await Navigation.PopPopupAsync();
                }
            }
        }
Exemplo n.º 2
0
        async void Login_Clicked(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(Usuario.Text))
            {
                await DisplayAlert("", "Por favor, indique el número de CUI de su DPI", "Aceptar");

                Usuario.Focus();
                return;
            }
            else if (Usuario.Text.Length < 15)
            {
                await DisplayAlert("", "Por favor, indique un número de CUI válido", "Aceptar");

                Usuario.Focus();
                return;
            }
            if (String.IsNullOrEmpty(Contrasenia.Text))
            {
                await DisplayAlert("", "Por favor, indique su contraseña", "Aceptar");

                Contrasenia.Focus();
                return;
            }
            string CUI = Regex.Replace(Usuario.Text, @"\s+", "");

            System.Diagnostics.Debug.WriteLine(CUI);
            await Navigation.PushPopupAsync(new NotificacionCargando());

            await Navigation.PushPopupAsync(new LoginVerificacion("1850"));
        }
Exemplo n.º 3
0
        async void Recuperar_Clicked(object sender, EventArgs e)
        {
            Usuario.IsEnabled = false;
            if (String.IsNullOrEmpty(Usuario.Text))
            {
                await DisplayAlert("", "Por favor, indique su correo electrónico ", "Aceptar");

                Usuario.IsEnabled = true;
                Usuario.Focus();
                return;
            }
            else
            {
                if (!Regex.Match(Usuario.Text, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$").Success)
                {
                    await DisplayAlert("", "Por favor, indique una dirección de correo electrónico válida", "Aceptar");

                    Usuario.IsEnabled = true;
                    Usuario.Focus();
                    return;
                }
            }
            this.IsBusy                  = true;
            recuperar.IsEnabled          = false;
            recuperar.IsVisible          = false;
            gridBotonRecuperar.IsVisible = false;


            ResetPassword peticion = new ResetPassword
            {
                email = Usuario.Text
            };

            var Respuesta = await App.ManejadorDatos.ResetPasswordAsync(peticion);

            if (Respuesta == null)
            {
                ShowToast(ToastNotificationType.Error, "Inconvenientes de conexión", "Lo lamentamos, existen inconvenientes en la conexión; intente más tarde.", 7);
                Usuario.IsEnabled = true;
                this.IsBusy       = false;
            }
            else if (!Respuesta.result.Equals("SUCCESS"))
            {
                ShowToast(ToastNotificationType.Error, "Recuperación de contraseña", "Servicio no disponible, intente más tarde.", 7);
                Usuario.IsEnabled = true;
                this.IsBusy       = false;
            }
            else
            {
                PwdReset_ID                  = Respuesta.token;
                envioCodigo.IsVisible        = false;
                confirmacionCodigo.IsVisible = true;
            }
            recuperar.IsVisible          = true;
            recuperar.IsEnabled          = true;
            gridBotonRecuperar.IsVisible = true;
        }
Exemplo n.º 4
0
        async void Continuar_Clicked(object sender, System.EventArgs e)
        {
            if (String.IsNullOrEmpty(Contrasenia.Text))
            {
                await DisplayAlert("", "Por favor, indique su contraseña de transacciones", "Aceptar");

                Contrasenia.Focus();
                return;
            }

            await Navigation.PushPopupAsync(new NotificacionCargando());

            await Task.Delay(3000);

            ShowToast(ToastNotificationType.Success, "¡Genial!", "Pago realizado con éxito", 4);
            MessagingCenter.Send <Pagar>(this, "Generales");
            try
            {
                Navigation.PopAllPopupAsync();
                Navigation.PopAsync(false);
                Navigation.PopAsync(false);
                Navigation.PopAsync(false);
                Navigation.PopAsync(false);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
 protected async override void OnAppearing()
 {
     base.OnAppearing();
     if (PacientesVistaPresentado)
     {
         mostrar_ABC();
         ActualizarPacientes();
         PacientesVistaPresentado = false;
     }
     BusquedaRapida.Focus();
 }
Exemplo n.º 6
0
        async void Continuar_Clicked(object sender, System.EventArgs e)
        {
            if (String.IsNullOrEmpty(Token.Text))
            {
                await DisplayAlert("", "Por favor, indique el token proporcionado", "Aceptar");

                Token.Focus();
                return;
            }
            //ShowToast(ToastNotificationType.Error, "Inicio de sesión", "Token de inicio de sesión incorrecto", 6);
            MessagingCenter.Send <LoginVerificacion>(this, "Login");
            ShowToast(ToastNotificationType.Success, "Bienvenido", "Inicio de sesión exitoso", 4);
        }
Exemplo n.º 7
0
        public void SetFocus()
        {
            switch (control)
            {
            case 0:
                contraseniaAnterior.Focus();
                break;

            case 1:
                contrasenia.Focus();
                break;

            case 2:
                contraseniaConfirmacion.Focus();
                break;
            }
        }
Exemplo n.º 8
0
        public void Focus()
        {
            switch (control)
            {
            case 0:
                nombreEmpresa.Focus();
                break;

            case 1:
                direccion.Focus();
                break;

            case 2:
                nombres.Focus();
                break;

            case 3:
                apellidos.Focus();
                break;
            }
        }
Exemplo n.º 9
0
        public void Focus()
        {
            switch (control)
            {
            case 0:
                nombres.Focus();
                break;

            case 1:
                apellidos.Focus();
                break;

            case 2:
                genero.Focus();
                break;

            case 3:
                correo.Focus();
                break;
            }
        }
Exemplo n.º 10
0
        async void Continuar_Clicked(object sender, EventArgs e)
        {
            if (Settings.session_MetodoPago.Equals("tarjeta"))
            {
                if (String.IsNullOrEmpty(Nombre.Text))
                {
                    await DisplayAlert("", "Por favor, indique el nombre que aparece en su tarjeta", "Aceptar");

                    Nombre.Focus();
                    return;
                }

                if (String.IsNullOrEmpty(Numero.Text))
                {
                    await DisplayAlert("", "Por favor, indique el número de su tarjeta", "Aceptar");

                    Numero.Focus();
                    return;
                }
                else if (!IsValidNumber(Regex.Replace(Numero.Text.Trim(), @"\s+", "")))
                {
                    await DisplayAlert("Número inválido", "Verifique el número de su tarjeta", "Aceptar");

                    Numero.Focus();
                    return;
                }
                if (String.IsNullOrEmpty(Vencimiento.Text))
                {
                    await DisplayAlert("", "Por favor, indique la fecha de expiración de su tarjeta", "Aceptar");

                    Vencimiento.Focus();
                    return;
                }
                else if (!IsValidExpiration(Regex.Replace(Vencimiento.Text.Trim(), @"\s+", "")))
                {
                    await DisplayAlert("Fecha inválida", "Verifique la fecha de expiración de su tarjeta", "Aceptar");

                    Vencimiento.Focus();
                    return;
                }
                if (String.IsNullOrEmpty(CVV.Text))
                {
                    await DisplayAlert("", "Por favor, indique el código CVV de su tarjeta", "Aceptar");

                    CVV.Focus();
                    return;
                }
                else if (CVV.Text.Trim().Length < 3)
                {
                    await DisplayAlert("Código CVV inválido", "Verifique el código CVV de su tarjeta", "Aceptar");

                    CVV.Focus();
                    return;
                }
            }
            else
            {
            }
            PopupPage pagar = new Pagar();
            //pagar.bac
            await Navigation.PushPopupAsync(pagar);
        }
Exemplo n.º 11
0
        public async void Login()
        {
            if (String.IsNullOrEmpty(Usuario.Text))
            {
                await DisplayAlert("", "Por favor, indique su usuario/carné", "Aceptar");

                Usuario.Focus();
                return;
            }

            if (String.IsNullOrEmpty(Contrasenia.Text))
            {
                await DisplayAlert("", "Por favor, indique su contraseña", "Aceptar");

                Contrasenia.Focus();
                return;
            }
            this.IsBusy     = true;
            login.IsEnabled = false;
            login.IsVisible = false;

            Login peticion = new Login
            {
                username = Usuario.Text.Trim(),
                password = Contrasenia.Text.Trim().Replace("&", "%26")
            };
            List <UsuarioRespuesta> Session = new List <UsuarioRespuesta>();

            Session = await App.ManejadorDatos.LoginAsync(peticion);

            bool isEmpty = !Session.Any();

            if (isEmpty)
            {
                ShowToast(ToastNotificationType.Error, "Verifique sus datos de inicio de sesión", "Los datos de acceso proporcionados son erroneos.", 5);
                login.IsVisible = true;
                login.IsEnabled = true;
                this.IsBusy     = false;
            }
            else
            {
                confirmUser peticion1 = new confirmUser
                {
                    username = Usuario.Text.Trim()
                };
                String Session1 = String.Empty;
                Session1 = await App.ManejadorDatos.confirmUserAsync(peticion1);

                if (String.IsNullOrEmpty(Session1))
                {
                    ShowToast(ToastNotificationType.Error, "Tenemos problemas en verificar tu cuenta.", "Inténtalo de nuevo más tarde o contáctanos.", 5);
                    login.IsVisible = true;
                    login.IsEnabled = true;
                    this.IsBusy     = false;
                    return;
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("llego aca");
                    if (Session1.Equals("1"))
                    {
                        foreach (var session in Session)
                        {
                            ShowToast(ToastNotificationType.Success, "¡Bienvenido!", "Has iniciado sesión correctamente.", 7);
                            Settings.session_access_token  = session.access_token;
                            Settings.session_token_type    = session.token_type;
                            Settings.session_refresh_token = session.refresh_token;
                            Settings.session_expires_in    = session.expires_in;
                            Settings.session_scope         = session.scope;
                            Settings.session_carne         = Usuario.Text.Trim();

                            if (Usuario.Text.Trim().Contains("-"))
                            {
                                Settings.session_role = "E";
                            }
                            else
                            {
                                Settings.session_role = "C";
                            }

                            MessagingCenter.Send <InicioSesion>(this, "Autenticado");
                        }
                    }
                    else
                    {
                        content_ingreso.IsVisible = false;
                        await Navigation.PushPopupAsync(new CambioContrasenia(Usuario.Text.Trim(), Contrasenia.Text.Trim()));
                    }
                }
            }
        }
Exemplo n.º 12
0
        public EventoDatosViewModel()
        {
            idPaciente = new ExtendedEntry
            {
                Placeholder      = "SELECCIONE CAPACITADOR",
                PlaceholderColor = Color.FromHex("B2B2B2"),
                TextColor        = Color.FromHex("3F3F3F"),
                HasBorder        = false,
                FontSize         = 14,
                FontFamily       = Device.OnPlatform("OpenSans-Bold", "OpenSans-Bold", null),
                XAlign           = TextAlignment.End,
                Margin           = new Thickness(0, 0, 15, 0)
                                   //HeightRequest = 25,
            };

            idPaciente.Focused += IdPaciente_Focused;

            /*idPaciente.TextChanged += delegate (object sender, TextChangedEventArgs args)
             * {
             *  pacientesLista.IsVisible = true;
             *  if (string.IsNullOrEmpty(idPaciente.Text))
             *  {
             *      //pacientesLista.ItemsSource = pacientes;
             *      pacientesLista.IsVisible = false;
             *  }
             *
             *  else
             *  {
             *      //pacientesLista.ItemsSource= pacientes.Where(t => t.nombrePila.ToLower().Contains(idPaciente.ToLower())).ToList().ForEach(t => Pacientes.Add(t));
             *
             *      var resultados = pacientes.Where(x => x.nombrePila.ToLower().Contains(idPaciente.Text.ToLower()));
             *      if (resultados.Count() == 0)
             *      {
             *          tituloFooterPacientes.IsVisible = true;
             *          pacientesLista.Footer = tituloFooterPacientes;
             *          pacientesLista.ItemsSource = resultados;
             *      }
             *      else
             *      {
             *          pacientesLista.Footer = "";
             *          pacientesLista.ItemsSource = resultados;
             *
             *      }
             *  }
             * };*/

            MessagingCenter.Subscribe <AsistentesFiltradoPage>(this, "OK", (sender) =>
            {
                idPacienteFocused   = false;
                empleados asistente = (empleados)sender.Pacientes.SelectedItem;
                idPaciente.Text     = asistente.nombre;
                //asunto.Text = asistente.nombrePila;
                idPaciente.TextColor            = Color.FromHex("3F3F3F");
                idPaciente.PlaceholderTextColor = Color.FromHex("B2B2B2");
                idPaciente.Unfocus();
                System.Diagnostics.Debug.WriteLine(idPacienteFocused);
                Constants.DatosEvento.idcapacitador = asistente.idEmpleado;
                foreach (var asis in Constants.AsistentesEvento)
                {
                    asis.rol = "Asistente";
                }
                if (Constants.AsistentesEvento.Any((asistent) => asistent.nombre.Equals(((empleados)sender.Pacientes.SelectedItem).nombre)))
                {
                    System.Diagnostics.Debug.WriteLine("Asistente ya esta en la lista");
                    Constants.AsistentesEvento.Remove((empleados)sender.Pacientes.SelectedItem);
                }
                ((empleados)sender.Pacientes.SelectedItem).rol = "Capacitador";
                Constants.AsistentesEvento.Add((empleados)sender.Pacientes.SelectedItem);
                MessagingCenter.Send <EventoDatosViewModel>(this, "OK_B");
            });

            MessagingCenter.Subscribe <AccionesFiltradoPage>(this, "OK", (sender) =>
            {
                if (Constants.AccionesEvento.Any((action) => action.idAccion == ((acciones)sender.AccionesContenido.SelectedItem).idAccion))
                {
                    System.Diagnostics.Debug.WriteLine("Action ya esta en la lista");
                }
                else
                {
                    Constants.AccionesEvento.Add((acciones)sender.AccionesContenido.SelectedItem);
                    ActionsColumns.Add(new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Auto)
                    });
                }
                int cnt = 0;
                Actions.Children.Clear();
                foreach (var accion in Constants.AccionesEvento)
                {
                    Actions.Children.Add(new Grid
                    {
                        WidthRequest  = 25,
                        HeightRequest = 25,
                        Children      =
                        {
                            new Image
                            {
                                Source = accion.icono,
                                Aspect = Aspect.AspectFit
                            }
                        }
                    }, cnt, 0);
                    cnt++;
                    System.Diagnostics.Debug.WriteLine(accion.Nombre);
                }
            });

            MessagingCenter.Subscribe <AplicacionesFiltradoPage>(this, "OK", (sender) =>
            {
                if (Constants.AplicacionesEvento.Any((app) => app.idAplicacion == ((aplicaciones)sender.AplicacionesContenido.SelectedItem).idAplicacion))
                {
                    System.Diagnostics.Debug.WriteLine("App ya esta en la lista");
                }
                else
                {
                    Constants.AplicacionesEvento.Add((aplicaciones)sender.AplicacionesContenido.SelectedItem);
                    AppsColumns.Add(new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Auto)
                    });
                }

                int cnt = 0;
                Apps.Children.Clear();
                foreach (var aplicacion in Constants.AplicacionesEvento)
                {
                    Apps.Children.Add(new Grid
                    {
                        WidthRequest  = 25,
                        HeightRequest = 25,
                        Children      =
                        {
                            new Image
                            {
                                Source = aplicacion.icono,
                                Aspect = Aspect.AspectFit
                            }
                        }
                    }, cnt, 0);
                    cnt++;
                    System.Diagnostics.Debug.WriteLine(aplicacion.Nombre);
                }
            });

            idPacienteFocused = false;
            Image FiltradoPaciente = new Image
            {
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Center,
                Source            = "idropdown.png",
                WidthRequest      = 10
            };
            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += (sender, e) =>
            {
                System.Diagnostics.Debug.WriteLine(idPacienteFocused);
                if (!idPacienteFocused && idPaciente.IsEnabled)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        idPaciente.Focus();
                    });/*
                        * idPacienteFocused = true;
                        * var modeloVista = new VistaModelos.Pacientes.PacientesModeloVista() { Navigation = Navigation };
                        * //Navigation.PushAsync(new PacientesVista(modeloVista));
                        * await Navigation.PushModalAsync(new PacientesFiltradoVista(modeloVista));
                        * idPacienteFocused = false;
                        * return;*/
                }
                else
                {
                    return;
                }
            };
            FiltradoPaciente.GestureRecognizers.Add(tapGestureRecognizer);


            AddApp = new Image
            {
                Source        = "iFABPb",
                Aspect        = Aspect.AspectFill,
                WidthRequest  = 32,
                HeightRequest = 32,
            };

            TapGestureRecognizer AddAppTAP = new TapGestureRecognizer();

            AddAppTAP.Tapped += AddAppTAP_Tapped;
            AddApp.GestureRecognizers.Add(AddAppTAP);

            AddAction = new Image
            {
                Source        = "iFABPb",
                Aspect        = Aspect.AspectFill,
                WidthRequest  = 32,
                HeightRequest = 32,
            };

            TapGestureRecognizer AddActionTAP = new TapGestureRecognizer();

            AddActionTAP.Tapped += AddActionTAP_Tapped;;
            AddAction.GestureRecognizers.Add(AddActionTAP);

            asunto = new ExtendedEntry
            {
                Placeholder      = "INGRESA EL NOMBRE DEL EVENTO",
                PlaceholderColor = Color.FromHex("B2B2B2"),
                TextColor        = Color.FromHex("3F3F3F"),
                HasBorder        = false,
                //WidthRequest = 15,
                FontFamily = Device.OnPlatform("OpenSans-Bold", "OpenSans-Bold", null),
                FontSize   = 14,
                XAlign     = TextAlignment.End,
                Margin     = new Thickness(0, 0, 15, 0)
            };
            asunto.SetBinding(Entry.TextProperty, "asunto");
            asunto.TextChanged += (sender, e) =>
            {
                //((ExtendedEntry)sender).Text=((ExtendedEntry)sender).Text.ToUpper();
                if (((ExtendedEntry)sender).Text.Length < 4)
                {
                    ((ExtendedEntry)sender).TextColor = Color.Red;
                }
                else
                {
                    ((ExtendedEntry)sender).TextColor = Color.FromHex("3F3F3F");
                }
            };
            asunto.Unfocused += (sender, e) =>
            {
                Constants.DatosEvento.nombre = asunto.Text.Trim();
            };
            lugar = new ExtendedEntry
            {
                PlaceholderColor = Color.FromHex("B2B2B2"),
                TextColor        = Color.FromHex("3F3F3F"),
                BackgroundColor  = Color.Transparent,
                HasBorder        = false,
                FontFamily       = Device.OnPlatform("OpenSans-Bold", "OpenSans-Bold", null),
                FontSize         = 14,
                Placeholder      = "INGRESE LUGAR DEL EVENTO",
                XAlign           = TextAlignment.End,
                Margin           = new Thickness(0, 0, 15, 0)
            };
            lugar.TextChanged += Lugar_TextChanged;



            globalizacion = new System.Globalization.CultureInfo("es-GT");

            fecha = new ExtendedDatePicker
            {
                HasBorder         = false,
                Format            = globalizacion.DateTimeFormat.ShortDatePattern,
                Date              = hInicio.Date,
                Margin            = new Thickness(0, 5),
                HorizontalOptions = LayoutOptions.Center,
                TextColor         = Color.FromHex("3F3F3F"),
                Font              = Device.OnPlatform <Font>(Font.OfSize("OpenSans-Bold", 14), Font.OfSize("OpenSans-Bold", 14), Font.Default)
            };
            horaInicio = new ExtendedTimePicker
            {
                HasBorder         = false,
                Format            = globalizacion.DateTimeFormat.ShortTimePattern,
                Time              = hInicio.TimeOfDay,
                Margin            = new Thickness(0, 5),
                HorizontalOptions = LayoutOptions.Center,
                TextColor         = Color.FromHex("3F3F3F"),
                Font              = Device.OnPlatform <Font>(Font.OfSize("OpenSans-Bold", 14), Font.OfSize("OpenSans-Bold", 14), Font.Default)
            };
            horaInicio.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == TimePicker.TimeProperty.PropertyName)
                {
                    if (horaInicio.Time.Hours.Equals(23))
                    {
                        horaFin.Time = new DateTime(hInicio.Year, hInicio.Month, hInicio.Day, horaInicio.Time.Hours, 59, 59, DateTimeKind.Local).TimeOfDay;
                    }
                    else
                    {
                        horaFin.Time = horaInicio.Time.Add(TimeSpan.FromHours(1));
                    }
                }
            };
            fechaInicio = new DateTimeControl(fecha, horaInicio);//2018-11-24T00:17:06.242Z
            Constants.DatosEvento.fechaInicio = fechaInicio.Value.ToString(@"yyyy-MM-ddTHH:mm:ss.fffZ");
            horaInicio.Unfocused += (sender, e) =>
            {
                fechaInicio = new DateTimeControl(fecha, horaInicio);
                Constants.DatosEvento.fechaInicio = fechaInicio.Value.ToString(@"yyyy-MM-ddTHH:mm:ss.fffZ");
            };
            horaFin = new ExtendedTimePicker
            {
                HasBorder         = false,
                Format            = globalizacion.DateTimeFormat.ShortTimePattern,
                Time              = hInicio.AddHours(1).TimeOfDay,
                Margin            = new Thickness(0, 5),
                HorizontalOptions = LayoutOptions.Center,
                TextColor         = Color.FromHex("3F3F3F"),
                Font              = Device.OnPlatform <Font>(Font.OfSize("OpenSans-Bold", 14), Font.OfSize("OpenSans-Bold", 14), Font.Default)
            };
            fechaFin = new DateTimeControl(fecha, horaFin);
            Constants.DatosEvento.fechaFin = fechaFin.Value.ToString(@"yyyy-MM-ddTHH:mm:ss.fffZ");
            horaFin.Unfocused += (sender, e) =>
            {
                fechaFin = new DateTimeControl(fecha, horaFin);
                Constants.DatosEvento.fechaFin = fechaFin.Value.ToString(@"yyyy-MM-ddTHH:mm:ss.fffZ");
            };
            horaFin.PropertyChanged += async(sender, e) =>
            {
                if (e.PropertyName == TimePicker.TimeProperty.PropertyName)
                {
                    if (horaInicio.Time > horaFin.Time)
                    {
                        //await DisplayAlert("¡Advertencia!", "La hora final de la cita debe ser mayor a la inicial.", "Aceptar");
                        if (horaInicio.Time.Hours.Equals(23))
                        {
                            horaFin.Time = new DateTime(hInicio.Year, hInicio.Month, hInicio.Day, horaInicio.Time.Hours, 59, 59, DateTimeKind.Local).TimeOfDay;
                        }
                        else
                        {
                            horaFin.Time = horaInicio.Time.Add(TimeSpan.FromHours(1));
                        }
                        return;
                    }
                }
            };


            Grid horas = new Grid
            {
                ColumnSpacing     = 10,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    }
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Auto)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Auto)
                    }
                }
            };

            horas.Children.Add(
                new Label {
                Text = "Hora inicio", TextColor = Color.FromHex("3F3F3F")
            }, 0, 0);
            horas.Children.Add(
                new Label {
                Text = "Hora fin", TextColor = Color.FromHex("3F3F3F")
            }, 2, 0);
            horas.Children.Add(horaInicio, 0, 1);
            horas.Children.Add(
                new Image
            {
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Center,
                Source            = "idropdown.png",
                WidthRequest      = 10
            }, 1, 1);
            horas.Children.Add(horaFin, 2, 1);
            horas.Children.Add(
                new Image
            {
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Center,
                Source            = "idropdown.png",
                WidthRequest      = 10
            }, 3, 1);


            Grid Fechas = new Grid
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                ColumnSpacing     = 10,
                //HeightRequest = 50,
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = new GridLength(45, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                }
            };

            Grid AppsHeader = new Grid
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                ColumnSpacing     = 10,
                //HeightRequest = 50,
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(32, GridUnitType.Absolute)
                    },
                }
            };

            AppsHeader.Children.Add(new Label
            {
                VerticalOptions       = LayoutOptions.Center,
                VerticalTextAlignment = TextAlignment.Center,
                Text           = "APLICACIONES A MONITOREAR:",
                FontSize       = 13,
                TextColor      = Color.FromHex("432161"),
                FontAttributes = FontAttributes.Bold,
                FontFamily     = Device.OnPlatform("OpenSans-Bold", "OpenSans-Bold", null)
            }, 0, 0);

            AppsHeader.Children.Add(AddApp, 1, 0);

            Grid ActionsHeader = new Grid
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                ColumnSpacing     = 10,
                //HeightRequest = 50,
                RowDefinitions =
                {
                    new RowDefinition {
                        Height = new GridLength(45, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(32, GridUnitType.Absolute)
                    },
                }
            };

            ActionsHeader.Children.Add(new Label
            {
                VerticalOptions       = LayoutOptions.Center,
                VerticalTextAlignment = TextAlignment.Center,
                Text           = "ACCIONES:",
                FontSize       = 13,
                TextColor      = Color.FromHex("432161"),
                FontAttributes = FontAttributes.Bold,
                FontFamily     = Device.OnPlatform("OpenSans-Bold", "OpenSans-Bold", null)
            }, 0, 0);

            ActionsHeader.Children.Add(AddAction, 1, 0);


            Apps = new Grid
            {
                Padding           = new Thickness(0, 10),
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.Center,
                ColumnSpacing     = 15,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions = AppsColumns
            };

            Actions = new Grid
            {
                Padding           = new Thickness(0, 10),
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.Center,
                ColumnSpacing     = 15,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                },
                ColumnDefinitions = ActionsColumns
            };

            RelativeLayout componenteInicio = new RelativeLayout();

            componenteInicio.Children.Add(
                new RoundedBoxView.Forms.Plugin.Abstractions.RoundedBoxView
            {
                BackgroundColor = Color.FromHex("B2B2B2"),
                CornerRadius    = 6,
            },
                Constraint.Constant(-4),
                Constraint.Constant(4),
                Constraint.RelativeToParent((parent) => { return(parent.Width + 4); }),
                Constraint.RelativeToParent((parent) => { return(parent.Height - 4); }));
            componenteInicio.Children.Add(
                new RoundedBoxView.Forms.Plugin.Abstractions.RoundedBoxView
            {
                BackgroundColor = Color.FromHex("E5E5E5"),
                CornerRadius    = 6,
            },
                Constraint.Constant(-4),
                Constraint.Constant(0),
                Constraint.RelativeToParent((parent) => { return(parent.Width); }),
                Constraint.RelativeToParent((parent) => { return(parent.Height - 4); }));

            Fechas.Children.Add(
                componenteInicio, 0, 0);
            Fechas.Children.Add(
                new StackLayout
            {
                Padding           = new Thickness(15, 10),
                Spacing           = 0,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Children          =
                {
                    new Label
                    {
                        Text              = "INICIO",
                        FontSize          = 13,
                        TextColor         = Color.FromHex("432161"),
                        FontAttributes    = FontAttributes.Bold,
                        HorizontalOptions = LayoutOptions.Start,
                        FontFamily        = Device.OnPlatform("OpenSans-Bold", "OpenSans-Bold", null)
                    },
                    new StackLayout
                    {
                        Spacing           = 0,
                        HorizontalOptions = LayoutOptions.CenterAndExpand,
                        VerticalOptions   = LayoutOptions.CenterAndExpand,
                        Children          =
                        {
                            fecha,
                            new BoxView {
                                BackgroundColor = Color.FromHex("432161"),HeightRequest                                          = 2
                            },
                            horaInicio
                        }
                    }
                }
            }, 0, 0);

            RelativeLayout componenteFinal = new RelativeLayout();

            componenteFinal.Children.Add(
                new RoundedBoxView.Forms.Plugin.Abstractions.RoundedBoxView
            {
                BackgroundColor = Color.FromHex("B2B2B2"),
                CornerRadius    = 6,
            },
                Constraint.Constant(4),
                Constraint.Constant(4),
                Constraint.RelativeToParent((parent) => { return(parent.Width + 4); }),
                Constraint.RelativeToParent((parent) => { return(parent.Height - 4); }));
            componenteFinal.Children.Add(
                new RoundedBoxView.Forms.Plugin.Abstractions.RoundedBoxView
            {
                BackgroundColor = Color.FromHex("E5E5E5"),
                CornerRadius    = 6,
            },
                Constraint.Constant(0),
                Constraint.Constant(0),
                Constraint.RelativeToParent((parent) => { return(parent.Width + 4); }),
                Constraint.RelativeToParent((parent) => { return(parent.Height - 4); }));
            Fechas.Children.Add(
                componenteFinal, 1, 0);
            Fechas.Children.Add(
                new StackLayout
            {
                Padding           = new Thickness(15, 10),
                Spacing           = 0,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                Children          =
                {
                    new Label
                    {
                        Text              = "FINAL",
                        FontSize          = 13,
                        TextColor         = Color.FromHex("432161"),
                        FontAttributes    = FontAttributes.Bold,
                        HorizontalOptions = LayoutOptions.Start,
                        FontFamily        = Device.OnPlatform("OpenSans-Bold", "OpenSans-Bold", null)
                    },
                    new StackLayout
                    {
                        Spacing           = 0,
                        HorizontalOptions = LayoutOptions.CenterAndExpand,
                        VerticalOptions   = LayoutOptions.CenterAndExpand,
                        Children          =
                        {
                            new Label
                            {
                                Text = "--",
                                HorizontalOptions = LayoutOptions.Center,
                                Margin            = new Thickness(0, Device.OnPlatform(5, 7, 0)),
                                FontSize          = 14,
                                TextColor         = Color.FromHex("B2B2B2"),
                                FontFamily        = Device.OnPlatform("OpenSans-Bold", "OpenSans-Bold", null),
                            },
                            new BoxView {
                                BackgroundColor = Color.FromHex("432161"), HeightRequest = 2
                            },
                            horaFin
                        }
                    }
                }
            }, 1, 0);

            contenidoCreacionEdicion = new ScrollView
            {
                Padding = new Thickness(0, 0, 0, 15),
                Content = new StackLayout
                {
                    Spacing  = 10,
                    Children =
                    {
                        new StackLayout
                        {
                            Spacing  = 0,
                            Children =
                            {
                                new StackLayout
                                {
                                    Padding         = new Thickness(15, 5, 15, 10),
                                    Spacing         = 0,
                                    BackgroundColor = Color.FromHex("E5E5E5"),
                                    Children        =
                                    {
                                        /*new StackLayout
                                         * {
                                         *  Orientation = StackOrientation.Horizontal,
                                         *  HorizontalOptions = LayoutOptions.CenterAndExpand,
                                         *  Children =
                                         *  {
                                         *      new IconView
                                         *      {
                                         *          Source = "iNCinfo.png",
                                         *          WidthRequest = 15,
                                         *          Foreground = Color.FromHex("432161"),
                                         *          VerticalOptions = LayoutOptions.Center
                                         *      },
                                         *      new Label
                                         *      {
                                         *          Text = "Datos de evento",
                                         *          TextColor = Color.FromHex("432161"),
                                         *          FontFamily = Device.OnPlatform("OpenSans-ExtraBold", "OpenSans-ExtraBold", null),
                                         *          FontSize = 18,
                                         *          VerticalOptions = LayoutOptions.Center
                                         *      }
                                         *  }
                                         * },*/
                                        new StackLayout
                                        {
                                            Spacing  = 0,
                                            Children =
                                            {
                                                new Label
                                                {
                                                    Text           = "NOMBRE DEL EVENTO:*",
                                                    FontSize       = 13,
                                                    TextColor      = Color.FromHex("432161"),
                                                    FontAttributes = FontAttributes.Bold,
                                                    FontFamily     = Device.OnPlatform("OpenSans-Bold", "OpenSans-Bold", null)
                                                },
                                                new StackLayout
                                                {
                                                    Spacing  = 1,
                                                    Children =
                                                    {
                                                        asunto,
                                                        new BoxView {
                                                            BackgroundColor = Color.FromHex("432161"),HeightRequest                                         = 2
                                                        },
                                                    }
                                                }
                                            }
                                        }
                                    }
                                },
                                new BoxView                         {
                                    VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("B3B3B3"), HeightRequest = 4
                                },
                            }
                        },
                        new StackLayout
                        {
                            Spacing  = 0,
                            Children =
                            {
                                new StackLayout
                                {
                                    Padding         = new Thickness(15, 5, 15, 10),
                                    Spacing         = 0,
                                    BackgroundColor = Color.FromHex("E5E5E5"),
                                    Children        =
                                    {
                                        new StackLayout
                                        {
                                            Spacing  = 0,
                                            Children =
                                            {
                                                new Label
                                                {
                                                    Text           = "DIRECCIÓN:*",
                                                    FontSize       = 13,
                                                    TextColor      = Color.FromHex("432161"),
                                                    FontAttributes = FontAttributes.Bold,
                                                    FontFamily     = Device.OnPlatform("OpenSans-Bold", "OpenSans-Bold", null)
                                                },
                                                new StackLayout
                                                {
                                                    Spacing  = 1,
                                                    Children =
                                                    {
                                                        lugar,
                                                        new BoxView {
                                                            BackgroundColor = Color.FromHex("432161"),HeightRequest                                          = 2
                                                        },
                                                    }
                                                }
                                            }
                                        }
                                    }
                                },
                                new BoxView                         {
                                    VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("B3B3B3"), HeightRequest = 4
                                },
                            }
                        },
                        new StackLayout
                        {
                            Spacing  = 0,
                            Children =
                            {
                                new StackLayout
                                {
                                    Padding         = new Thickness(15, 5, 15, 10),
                                    Spacing         = 0,
                                    BackgroundColor = Color.FromHex("E5E5E5"),
                                    Children        =
                                    {
                                        new StackLayout
                                        {
                                            Spacing  = 0,
                                            Children =
                                            {
                                                new Label
                                                {
                                                    Text           = "CAPACITADOR:*",
                                                    TextColor      = Color.FromHex("432161"),
                                                    FontSize       = 13,
                                                    FontAttributes = FontAttributes.Bold,
                                                    FontFamily     = Device.OnPlatform("OpenSans-Bold", "OpenSans-Bold", null)
                                                },
                                                new StackLayout
                                                {
                                                    Spacing  = 1,
                                                    Children =
                                                    {
                                                        //entry, myListView ,
                                                        new Grid
                                                        {
                                                            Children =
                                                            {
                                                                new StackLayout
                                                                {
                                                                    Children =
                                                                    {
                                                                        idPaciente,
                                                                        //pacientesLista
                                                                    }
                                                                },
                                                                FiltradoPaciente
                                                            }
                                                        },
                                                        new BoxView {
                                                            BackgroundColor = Color.FromHex("432161"), HeightRequest = 2
                                                        },
                                                    }
                                                }
                                            }
                                        }
                                    }
                                },
                                new BoxView                         {
                                    VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("B3B3B3"), HeightRequest = 4
                                },
                            }
                        },
                        Fechas,
                        new StackLayout
                        {
                            Spacing  = 0,
                            Children =
                            {
                                new StackLayout
                                {
                                    Padding         = new Thickness(15, 5),
                                    BackgroundColor = Color.FromHex("E5E5E5"),
                                    Children        =
                                    {
                                        new StackLayout
                                        {
                                            Spacing  = 0,
                                            Children =
                                            {
                                                AppsHeader,
                                                Apps
                                            }
                                        }
                                    }
                                },
                                new BoxView                         {
                                    VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("B3B3B3"), HeightRequest = 4
                                },
                            }
                        },
                        new StackLayout
                        {
                            Spacing  = 0,
                            Children =
                            {
                                new StackLayout
                                {
                                    Padding         = new Thickness(15, 5),
                                    BackgroundColor = Color.FromHex("E5E5E5"),
                                    Children        =
                                    {
                                        new StackLayout
                                        {
                                            Spacing  = 0,
                                            Children =
                                            {
                                                ActionsHeader,
                                                Actions
                                            }
                                        }
                                    }
                                },
                                new BoxView                         {
                                    VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.FromHex("B3B3B3"), HeightRequest = 4
                                },
                            }
                        }
                    }
                }
            };

            Content = contenidoCreacionEdicion;
        }
Exemplo n.º 13
0
        async void recuperacion()
        {
            if (String.IsNullOrEmpty(contrasenia.Text))
            {
                await DisplayAlert("", "Por favor, indique su nueva contraseña", "Aceptar");

                contrasenia.Focus();
                return;
            }
            if (String.IsNullOrEmpty(confirmacionContrasenia.Text))
            {
                await DisplayAlert("", "Por favor, confirme su nueva contraseña.", "Aceptar");

                confirmacionContrasenia.Focus();
                return;
            }

            if ((!String.IsNullOrEmpty(contrasenia.Text) && !String.IsNullOrEmpty(confirmacionContrasenia.Text)) && !confirmacionContrasenia.Text.Equals(contrasenia.Text))
            {
                await DisplayAlert("", "Las contraseñas no coinciden", "Aceptar");

                confirmacionContrasenia.Focus();
                return;
            }
            this.IsBusy       = true;
            cambiar.IsEnabled = false;
            cambiar.IsVisible = false;
            changepassword peticion1 = new changepassword
            {
                actualpass  = pass,
                newpass     = contrasenia.Text.Trim(),
                confirmpass = confirmacionContrasenia.Text.Trim(),
                user        = user
            };
            String Session1 = String.Empty;

            Session1 = await App.ManejadorDatos.changepasswordAsync(peticion1);

            if (String.IsNullOrEmpty(Session1))
            {
                ShowToast(ToastNotificationType.Error, "Inconvenientes al cambiar la contraseña", "Inténtalo de nuevo más tarde o contáctanos.", 5);
                cambiar.IsVisible = true;
                cambiar.IsEnabled = true;
                this.IsBusy       = false;
                await Navigation.PopAllPopupAsync();

                return;
            }
            else
            {
                if (Session1.Equals("Password Actualizado correctamente"))
                {
                    Login(user, contrasenia.Text);
                }
                else
                {
                    ShowToast(ToastNotificationType.Error, "Cambio de contraseña", Session1, 5);
                    cambiar.IsVisible = true;
                    cambiar.IsEnabled = true;
                    this.IsBusy       = false;
                }
            }
            this.IsBusy       = false;
            cambiar.IsVisible = true;
            cambiar.IsEnabled = true;
        }
Exemplo n.º 14
0
        public CambioContrasenia(String user, String pass)
        {
            this.user = user;
            this.pass = pass;

            IconView contraseniaView = new IconView
            {
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Center,
                Source            = "iPassView.png",
                Foreground        = Color.FromHex("B2B2B2"),
                WidthRequest      = 25
            };
            IconView contraseniaConfirmacionView = new IconView
            {
                HorizontalOptions = LayoutOptions.End,
                VerticalOptions   = LayoutOptions.Center,
                Source            = "iPassView.png",
                Foreground        = Color.FromHex("B2B2B2"),
                WidthRequest      = 25
            };


            TapGestureRecognizer contraseniaViewTAP             = new TapGestureRecognizer();
            TapGestureRecognizer contraseniaConfirmacionViewTAP = new TapGestureRecognizer();

            contraseniaViewTAP.Tapped += (sender, e) =>
            {
                if (contrasenia.IsPassword)
                {
                    contrasenia.IsPassword     = false;
                    contraseniaView.Foreground = Color.FromHex("007D8C");
                }
                else
                {
                    contrasenia.IsPassword     = true;
                    contraseniaView.Foreground = Color.FromHex("B2B2B2");
                }
            };

            contraseniaConfirmacionViewTAP.Tapped += (sender, e) =>
            {
                if (confirmacionContrasenia.IsPassword)
                {
                    confirmacionContrasenia.IsPassword     = false;
                    contraseniaConfirmacionView.Foreground = Color.FromHex("007D8C");
                }
                else
                {
                    confirmacionContrasenia.IsPassword     = true;
                    contraseniaConfirmacionView.Foreground = Color.FromHex("B2B2B2");
                }
            };

            contraseniaView.GestureRecognizers.Add(contraseniaViewTAP);
            contraseniaConfirmacionView.GestureRecognizers.Add(contraseniaConfirmacionViewTAP);



            cambiar = new Button
            {
                Text              = "CONFIRMAR",
                VerticalOptions   = LayoutOptions.Start,
                TextColor         = Color.FromHex("ffffff"),
                FontFamily        = Device.OnPlatform("Montserrat-Bold", "Montserrat-Bold", null),
                FontSize          = 15,
                HorizontalOptions = LayoutOptions.Center,
                BackgroundColor   = Color.FromHex("3E1152"),
                WidthRequest      = 200,
                HeightRequest     = 35,
                BorderRadius      = 20,
            };
            cambiar.Clicked += Cambiar_Clicked;


            var indicador = new ActivityIndicator
            {
                IsVisible         = true,
                IsRunning         = true,
                BindingContext    = this,
                Color             = Color.FromHex("2AB4EE"),
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            indicador.SetBinding(ActivityIndicator.IsVisibleProperty, "IsBusy");

            contrasenia = new ExtendedEntry
            {
                HasBorder   = false,
                IsPassword  = false,
                Placeholder = "Toca para ingresar",

                XAlign           = TextAlignment.End,
                PlaceholderColor = Color.FromHex("91a5af"),
                FontFamily       = Device.OnPlatform("Montserrat-Regular", "Montserrat-Regular", null),
                TextColor        = Color.FromHex("CDCDCD"),
                FontSize         = Device.OnPlatform(16, 18, 12),
                Margin           = new Thickness(0, 0, 35, 0),
                ReturnKeyType    = ReturnKeyTypes.Next
            };
            contrasenia.Completed += (sender, e) => { confirmacionContrasenia.Focus(); };

            confirmacionContrasenia = new ExtendedEntry
            {
                HasBorder   = false,
                IsPassword  = false,
                Placeholder = "Toca para confirmar contraseña",

                XAlign           = TextAlignment.End,
                PlaceholderColor = Color.FromHex("91a5af"),
                FontFamily       = Device.OnPlatform("Montserrat-Regular", "Montserrat-Regular", null),
                TextColor        = Color.FromHex("CDCDCD"),
                FontSize         = Device.OnPlatform(16, 18, 12),
                Margin           = new Thickness(0, 0, 35, 0),
                ReturnKeyType    = ReturnKeyTypes.Go
            };
            confirmacionContrasenia.Completed += (sender, e) => { recuperacion(); };

            confirmacionContrasenia.TextChanged += (sender, e) =>
            {
                if (!confirmacionContrasenia.Text.Equals(contrasenia.Text))
                {
                    confirmacionContrasenia.TextColor = Color.FromHex("E9242A");
                    contrasenia.TextColor             = Color.FromHex("3F3F3F");
                }
                else
                {
                    contrasenia.TextColor             = Color.FromHex("53A946");
                    confirmacionContrasenia.TextColor = Color.FromHex("53A946");
                }
            };


            cambioContrasenia = new StackLayout
            {
                IsVisible = true,
                Padding   = new Thickness(20, 5),
                Spacing   = 25,
                Children  =
                {
                    new StackLayout
                    {
                        HorizontalOptions = LayoutOptions.CenterAndExpand,
                        Children          =
                        {
                            new Label
                            {
                                Text = "CAMBIO DE CONTRASEÑA",
                                HorizontalTextAlignment = TextAlignment.Center,
                                TextColor       = Color.FromHex("3E1152"),
                                FontFamily      = Device.OnPlatform("Montserrat-Bold", "Montserrat-Bold", null),
                                FontSize        = 18,
                                VerticalOptions = LayoutOptions.Center
                            },
                            new Label
                            {
                                Text = "Actualiza tu contraseña para continuar",
                                HorizontalTextAlignment = TextAlignment.Center,
                                TextColor       = Color.FromHex("3E1152"),
                                FontFamily      = Device.OnPlatform("Montserrat-Regular", "Montserrat-Regular", null),
                                FontSize        = 14,
                                VerticalOptions = LayoutOptions.Center
                            }
                        }
                    },
                    new StackLayout
                    {
                        Spacing  = 0,
                        Children =
                        {
                            new Label
                            {
                                Text       = "NUEVA CONTRASEÑA:*",
                                FontSize   = 13,
                                TextColor  = Color.FromHex("3E1152"),
                                FontFamily = Device.OnPlatform("Montserrat-Bold", "Montserrat-Bold", null),
                            },
                            new StackLayout
                            {
                                Spacing  = 1,
                                Children =
                                {
                                    new Grid
                                    {
                                        Children =
                                        {
                                            contrasenia,
                                            contraseniaView
                                        }
                                    },
                                    new BoxView {
                                        BackgroundColor = Color.FromHex("3E1152"), HeightRequest = 2
                                    },
                                    new BoxView {
                                        HeightRequest = 0
                                    }
                                }
                            }
                        }
                    },
                    new StackLayout
                    {
                        Spacing  = 0,
                        Children =
                        {
                            new Label
                            {
                                Text       = "CONFIRMAR CONTRASEÑA:*",
                                FontSize   = 13,
                                TextColor  = Color.FromHex("3E1152"),
                                FontFamily = Device.OnPlatform("Montserrat-Bold", "Montserrat-Bold", null),
                            },
                            new StackLayout
                            {
                                Spacing  = 1,
                                Children =
                                {
                                    new Grid
                                    {
                                        Children =
                                        {
                                            confirmacionContrasenia,
                                            contraseniaConfirmacionView
                                        }
                                    },
                                    new BoxView {
                                        BackgroundColor = Color.FromHex("3E1152"), HeightRequest = 2
                                    },
                                    new BoxView {
                                        HeightRequest = 0
                                    }
                                }
                            }
                        }
                    },
                    indicador,
                    cambiar
                }
            };

            Padding = new Thickness(15, 0);;
            Content = new Frame
            {
                VerticalOptions   = LayoutOptions.Center,
                Padding           = 5,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                OutlineColor      = Color.White,
                HasShadow         = true,
                BackgroundColor   = Color.White,
                Content           = new StackLayout
                {
                    Padding  = 5,
                    Spacing  = 0,
                    Children =
                    {
                        new ScrollView
                        {
                            Padding           = 0,
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            VerticalOptions   = LayoutOptions.FillAndExpand,
                            Content           = new StackLayout
                            {
                                Children =
                                {
                                    cambioContrasenia
                                }
                            }
                        }
                    }
                }
            };
            contrasenia.IsPassword             = true;
            confirmacionContrasenia.IsPassword = true;
        }
Exemplo n.º 15
0
        async void recuperacion()
        {
            Usuario.IsEnabled = false;
            if (String.IsNullOrEmpty(Usuario.Text))
            {
                await DisplayAlert("", "Por favor, indique su Usuario/Carné ", "Aceptar");

                Usuario.IsEnabled = true;
                Usuario.Focus();
                return;
            }
            this.IsBusy         = true;
            recuperar.IsEnabled = false;
            recuperar.IsVisible = false;
            this.IsBusy         = true;

            reloadmail peticion1 = new reloadmail
            {
                nocarnet = Usuario.Text.Trim()
            };
            String Session1 = String.Empty;

            Session1 = await App.ManejadorDatos.reloadmailAsync(peticion1);

            if (String.IsNullOrEmpty(Session1))
            {
                ShowToast(ToastNotificationType.Error, "Inconvenientes al recuperar la contraseña", "Inténtalo de nuevo más tarde o contáctanos.", 5);
                recuperar.IsVisible = true;
                recuperar.IsEnabled = true;
                this.IsBusy         = false;
                await Navigation.PopAllPopupAsync();

                return;
            }
            else
            {
                if (Session1.Equals("Realizado"))
                {
                    ShowToast(ToastNotificationType.Success, "Recuperación de contraseña", "Se han enviado nuevos datos de acceso a tu dirección de correo electrónico registrada.", 10);
                    recuperar.IsVisible = true;
                    recuperar.IsEnabled = true;
                    this.IsBusy         = false;
                    await Navigation.PopAllPopupAsync();

                    return;
                }
                else
                {
                    ShowToast(ToastNotificationType.Error, "Recuperación de contraseña", Session1, 5);
                    recuperar.IsVisible = true;
                    recuperar.IsEnabled = true;
                    this.IsBusy         = false;
                }
            }



            this.IsBusy         = false;
            recuperar.IsVisible = true;
            recuperar.IsEnabled = true;
        }
        public AsistentesFiltradoPage(bool capacitador)
        {
            Title            = "Filtrado";
            this.capacitador = capacitador;

            indicadorFooterPacientes = new ActivityIndicator
            {
                IsRunning         = true,
                Color             = Color.Accent,
                HorizontalOptions = LayoutOptions.End,
                WidthRequest      = 20
            };
            tituloFooterPacientes = new Label
            {
                FontFamily        = Device.OnPlatform("OpenSans-Bold", "OpenSans-Bold", null),
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                Text = "Cargando empleados..."
            };
            Grid PacientesFooter = new Grid
            {
                HeightRequest     = 60,
                Padding           = new Thickness(5, 0, 5, 0),
                RowSpacing        = 1,
                ColumnSpacing     = 1,
                BackgroundColor   = Color.Transparent,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    }
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Auto)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                }
            };

            PacientesFooter.Children.Add(indicadorFooterPacientes, 0, 0);
            PacientesFooter.Children.Add(tituloFooterPacientes, 1, 0);

            BusquedaRapida =
                new ExtendedEntry
            {
                Placeholder      = "Buscar",
                HasBorder        = false,
                BackgroundColor  = Color.Transparent,
                Margin           = new Thickness(10, 0),
                HeightRequest    = 30,
                PlaceholderColor = Color.FromHex("432161"),
                FontSize         = 14,
                TextColor        = Color.FromHex("432161"),
                FontFamily       = Device.OnPlatform("OpenSans", "OpenSans-Regular", null)
            };

            BusquedaRapida.TextChanged += BusquedaRapida_TextChanged;

            Grid PacientesHeader = new Grid
            {
                //Padding = new Thickness(0,0,10,0),
                ColumnSpacing     = 5,
                VerticalOptions   = LayoutOptions.CenterAndExpand,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    }
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Auto)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Auto)
                    },
                }
            };
            Image cancelar = new Image
            {
                //Foreground = Color.FromHex("F7B819"),
                Source        = "iCancelarB.png",
                HeightRequest = 25,
                WidthRequest  = 25,
            };
            TapGestureRecognizer cancelarTAP = new TapGestureRecognizer();

            cancelarTAP.Tapped += (sender, e) => { Navigation.PopModalAsync(); };
            cancelar.GestureRecognizers.Add(cancelarTAP);
            Image buscar = new Image
            {
                Source        = "iBusqueda.png",
                HeightRequest = 25,
                WidthRequest  = 25,
            };
            TapGestureRecognizer buscarTAP = new TapGestureRecognizer();

            buscarTAP.Tapped += async(sender, e) =>
            {
                /*OcultarModal();
                 * if (String.IsNullOrEmpty(BusquedaRapida.Text))
                 * {
                 *  await DisplayAlert("Búsqueda avanzada", "Debe ingresar una expresión para buscar en la nube.", "Aceptar");
                 *  return;
                 * }
                 * tituloFooterPacientes.Text = "Buscando coincidencias...";
                 * indicadorFooterPacientes.IsRunning = true;
                 *
                 *
                 * SelectForList peticion = new SelectForList
                 * {
                 *  searchText = BusquedaRapida.Text
                 * };
                 * await App.ManejadorDatos.SelectForListAsync(peticion, true);
                 * var PacientesActualizados = new ObservableCollection<pacientes>(App.Database.GetPacientesOrderByNombre());
                 * try
                 * {
                 *  VistaModelo.FiltrarPacientes(BusquedaRapida.Text.Trim(), PacientesActualizados.ToList());
                 *  Pacientes.ItemsSource = VistaModelo.PacientesAgrupados;
                 * }
                 * finally
                 * {
                 *  indicadorFooterPacientes.IsRunning = false;
                 *  if (VistaModelo.Pacientes.Count != 0)
                 *      tituloFooterPacientes.Text = VistaModelo.Pacientes.Count + " paciente(s) encontrados";
                 *  else
                 *  {
                 *      iBusquedaIndicador.IsVisible = false;
                 *      tituloFooterPacientes.Text = VistaModelo.Pacientes.Count + " paciente(s) encontrados";
                 *      ModalMensaje.Text = "Lo lamentamos, tampoco hemos encontrado resultados para tu búsqueda: '" + BusquedaRapida.Text + "' en medicloud.me (web) intente con otra expresión.";
                 *      ModalInstruccion.Text = "";
                 *      Contenido.Children.Add(Modal,
                 *              xConstraint: Constraint.Constant(0),
                 *              yConstraint: Constraint.RelativeToView(HeaderPacientes, (parent, view) => { return (view.Y + view.Height); }),
                 *              widthConstraint: Constraint.RelativeToParent((parent) => { return parent.Width; }),
                 *              heightConstraint: Constraint.RelativeToView(HeaderPacientes, (parent, view) => { return (parent.Height - view.Height); })
                 *          );
                 *  }
                 * }*/
            };
            buscar.GestureRecognizers.Add(buscarTAP);
            PacientesHeader.Children.Add(
                new RoundedBoxView.Forms.Plugin.Abstractions.RoundedBoxView
            {
                BackgroundColor = Color.FromHex("E5E5E5"),
                CornerRadius    = 6,
                HeightRequest   = 20,
                //WidthRequest = 128,
            }, 0, 0);
            PacientesHeader.Children.Add(BusquedaRapida, 0, 0);
            PacientesHeader.Children.Add(cancelar, 1, 0);
            PacientesHeader.Children.Add(buscar, 2, 0);

            HeaderPacientes = new StackLayout
            {
                Padding  = new Thickness(10, 10, 10, 20),
                Children = { PacientesHeader }
            };



            Modal = new Grid();
            Modal.Children.Add(new Grid
            {
                BackgroundColor = Color.Black,
                Opacity         = 0.65,
                Padding         = new Thickness(0, 0, 0, 0),
                WidthRequest    = 200,
                HeightRequest   = 200,
            });

            ModalMensaje = new Label
            {
                TextColor  = Color.White,
                FontFamily = Device.OnPlatform("OpenSans-Bold", "OpenSans-Bold", null),
                FontSize   = 18,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
            };
            ModalInstruccion = new Label
            {
                TextColor  = Color.White,
                FontFamily = Device.OnPlatform("OpenSans-Bold", "OpenSans-Bold", null),
                FontSize   = 18,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
            };
            iBusquedaIndicador = new Image
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.End,
                WidthRequest      = 25,
                HeightRequest     = 25,
                Source            = "iBusquedaIndicador.png"
            };
            StackLayout ModalContenido = new StackLayout
            {
                Padding           = 15,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    iBusquedaIndicador,
                    new StackLayout
                    {
                        HorizontalOptions = LayoutOptions.CenterAndExpand,
                        VerticalOptions   = LayoutOptions.CenterAndExpand,
                        Spacing           = 15,
                        Padding           = 30,
                        Children          =
                        {
                            ModalMensaje,
                            ModalInstruccion
                        }
                    }
                }
            };

            Modal.Children.Add(ModalContenido);



            var GestoModal = new TapGestureRecognizer();

            GestoModal.Tapped += (s, e) =>
            {
                ActualizarPacientes();
                OcultarModal();
                BusquedaRapida.Focus();
            };

            ModalContenido.GestureRecognizers.Add(GestoModal);
            Pacientes = new ListView
            {
                BackgroundColor   = Color.Transparent,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                //IsScrollEnable = false,
                ItemsSource            = App.Database.GetEmpleados(Convert.ToInt32(Settings.session_idUsuario)).ToList(),
                ItemTemplate           = new DataTemplate(typeof(EventoEmpleadosDTViewModel)),
                Margin                 = 0,
                RowHeight              = 55, //Convert.ToInt32((App.DisplayScreenHeight / 13.533333333333333)),
                IsPullToRefreshEnabled = false,
                SeparatorVisibility    = SeparatorVisibility.None,
                SeparatorColor         = Color.Transparent,
                HasUnevenRows          = false,
                VerticalOptions        = LayoutOptions.FillAndExpand,
            };

            //Pacientes.IsPullToRefreshEnabled
            Pacientes.Refreshing   += Pacientes_Refreshing;
            Pacientes.ItemSelected += Pacientes_ItemSelected;
            Pacientes.Focused      += (sender, e) =>
            {
                System.Diagnostics.Debug.WriteLine("entro a focus lista");
                try { BusquedaRapida.Unfocus(); }
                catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); }
            };

            Contenido = new RelativeLayout();
            Contenido.Children.Add(HeaderPacientes,
                                   xConstraint: Constraint.Constant(0),
                                   yConstraint: Constraint.Constant(0),
                                   widthConstraint: Constraint.RelativeToParent(parent => parent.Width));
            Padding = new Thickness(0, 40, 0, 0);
            Content = Contenido;
            PacientesVistaVisible    = false;
            PacientesVistaPresentado = true;
        }
        public ServiciosAsociadosDTModeloVista()
        {
            Titulo = new ExtendedEntry()
            {
                Margin            = 0,
                IsEnabled         = false,
                Keyboard          = Keyboard.Text,
                Placeholder       = "Alias de servicio",
                PlaceholderColor  = Color.FromHex("D9D9D9"),
                FontFamily        = Device.OnPlatform("Montserrat-Bold", "Montserrat-Bold", null),
                TextColor         = Color.FromHex("4D4D4D"),
                BackgroundColor   = Color.Transparent,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HasBorder         = false,
                FontSize          = App.DisplayScreenWidth / 25.066666666666667
            };

            Titulo.SetBinding(ExtendedEntry.TextProperty, "alias");

            Titulo.Focused += (sender, e) =>
            {
                Titulo.TextChanged += Titulo_TextChanged;
            };
            Titulo.Unfocused += (sender, e) =>
            {
                Titulo.TextChanged -= Titulo_TextChanged;
                servicios ContextoActual = (servicios)this.BindingContext;

                /*if (ContextoActual != null && !string.IsNullOrEmpty(ContextoActual.name))
                 *  App.Database.InsertLista(ContextoActual);*/
            };

            IconView Editar = new IconView
            {
                Source        = "iEditar",
                Foreground    = Color.FromHex("BFBFBF"),
                WidthRequest  = App.DisplayScreenWidth / 25.066666666666667,
                HeightRequest = App.DisplayScreenHeight / 25.066666666666667
            };

            TapGestureRecognizer EditarTAP = new TapGestureRecognizer {
                NumberOfTapsRequired = 1
            };

            EditarTAP.Tapped += (sender, e) =>
            {
                if (Titulo.IsEnabled)
                {
                    Titulo.Unfocus();
                    Titulo.IsEnabled = false;
                }

                else
                {
                    Titulo.IsEnabled = true;
                    Titulo.Focus();
                }
            };
            Editar.GestureRecognizers.Add(EditarTAP);

            Label Proveedor = new Label
            {
                BackgroundColor = Color.Transparent,
                FontFamily      = Device.OnPlatform("Montserrat-Regular", "Montserrat-Regular", null),
                TextColor       = Color.FromHex("4D4D4D"),
                FontSize        = (App.DisplayScreenWidth / 37.6)
            };

            Proveedor.SetBinding(Label.TextProperty, "proveedor");

            Image iProveedor = new Image
            {
                Source            = "iEEGSA",
                HorizontalOptions = LayoutOptions.Start,
                VerticalOptions   = LayoutOptions.Center,
                WidthRequest      = App.DisplayScreenWidth / 3.159663865546218,
                HeightRequest     = App.DisplayScreenWidth / 6.121784435037447,
                Aspect            = Aspect.Fill
            };

            Label Categoria = new Label
            {
                BackgroundColor = Color.Transparent,
                FontFamily      = Device.OnPlatform("Montserrat-Regular", "Montserrat-Regular", null),
                TextColor       = Color.FromHex("4D4D4D"),
                FontSize        = (App.DisplayScreenWidth / 37.6)
            };

            Categoria.SetBinding(Label.TextProperty, "categoria");

            Label Saldo = new Label
            {
                HorizontalTextAlignment = TextAlignment.End,
                BackgroundColor         = Color.Transparent,
                FontFamily = Device.OnPlatform("Montserrat-Bold", "Montserrat-Bold", null),
                TextColor  = Color.FromHex("4D4D4D"),
                FontSize   = (App.DisplayScreenWidth / 31.333333333333333)
            };

            Saldo.SetBinding(Label.TextProperty, "saldo");

            Label Aviso = new Label
            {
                HorizontalTextAlignment = TextAlignment.End,
                BackgroundColor         = Color.Transparent,
                FontFamily = Device.OnPlatform("Montserrat-Regular", "Montserrat-Regular", null),
                TextColor  = Color.FromHex("4D4D4D"),
                FontSize   = (App.DisplayScreenWidth / 37.6)
            };

            Aviso.SetBinding(Label.TextProperty, "aviso");

            Label Vencimiento = new Label
            {
                HorizontalTextAlignment = TextAlignment.End,
                BackgroundColor         = Color.Transparent,
                FontFamily = Device.OnPlatform("Montserrat-Regular", "Montserrat-Regular", null),
                TextColor  = Color.FromHex("4D4D4D"),
                FontSize   = (App.DisplayScreenWidth / 37.6)
            };

            Vencimiento.SetBinding(Label.TextProperty, "vencimiento");


            Header = new Grid
            {
                Padding           = 0,
                ColumnSpacing     = App.DisplayScreenWidth / 37.6,
                RowSpacing        = 0,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    }
                },

                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Auto)
                    }
                }
            };

            Header.Children.Add(Titulo, 0, 0);
            Header.Children.Add(Proveedor, 0, 1);
            Header.Children.Add(Categoria, 0, 2);
            Header.Children.Add(Editar, 1, 0);


            Footer = new Grid
            {
                Padding           = 0,
                RowSpacing        = 0,
                VerticalOptions   = LayoutOptions.End,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    }
                },

                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    }
                }
            };

            Footer.Children.Add(Saldo, 0, 0);
            Footer.Children.Add(Aviso, 0, 1);
            Footer.Children.Add(Vencimiento, 0, 2);

            Grid Contenido = new Grid
            {
                Padding           = new Thickness((App.DisplayScreenWidth / 10.742857142857143), (App.DisplayScreenWidth / 16.347826086956522), (App.DisplayScreenWidth / 10.742857142857143), (App.DisplayScreenWidth / 18.8)),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                RowSpacing        = App.DisplayScreenWidth / 26.666666666666667,
                RowDefinitions    =
                {
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    },
                    new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Star)
                    }
                },
                ColumnDefinitions =
                {
                    new ColumnDefinition {
                        Width = new GridLength(1, GridUnitType.Star)
                    },
                }
            };

            Contenido.Children.Add(Header, 0, 0);
            Contenido.Children.Add(new Grid
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          =
                {
                    iProveedor,
                    Footer
                }
            }, 0, 1);



            View = new Grid
            {
                Padding  = new Thickness((App.DisplayScreenWidth / 12.533333333333333), (App.DisplayScreenWidth / 37.6), 0, (App.DisplayScreenWidth / 37.6)),
                Children =
                {
                    new Frame
                    {
                        Padding           = 0,
                        HeightRequest     = App.DisplayScreenWidth / 2.211764705882353,
                        BackgroundColor   = Color.Transparent,
                        HasShadow         = true,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Content           = new Grid
                        {
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            VerticalOptions   = LayoutOptions.FillAndExpand,
                            Padding           = 0,
                            Children          =
                            {
                                new Image
                                {
                                    Source = "iServicioBackground",
                                    Aspect = Aspect.Fill
                                },
                                Contenido
                            }
                        }
                    }
                }
            };
        }
Exemplo n.º 18
0
        private async void Guardar_Clicked(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(nombres.Text))
            {
                await DisplayAlert("", "Por favor, indique un nombre", "Aceptar");

                nombres.Focus();
                return;
            }
            if (String.IsNullOrEmpty(apellidos.Text))
            {
                await DisplayAlert("", "Por favor, indique un apellido", "Aceptar");

                apellidos.Focus();
                return;
            }
            if (genero.SelectedIndex == -1)
            {
                await DisplayAlert("", "Por favor, seleccione el género", "Aceptar");

                genero.Focus();
                return;
            }
            if (String.IsNullOrEmpty(correo.Text))
            {
                await DisplayAlert("", "Por favor, indique su correo electrónico ", "Aceptar");

                correo.Focus();
                return;
            }
            else
            {
                if (!Regex.Match(correo.Text, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$").Success)
                {
                    await DisplayAlert("", "Por favor, indique una dirección de correo electrónico válida", "Aceptar");

                    correo.Focus();
                    return;
                }
            }
            if (guardar.Text.Equals("ACTUALIZAR"))
            {
                await Navigation.PushPopupAsync(new Indicador("Actualizando datos de empleado", Color.White));

                await Task.Delay(3000);

                ShowToast(ToastNotificationType.Success, "Actualización de empleado", "Datos de empleado actualizados con éxito.", 5);
                await Navigation.PopAsync();

                return;
            }

            await Navigation.PushPopupAsync(new Indicador("Registrando empleado", Color.White));

            try
            {
                CreateUser peticion = new CreateUser
                {
                    firstName = nombres.Text,
                    lastName  = apellidos.Text,
                    email     = correo.Text,
                    genero    = Constants.genero[genero.Items[genero.SelectedIndex]],
                    role      = 1
                };
                if (puesto.SelectedIndex == -1)
                {
                    peticion.puesto = 0;
                }
                else
                {
                    peticion.puesto = puestos.Find(x => (x.nombre == puesto.Items[puesto.SelectedIndex])).id;
                }

                var response = await App.ManejadorDatos.CreateUserAsync(peticion);

                await Navigation.PopAllPopupAsync();

                if (response)
                {
                    MessagingCenter.Send <EmpleadoPage>(this, "EmpleadoCreado");
                    ShowToast(ToastNotificationType.Success, "Registro de empleado", "Empleado registrado con éxito.", 5);
                    await Navigation.PopAsync();

                    return;
                }
                else
                {
                    ShowToast(ToastNotificationType.Error, "¡Verifique!", "Ha ocurrido algo inesperado en el registro del empleado, intentalo de nuevo.", 5);
                    return;
                }
            }
            catch
            {
                await Navigation.PopAllPopupAsync();

                ShowToast(ToastNotificationType.Error, "Nuevo empleado", "Ha ocurrido algo inesperado en el registro del empleado, inténtalo de nuevo.", 5);
            }
        }
Exemplo n.º 19
0
        private async void Login_Clicked(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(Usuario.Text))
            {
                await DisplayAlert("", "Por favor, indique su correo electrónico ", "Aceptar");

                Usuario.Focus();
                return;
            }
            else
            {
                if (!Regex.Match(Usuario.Text, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$").Success)
                {
                    await DisplayAlert("", "Por favor, indique una dirección de correo electrónico válida", "Aceptar");

                    Usuario.Focus();
                    return;
                }
            }
            if (String.IsNullOrEmpty(Contrasenia.Text))
            {
                await DisplayAlert("", "Por favor, indique su contraseña", "Aceptar");

                Contrasenia.Focus();
                return;
            }
            this.IsBusy     = true;
            login.IsEnabled = false;
            login.IsVisible = false;

            Login peticion = new Login
            {
                username = Usuario.Text,
                password = getContrasenia()
            };
            LoginResponse Session = new LoginResponse();

            Session = await App.ManejadorDatos.LoginAsync(peticion);

            if (Session == null)
            {
                ShowToast(ToastNotificationType.Error, "Inconvenientes de conexión", "Lo lamentamos, existen inconvenientes en la conexión; intente más tarde.", 7);
                login.IsVisible = true;
                login.IsEnabled = true;
                this.IsBusy     = false;
            }
            else if (string.IsNullOrEmpty(Session.access_token))
            {
                ShowToast(ToastNotificationType.Error, "Verifique sus datos de inicio de sesión", "A ocurrido algo inesperado en el inicio de sesión", 5);
                login.IsVisible = true;
                login.IsEnabled = true;
                this.IsBusy     = false;
            }
            else
            {
                Settings.session_access_token = Session.access_token;
                Settings.session_expires_in   = Session.expires_in.ToString();
                Settings.session_username     = Session.user.username;
                Settings.session_authority    = Session.user.authorities[0].authority;
                usuarios usuario = App.Database.GetUser(peticion.username);
                if (usuario == null)
                {
                    usuario = new usuarios
                    {
                        email = peticion.username
                    };
                    Logeado = false;
                }
                else
                {
                    Logeado = true;
                }
                usuario.idUsuario             = Session.user.id;
                usuario.fechaUltimoInicio     = DateTime.Now.ToString();
                usuario.username              = Settings.session_username;
                usuario.firstName             = Session.user.firstName;
                usuario.lastName              = Session.user.lastName;
                usuario.phoneNumber           = Session.user.phoneNumber;
                usuario.enabled               = Session.user.enabled;
                usuario.lastPasswordResetDate = Session.user.lastPasswordResetDate;
                usuario.genero       = Session.user.genero;
                usuario.idPuesto     = Session.puesto.idPuesto;
                usuario.nombrePuesto = Session.puesto.nombre;
                var res = App.Database.InsertUsuario(usuario);
                if (!Logeado)
                {
                    usuario = App.Database.GetUser(peticion.username);
                }
                Settings.session_idUsuario = usuario.id.ToString();

                empresas empresa = App.Database.GetEmpresa(Session.empresa.id);
                if (empresa == null)
                {
                    empresa = new empresas
                    {
                        idEmpresa = Session.empresa.id
                    };
                    Logeado = false;
                }
                else
                {
                    Logeado = true;
                }

                empresa.nombre              = Session.empresa.nombre;
                empresa.direccion           = Session.empresa.direccion;
                empresa.numeroColaboradores = Session.empresa.numeroColaboradores;
                empresa.telefono            = Session.empresa.telefono;
                empresa.logo        = Session.empresa.logo;
                empresa.descripcion = Session.empresa.descripcion;
                empresa.status      = Session.empresa.status;
                res = App.Database.InsertEmpresa(empresa);
                if (!Logeado)
                {
                    empresa = App.Database.GetEmpresa(Session.empresa.id);
                }
                Settings.session_idEmpresa     = empresa.idEmpresa.ToString();
                Settings.session_nombreEmpresa = empresa.nombre;

                this.IsBusy = false;
                MessagingCenter.Send <LoginPage>(this, "Autenticado");
            }
        }