Esempio n. 1
0
 private bool agregarAlumno()
 {
     if (validarCampos())
     {
         Alumno a = new Alumno();
         a.nombre    = txtNombre.Text;
         a.direccion = txtDireccion.Text;
         a.telefono1 = txtTelefono1.Text;
         if (txtTelefono2.Text == null || txtTelefono2.Text == "")
         {
             a.telefono2 = " ";
         }
         else
         {
             a.telefono2 = txtTelefono2.Text;
         }
         a.correo             = txtCorreo.Text;
         a.facebook           = txtFacebook.Text;
         a.curp               = txtCURP.Text;
         a.rfc                = txtRFC.Text;
         a.sexo               = cmbSexo.SelectedItem.ToString();
         a.estadoCivil        = cmbEstadoCivil.SelectedItem.ToString();
         a.escuelaProcedencia = txtEscuelaProcedencia.Text;
         a.carrera            = txtCarrera.Text;
         a.nivel              = cmbNivel.SelectedItem.ToString();
         a.programa           = cmbPrograma.SelectedItem.ToString();
         a.tipo               = "Regular";
         a.estado             = "Registrado";
         a.fecha              = DateTime.Now;
         a.observaciones      = txtObservaciones.Text;
         a.matricula          = txtMatricula.Text;
         if (modificacion)
         {
             a.rfc = txtRFC.Text;
             if (control.actualizarAlumno(a))
             {
                 return(true);
             }
             else
             {
                 throw new Exception("Error al actualizar los datos del alumno");
             }
         }
         else
         {
             if (control.agregarAlumno(a))
             {
                 return(true);
             }
             else
             {
                 throw new Exception("Error al agregar el alumno");
             }
         }
     }
     else
     {
         MessageBox.Show("No deje los campos marcados con * vacios");
     }
     return(false);
 }