public Perfil() { InitializeComponent(); local = new DespertadorDAOLocal(); us = local.findAllUsuario().ElementAt(0); user.Text = us.Nombre; }
protected override void OnNavigatedTo(NavigationEventArgs e) { if (al == null) { if (NavigationContext.QueryString.ContainsKey("idal")) { String dato1 = NavigationContext.QueryString["idal"]; idalarma = int.Parse(dato1); } else { } DespertadorDAOLocal dao = new DespertadorDAOLocal(); List <Alarma> alarmas = dao.findAllAlarma(); for (int i = 0; i < alarmas.Count; i++) { if (alarmas.ElementAt(i).ID == idalarma) { al = alarmas.ElementAt(i); } } nombre.Text = al.Nombre; hora.Value = new TimeSpan(al.Hora.Hour, al.Hora.Minute, al.Hora.Second); int a = 0; if (al.Modo.Equals("Ovejas")) { a = 2; } if (al.Modo.Equals("Matematicas")) { a = 1; } if (al.Modo.Equals("Basico")) { a = 0; } repeat.IsChecked = al.recurrente; lunes.IsChecked = al.lunes; martes.IsChecked = al.martes; miercoles.IsChecked = al.miercoles; jueves.IsChecked = al.jueves; viernes.IsChecked = al.viernes; sabado.IsChecked = al.sabado; domingo.IsChecked = al.domingo; if (repeat.IsChecked == true) { gridDias.Visibility = System.Windows.Visibility.Visible; } else { gridDias.Visibility = System.Windows.Visibility.Collapsed; } cmbCurrFrom.SelectedIndex = a; } }
private void iniciarSesion(object sender, RoutedEventArgs e) { mongo.findAllDocuments(this); DespertadorDAOLocal local = new DespertadorDAOLocal(); bool validacion = true; Usuario us = new Usuario(); for (int i = 0; i < users.Count; i++) { if (login.Text.Equals(users.ElementAt(i).Login)) { if (login.Text.Equals(users.ElementAt(i).Contrasena)) { validacion = true; us.Contrasena = users.ElementAt(i).Contrasena; us.Login = users.ElementAt(i).Login; us.Nombre = users.ElementAt(i).Nombre; us.Email = users.ElementAt(i).Email; i = users.Count; } else { validacion = false; } } else { validacion = false; } } //aqui poner la validacion de inicio de sesion if (validacion) { int i; i = local.insertUsuario(us); if (i == 1) { MessageBox.Show("Sesión iniciada como: " + us.Nombre); NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); } else { MessageBox.Show("Error, revise sus datos"); } } else { MessageBox.Show("Login o password Incorrectos"); } }
void addButton_Click(object sender, EventArgs e) { DespertadorDAOLocal dao = new DespertadorDAOLocal(); List <Usuario> us = dao.findAllUsuario(); int iduser; try{ iduser = us.ElementAt(0).ID; }catch (Exception E) { iduser = -1; } NavigationService.Navigate(new Uri("/NuevaAlarma.xaml?iduser=" + iduser, UriKind.Relative)); }
void deleteButton_Click(object sender, EventArgs e) { DespertadorDAOLocal dao = new DespertadorDAOLocal(); var alarma = list.SelectedItem as Alarma; int i = dao.deleteAlarma(alarma); if (i == 1) { MessageBox.Show("Alarma Eliminada Correctamente"); } else { MessageBox.Show("Error al eliminar Alarma"); } cargarAlarmasPre(); }
private void cerrarSesion(object sender, RoutedEventArgs e) { DespertadorDAOLocal dao = new DespertadorDAOLocal(); Usuario us = new Usuario(); try { us = dao.findAllUsuario().ElementAt(0); } catch (Exception E) { } dao.deleteUsuario(us); var alarmas = App.Current.Resources["alarmas"] as Alarmas; alarmas.Data = null; NavigationService.Navigate( new Uri("/MainPage.xaml", UriKind.Relative) ); }
private void cargarAlarmasPre() { var alarmas = App.Current.Resources["alarmas"] as Alarmas; DespertadorDAOLocal dao = new DespertadorDAOLocal(); List <Usuario> us = dao.findAllUsuario(); List <Alarma> lista = new List <Alarma>();// aqui se debe colocar el llamado de la base de datos. try { int iduser = us.ElementAt(0).ID; lista = dao.findAllAlarmaByIduser(iduser); ObservableCollection <Alarma> myCollection = new ObservableCollection <Alarma>(lista); alarmas.Data = myCollection; } catch (Exception e) { lista = dao.findAllAlarmaByIduser(-1); ObservableCollection <Alarma> myCollection = new ObservableCollection <Alarma>(lista); alarmas.Data = myCollection; } }
private void verificarPerfil(object sender, RoutedEventArgs e) { DespertadorDAOLocal dao = new DespertadorDAOLocal(); List <Usuario> us = dao.findAllUsuario(); try { if (dao.findAllUsuario().Count != 0) { NavigationService.Navigate(new Uri("/Perfil.xaml", UriKind.Relative)); } else { NavigationService.Navigate( new Uri("/IniciarSesion.xaml", UriKind.Relative) ); } } catch (Exception E) { // andres.Text = "hola " + E; } }
void saveButton_Click(object sender, EventArgs e) { DespertadorDAOLocal local = new DespertadorDAOLocal(); TimeSpan time = hora.Value.Value; int horas = time.Hours; int minutos = time.Minutes; int segundos = time.Seconds; DateTime fechaHoy = DateTime.Now; DateTime config = new DateTime(fechaHoy.Date.Year, fechaHoy.Date.Month, fechaHoy.Day, horas, minutos, segundos); TimeSpan ts; Alarma al = new Alarma(); int modo = cmbCurrFrom.SelectedIndex; al.mode = modo; if (modo == 0) { al.Modo = "Basico"; } if (modo == 1) { al.Modo = "Matematicas"; } if (modo == 2) { al.Modo = "Ovejas"; } bool bandera = false; bool bandera2 = false; bool rec = repeat.IsChecked.Value; al.lunes = lunes.IsChecked.Value; al.martes = martes.IsChecked.Value; al.miercoles = miercoles.IsChecked.Value; al.jueves = jueves.IsChecked.Value; al.viernes = viernes.IsChecked.Value; al.sabado = sabado.IsChecked.Value; al.domingo = domingo.IsChecked.Value; al.recurrente = rec; if (rec) { al.Recur = "Recurrente"; switch ((int)fechaHoy.DayOfWeek) { case 1: if (al.lunes) { ts = fechaHoy - config; if (ts.TotalMilliseconds < 0) { al.Hora = config; } else { al.Hora = config.AddDays(7); } } else if (al.martes) { al.Hora = config.AddDays(1); } else if (al.miercoles) { al.Hora = config.AddDays(2); } else if (al.jueves) { al.Hora = config.AddDays(3); } else if (al.viernes) { al.Hora = config.AddDays(4); } else if (al.sabado) { al.Hora = config.AddDays(5); } else if (al.domingo) { al.Hora = config.AddDays(6); } else { bandera = true; } break; case 2: if (al.martes) { ts = fechaHoy - config; if (ts.TotalMilliseconds < 0) { al.Hora = config; } else { al.Hora = config.AddDays(7); } } else if (al.miercoles) { al.Hora = config.AddDays(1); } else if (al.jueves) { al.Hora = config.AddDays(2); } else if (al.viernes) { al.Hora = config.AddDays(3); } else if (al.sabado) { al.Hora = config.AddDays(4); } else if (al.domingo) { al.Hora = config.AddDays(5); } else if (al.lunes) { al.Hora = config.AddDays(6); } else { bandera = true; } break; case 3: if (al.miercoles) { ts = fechaHoy - config; if (ts.TotalMilliseconds < 0) { al.Hora = config; } else { al.Hora = config.AddDays(7); } } else if (al.jueves) { al.Hora = config.AddDays(1); } else if (al.viernes) { al.Hora = config.AddDays(2); } else if (al.sabado) { al.Hora = config.AddDays(3); } else if (al.domingo) { al.Hora = config.AddDays(4); } else if (al.lunes) { al.Hora = config.AddDays(5); } else if (al.martes) { al.Hora = config.AddDays(6); } else { bandera = true; } break; case 4: if (al.jueves) { ts = fechaHoy - config; if (ts.TotalMilliseconds < 0) { al.Hora = config; } else { al.Hora = config.AddDays(7); } } else if (al.viernes) { al.Hora = config.AddDays(1); } else if (al.sabado) { al.Hora = config.AddDays(2); } else if (al.domingo) { al.Hora = config.AddDays(3); } else if (al.lunes) { al.Hora = config.AddDays(4); } else if (al.martes) { al.Hora = config.AddDays(5); } else if (al.miercoles) { al.Hora = config.AddDays(6); } else { bandera = true; } break; case 5: if (al.viernes) { ts = fechaHoy - config; if (ts.TotalMilliseconds < 0) { al.Hora = config; } else { al.Hora = config.AddDays(7); } } else if (al.sabado) { al.Hora = config.AddDays(1); } else if (al.domingo) { al.Hora = config.AddDays(2); } else if (al.lunes) { al.Hora = config.AddDays(3); } else if (al.martes) { al.Hora = config.AddDays(4); } else if (al.miercoles) { al.Hora = config.AddDays(5); } else if (al.jueves) { al.Hora = config.AddDays(6); } else { bandera = true; } break; case 6: if (al.sabado) { ts = fechaHoy - config; if (ts.TotalMilliseconds < 0) { al.Hora = config; } else { al.Hora = config.AddDays(7); } } else if (al.domingo) { al.Hora = config.AddDays(1); } else if (al.lunes) { al.Hora = config.AddDays(2); } else if (al.martes) { al.Hora = config.AddDays(3); } else if (al.miercoles) { al.Hora = config.AddDays(4); } else if (al.jueves) { al.Hora = config.AddDays(5); } else if (al.viernes) { al.Hora = config.AddDays(6); } else { bandera = true; } break; case 7: if (al.domingo) { ts = fechaHoy - config; if (ts.TotalMilliseconds < 0) { al.Hora = config; } else { al.Hora = config.AddDays(7); } } else if (al.lunes) { al.Hora = config.AddDays(1); } else if (al.martes) { al.Hora = config.AddDays(2); } else if (al.miercoles) { al.Hora = config.AddDays(3); } else if (al.jueves) { al.Hora = config.AddDays(4); } else if (al.viernes) { al.Hora = config.AddDays(5); } else if (al.sabado) { al.Hora = config.AddDays(6); } else { bandera = true; } break; } } else { al.Recur = "No Recurrente"; ts = fechaHoy - config; if (ts.TotalMilliseconds < 0) { al.Hora = config; } else { MessageBox.Show("Hora invalida"); bandera2 = true; } } if (!bandera2) { if (nombre.Text != "") { if (!bandera) { al.Nombre = nombre.Text; al.iduser = iduser; local.insertAlarma(al); NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); } else { MessageBox.Show("Debe seleccionar por lo menos un día"); } } else { MessageBox.Show("Agregar un nombre"); } } }