private async void accesar() { prLoading.IsActive = true; try { prLoading.IsActive = true; if (await validaCampos()) { tcUsuario usDAO = new tcUsuario(App.uriServicio); App.usuarioAutentificado = await usDAO.getUsuarioByUsuarioId(tbUsuario.Text); if (App.usuarioAutentificado != null) { if (tbPassword.Password != App.usuarioAutentificado.Contrasena) { await new MessageDialog("La contraseña es incorrecta.").ShowAsync(); tbPassword.Focus(FocusState.Programmatic); tbPassword.SelectAll(); return; } else { Frame rootFrame = (Window.Current.Content as Frame); rootFrame.Navigate(typeof(pMasterPage), this); } } else { await new MessageDialog("El usuario es incorrecto.").ShowAsync(); tbUsuario.Focus(FocusState.Programmatic); tbUsuario.SelectAll(); } } } catch (Exception ex) { var messageDialog = new MessageDialog("", ex.InnerException == null ? ex.Message : ex.InnerException.Message); messageDialog.Commands.Add(new UICommand("Aceptar")); messageDialog.DefaultCommandIndex = 0; await messageDialog.ShowAsync(); } finally { prLoading.IsActive = false; } }
private async void btnCancelar_Click(object sender, RoutedEventArgs e) { limpiarCampos(); try { Usuario user = new Usuario { EmpleadoId = "14490224", Contrasena = "potter13", Nivel = 1, UsuarioRegistro = App.usuarioAutentificado.UsuarioId, FechaHoraRegistro = DateTime.Now, UsuarioId = "2" }; tcUsuario usDAO = new tcUsuario(App.uriServicio); usDAO.Insertar(user); await new MessageDialog("correcto").ShowAsync(); } catch (Exception ex) { await new MessageDialog("Error al insertar usuario" + ex.Message).ShowAsync(); } }