示例#1
0
        /// <summary>
        /// Function assigned to generate requested sales graph given the chosen congfigurations
        /// </summary>
        private void GenerateSalesBarChart()
        {
            // Counters
            int     numberOfSales = 0;
            Decimal total         = 0;

            if (usernamesSalesListBox.SelectedItem.ToString() == "ALL") // the user requests to see generated sales made by all registered users
            {
                totalSalesChart.Series.Clear();                         // clearing the sales chart of previous information
                totalSalesChart.Visible = true;                         // Showing the proper graph to display sales made by all users
                userSalesChart.Visible  = false;                        // Hiding graph designated to view the sales of a single user

                // Requesting the neccessary information to generate the graphs
                List <Sale> salesBar = GraphInformationManager.ConsultSalesBarChartInformation(newestSalesBarChartDateTimePicker.Value, oldestSalesBarChartDateTimePicker.Value);

                if (salesBar.Count > 0) // assuring at least one graph point exists
                {
                    // Establishing series name with the time interval specifications
                    String seriesName = "Sales between " + oldestSalesBarChartDateTimePicker.Value.ToShortDateString() + " and " + newestSalesBarChartDateTimePicker.Value.ToShortDateString();

                    // Configuring the series
                    totalSalesChart.Series.Add(seriesName);                                                      // specifying the series
                    totalSalesChart.Series[seriesName].ChartType                       = SeriesChartType.Column; // specifying what type of graph is desired
                    totalSalesChart.ChartAreas["BarChartArea"].AxisX.Title             = "Username";             // Naming the X-axis
                    totalSalesChart.ChartAreas["BarChartArea"].AxisY.Title             = "Sales Amount ($)";     // Naming the Y-axis
                    totalSalesChart.ChartAreas["BarChartArea"].AxisY.LabelStyle.Format = "$0.00";                // Formating the scale of the Y-axis
                    totalSalesChart.ChartAreas["BarChartArea"].AxisY.Minimum           = 0;                      // Establishing the Y-axis minimum

                    // Establishing the data points for the graph
                    foreach (Sale bar in salesBar)
                    {
                        numberOfSales += bar.NumberOfSales; // counting the number of sales preformed

                        // Adding new data point to graph
                        int position = totalSalesChart.Series[seriesName].Points.AddXY(bar.Username, bar.Total); // X: p.siclait, Y: $1000.00
                        // Adding a label to provide more accuracy and readability of the graph
                        totalSalesChart.Series[seriesName].Points[position].Label = bar.NumberOfSales + " sale(s) for " + bar.Total.ToString("$0.00");

                        total += bar.Total; // adding the total amount of dollars generated
                    }
                }
            }
            else // User has chosen to view the sales genenerated by one specific user
            {
                userSalesChart.Series.Clear(); // clearing the username's sales chart of previous information
                userSalesChart.Visible  = true;  // Showing graph designated to view the sales of a single user
                totalSalesChart.Visible = false; // Hiding the proper graph to display sales made by all users

                // Requesting the neccessary information to generate the graphs
                List <Sale> salesBar = GraphInformationManager.ConsultUserSalesBarChartInformation(usernamesSalesListBox.SelectedItem.ToString(), newestSalesBarChartDateTimePicker.Value, oldestSalesBarChartDateTimePicker.Value);

                if (salesBar.Count > 0) // assuring at least one graph point exists
                {
                    // Configuring the series
                    userSalesChart.Series.Add(usernamesSalesListBox.SelectedItem.ToString());                                // specifying the series
                    userSalesChart.Series[usernamesSalesListBox.SelectedItem.ToString()].ChartType = SeriesChartType.Column; // specifying what type of graph is desired
                    userSalesChart.ChartAreas["BarChartArea"].AxisX.Title             = "Transaction Dates";                 // Naming the X-axis
                    userSalesChart.ChartAreas["BarChartArea"].AxisY.Title             = "Sales Amount ($)";                  // Naming the Y-axis
                    userSalesChart.ChartAreas["BarChartArea"].AxisY.LabelStyle.Format = "$0.00";                             // Formating the scale of the Y-axis
                    userSalesChart.ChartAreas["BarChartArea"].AxisY.Minimum           = 0;                                   // Establishing the Y-axis minimum

                    // Establishing the data points for the graph
                    foreach (Sale bar in salesBar)
                    {
                        numberOfSales += bar.NumberOfSales; // counting the number of sales preformed

                        // Adding new data point to graph
                        int position = userSalesChart.Series[usernamesSalesListBox.SelectedItem.ToString()].Points.AddXY(bar.TransactionDate, bar.Total); // X: 09-01-2020, Y:$45000.00
                        // Adding a label to provide more accuracy and readability of the graph
                        userSalesChart.Series[usernamesSalesListBox.SelectedItem.ToString()].Points[position].Label = bar.NumberOfSales + " sale(s) for " + bar.Total.ToString("$0.00");

                        total += bar.Total; // adding the total amount of dollars generated
                    }
                }
            }

            // Updating supplementary summary information
            numberSalesLabel.Text = numberSalesLabel.Text.Split(':')[0] + ": " + numberOfSales;
            totalSalesLabel.Text  = totalSalesLabel.Text.Split('$')[0] + "$" + total.ToString("0.00");
        }
