예제 #1
0
        private void btnCancelar_Click(object sender, RoutedEventArgs e)
        {
            frmMostrarUsuarios frmUsers = new frmMostrarUsuarios();

            frmUsers.Show();
            Close();
        }
예제 #2
0
        private async void btnActualizar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!(txtNombre.Text == "" || txtUsuario.Text == "" || txtEmail.Text == ""))
                {
                    user.Id       = Convert.ToInt64(txtId.Text);
                    user.Nombre   = txtNombre.Text;
                    user.Username = txtUsuario.Text;
                    user.Email    = txtEmail.Text;
                    user.Clave    = pwbClave.Password;

                    if (userBL.ActualizarUsuario(user) > 0)
                    {
                        await this.ShowMessageAsync("Éxito", "Usuario actualizado correctamente.");

                        frmMostrarUsuarios frmMostrar = new frmMostrarUsuarios();
                        Close();
                        frmMostrar.Show();
                    }
                    else
                    {
                        await this.ShowMessageAsync("Error", "No se pudo actualizar el registro.");
                    }
                }
                else
                {
                    await this.ShowMessageAsync("Advertencia!", "Todos los campos son requeridos", MessageDialogStyle.Affirmative);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Asegurate que todos los campos tengan contenido del mismo tipo de dato", "Error");
            }
        }
예제 #3
0
        private void btnMostrarUsuarios_Click(object sender, RoutedEventArgs e)
        {
            frmMostrarUsuarios frmUsers = new frmMostrarUsuarios();

            frmMostrarUsuarios.mensje = mensje;
            Hide();
            frmUsers.ShowDialog();
        }
예제 #4
0
        private async void btnEliminar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!(txtId.Text == ""))
                {
                    MessageDialogResult resp = await this.ShowMessageAsync("¡Advertencia!", "¿Está tratando de eliminar un registro de la base de datos, está segur@?", MessageDialogStyle.AffirmativeAndNegative);

                    if (resp == MessageDialogResult.Affirmative)
                    {
                        user.Id = Convert.ToInt64(txtId.Text);

                        if (userBL.EliminarUsuario(user) > 0)
                        {
                            await this.ShowMessageAsync("Éxito", "Usuario eliminado correctamente.");

                            frmMostrarUsuarios frmMostrar = new frmMostrarUsuarios();
                            Close();
                            frmMostrar.Show();
                        }
                        else
                        {
                            await this.ShowMessageAsync("Error", "No se pudo eliminar el registro.");
                        }
                    }
                    else
                    {
                        frmMostrarUsuarios frmMostrar = new frmMostrarUsuarios();
                        Close();
                        frmMostrar.Show();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Ocurrió un error inesperado", "Error");
            }
        }