Ejemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        uxPagingControl.BubbleEvent += new EventHandler(uxGrid_RefreshHandler);

        if (!MainContext.IsPostBack)
        {
            HttpBrowserCapabilities browser = Request.Browser;
            string browserName = browser.Browser;

            PopulateControls();
            RefreshGrid();

            string script = "<script language='javascript'>CreateChart(document.getElementById('" +
                            uxPeriodDrop.ClientID + "').value,document.getElementById('" + uxReportDrop.ClientID + "').value," +
                            "'null','null','" + browserName + "','true','0')</script>";
            ScriptManager.RegisterStartupScript(this, GetType(), "startScript", script, false);
        }
        if (ReportFilterUtilities.ConvertToPeriodType(uxPeriodDrop.SelectedValue) == PeriodType.Custom)
        {
            uxSetDate.Style.Add("display", "block");
        }
        else
        {
            uxSetDate.Style.Add("display", "none");
        }
    }
Ejemplo n.º 2
0
    private void RefreshGrid()
    {
        PeriodType period = ReportFilterUtilities.ConvertToPeriodType(uxPeriodGraphicDrop.SelectedValue);

        ReportFilterUtilities.GetOrderDateRange(period, out _startOrderDate, out _endOrderDate);

        decimal           revenue       = 0;
        int               sumQuantity   = 0;
        decimal           sumTax        = 0;
        decimal           sumShipping   = 0;
        SaleReportBuilder reportBuilder = new SaleReportBuilder();
        DataTable         table         = reportBuilder.GetReportData(
            period,
            _startOrderDate,
            _endOrderDate,
            StoreID
            );

        foreach (DataRow row in table.Rows)
        {
            revenue     += Convert.ToDecimal(row["Total"]);
            sumQuantity += Convert.ToInt32(row["Quantity"]);
            sumTax      += Convert.ToDecimal(row["TotalTax"]);
            sumShipping += Convert.ToDecimal(row["TotalShippingCost"]);
        }

        uxRevenueValueLabel.Text  = revenue.ToString("F", CultureInfo.InvariantCulture);
        uxQuantityValueLabel.Text = sumQuantity.ToString("F", CultureInfo.InvariantCulture);
        uxTaxValueLabel.Text      = sumTax.ToString("F", CultureInfo.InvariantCulture);
        uxShippingValueLabel.Text = sumShipping.ToString("F", CultureInfo.InvariantCulture);
    }
