Exemplo n.º 1
0
        protected void BindReport()
        {
            //GET THE REPORT DATE
            DateTime fromDate = StartDate.SelectedStartDate;
            DateTime toDate   = EndDate.SelectedEndDate;

            //RESET THE TOTALS
            _TotalsCalculated = false;

            //GET SUMMARIES
            _MonthlySales = ReportDataSource.GetMonthlySales(fromDate, toDate);

            //UPDATE CHART
            UpdateChart();

            // FILTER OUT RESULTS FOR GRID DISPLAY
            for (int i = (_MonthlySales.Count - 1); i >= 0; i--)
            {
                if (_MonthlySales[i].OrderCount == 0)
                {
                    _MonthlySales.RemoveAt(i);
                }
            }
            MonthlySalesGrid.DataSource = _MonthlySales;
            MonthlySalesGrid.DataBind();
        }
Exemplo n.º 2
0
        protected void ExportButton_Click(Object sender, EventArgs e)
        {
            GenericExportManager <SalesSummary> exportManager = GenericExportManager <SalesSummary> .Instance;
            GenericExportOptions <SalesSummary> options       = new GenericExportOptions <SalesSummary>();

            options.CsvFields = new string[] { "StartDate", "OrderCount", "ProductTotal", "CostOfGoodTotal", "ShippingTotal", "TaxTotal", "DiscountTotal", "CouponTotal", "GiftWrapTotal", "OtherTotal", "ProfitTotal", "GrandTotal" };

            DateTime fromDate = StartDate.SelectedStartDate;
            DateTime toDate   = EndDate.SelectedEndDate;

            if (_MonthlySales == null)
            {
                _MonthlySales = ReportDataSource.GetMonthlySales(fromDate, toDate);

                // FILTER OUT RESULTS FOR GRID DISPLAY
                for (int i = (_MonthlySales.Count - 1); i >= 0; i--)
                {
                    if (_MonthlySales[i].OrderCount == 0)
                    {
                        _MonthlySales.RemoveAt(i);
                    }
                }
            }

            options.ExportData = _MonthlySales;
            options.FileTag    = string.Format("SALES_OVER_TIME(from_{0}_to_{1})", fromDate.ToShortDateString(), toDate.ToShortDateString());
            exportManager.BeginExport(options);
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.AppendHeader("pragma", "no-store,no-cache");
            Response.AppendHeader("cache-control", "no-cache, no-store,must-revalidate, max-age=-1");
            Response.AppendHeader("expires", "-1");

            //Initialize the chart data
            DateTime localNow = LocaleHelper.LocalNow;
            DateTime fromDate = new DateTime(localNow.Year, localNow.Month, 1);
            DateTime toDate   = new DateTime(localNow.Year, localNow.Month, DateTime.DaysInMonth(localNow.Year, localNow.Month));

            CurrentMonthSales.Sales = initMonthChart(CurrentMonthChart, fromDate, toDate);

            fromDate             = fromDate.AddMonths(-1);
            toDate               = new DateTime(fromDate.Year, fromDate.Month, DateTime.DaysInMonth(localNow.Year, fromDate.Month));
            LastMonthSales.Sales = initMonthChart(LastMonthChart, fromDate, toDate);

            initPastMonthsChart(PastThreeMonthChart, 3);
            initPastMonthsChart(PastSixMonthChart, 6);
            initPastMonthsChart(PastTwelveMonthChart, 12);

            PastThreeMonthSales.Sales = ReportDataSource.GetMonthlySales(localNow.AddMonths(-3), localNow);
            PastSixMonthSales.Sales   = ReportDataSource.GetMonthlySales(localNow.AddMonths(-6), localNow);
            Past12MonthSales.Sales    = ReportDataSource.GetMonthlySales(localNow.AddMonths(-12), localNow);

            SalesOverTimePanel.Visible = true;
        }
Exemplo n.º 4
0
        private IList <SalesSummary> initMonthChart(Chart monthChart, DateTime fromDate, DateTime toDate)
        {
            string       cacheKey     = "E38012C3-C1A0-45a2-A0FF-F32D8DDE043G" + monthChart.ID;
            CacheWrapper cacheWrapper = Cache[cacheKey] as CacheWrapper;

            if (cacheWrapper == null)
            {
                //LOAD DATA
                IList <SalesSummary> sales = ReportDataSource.GetMonthlySales(fromDate, toDate);

                //BUILD BAR CHART
                monthChart.Series["Sales"].Points.Clear();
                for (int i = 0; i < sales.Count; i++)
                {
                    int       roundedTotal = (int)Math.Round(sales[i].GrandTotal, 0);
                    DataPoint point        = new DataPoint(monthChart.Series["Sales"]);
                    point.SetValueXY(sales[i].StartDate.ToString("MMM d"), new object[] { roundedTotal });
                    monthChart.Series["Sales"].Points.Add(point);
                }
                monthChart.DataBind();

                //CACHE THE DATA
                cacheWrapper = new CacheWrapper(sales);
                Cache.Remove(cacheKey);
                Cache.Add(cacheKey, cacheWrapper, null, LocaleHelper.LocalNow.AddMinutes(5).AddSeconds(-1), TimeSpan.Zero, System.Web.Caching.CacheItemPriority.High, null);
                return(sales);
            }
            else
            {
                //USE CACHED VALUES
                IList <SalesSummary> salesByDay = (IList <SalesSummary>)cacheWrapper.CacheValue;
                monthChart.Series["Sales"].Points.Clear();
                for (int i = 0; i < salesByDay.Count; i++)
                {
                    int       roundedTotal = (int)Math.Round(salesByDay[i].GrandTotal, 0);
                    DataPoint point        = new DataPoint(monthChart.Series["Sales"]);
                    point.SetValueXY(salesByDay[i].StartDate.ToString("MMM d"), new object[] { roundedTotal });
                    monthChart.Series["Sales"].Points.Add(point);
                }
                monthChart.DataBind();
                return(salesByDay);
            }
        }