コード例 #1
0
 /// <summary>
 /// Ingresa los valores a la base de datos al presionar el botón
 /// </summary>
 private void btnAgregarPaciente_Click(object sender, RoutedEventArgs e)
 {
     //Comprueba que todos los campos estén llenos
     if (txtAgregarApellido.Text == String.Empty || txtAgregarNombre.Text == String.Empty || txtAgregarIdentidad.Text == String.Empty || txtAgregarTelefono.Text == String.Empty || txtAgregarEdad.Text == String.Empty || rbMasculino.IsChecked == false && rbFemenino.IsChecked == false)
     {
         MessageBox.Show("¡Por favor llena todos los campos!");
         txtAgregarNombre.Focus();
     }
     //Intenta ingresar datos a la BD
     else
     {
         try
         {
             ObtenerValores();
             paciente.AgregarPaciente(paciente);
             MessageBox.Show("Datos ingresados correctamente.");
             Limpiar();
         }
         //Lanza una excepcion si ocurre un fallo
         catch (Exception)
         {
             MessageBox.Show("Ha ocurrido un error, revise sus datos e intente de nuevo");
         }
     }
 }