Пример #1
0
        private async void btn_Registrarse_Clicked(object sender, EventArgs e)
        {
            if (txtNombre.Text == null || txtApellido.Text == null || txtCorreo.Text == null || txtTipousu.Text == null || txtContrasena.Text == null)
            {
                await DisplayAlert("Error", "Es obligatorio llenar todos los campos", "OK");
            }
            else
            {
                var datos = new Registrosusuarios
                {
                    Id         = txtID.Text,
                    Nombre     = txtNombre.Text,
                    Apellido   = txtApellido.Text,
                    Correo     = txtCorreo.Text,
                    Tipousu    = txtTipousu.Text,
                    Contrasena = txtContrasena.Text
                };

                try
                {
                    await DataPage.Tabla.InsertAsync(datos);
                    await DisplayAlert("Exitoso", "Usuario agregado correctamente", "OK");
                }
                catch (Exception error)
                {
                    await DisplayAlert("error", "" + error, "OK");
                }
            }
        }
Пример #2
0
        private async void btnreg_Clicked(object sender, EventArgs e)
        {
            if (txtuser.Text == null || txtnombre.Text == null || txtapellido.Text == null || txtcorreo.Text == null || txttipousu.Text == null)
            {
                await DisplayAlert("Error", "Debe llenar todos los campos", "Ok");
            }
            else
            {
                byte[] encryted = System.Text.Encoding.Unicode.GetBytes(txtuser.Text);
                string result   = Convert.ToBase64String(encryted);
                var    datos    = new Registrosusuarios
                {
                    Id         = txtuser.Text,
                    Nombre     = txtnombre.Text,
                    Apellido   = txtapellido.Text,
                    Correo     = txtcorreo.Text,
                    Tipousu    = txttipousu.Text,
                    Contrasena = result
                };

                try
                {
                    await tabla.InsertAsync(datos);
                    await DisplayAlert("Correcto", "El Usuario se a agregado correctamente", "Ok");
                }
                catch (Exception error)
                {
                    await DisplayAlert("error", "" + error, "Ok");
                }
            }
        }