Ejemplo n.º 3
0
    protected void uxExportButton_Click(object sender, EventArgs e)
    {
        string             message, message1, filePhysicalPathName, fileNameLinkText, fileNameLinkURL;
        CustomerReportType customerReportType = ReportFilterUtilities.ConvertToCustomerReportType(uxReportDrop.SelectedValue);

        filePhysicalPathName = Server.MapPath("../");

        if (customerReportType == CustomerReportType.UserRegistration)
        {
            CustomerReportExporter exporter = new CustomerReportExporter();
            fileNameLinkURL = exporter.ExportCustomerReportData(
                customerReportType,
                ReportFilterUtilities.ConvertToPeriodType(uxPeriodDrop.SelectedValue),
                filePhysicalPathName,
                _startOrderDate,
                _endOrderDate,
                out message,
                out message1,
                out fileNameLinkText);
        }

        else
        {
            CustomerReportExporter exporter = new CustomerReportExporter();
            fileNameLinkURL = exporter.ExportCustomerReportData(
                ReportFilterUtilities.ConvertToCustomerReportType(uxReportDrop.SelectedValue),
                ReportFilterUtilities.ConvertToPeriodType(uxPeriodDrop.SelectedValue),
                uxNumberItemsDrop.SelectedItem.ToString(),
                filePhysicalPathName,
                _startOrderDate,
                _endOrderDate,
                out message,
                out message1,
                out fileNameLinkText);
        }

        if (String.IsNullOrEmpty(fileNameLinkURL))
        {
            uxMessage.DisplayError(message);
            uxMessage1.Visible         = false;
            uxFileNameLink.Text        = fileNameLinkText;
            uxFileNameLink.NavigateUrl = fileNameLinkURL;
        }
        else
        {
            uxMessage.DisplayMessage(message);
            uxMessage1.Visible = true;
            uxMessage1.DisplayMessageNoNewLIne(message1);
            uxFileNameLink.Text        = fileNameLinkText;
            uxFileNameLink.NavigateUrl = fileNameLinkURL;
            uxFileNameLink.Target      = "_blank";
        }

        if (uxReportDrop.SelectedItem.ToString() == "Customer Registration")
        {
            CreateChart();
        }
        setCustomDateDisplay();
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        OpenFlashChart.OpenFlashChart chart = new OpenFlashChart.OpenFlashChart();
        DateTime startOrderDate;
        DateTime endOrderDate;

        if (Period == PeriodType.Custom)
        {
            startOrderDate = Convert.ToDateTime(StartDate);
            endOrderDate   = Convert.ToDateTime(EndDate);
        }
        else
        {
            ReportFilterUtilities.GetOrderDateRange(Period, out startOrderDate, out endOrderDate);
        }

        SetUpChart(chart, startOrderDate, endOrderDate);

        double    maxRange = 0;
        DataTable table    = CreateDataAndLabel(startOrderDate, endOrderDate);

        if (table.Rows.Count < 1)
        {
            maxRange = InitialMaxYAxisRange;
        }
        else
        {
            foreach (DataRow row in table.Rows)
            {
                double val = ConvertUtilities.ToDouble(row[_value]);

                if (val > maxRange)
                {
                    maxRange = val;
                    if (val < InitialMaxYAxisRange)
                    {
                        maxRange = InitialMaxYAxisRange;
                    }
                }
            }
        }

        chart.AddElement(CreateLine(_data1));

        SetChartStyle(chart);

        SetRangeScale(chart, (int)maxRange);

        SetYLengend(chart, _yLegend);

        SetXLengend(chart, _xLegend);

        SetXAxis(chart, _label1);

        Response.Clear();
        //Response.CacheControl = "no-cache";
        Response.Write(chart.ToString());
        Response.End();
    }
Ejemplo n.º 5
0
    private void RefreshGrid()
    {
        if (!MainContext.IsPostBack)
        {
            uxPagingControl.ItemsPerPages = AdminConfig.OrderItemsPerPage;
        }
        int totalItems;

        PeriodType period = ReportFilterUtilities.ConvertToPeriodType(uxPeriodDrop.SelectedValue);

        if (period == PeriodType.Custom)
        {
            string errorMessage;
            if (VerifyCustomInput(out errorMessage))
            {
                LoadCustomInput();
            }
            else
            {
                uxMessage.DisplayError(errorMessage);
                uxMessage1.Visible = false;
                return;
            }
        }
        else
        {
            ReportFilterUtilities.GetOrderDateRange(period, out _startOrderDate, out _endOrderDate);
        }

        BestSellingReportBuilder bestSellingReportBuilder = new BestSellingReportBuilder();
        DataTable table = bestSellingReportBuilder.GetBestSellingReportData(
            GridHelper.GetFullSortText(),
            StoreContext.Culture.CultureID,
            period,
            ReportFilterUtilities.ConvertToBestSellReportType(uxReportDrop.SelectedValue),
            uxNumberItemsDrop.SelectedItem.ToString(),
            StoreContext.CurrentStore.StoreID,
            _startOrderDate,
            _endOrderDate,
            uxPagingControl.StartIndex,
            uxPagingControl.EndIndex,
            out totalItems);

        if (table.Rows.Count > 0)
        {
            uxTitleLabel.Visible = true;
            setTitle();
        }
        else
        {
            uxTitleLabel.Visible = false;
        }

        uxPagingControl.NumberOfPages = (int)Math.Ceiling((double)totalItems / uxPagingControl.ItemsPerPages);
        uxGrid.DataSource             = table;
        uxGrid.DataBind();
        setCustomDateDisplay();
    }
