Exemplo n.º 1
0
 private void txtMatricula_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == Convert.ToChar(Keys.Enter))
     {
         string nombre, apellido, matricula;
         try
         {
             Estudiante pE = new Estudiante();
             if (txtNombre.Text == string.Empty)
             {
                 nombre = "";
             }
             else
             {
                 nombre = txtNombre.Text;
             }
             if (txtApellido.Text == string.Empty)
             {
                 apellido = "";
             }
             else
             {
                 apellido = txtApellido.Text;
             }
             if (txtMatricula.Text == string.Empty)
             {
                 matricula = "";
             }
             else
             {
                 matricula = txtMatricula.Text;
             }
             nombre    = txtNombre.Text;
             apellido  = txtApellido.Text;
             matricula = txtMatricula.Text;
             dataGridView1.DataSource = EstudianteDB.BuscarEstudiante(nombre, apellido, matricula);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Exemplo n.º 2
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            string nombre, apellido, matricula;

            try
            {
                Estudiante pE = new Estudiante();
                if (txtNombre.Text == string.Empty)
                {
                    nombre = "";
                }
                else
                {
                    nombre = txtNombre.Text;
                }
                if (txtApellido.Text == string.Empty)
                {
                    apellido = "";
                }
                else
                {
                    apellido = txtApellido.Text;
                }
                if (txtMatricula.Text == string.Empty)
                {
                    matricula = "";
                }
                else
                {
                    matricula = txtMatricula.Text;
                }
                nombre    = txtNombre.Text;
                apellido  = txtApellido.Text;
                matricula = txtMatricula.Text;
                dataGridView1.DataSource = EstudianteDB.BuscarEstudiante(nombre, apellido, matricula);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }