public void InsertarEstudiantes(Eestudiantes estudiante) { if (ValidarCursos(estudiante)) { acceso_datos.InsertarEstudiantes(estudiante); } }
//______________________ESTUDIANTES_______________________________ public void InsertarEstudiantes(Eestudiantes estudiante) { try { con.ConnectionString = Conexion.cadenaConexion; comando = new SqlCommand("Sp_estudiantes", con); comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@a", estudiante.a); comando.Parameters.AddWithValue("@nombre", estudiante.nombre); comando.Parameters.AddWithValue("@apellidos", estudiante.apellidos); comando.Parameters.AddWithValue("@rne", estudiante.rne); comando.Parameters.AddWithValue("@fecha", estudiante.fecha); comando.Parameters.AddWithValue("@sexo", estudiante.sexo); comando.Parameters.AddWithValue("@direccion", estudiante.direccion); comando.Parameters.AddWithValue("@telefono", estudiante.telefono); comando.Parameters.AddWithValue("@enfermedades", estudiante.enfermedades); comando.Parameters.AddWithValue("@tipo_sangre", estudiante.tipo_sangre); comando.Parameters.AddWithValue("@ano", estudiante.ano); comando.Parameters.AddWithValue("@tanda", estudiante.tanda); comando.Parameters.AddWithValue("@curso", estudiante.curso); comando.Parameters.AddWithValue("@instituto", estudiante.instituto); con.Open(); comando.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } finally { con.Close(); } }
public static bool BuscarEstudiantes(Eestudiantes estudiante) { datos = acceso_datos.BuscarEstudiantes(estudiante); if (datos.Rows.Count > 0) { return(true); } else { return(false); } }
private bool ValidarCursos(Eestudiantes estudiante) { stringBuilder.Clear(); if (string.IsNullOrEmpty(estudiante.nombre)) { stringBuilder.Append("El campo NOMBRE es obligatorio"); } if (string.IsNullOrEmpty(estudiante.apellidos)) { stringBuilder.Append("El campo APELLIDO es obligatorio"); } if (string.IsNullOrEmpty(estudiante.rne)) { stringBuilder.Append("El campo RNE es obligatorio"); } if (string.IsNullOrEmpty(estudiante.fecha)) { stringBuilder.Append("El campo FECHA NACIMIENTO es obligatorio"); } if (string.IsNullOrEmpty(estudiante.sexo)) { stringBuilder.Append("El campo SEXO es obligatorio"); } if (string.IsNullOrEmpty(estudiante.direccion)) { stringBuilder.Append("El campo DIRECCION es obligatorio"); } if (string.IsNullOrEmpty(estudiante.telefono)) { stringBuilder.Append("El campo TELEFONO es obligatorio"); } if (string.IsNullOrEmpty(estudiante.tipo_sangre)) { stringBuilder.Append("El campo TIPO DE SANGRE es obligatorio"); } if (string.IsNullOrEmpty(estudiante.ano.ToString())) { stringBuilder.Append("El campo FECHA NAC. es obligatorio"); } if (string.IsNullOrEmpty(estudiante.tanda)) { stringBuilder.Append("El campo TANDA es obligatorio"); } if (string.IsNullOrEmpty(estudiante.curso)) { stringBuilder.Append("El campo CURSO es obligatorio"); } return(stringBuilder.Length == 0); }
private void Guardar() { try { string sexo = ""; if (estudiante == null) { estudiante = new Eestudiantes(); } estudiante.a = "Insertar"; estudiante.nombre = txtNombre.Text; estudiante.apellidos = txtApelli1.Text + " " + txtApelli2.Text; estudiante.rne = txtRNE.Text; estudiante.fecha = txtFecha.Text; if (rbMascu.Checked == true) { sexo = "MASCULINO"; } else if (rbFeme.Checked == true) { sexo = "FEMENINO"; } estudiante.sexo = sexo; estudiante.direccion = txtDire.Text; estudiante.telefono = txtTel.Text; estudiante.enfermedades = txtComentario.Text; estudiante.tipo_sangre = cbSangre.Text; estudiante.tanda = cbTanda.Text; estudiante.curso = cbCurso.Text; estudiante.instituto = txtInstituto.Text; acceso_estudiantes.InsertarEstudiantes(estudiante); if (acceso_estudiantes.stringBuilder.Length != 0) { MessageBox.Show(acceso_estudiantes.stringBuilder.ToString(), "Para continuar:", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show("ESTUDIANTE REGISTRADO CORRECTAMENTE", "ESTUDIANTE REGISTRADO", MessageBoxButtons.OK, MessageBoxIcon.None); } } catch (Exception ex) { MessageBox.Show(string.Format("Error: {0}", ex.Message), "Error inesperado", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public DataTable BuscarEstudiantes(Eestudiantes estudiante) { con.ConnectionString = Conexion.cadenaConexion; comando = new SqlCommand("Sp_estudiantes", con); comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@a", estudiante.a); comando.Parameters.AddWithValue("@nombre", estudiante.nombre); comando.Parameters.AddWithValue("@apellidos", estudiante.apellidos); comando.Parameters.AddWithValue("@rne", estudiante.rne); comando.Parameters.AddWithValue("@fecha", ""); comando.Parameters.AddWithValue("@sexo", ""); comando.Parameters.AddWithValue("@direccion", ""); comando.Parameters.AddWithValue("@telefono", ""); comando.Parameters.AddWithValue("@enfermedades", ""); comando.Parameters.AddWithValue("@tipo_sangre", ""); comando.Parameters.AddWithValue("@ano", ""); comando.Parameters.AddWithValue("@tanda", ""); comando.Parameters.AddWithValue("@curso", estudiante.curso); comando.Parameters.AddWithValue("@instituto", ""); return(MetodosDatos.ejecutarComandoSelect(comando)); }