示例#2
0
        /// <summary>
        /// Function assigned to generate requested timesheet graph given the chosen congfigurations
        /// </summary>
        private void GenerateTimesheetBubbleChart()
        {
            timesheetChart.Series.Clear(); // clearig the bubble chart of any previous information

            // Counters
            int totalSessions   = 0;
            int shownSessions   = 0;
            int missingSessions = 0;

            if (usernamesTimesheetListBox.SelectedItem.ToString() == "ALL")  // the user requests to see generated timesheets of all registered users
            {
                foreach (String username in usernamesTimesheetListBox.Items) // generating a timesheet for each reagistered user
                {
                    if (username != "ALL")                                   // ignoring the all option given that this is not a recognized username
                    {
                        // Requesting a timesheet for the designated username
                        List <BubblePoint> bubblePoints = GraphInformationManager.ConsultUserTimesheetBubbleChartInformation(username, newestBubbleDateTimePicker.Value, CalculateOldestDate());

                        if (bubblePoints.Count > 0) // ensuring at least one graph point exists
                        {
                            // Configuring the series
                            timesheetChart.Series.Add(username);                                                       // Creating the series
                            timesheetChart.Series[username].ChartType   = SeriesChartType.Bubble;                      // specifying what type of graph is desired
                            timesheetChart.Series[username].MarkerStyle = MarkerStyle.Circle;                          // Chosing the shape of the bubbles
                            timesheetChart.ChartAreas["BubbleChartArea"].AxisX.Title             = "Date";             // Naming the X-axis
                            timesheetChart.ChartAreas["BubbleChartArea"].AxisY.Title             = "Hours of the Day"; // Naming the Y-axis
                            timesheetChart.ChartAreas["BubbleChartArea"].AxisY.LabelStyle.Format = "00H";              // Formating the scale of the Y-axis
                            timesheetChart.ChartAreas["BubbleChartArea"].AxisY.Minimum           = 0;                  // Establishing the Y-axis minimum
                            timesheetChart.ChartAreas["BubbleChartArea"].AxisY.Maximum           = 24;                 // Establishing the Y-axis maximum

                            // Adding points
                            foreach (BubblePoint bubble in bubblePoints)
                            {
                                totalSessions++;        // counting the total amount of sessions

                                if (bubble.Minutes > 0) // generating data points only for sessions that last longer than a minute
                                {
                                    // Adding new data point to graph
                                    timesheetChart.Series[username].Points.AddXY(
                                        DateTime.Parse(bubble.LogInDate),                                                     // log in date
                                        ConvertTimeToDecimal(bubble.LogInTime.Split(':')[0], bubble.LogInTime.Split(':')[1]), // the hour at which the user was logged in (VERY INACCURATE)
                                        bubble.Seconds);                                                                      // total seconds logged in to establich each bubble's magnitude/area/size

                                    shownSessions++;                                                                          // counting all sessions at least a minute long
                                }
                                else
                                {
                                    missingSessions++; // counting all sessions less than a minute long
                                }
                            }

                            // adding invisible ancor point
                            int i = timesheetChart.Series[username].Points.AddXY(newestBubbleDateTimePicker.Value, 1, 0);
                            timesheetChart.Series[username].Points[i].Color = Color.Transparent;
                        }
                    }
                }
            }
            else // User has chosen to view the timesheet of one specific user
            {
                // Requesting a timesheet for the selected username
                List <BubblePoint> bubblePoints = GraphInformationManager.ConsultUserTimesheetBubbleChartInformation(usernamesTimesheetListBox.SelectedItem.ToString(), newestBubbleDateTimePicker.Value, CalculateOldestDate());

                if (bubblePoints.Count > 0) // assuring at least one graph point exists
                {
                    // Configuring the series
                    timesheetChart.Series.Add(usernamesTimesheetListBox.SelectedItem.ToString());                                  // Creating the series
                    timesheetChart.Series[usernamesTimesheetListBox.SelectedItem.ToString()].ChartType   = SeriesChartType.Bubble; // specifying what type of graph is desired
                    timesheetChart.Series[usernamesTimesheetListBox.SelectedItem.ToString()].MarkerStyle = MarkerStyle.Circle;     // Chosing the shape of the bubbles
                    timesheetChart.ChartAreas["BubbleChartArea"].AxisX.Title             = "Date";                                 // Naming the X-axis
                    timesheetChart.ChartAreas["BubbleChartArea"].AxisY.Title             = "Hours of the Day";                     // Naming the Y-axis
                    timesheetChart.ChartAreas["BubbleChartArea"].AxisY.LabelStyle.Format = "00H";                                  // Formating the scale of the Y-axis
                    timesheetChart.ChartAreas["BubbleChartArea"].AxisY.Minimum           = 0;                                      // Establishing the Y-axis minimum
                    timesheetChart.ChartAreas["BubbleChartArea"].AxisY.Maximum           = 24;                                     // Establishing the Y-axis maximum

                    int minimum = 25;                                                                                              // indicator to limit the individual timesheet

                    // Adding points
                    foreach (BubblePoint bubble in bubblePoints)
                    {
                        totalSessions++;        // counting the total amount of sessions

                        if (bubble.Minutes > 0) // generating data points only for sessions that last longer than a minute
                        {
                            // Adding new data point to graph
                            int position = timesheetChart.Series[usernamesTimesheetListBox.SelectedItem.ToString()].Points.AddXY(
                                DateTime.Parse(bubble.LogInDate),                                                     // log in date
                                ConvertTimeToDecimal(bubble.LogInTime.Split(':')[0], bubble.LogInTime.Split(':')[1]), // the hour at which the user was logged in (VERY INACCURATE)
                                bubble.Seconds);
                            // Adding label to improve readability of graph
                            timesheetChart.Series[usernamesTimesheetListBox.SelectedItem.ToString()].Points[position].Label = bubble.Minutes.ToString("0.####") + " min";

                            if (FormatToInt(bubble.LogInTime.Split(':')[0]) < minimum)
                            {
                                minimum = FormatToInt(bubble.LogInTime.Split(':')[0]) - 4 > 0 ? FormatToInt(bubble.LogInTime.Split(':')[0]) - 4 : 0;
                            }

                            shownSessions++; // counting all sessions at least a minute long
                        }
                        else
                        {
                            missingSessions++; // counting all sessions less than a minute long
                        }
                    }

                    // adding invisible ancor point
                    int i = timesheetChart.Series[usernamesTimesheetListBox.SelectedItem.ToString()].Points.AddXY(newestBubbleDateTimePicker.Value, minimum + 1, 0);
                    timesheetChart.Series[usernamesTimesheetListBox.SelectedItem.ToString()].Points[i].Color = Color.Transparent;

                    // Updating chart minimum
                    timesheetChart.ChartAreas["BubbleChartArea"].AxisY.Minimum = minimum;
                }
            }

            // Updating supplementary summary information for timesheet tab
            totalSessionsLabel.Text = totalSessionsLabel.Text.Split(':')[0] + ": " + totalSessions;
            shownLabel.Text         = shownLabel.Text.Split(':')[0] + ": " + shownSessions;
            missingLabel.Text       = missingLabel.Text.Split(':')[0] + ": " + missingSessions;
        }
示例#3
0
 /// <summary>
 /// Function to populate the list box with the username of all registered users for the sales tab
 /// </summary>
 private void PopulateUsernameSalesListBox()
 {
     usernamesSalesListBox.DataSource = GraphInformationManager.ConsultAllRegisteredUsernameInformation(searchSalesTextBox.Text);
 }