Example #1
0
        private void btn_x_cantidad_Click(object sender, EventArgs e)
        {
            //SELECT p.id, p.nombre, SUM(dv.cantidad) as cantidad, SUM(totalVenta) as total FROM productos p, detalleventas dv, ventas v where p.id=dv.idProducto and dv.idVenta=v.id and date(v.fecVenta) BETWEEN '2018-06-17' and '2018-06-18' GROUP by p.id ORDER by cantidad DESC
            int    id_cliente = 0;
            string pedidos    = "";

            if (int.Parse(((DataRowView)cb_cliente.SelectedValue)[0].ToString()) == 0)
            {
                id_cliente = -1;
            }
            else
            {
                id_cliente = int.Parse(((DataRowView)cb_cliente.SelectedValue)[0].ToString());
            }
            switch (cb_pedidos.SelectedItem.ToString())
            {
            case "Pedidos":
                pedidos = "pedido";
                break;

            case "Factura":
                pedidos = "factura";
                break;

            case "Todos":
                pedidos = "Todos";
                break;
            }
            string fecha_inicio = dt_inicio.Value.ToString("yyyy-MM-dd");
            string fecha_final  = dt_final.Value.ToString("yyyy-MM-dd");

            lista.DataSource            = CReporte.Reporte3(id_cliente, pedidos, fecha_inicio, fecha_final);
            lista.Columns["id"].Visible = false;
            lb_producto.Text            = lista.Rows.Count + " Productos Diferentes";
            double sum  = 0.0;
            int    cv   = 0;
            int    cf   = 0;
            int    cant = 0;

            foreach (System.Windows.Forms.DataGridViewRow row in lista.Rows)
            {
                string cad = row.Cells["importe"].Value.ToString();
                sum  += (Double.Parse(cad));
                cad   = row.Cells["cantidad"].Value.ToString();
                cant += (int.Parse(cad));
            }
            this.lb_importe.Text = sum.ToString();
            lb_ventas.Text       = cant + " Productos Vendidos";
            lb_facturas.Text     = "_";
            lb_sin_factura.Text  = "_";
            lb_empresa.Text      = "REPORTE POR CANTIDAD DE PRODUCTO VENDIDO";
            lb_anulados.Text     = "_";
        }