Ejemplo n.º 6
0
    private void RefreshGrid()
    {
        if (!MainContext.IsPostBack)
        {
            uxPagingControl.ItemsPerPages = AdminConfig.OrderItemsPerPage;
        }
        int totalItems;

        _errorFlag = false;

        PeriodType period = ReportFilterUtilities.ConvertToPeriodType(uxPeriodDrop.SelectedValue);

        if (period == PeriodType.Custom)
        {
            string errorMessage;
            if (VerifyCustomInput(out errorMessage))
            {
                LoadCustomInput();
            }
            else
            {
                uxMessage.DisplayError(errorMessage);
                uxMessage1.Visible = false;
                _errorFlag         = true;
                return;
            }
        }
        else
        {
            ReportFilterUtilities.GetOrderDateRange(period, out _startOrderDate, out _endOrderDate);
        }

        PaymentReportBuilder paymentReportBuilder = new PaymentReportBuilder();

        DataTable table = paymentReportBuilder.GetPaymentReportData(
            GridHelper.GetFullSortText(),
            period,
            _startOrderDate,
            _endOrderDate,
            uxPagingControl.StartIndex,
            uxPagingControl.EndIndex,
            out totalItems);

        if (table.Rows.Count == 0)
        {
            uxDisplayChart.Style.Add("Display", "none");
        }
        else
        {
            uxDisplayChart.Style.Add("Display", "");
        }

        uxPagingControl.NumberOfPages = (int)Math.Ceiling((double)totalItems / uxPagingControl.ItemsPerPages);
        uxGrid.DataSource             = table;
        uxGrid.DataBind();
        setCustomDateDisplay();
    }
Ejemplo n.º 7
0
    protected string GetDateTimeText(object registerPeriod)
    {
        DateTime startDate = DateTime.Now;
        DateTime endDate   = DateTime.Now;

        return(RepositoryDisplayFormatter.GetDateTimeText(
                   registerPeriod,
                   ReportFilterUtilities.ConvertToPeriodType(uxPeriodGraphicDrop.SelectedValue),
                   startDate,
                   endDate));
    }
Ejemplo n.º 8
0
 private void setCustomDateDisplay()
 {
     if (ReportFilterUtilities.ConvertToPeriodType(uxPeriodDrop.SelectedValue) == PeriodType.Custom)
     {
         uxSetDate.Style.Add("display", "block");
     }
     else
     {
         uxSetDate.Style.Add("display", "none");
     }
 }
Ejemplo n.º 9
0
    private void PopulateControls()
    {
        if (!IsAdminModifiable())
        {
            uxExportButton.Visible = false;
        }

        uxPeriodDrop.DataSource = ReportFilterUtilities.GetPeriodList();
        uxPeriodDrop.DataBind();
        uxPeriodDrop.SelectedIndex = 5;

        uxPeriodDrop.Attributes.Add("onchange", "GetCustomDate(this.value,'" + uxSetDate.ClientID + "')");
    }
Ejemplo n.º 10
0
 private void setTitle()
 {
     if (ReportFilterUtilities.ConvertToPeriodType(uxPeriodDrop.SelectedValue) == PeriodType.Custom)
     {
         uxTitleLabel.Text = uxReportDrop.SelectedItem.ToString() + " ( From " +
                             uxStartDateCalendarPopup.SelectedDate.ToShortDateString() + " To " +
                             uxEndDateCalendarPopUp.SelectedDate.ToShortDateString() + ")";
     }
     else
     {
         uxTitleLabel.Text = uxReportDrop.SelectedItem.ToString() + " (" +
                             uxPeriodDrop.SelectedItem.Text + ")";
     }
 }
Ejemplo n.º 11
0
 private void SetUpChart(OpenFlashChart.OpenFlashChart chart)
 {
     if (Period == PeriodType.Custom)
     {
         chart.Title = new Title("Shipping Report" + " ( From " + _startOrderDate.ToShortDateString()
                                 + " To " + _endOrderDate.ToShortDateString() + ")");
     }
     else
     {
         chart.Title = new Title("Shipping Report" + " (" + ReportFilterUtilities.ConvertToPeriodText(Period) + ")");
     }
     chart.Bgcolor     = "#ffffff";
     chart.Title.Style = "{font-size: 17px; font-family: Times New Roman; font-weight: bold; " +
                         " color: #9bbde0; text-align: center; wmode: transparent; padding-bottom: 30px;}";
 }
Ejemplo n.º 12
0
    protected string GetDateTimeText(object registerPeriod)
    {
        DateTime startDate = DateTime.Now;
        DateTime endDate   = DateTime.Now;

        if (ReportFilterUtilities.ConvertToPeriodType(uxPeriodDrop.SelectedValue) == PeriodType.Custom)
        {
            startDate = uxStartDateCalendarPopup.SelectedDate;
            endDate   = uxEndDateCalendarPopUp.SelectedDate;
        }
        return(RepositoryDisplayFormatter.GetDateTimeText(
                   registerPeriod,
                   ReportFilterUtilities.ConvertToPeriodType(uxPeriodDrop.SelectedValue),
                   startDate,
                   endDate));
    }
Ejemplo n.º 13
0
 private void SetUpChart(OpenFlashChart.OpenFlashChart chart, DateTime startOrderDate, DateTime endOrderDate)
 {
     if (Period == PeriodType.Custom)
     {
         chart.Title = new Title(ReportFilterUtilities.ConvertToCustomerReportText(CustomerReport) +
                                 " ( From " + startOrderDate.ToShortDateString()
                                 + " To " + endOrderDate.ToShortDateString() + ")");
     }
     else
     {
         chart.Title = new Title(ReportFilterUtilities.ConvertToCustomerReportText(CustomerReport) +
                                 " (" + ReportFilterUtilities.ConvertToPeriodText(Period) + ")");
     }
     _yLegend = "Register";
     _value   = "RegisterCustomer";
 }
Ejemplo n.º 14
0
    private void RefreshGrid()
    {
        if (!MainContext.IsPostBack)
        {
            uxPagingControl.ItemsPerPages = AdminConfig.OrderItemsPerPage;
        }

        int totalItems;

        _errorFlag = false;

        PeriodType period = ReportFilterUtilities.ConvertToPeriodType(uxPeriodDrop.SelectedValue);

        ReportFilterUtilities.GetOrderDateRange(period, out _startOrderDate, out _endOrderDate);

        SaleReportBuilder reportBuilder = new SaleReportBuilder();
        DataTable         table         = reportBuilder.GetReportData(
            GridHelper.GetFullSortText(),
            period,
            _startOrderDate,
            _endOrderDate,
            uxPagingControl.StartIndex,
            uxPagingControl.EndIndex,
            StoreID,
            out totalItems);

        uxPagingControl.NumberOfPages = (int)Math.Ceiling((double)totalItems / uxPagingControl.ItemsPerPages);
        uxGrid.DataSource             = table;
        uxGrid.DataBind();

        decimal revenue     = 0;
        int     sumQuantity = 0;
        decimal sumTax      = 0;
        decimal sumShipping = 0;

        foreach (DataRow row in table.Rows)
        {
            revenue     += Convert.ToDecimal(row["Total"]);
            sumQuantity += Convert.ToInt32(row["Quantity"]);
            sumTax      += Convert.ToDecimal(row["TotalTax"]);
            sumShipping += Convert.ToDecimal(row["TotalShippingCost"]);
        }
        uxRevenueValueLabel.Text  = revenue.ToString("F", CultureInfo.InvariantCulture);
        uxQuantityValueLabel.Text = sumQuantity.ToString("F", CultureInfo.InvariantCulture);
        uxTaxValueLabel.Text      = sumTax.ToString("F", CultureInfo.InvariantCulture);
        uxShippingValueLabel.Text = sumShipping.ToString("F", CultureInfo.InvariantCulture);
    }
Ejemplo n.º 15
0
    private void SetUpChart(OpenFlashChart.OpenFlashChart chart, DateTime startOrderDate, DateTime endOrderDate)
    {
        if (IsDisplayTitle == "true")
        {
            if (Period == PeriodType.Custom)
            {
                chart.Title = new Title(ReportFilterUtilities.ConvertToSaleReportText(SaleReport) +
                                        " ( From " + startOrderDate.ToShortDateString() + " To " +
                                        endOrderDate.ToShortDateString() + ")");
            }
            else
            {
                chart.Title = new Title(ReportFilterUtilities.ConvertToSaleReportText(SaleReport) +
                                        " (" + ReportFilterUtilities.ConvertToPeriodText(Period) + ")");
            }
        }
        else
        {
            chart.Title = new Title("");
        }

        if (SaleReport == SaleReportType.OrderTotals)
        {
            _yLegend = "Amount (" + CurrencyUtilities.BaseCurrencySymbol + ")";
            _value   = "Total";
        }
        else if (SaleReport == SaleReportType.AverageOrderTotals)
        {
            _yLegend = "Amount (" + CurrencyUtilities.BaseCurrencySymbol + ")";
            _value   = "Average";
        }
        else if (SaleReport == SaleReportType.NumberOfOrder)
        {
            _yLegend = "Orders";
            _value   = "NumberOfOrder";
        }
        else if (SaleReport == SaleReportType.NumberOfItemsSold)
        {
            _yLegend = "Items";
            _value   = "Quantity";
        }
        else if (SaleReport == SaleReportType.AverageItemPerOrder)
        {
            _yLegend = "Items";
            _value   = "AvgQuantity";
        }
    }
Ejemplo n.º 16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        OpenFlashChart.OpenFlashChart chart = new OpenFlashChart.OpenFlashChart();
        OpenFlashChart.Pie            pie   = new OpenFlashChart.Pie();

        if (Period == PeriodType.Custom)
        {
            _startOrderDate = Convert.ToDateTime(StartDate);
            _endOrderDate   = Convert.ToDateTime(EndDate);
        }
        else
        {
            ReportFilterUtilities.GetOrderDateRange(Period, out _startOrderDate, out _endOrderDate);
        }

        ShippingReportBuilder shippingReportBuilder = new ShippingReportBuilder();
        DataTable             table = shippingReportBuilder.GetShippingReportData(
            Period,
            _startOrderDate,
            _endOrderDate);

        for (int i = 0; i < table.Rows.Count; i++)
        {
            string shippingMethod;
            if (String.IsNullOrEmpty(table.Rows[i]["ShippingMethod"].ToString()))
            {
                shippingMethod = "Non-shipping Order";
            }
            else
            {
                shippingMethod = table.Rows[i]["ShippingMethod"].ToString();
            }
            _values.Add(new PieValue(Convert.ToDouble(table.Rows[i]["SumShippingMethod"]), shippingMethod));
        }

        SetUpChart(chart);

        SetUpPie(pie);

        chart.AddElement(pie);

        Response.Clear();
        //Response.CacheControl = "no-cache";
        Response.Write(chart.ToString());
        Response.End();
    }
Ejemplo n.º 17
0
    protected void Page_Load(object sender, EventArgs e)
    {
        uxPagingControl.BubbleEvent += new EventHandler(uxGrid_RefreshHandler);

        if (!MainContext.IsPostBack)
        {
            PopulateControls();
            RefreshGrid();
        }
        if (ReportFilterUtilities.ConvertToPeriodType(uxPeriodDrop.SelectedValue) == PeriodType.Custom)
        {
            uxSetDate.Style.Add("display", "block");
        }
        else
        {
            uxSetDate.Style.Add("display", "none");
        }
    }
Ejemplo n.º 18
0
    private void setCustomDateDisplay()
    {
        if (ReportFilterUtilities.ConvertToPeriodType(uxPeriodDrop.SelectedValue) == PeriodType.Custom)
        {
            uxSetDate.Style.Add("display", "block");
        }
        else
        {
            uxSetDate.Style.Add("display", "none");
        }

        if (ReportFilterUtilities.ConvertToCustomerReportType(uxReportDrop.SelectedValue) != CustomerReportType.UserRegistration)
        {
            uxSetItems.Style.Add("display", "block");
        }
        else
        {
            uxSetItems.Style.Add("display", "none");
        }
    }
Ejemplo n.º 19
0
    protected void uxExportButton_Click(object sender, EventArgs e)
    {
        string message, message1, filePhysicalPathName, fileNameLinkText, fileNameLinkURL;

        filePhysicalPathName = Server.MapPath("../");

        BestSellerReportExporter exporter = new BestSellerReportExporter(
            CurrencyUtilities.BaseCurrencySymbol, StoreContext.Culture.CultureID);

        fileNameLinkURL = exporter.ExportBestSellerReportData(
            ReportFilterUtilities.ConvertToBestSellReportType(uxReportDrop.SelectedValue),
            ReportFilterUtilities.ConvertToPeriodType(uxPeriodDrop.SelectedValue),
            uxNumberItemsDrop.SelectedItem.ToString(),
            filePhysicalPathName,
            StoreContext.CurrentStore.StoreID,
            _startOrderDate,
            _endOrderDate,
            out message,
            out message1,
            out fileNameLinkText
            );

        if (String.IsNullOrEmpty(fileNameLinkURL))
        {
            uxMessage.DisplayError(message);
            uxMessage1.Visible         = false;
            uxFileNameLink.Text        = fileNameLinkText;
            uxFileNameLink.NavigateUrl = fileNameLinkURL;
        }
        else
        {
            uxMessage.DisplayMessage(message);
            uxMessage1.Visible = true;
            uxMessage1.DisplayMessageNoNewLIne(message1);
            uxFileNameLink.Text        = fileNameLinkText;
            uxFileNameLink.NavigateUrl = fileNameLinkURL;
            uxFileNameLink.Target      = "_blank";
        }

        setCustomDateDisplay();
    }
Ejemplo n.º 20
0
    protected void uxExportButton_Click(object sender, EventArgs e)
    {
        string message, message1, filePhysicalPathName, fileNameLinkText, fileNameLinkURL;

        filePhysicalPathName = Server.MapPath("../");

        SaleReportExporter exporter = new SaleReportExporter(CurrencyUtilities.BaseCurrencySymbol);

        fileNameLinkURL = exporter.ExportSellReportData(
            ReportFilterUtilities.ConvertToPeriodType(uxPeriodDrop.SelectedValue),
            filePhysicalPathName,
            _startOrderDate,
            _endOrderDate,
            "0",
            out message,
            out message1,
            out fileNameLinkText
            );

        if (String.IsNullOrEmpty(fileNameLinkURL))
        {
            uxMessage.DisplayError(message);
            uxMessage1.Visible         = false;
            uxFileNameLink.Text        = fileNameLinkText;
            uxFileNameLink.NavigateUrl = fileNameLinkURL;
        }
        else
        {
            uxMessage.DisplayMessage(message);
            uxMessage1.Visible = true;
            uxMessage1.DisplayMessageNoNewLIne(message1);
            uxFileNameLink.Text        = fileNameLinkText;
            uxFileNameLink.NavigateUrl = fileNameLinkURL;
            uxFileNameLink.Target      = "_blank";
        }
        RefreshGrid();
        CreateChart();
        setCustomDateDisplay();
    }
Ejemplo n.º 21
0
    private void CreateChart()
    {
        HttpBrowserCapabilities browser = Request.Browser;
        string browserName = browser.Browser;

        if (ReportFilterUtilities.ConvertToPeriodType(uxPeriodDrop.SelectedValue) == PeriodType.Custom)
        {
            string script = "<script language='javascript'>CreateCustomerChart(document.getElementById('" +
                            uxPeriodDrop.ClientID + "').value,document.getElementById('" + uxReportDrop.ClientID + "').value, '" +
                            _startOrderDate.ToShortDateString() + "','" +
                            _endOrderDate.ToShortDateString() + "','" +
                            browserName +
                            "')</script>";
            ScriptManager.RegisterStartupScript(this, GetType(), "startScript", script, false);
        }
        else
        {
            string script = "<script language='javascript'>CreateCustomerChart(document.getElementById('" +
                            uxPeriodDrop.ClientID + "').value,document.getElementById('" + uxReportDrop.ClientID + "').value, " +
                            "'null','null','" + browserName + "')</script>";
            ScriptManager.RegisterStartupScript(this, GetType(), "startScript", script, false);
        }
    }
Ejemplo n.º 22
0
    private DataTable CreateDataAndLabel(DateTime startOrderDate, DateTime endOrderDate)
    {
        DateTime              day;
        int                   numDay;
        DataTable             table = new DataTable();
        CustomerReportBuilder customerReportBuilder = new CustomerReportBuilder();

        if (Period == PeriodType.LastMonth)
        {
            day    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(-1);
            numDay = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddDays(-1).Day;
            table  = customerReportBuilder.GetCustomerReport(startOrderDate, endOrderDate);
            CreateMonthData(table, day, numDay);
        }
        else if (Period == PeriodType.Last30Days)
        {
            day    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(-30);
            numDay = 30;
            table  = customerReportBuilder.GetCustomerReport(startOrderDate, endOrderDate);
            CreateMonthData(table, day, numDay);
        }
        else if (Period == PeriodType.Last7Days)
        {
            day    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day).AddDays(-7);
            numDay = 7;
            table  = customerReportBuilder.GetCustomerReport(startOrderDate, endOrderDate);
            CreateMonthData(table, day, numDay);
        }
        else if (Period == PeriodType.Today)
        {
            day   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
            table = customerReportBuilder.GetOneDayCustomerReport(startOrderDate, endOrderDate);
            CreateDayData(table, day);
        }
        else if (Period == PeriodType.Yesterday)
        {
            day   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0).AddDays(-1);
            table = customerReportBuilder.GetOneDayCustomerReport(startOrderDate, endOrderDate);
            CreateDayData(table, day);
        }
        else if (Period == PeriodType.Last24Hours)
        {
            day   = DateTime.Now.AddHours(-23);
            table = customerReportBuilder.Get24HoursCustomerReport(startOrderDate, endOrderDate);
            CreateDayData(table, day);
        }
        else if (Period == PeriodType.ThisMonth)
        {
            day    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            numDay = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddSeconds(-1).Day;
            table  = customerReportBuilder.GetCustomerReport(startOrderDate, endOrderDate);
            CreateMonthData(table, day, numDay);
        }
        else if (Period == PeriodType.ThisYear)
        {
            day = new DateTime(DateTime.Now.Year, 1, 1);
            int numMonth = 12;
            table = customerReportBuilder.GetYearCustomerReport(startOrderDate, endOrderDate);
            CreateYearData(table, day, numMonth);
        }
        else if (Period == PeriodType.Last3Years)
        {
            day = new DateTime(DateTime.Now.Year, 1, 1).AddYears(-2);
            int numMonth = 36;
            table = customerReportBuilder.GetYearCustomerReport(startOrderDate, endOrderDate);
            CreateYearData(table, day, numMonth);
        }
        else if (Period == PeriodType.Custom)
        {
            PeriodType customPeriod = ReportFilterUtilities.ResolveCustomPeriodType(startOrderDate, endOrderDate);
            if (customPeriod == PeriodType.ThisYear)
            {
                day = new DateTime(startOrderDate.Year, startOrderDate.Month, startOrderDate.Day);
                int yearDiff  = endOrderDate.Year - startOrderDate.Year;
                int monthDiff = endOrderDate.Month - startOrderDate.Month;
                yearDiff = yearDiff * 12;
                int numMonth = yearDiff + monthDiff;
                table = customerReportBuilder.GetYearCustomerReport(startOrderDate, endOrderDate);
                CreateYearData(table, day, numMonth + 1);
            }
            else if (customPeriod == PeriodType.Today)
            {
                table = customerReportBuilder.GetOneDayCustomerReport(startOrderDate, endOrderDate);
                CreateDayData(table, startOrderDate);
            }
            else
            {
                TimeSpan dateDifference = endOrderDate.Subtract(startOrderDate);
                int      days           = dateDifference.Days;
                table = customerReportBuilder.GetCustomerReport(startOrderDate, endOrderDate);
                CreateMonthData(table, startOrderDate, days + 1);
            }
        }
        return(table);
    }
Ejemplo n.º 23
0
    private void RefreshGrid()
    {
        if (!MainContext.IsPostBack)
        {
            uxPagingControl.ItemsPerPages = AdminConfig.OrderItemsPerPage;
        }
        int totalItems;

        _errorFlag = false;

        PeriodType         period             = ReportFilterUtilities.ConvertToPeriodType(uxPeriodDrop.SelectedValue);
        CustomerReportType customerReportType = ReportFilterUtilities.ConvertToCustomerReportType(uxReportDrop.SelectedValue);

        if (period == PeriodType.Custom)
        {
            string errorMessage;
            if (VerifyCustomInput(out errorMessage))
            {
                LoadCustomInput();
            }
            else
            {
                uxMessage.DisplayError(errorMessage);
                uxMessage1.Visible = false;
                _errorFlag         = true;
                return;
            }
        }
        else
        {
            ReportFilterUtilities.GetOrderDateRange(period, out _startOrderDate, out _endOrderDate);
        }


        CustomerReportBuilder customerReportBuilder = new CustomerReportBuilder();

        if (customerReportType != CustomerReportType.UserRegistration)
        {
            _table = customerReportBuilder.GetTopCustomerReportData(
                GridHelper1.GetFullSortText(),
                period,
                customerReportType,
                uxNumberItemsDrop.SelectedItem.ToString(),
                _startOrderDate,
                _endOrderDate,
                uxPagingControl.StartIndex,
                uxPagingControl.EndIndex,
                out totalItems);

            uxTopCustomerGrid.DataSource = _table;
            uxTopCustomerGrid.DataBind();
            uxTopCustomerGrid.Visible = true;
            uxGrid.Visible            = false;
            uxPadding.Visible         = false;

            if (_table.Rows.Count > 0)
            {
                uxTitleLabel.Visible = true;
                setTitle();
            }
            else
            {
                uxTitleLabel.Visible = false;
            }
        }
        else
        {
            _table = customerReportBuilder.GetCustomerReportData(
                GridHelper.GetFullSortText(),
                period,
                _startOrderDate,
                _endOrderDate,
                uxPagingControl.StartIndex,
                uxPagingControl.EndIndex,
                out totalItems);

            uxGrid.DataSource = _table;
            uxGrid.DataBind();
            uxGrid.Visible            = true;
            uxTopCustomerGrid.Visible = false;
            uxPadding.Visible         = true;
            uxTitleLabel.Visible      = false;
        }

        uxPagingControl.NumberOfPages = (int)Math.Ceiling((double)totalItems / uxPagingControl.ItemsPerPages);
        setCustomDateDisplay();
    }