private void ListadoDeInstructores(BuscarInstructorPor criterio, string texto) { try { dgvInstructor.AutoGenerateColumns = false; DataTable dt = Instructor.ListadoDeInstructores(criterio, texto, false); dgvInstructor.Columns["Id"].DataPropertyName = "ID_INSTRUCTOR"; dgvInstructor.Columns["Nomb"].DataPropertyName = "NOMBRE"; dgvInstructor.Columns["Dir"].DataPropertyName = "DIRECCION"; dgvInstructor.Columns["Tel"].DataPropertyName = "TELEFONO"; dgvInstructor.Columns["Cel"].DataPropertyName = "CELULAR"; dgvInstructor.Columns["Email"].DataPropertyName = "EMAIL"; dgvInstructor.Columns["Tipo"].DataPropertyName = "TIPO"; dgvInstructor.Columns["Prof"].DataPropertyName = "NOMBRE_PROFESION"; //dgvInstructor.Columns["Exp_contrat"].DataPropertyName = "EXP_CONTRATO"; dgvInstructor.DataSource = dt; } catch (Exception ex) { VentanaMsjes ventana2 = new VentanaMsjes("ERROR", ex.Message); ventana2.iconoPregunta.Image = global::Ej_Interfaz_Proyecto.Properties.Resources.icn_err; ventana2.btnAceptar.Visible = true; ventana2.ShowDialog(); } }
public static DataTable ListadoDeInstructores(BuscarInstructorPor criterio, string texto, bool tipo) { string SQL = ""; if (criterio == BuscarInstructorPor.Identificación) { if (tipo == true) { SQL = "select i.ID_INSTRUCTOR as Identificación,i.NOMBRE as Nombre,i.CELULAR from instructor i where ID_INSTRUCTOR LIKE'" + texto + "%' order by ID_INSTRUCTOR"; } else { SQL = "SELECT ID_INSTRUCTOR, NOMBRE, DIRECCION, TELEFONO, CELULAR, " + "EMAIL, TIPO, NOMBRE_PROFESION FROM INSTRUCTOR LEFT JOIN PROFESION ON INSTRUCTOR.ID_PROFESION = PROFESION.ID_PROFESION WHERE ID_INSTRUCTOR LIKE @PARAM +'%' ORDER BY ID_INSTRUCTOR"; } } else if (criterio == BuscarInstructorPor.Nombre) { if (tipo == true) { SQL = "select i.ID_INSTRUCTOR as Identificación,i.NOMBRE as Nombre,i.CELULAR from instructor i where NOMBRE LIKE'" + texto + "%' order by Nombre"; } else { SQL = "SELECT ID_INSTRUCTOR, NOMBRE, DIRECCION, TELEFONO, CELULAR, " + "EMAIL, TIPO, NOMBRE_PROFESION FROM INSTRUCTOR LEFT JOIN PROFESION ON INSTRUCTOR.ID_PROFESION = PROFESION.ID_PROFESION WHERE NOMBRE LIKE @PARAM +'%' ORDER BY ID_INSTRUCTOR"; } } try { SqlDataAdapter da = new SqlDataAdapter(SQL, Conexion.CadenaDeConexion); da.SelectCommand.Parameters.AddWithValue("@PARAM", texto); DataTable dt = new DataTable(); da.Fill(dt); return(dt); } catch (Exception ex) { throw new Exception(ex.Message); } }