private void Button_Click(object sender, RoutedEventArgs e) { MyDataContext db = new MyDataContext(MyDataContext.cadena); try { Participantes p = new Participantes(); p.ApPaterno = txtApPaterno.Text; p.ApMaterno = txtApMaterno.Text; p.Nombres = txtNombres.Text; p.DNI = txtDNI.Text; p.Correo = txtCorreo.Text; p.Direccion = txtDireccion.Text; p.Telefono = txtTelefono.Text; if (rbnM.IsChecked == true) { p.Genero = "M"; } else { p.Genero = "F"; } db.listaParticipantes.InsertOnSubmit(p); db.SubmitChanges(); MessageBox.Show("Registro agregado correctamente"); NavigationService.Navigate(new Uri("/Confirmacion.xaml", UriKind.RelativeOrAbsolute)); } catch (Exception) { MessageBox.Show("Error al agregar el registro."); } }
private void Button_Loaded(object sender, RoutedEventArgs e) { db = new MyDataContext(MyDataContext.cadena); if (!db.DatabaseExists()) { db.CreateDatabase(); AgregarUsuarioInicial(); } }
private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) { MyDataContext db = new MyDataContext(MyDataContext.cadena); lstParticipantes.ItemsSource = db.listaParticipantes; }