private void btnBuscar_Click(object sender, EventArgs e) { try { if (rbProfesores.Checked == true) { string nombre, apellido; if (txtNombre.Text == string.Empty) { nombre = ""; } else { nombre = txtNombre.Text; } if (txtApellido.Text == string.Empty) { apellido = ""; } else { apellido = txtApellido.Text; } dgvTabla.DataSource = ProfesoresDB.BuscarProfesores(nombre, apellido); } else { } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void txtNombre_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == Convert.ToChar(Keys.Enter)) { try { string nombre, apellido; if (txtNombre.Text == string.Empty) { nombre = ""; } else { nombre = txtNombre.Text; } if (txtApellido.Text == string.Empty) { apellido = ""; } else { apellido = txtApellido.Text; } dgvTabla.DataSource = ProfesoresDB.BuscarProfesores(nombre, apellido); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }