Пример #1
0
        private void reportForm_Load_1(object sender, EventArgs e)
        {
            CustomerReview        reviews    = new CustomerReview();
            List <CustomerReview> reviewList = reviews.List();

            TotalReviewsCountLbl.Text = reviewList.Count.ToString();
            DataTable dt = ReportsPage.ConvertToDataTable(reviews.List());

            AllReviewsTable.DataSource = dt;

            Dictionary <string, int> chartData1 = ReportsPage.chartData1(reviewList);

            foreach (KeyValuePair <string, int> entry in chartData1)
            {
                numberOfRatingChart.Series["Number of Reviews"].Points.AddXY(entry.Key, entry.Value);
            }


            Dictionary <string, double> chartData2 = ReportsPage.chartData2(reviewList);

            foreach (KeyValuePair <string, double> entry in chartData2)
            {
                AverageRating.Series["Average Rating"].Points.AddXY(entry.Key, entry.Value);
            }
        }
Пример #2
0
        private void btnSortRating_Click(object sender, EventArgs e)
        {
            CustomerReview        reviews    = new CustomerReview();
            List <CustomerReview> reviewList = reviews.List();
            DataTable             dt         = ReportsPage.ConvertToDataTable(CustomerReview.SortByDate(reviews.List()));

            AllReviewsTable.DataSource = dt;
        }
Пример #3
0
        private void viewReportBtn_Click(object sender, EventArgs e)
        {
            ReportsPage report = new ReportsPage();

            this.Hide();
            report.StartPosition = FormStartPosition.CenterParent;
            report.ShowDialog();
            report.Location = this.Location;
            this.Show();
        }
Пример #4
0
        private void btnReset_Click(object sender, EventArgs e)
        {
            CustomerReview        reviews    = new CustomerReview();
            List <CustomerReview> reviewList = reviews.List();

            TotalReviewsCountLbl.Text = reviewList.Count.ToString();
            DataTable dt = ReportsPage.ConvertToDataTable(reviews.List());

            AllReviewsTable.DataSource = dt;
        }
Пример #5
0
        public static DataTable ConvertToDataTable(List <CustomerReview> reviews)
        {
            PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(typeof(CustomerReview));
            DataTable table = new DataTable();

            foreach (PropertyDescriptor prop in properties)
            {
                if (prop.Name != "customerRatings")
                {
                    table.Columns.Add(prop.Name);
                }
                else
                {
                    List <string> criterias = ReportsPage.Criterias();
                    foreach (var criteria in criterias)
                    {
                        table.Columns.Add(criteria);
                    }
                }
            }


            if (reviews != null)
            {
                foreach (CustomerReview item in reviews)
                {
                    DataRow row = table.NewRow();
                    foreach (PropertyDescriptor prop in properties)
                    {
                        if (prop.Name != "customerRatings")
                        {
                            row[prop.Name] = prop.GetValue(item);
                        }
                        else
                        {
                            foreach (KeyValuePair <string, int> entry in item.customerRatings)
                            {
                                row[entry.Key] = entry.Value;
                            }
                        }
                    }
                    table.Rows.Add(row);
                }
            }
            return(table);
        }