コード例 #1
0
        void BindListado(int busqueda)
        {
            int estado = 2;  // 0 : No Colaborador , 1 : Colaborador  , 2 : Todos
            int orden  = 0;

            Session["Busqueda"] = busqueda.ToString(); //guardamos la busqueda
            estado = (chkColaborador.Checked && !chkNoColaborador.Checked) ? 1 : ((chkNoColaborador.Checked && !chkColaborador.Checked) ? 0 : 2);
            orden  = (chkCompra.Checked && !chkNoCompra.Checked) ? 1 : ((chkNoCompra.Checked && !chkCompra.Checked) ? 0 : 2);

            if (busqueda == 1)
            {
                int criterio = (rtnCliente.Checked) ? 1 : ((rtnDNI.Checked) ? 2 : ((rtnEmail.Checked) ? 3 : ((rtnFecha.Checked) ? 4 : 0)));

                String desde = (txtDesde.Text == "") ? DateTime.Now.ToString() : txtDesde.Text;
                String hasta = (txtHasta.Text == "") ? DateTime.Now.ToString() : txtHasta.Text;
                List <eUsuariosWeb> lCliente = new List <eUsuariosWeb>();
                lCliente = cCMS.Cliente_buscar(criterio, txtNombreCliente.Text, txtDNI.Text, txtEmailCliente.Text, Convert.ToDateTime(desde), Convert.ToDateTime(hasta).AddDays(1), estado, orden);
                if (lCliente.Count > 0)
                {
                    litConteoTotal.Text           = "Se han encontrado " + lCliente.Count + " resultados de busqueda";
                    grvListadoClientes.DataSource = lCliente;
                    grvListadoClientes.DataBind();
                    MostrarBotones(true);
                }
                else
                {
                    MostrarBotones(false);
                    grvListadoClientes.DataSource = null;
                    grvListadoClientes.DataBind();
                    litConteoTotal.Text = "No hay resultados de busqueda";
                }
            }
            else
            {
                List <eUsuariosWeb> lCliente = new List <eUsuariosWeb>();
                lCliente                      = cCMS.Cliente_buscar(0, "", "", "", DateTime.Now, DateTime.Now, estado, 2);
                litConteoTotal.Text           = "Se han encontrado " + lCliente.Count + " resultados de busqueda";
                grvListadoClientes.DataSource = lCliente;
                grvListadoClientes.DataBind();
                MostrarBotones(true);
            }
        }