Beispiel #1
0
        private void btnConsultar_Click(object sender, EventArgs e)
        {
            String condiciones = "";

            var filters = new Dictionary <string, object>();

            if (!chkTodos.Checked)
            {
                // Validar si el textBox 'Nombre' esta vacio.
                if (cboNombre.Text != string.Empty)
                {
                    // Si el textBox tiene un texto no vacìo entonces recuperamos el valor del texto
                    filters.Add("p.nombre", cboNombre.Text);
                    condiciones += " AND p.nombre LIKE " + "'%" + cboNombre.Text + "%'";
                }

                if (filters.Count > 0)
                {
                    //si agrego alguna condicion
                    //SIN PARAMETROS

                    MessageBox.Show("condiciones para el where del sql " + condiciones, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    dgvPerfiles.DataSource = oPerfilService.ConsultarConFiltrosSinParametros(condiciones);

                    //CON PARAMETROS
                    //dgvPerfil.DataSource = oCursoService.ConsultarConFiltrosConParametros(filters);
                }
                else
                {
                    MessageBox.Show("Debe ingresar al menos un dato.", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                //selecciono el checkbox(todos)
                dgvPerfiles.DataSource = oPerfilService.ObtenerTodos();
                habilitar();
            }
        }