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 (txtMarca.Text != string.Empty)
                {
                    // Si el textBox tiene un texto no vacìo entonces recuperamos el valor del texto
                    filters.Add("nombre", txtMarca.Text);
                    condiciones += "AND nombre=" + "'" + txtMarca.Text + "'";
                }

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


                else
                {
                    MessageBox.Show("Debe ingresar al menos un criterio", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                dgvMarcas.DataSource = oMarcaService.ObtenerTodos();
            }
        }