public void CargarGrilla()
        {
            DBUtil db    = new DBUtil();
            string query = "";

            query += " select VC.FACTURA, CP.tipo_doc as Tipo, Monto, Cuenta, Moneda, Descripcion, CB.NOM_BANCO AS Banco  from cobranza_pagos CP INNER JOIN COBRANZA_BANCOS CB ON CB.ID = CP.BANCO INNER JOIN V_COBRANZA VC ON CP.ID_COBRANZA = VC.ID   ";

            G_Listado.DataSource = db.consultar(query);
            G_Listado.DataBind();
        }
        protected void FILTRAR_Click(object sender, EventArgs e)
        {
            DBUtil   db    = new DBUtil();
            string   query = "";
            DateTime t     = DateTime.Now;

            t   = new DateTime(t.Year, t.Month, t.Day);
            hoy = t.ToShortDateString();


            if (CB_Opcion.SelectedValue == "1")
            {
                where = "";

                //query = "SELECT cast(ROUND(SUM(monto_doc),0,1) as float) FROM v_cobranza where fecha_venc >= convert(datetime, '" + hoy + "', 103) and factura not in (SELECT factura FROM v_cobranza where fecha_venc >= convert(datetime, '" + hoy + "', 103) and tipo_doc = 'PA') ";
                if (IN_DM.SelectedValue == "1")
                {
                    //query += " and tipo_doc in ('IN') ";
                    where += " and tipo_doc in ('IN') ";
                }
                else if (IN_DM.SelectedValue == "2")
                {
                    //query += " and tipo_doc in ('DM') ";
                    where += " and tipo_doc in ('DM') and isnumeric(num_factura) <> 1 ";
                }
                else if (IN_DM.SelectedValue == "3")
                {
                    //query += " and tipo_doc in ('DM', 'IN') ";
                    where += " and tipo_doc in ('DM', 'IN') ";
                }
                else if (IN_DM.SelectedValue == "4")
                {
                    //query += " and tipo_doc in ('DM') ";
                    where += " and tipo_doc in ('DM') and isnumeric(num_factura) = 1 ";
                }

                if (D_CLIENTES.SelectedValue != "-1")
                {
                    //query += " and rutcliente like '%"+D_CLIENTES.SelectedValue+"%'";
                    where += " and rutcliente like '%" + D_CLIENTES.SelectedValue + "%'";
                }

                G_Listado.DataSource = ReporteRNegocio.privot_semanas(hoy, where);
                G_Listado.DataBind();
                muestra_total.Visible  = true;
                G_Listado.Visible      = true;
                Label1.Visible         = true;
                Label2.Visible         = true;
                total_estimado.Visible = true;
                total_vencido.Visible  = true;
            }

            if (CB_Opcion.SelectedValue == "2")
            {
                query = "SELECT  SUM(saldo)  FROM v_cobranza where fecha_venc >= convert(datetime, '" + txt_desde.Text + "', 103) and fecha_venc <= convert(datetime, '" + txt_hasta.Text + "', 103) and tipo_doc in ('PA') ";
                if (D_CLIENTES2.SelectedValue != "-1")
                {
                    query += " and rutcliente like '%" + D_CLIENTES2.SelectedValue + "%'";
                }

                //G_Listado.DataSource = db.consultar(query);
                //G_Listado.DataBind();
                foreach (DataRow r in db.consultar(query).Rows)
                {
                    total_.Text = r[0].ToString();

                    double d;
                    double.TryParse(total_.Text, out d);
                    string aux = "";
                    if (d == 0)
                    {
                        aux = "";
                    }
                    else
                    {
                        aux = d.ToString("N0");
                    }
                    total_.Text = aux.Replace("-", "");

                    muestra_total.Visible  = true;
                    G_Listado.Visible      = false;
                    Label1.Visible         = false;
                    Label2.Visible         = false;
                    total_estimado.Visible = false;
                    total_vencido.Visible  = false;
                }
            }

            if (CB_Opcion.SelectedValue == "3")
            {
                //query = "select VC.FACTURA, CP.tipo_doc as Tipo, Monto, Cuenta, Moneda, Descripcion, CB.NOM_BANCO AS Banco  from cobranza_pagos CP INNER JOIN COBRANZA_BANCOS CB ON CB.ID = CP.BANCO INNER JOIN V_COBRANZA VC ON CP.ID_COBRANZA = VC.ID ";

                //G_Listado.DataSource = db.consultar(query);
                //G_Listado.DataBind();
            }


            //CargarGrilla();
        }