Exemplo n.º 1
0
    protected void btnreporte_Click(object sender, EventArgs e)
    {
        conexion();

        if (string.IsNullOrWhiteSpace(txtemision.Text) || string.IsNullOrWhiteSpace(txtpago.Text))
        {
            lblmensaje.Text = "Ingrese la fecha de emisión o fecha de pago";
        }
        else
        {
            OdbcDataAdapter da = new OdbcDataAdapter("select p.Id_planilla as numero_plantilla,s.Id_Socio,s.cedula,s.nombre,s.apellido,s.numero_medidor,p.metros_Consumo,p.fecha_emision,p.fecha_pago  from planilla p join socios s on s.Id_socio=p.Id_socio  where p.fecha_emision like'" + txtemision.Text + "%' and p.fecha_pago like '" + txtpago.Text + "%'", cnn);
            DataTable       ds = new DataTable();
            da.Fill(ds);
            //dataGridView1.DataSource = ds;
            GridConsumo.DataSource = ds;
            GridConsumo.DataBind();
            cnn.Close();


            Response.Clear();
            Response.Buffer  = true;
            Response.Charset = "";
            Response.AddHeader("content-disposition", "attachment;filename=Consumo.xls");
            Response.ContentType = "application/ms-excel";
            StringWriter   sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            GridConsumo.AllowPaging = false;
            GridConsumo.AutoGenerateSelectButton = false;
            GridConsumo.DataBind();
            GridConsumo.RenderControl(hw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
        }
    }
Exemplo n.º 2
0
    private void buscar(string sql)
    {
        conexion();

        OdbcDataAdapter da = new OdbcDataAdapter(sql, cnn);
        DataTable       ds = new DataTable();

        da.Fill(ds);
        GridConsumo.DataSource = ds;
        GridConsumo.DataBind();
        cnn.Close();
    }
Exemplo n.º 3
0
    private void cargar_tabla()
    {
        conexion();

        OdbcDataAdapter da = new OdbcDataAdapter("select p.Id_planilla as numero_plantilla,s.Id_Socio,s.cedula,s.nombre,s.apellido,s.numero_medidor,p.metros_Consumo,p.fecha_emision,p.fecha_pago from planilla p join socios s on s.Id_socio=p.Id_socio and s.estado=1 and p.estado='D'", cnn);
        DataTable       ds = new DataTable();

        da.Fill(ds);
        //dataGridView1.DataSource = ds;
        GridConsumo.DataSource = ds;
        GridConsumo.DataBind();
        cnn.Close();
    }