Beispiel #1
0
        private void btnConsultar_Click(object sender, EventArgs e)
        {
            String condiciones = "";
            var    filters     = new Dictionary <string, object>();

            if (!chkTodas.Checked)//si el checkbox no esta marcado...
            {
                if (txtNombre.Text != string.Empty)
                {
                    // Si el textBox tiene un texto no vacìo entonces recuperamos el valor del texto
                    filters.Add("marca", txtNombre.Text);
                    //condiciones += "AND u.usuario=" + "'" + txtNombre.Text + "'";

                    condiciones += " AND (nombre LIKE '%" + txtNombre.Text + "%') ";

                    // strSql += " AND (u.usuario LIKE '%' + @usuario + '%') ";
                }

                if (filters.Count > 0)
                {
                    //SIN PARAMETROS
                    dgvMarcas.DataSource = oMarcaService.ConsultarConFiltros(condiciones);
                }


                else
                {
                    MessageBox.Show("Debe ingresar una Marca", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                dgvMarcas.DataSource = oMarcaService.ObtenerTodos();
            }
        }