// boton agregar tareas private void ApplicationBarIconButton_Click(object sender, EventArgs e) { try { valor++; using (BaseListasDataContext contextoDatos = new BaseListasDataContext("Data source='isostore:/ListasDB.sdf'")) { // misListas = contextoDatos.Lista.ToList(); var cont = contextoDatos.Lista.Where(c => c.Id == valor).FirstOrDefault(); if (cont != null) { // agregar tarea 1 if (valor == 1) { Tarea1.Text = cont.Tarea; horaUno = Convert.ToInt32(cont.Hora); minutoUno = Convert.ToInt32(cont.Minuto); segundoUno = Convert.ToInt32(cont.Segundo); a = Convert.ToInt32(cont.Segundo); if ((Tarea1.Text).Length != 0) { temporizador1.Start(); } else { contextoDatos.DeleteDatabase(); MessageBox.Show("¡Todavia no has creado ninguna lista!"); valor = 0; Tarea1.Text = "_______________________________________"; Crono1.Text = "00:00:00"; NavigationService.Navigate(new Uri("/AgregarTarea.xaml", UriKind.Relative)); temporizador1.Stop(); } } // agregar tarea 2 if (valor == 2) { Tarea2.Text = cont.Tarea; horaDos = Convert.ToInt32(cont.Hora); minutoDos = Convert.ToInt32(cont.Minuto); segundoDos = Convert.ToInt32(cont.Segundo); b = Convert.ToInt32(cont.Segundo); Crono2.Text = horaDos + ":" + minutoDos + ":" + segundoDos; } // agregar tarea 3 if (valor == 3) { Tarea3.Text = cont.Tarea; horaTres = Convert.ToInt32(cont.Hora); minutoTres = Convert.ToInt32(cont.Minuto); segundoTres = Convert.ToInt32(cont.Segundo); c = Convert.ToInt32(cont.Segundo); Crono3.Text = horaTres + ":" + minutoTres + ":" + segundoTres; } // agregar tarea 4 if (valor == 4) { Tarea4.Text = cont.Tarea; horaCuatro = Convert.ToInt32(cont.Hora); minutoCuatro = Convert.ToInt32(cont.Minuto); segundoCuatro = Convert.ToInt32(cont.Segundo); d = Convert.ToInt32(cont.Segundo); Crono4.Text = horaCuatro + ":" + minutoCuatro + ":" + segundoCuatro; } // agregar tarea 5 if (valor == 5) { Tarea5.Text = cont.Tarea; horaCinco = Convert.ToInt32(cont.Hora); minutoCinco = Convert.ToInt32(cont.Minuto); segundoCinco = Convert.ToInt32(cont.Segundo); n = Convert.ToInt32(cont.Segundo); Crono5.Text = horaCinco + ":" + minutoCinco + ":" + segundoCinco; } // agregar tarea 6 if (valor == 6) { Tarea6.Text = cont.Tarea; horaSeis = Convert.ToInt32(cont.Hora); minutoSeis = Convert.ToInt32(cont.Minuto); segundoSeis = Convert.ToInt32(cont.Segundo); f = Convert.ToInt32(cont.Segundo); Crono6.Text = horaSeis + ":" + minutoSeis + ":" + segundoSeis; } // agregar tarea 7 if (valor == 7) { Tarea7.Text = cont.Tarea; horaSiete = Convert.ToInt32(cont.Hora); minutoSiete = Convert.ToInt32(cont.Minuto); segundoSiete = Convert.ToInt32(cont.Segundo); g = Convert.ToInt32(cont.Segundo); Crono7.Text = horaSiete + ":" + minutoSiete + ":" + segundoSiete; } // agregar tarea 8 if (valor == 8) { Tarea8.Text = cont.Tarea; horaOcho = Convert.ToInt32(cont.Hora); minutoOcho = Convert.ToInt32(cont.Minuto); segundoOcho = Convert.ToInt32(cont.Segundo); h = Convert.ToInt32(cont.Segundo); Crono8.Text = horaOcho + ":" + minutoOcho + ":" + segundoOcho; } // agregar tarea 9 if (valor == 9) { Tarea9.Text = cont.Tarea; horaNueve = Convert.ToInt32(cont.Hora); minutoNueve = Convert.ToInt32(cont.Minuto); segundoNueve = Convert.ToInt32(cont.Segundo); i = Convert.ToInt32(cont.Segundo); Crono9.Text = horaNueve + ":" + minutoNueve + ":" + segundoNueve; } // agregar tarea 10 if (valor == 10) { Tarea10.Text = cont.Tarea; horaDiez = Convert.ToInt32(cont.Hora); minutoDiez = Convert.ToInt32(cont.Minuto); segundoDiez = Convert.ToInt32(cont.Segundo); j = Convert.ToInt32(cont.Segundo); Crono10.Text = horaDiez + ":" + minutoDiez + ":" + segundoDiez; } // agregar tarea 11 if (valor == 11) { Tarea11.Text = cont.Tarea; horaOnce = Convert.ToInt32(cont.Hora); minutoOnce = Convert.ToInt32(cont.Minuto); segundoOnce = Convert.ToInt32(cont.Segundo); k = Convert.ToInt32(cont.Segundo); Crono11.Text = horaOnce + ":" + minutoOnce + ":" + segundoOnce; } // agregar tarea 12 if (valor == 12) { Tarea12.Text = cont.Tarea; horaDoce = Convert.ToInt32(cont.Hora); minutoDoce = Convert.ToInt32(cont.Minuto); segundoDoce = Convert.ToInt32(cont.Segundo); l = Convert.ToInt32(cont.Segundo); Crono12.Text = horaDoce + ":" + minutoDoce + ":" + segundoDoce; } } cont = null; } } catch (Exception) { MessageBox.Show("¡No puedes agregar tareas ya que no has creado ninguna lista !"); } }
// boton borrar private void ApplicationBarIconButton_Click_1(object sender, EventArgs e) { using (BaseListasDataContext dataContext1 = new BaseListasDataContext("Data source='isostore:/ListasDB.sdf'")) { dataContext1.DeleteDatabase(); valor = 0; // borrar tarea 1 Tarea1.Text = "_______________________________________"; Crono1.Text = "00:00:00"; // borrar tarea 2 Tarea2.Text = "_______________________________________"; Crono2.Text = "00:00:00"; // borrar tarea 3 Tarea3.Text = "_______________________________________"; Crono3.Text = "00:00:00"; // borrar tarea 4 Tarea4.Text = "_______________________________________"; Crono4.Text = "00:00:00"; // borrar tarea 5 Tarea5.Text = "_______________________________________"; Crono5.Text = "00:00:00"; // borrar tarea 6 Tarea6.Text = "_______________________________________"; Crono6.Text = "00:00:00"; // borrar tarea 7 Tarea7.Text = "_______________________________________"; Crono7.Text = "00:00:00"; // borrar tarea 8 Tarea8.Text = "_______________________________________"; Crono8.Text = "00:00:00"; // borrar tarea 9 Tarea9.Text = "_______________________________________"; Crono9.Text = "00:00:00"; // borrar tarea 10 Tarea10.Text = "_______________________________________"; Crono10.Text = "00:00:00"; // borrar tarea 11 Tarea11.Text = "_______________________________________"; Crono11.Text = "00:00:00"; // borrar tarea 12 Tarea12.Text = "_______________________________________"; Crono12.Text = "00:00:00"; } MessageBox.Show("La lista ha sido borrada "); }