コード例 #1
0
        public void CargarDashboard()
        {
            try
            {
                CantidadFacturasConySinDeudasTableAdapter facturasConySinDeudasAdapter = new CantidadFacturasConySinDeudasTableAdapter();
                CantidadFacturasConySinDeudasDataTable    FacturasConySinDeudasData    = facturasConySinDeudasAdapter.CantidadFacturasConySinDeudas();

                chartFacturasConySinDeudas.Series[0].Points.DataBindXY(FacturasConySinDeudasData.Rows, "TipoFactura", FacturasConySinDeudasData.Rows, "Cantidad");

                VentasPorDiaUltimos30TableAdapter ventasPorDiaAdapter = new VentasPorDiaUltimos30TableAdapter();
                VentasPorDiaUltimos30DataTable    ventasPorDiaData    = ventasPorDiaAdapter.VentasPorDiaUltimos30();

                chartVentasPorDia.Series[0].Points.DataBindXY(ventasPorDiaData.Rows, "FechaAbreviada", ventasPorDiaData.Rows, "TotalVentas");

                VentasProductosPorCategoriaTableAdapter productosVendidodPorCatAdapter = new VentasProductosPorCategoriaTableAdapter();
                VentasProductosPorCategoriaDataTable    productosVendidosPorCatData    = productosVendidodPorCatAdapter.VentasProductosPorCategoria();

                chartCategoriasMasVendidas.Series[0].Points.DataBindXY(productosVendidosPorCatData.Rows, "Nombre", productosVendidosPorCatData.Rows, "Cantidad");

                Top5ProductosMasVendidosTableAdapter top5ProductosAdapter = new Top5ProductosMasVendidosTableAdapter();
                Top5ProductosMasVendidosDataTable    top5ProductosData    = top5ProductosAdapter.Top5ProductosMasVendidos();

                chartProductosMasVendidos.Series[0].Points.DataBindXY(top5ProductosData.Rows, "NombreProducto", top5ProductosData.Rows, "Vendido");

                FuncionesTableAdapter funcionesAdapter = new FuncionesTableAdapter();
                decimal totalVentas = funcionesAdapter.VentasEnUltimos30Dias()[0].Valor,
                        totalAbono  = funcionesAdapter.AbonosEnUltimos30Dias()[0].Valor,
                        deudaTotal  = funcionesAdapter.DeudaTotal()[0].Valor;

                int cantidadVentas = Convert.ToInt32(funcionesAdapter.FacturasEnUltimos30Dias()[0].Valor),
                    cantidadProductosAcabandose = Convert.ToInt32(funcionesAdapter.CantidadProductosAcabandose()[0].Valor);

                lblVentasAcumuladas.Text = "RD$" + string.Format("{0:0,0.00}", totalVentas);
                lblTotalAbonos.Text      = "RD$" + string.Format("{0:0,0.00}", totalAbono);
                lblDeudaTotal.Text       = "RD$" + string.Format("{0:0,0.00}", deudaTotal);

                lblCantVentas.Text        = cantidadVentas.ToString();
                lblCantidadProductos.Text = cantidadProductosAcabandose.ToString();
            }
            catch (Exception error)
            {
                log.Error($"Error: {error.Message}", error);
                MessageBox.Show($"Error: {error.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }