Ejemplo n.º 1
0
        private void TopNMovies_Click(object sender, EventArgs e)
        {
            filename = this.txtFilename.Text;
            string N = this.topNtxt1.Text;

            if (!fileExists(filename))
            {
                return;
            }
            if (!connectionTest(filename))
            {
                return;
            }

            BusinessTier.Business biztier = new BusinessTier.Business(filename);

            var TopNList = biztier.GetTopMoviesByAvgRating(Convert.ToInt32(N));

            SubForm frm = new SubForm();

            frm.label_header.Text = "Top Movies by Average Rating";

            string line;

            foreach (var data in TopNList)
            {
                var avg = biztier.GetMovieDetail(data.MovieID);
                line = String.Format("{0}: {1}", data.MovieName, avg.AvgRating);
                frm.listBox1.Items.Add(line);
            }

            frm.ShowDialog();
        }
Ejemplo n.º 2
0
        private void EachRate_Click(object sender, EventArgs e)
        {
            filename = this.txtFilename.Text;
            if (!fileExists(filename))
            {
                return;
            }
            if (!connectionTest(filename))
            {
                return;
            }
            if (this.ListDisplay.SelectedIndex < 0)
            {
                MessageBox.Show("Please select a movie...");
                return;
            }

            BusinessTier.Business biztier = new BusinessTier.Business(filename);

            int movieID = Convert.ToInt32(this.MovieIdBox.Text);

            var movieData = biztier.GetMovieDetail(movieID);

            if (movieData == null)
            {
                MessageBox.Show("Invalid movie ID!!"); return;
            }

            var movieReview = movieData.Reviews;

            int[] eachRating = { 0, 0, 0, 0, 0 };
            int   totalCount = 0;

            foreach (var data in movieReview)
            {
                eachRating[data.Rating - 1]++;
            }

            Array.Reverse(eachRating);

            SubForm frm = new SubForm();

            frm.label_header.Text = string.Format("Each Rating for \"{0}\"", movieData.movie.MovieName);

            frm.listBox1.Items.Add(movieData.movie.MovieName);
            frm.listBox1.Items.Add(" ");

            int num = 5;

            foreach (int count in eachRating)
            {
                totalCount += count;
                frm.listBox1.Items.Add(String.Format("{0}: {1}", num--, Convert.ToString(count)));
            }

            frm.listBox1.Items.Add(" ");
            frm.listBox1.Items.Add(String.Format("Total: {0}", totalCount.ToString()));

            frm.ShowDialog();
        }
Ejemplo n.º 3
0
        private void GetUserReview_Click(object sender, EventArgs e)
        {
            filename = this.txtFilename.Text;
            if (!fileExists(filename))
            {
                return;
            }
            if (!connectionTest(filename))
            {
                return;
            }
            if (this.ListDisplay2.SelectedIndex < 0)
            {
                MessageBox.Show("Please select a user...");
                return;
            }

            string userId = this.userIdBox.Text;

            BusinessTier.Business biztier = new BusinessTier.Business(filename);

            var userDataList = biztier.GetUserDetail(Convert.ToInt32(userId));

            if (userDataList == null)
            {
                MessageBox.Show("Invalid User ID!!"); return;
            }

            string userName;

            if (userDataList.user.UserName.IndexOf(userDataList.user.UserID.ToString()) != -1)
            {
                userName = "******";
            }
            else
            {
                userName = userDataList.user.UserName;
            }

            SubForm frm = new SubForm();

            frm.label_header.Text = String.Format("Reviews by \"{0}\"", userName);

            string movieName;
            int    rate;
            string line;

            foreach (var review in userDataList.Reviews)
            {
                movieName = biztier.GetMovie(review.MovieID).MovieName;
                rate      = review.Rating;

                line = String.Format("{0} : {1}", movieName, rate);

                frm.listBox1.Items.Add(line);
            }

            frm.ShowDialog();
        }
Ejemplo n.º 4
0
        private void GetMovieReview_Click(object sender, EventArgs e)
        {
            filename = this.txtFilename.Text;
            if (!fileExists(filename))
            {
                return;
            }
            if (!connectionTest(filename))
            {
                return;
            }
            if (this.ListDisplay.SelectedIndex < 0)
            {
                MessageBox.Show("Please select a movie...");
                return;
            }

            BusinessTier.Business biztier = new BusinessTier.Business(filename);

            int movieID = Convert.ToInt32(this.MovieIdBox.Text);

            var movieData = biztier.GetMovieDetail(movieID);

            if (movieData == null)
            {
                MessageBox.Show("Invalid movie ID!!"); return;
            }

            var movieReview = movieData.Reviews;

            string name = movieData.movie.MovieName;

            SubForm frm = new SubForm();

            frm.label_header.Text = String.Format("Reviews for \"{0}\"", name);

            frm.listBox1.Items.Add(name);
            frm.listBox1.Items.Add(" ");

            string line;
            string userID;
            string rate;

            foreach (var data in movieReview)
            {
                userID = data.UserID.ToString();
                rate   = data.Rating.ToString();
                line   = string.Format("{0}: {1}", userID, rate);

                frm.listBox1.Items.Add(line);
            }
            frm.listBox1.Items.Add(" ");

            frm.ShowDialog();
        }
Ejemplo n.º 5
0
        private void TopNUsers_Click(object sender, EventArgs e)
        {
            filename = this.txtFilename.Text;
            string N = this.topNtxt1.Text;

            if (!fileExists(filename))
            {
                return;
            }
            if (!connectionTest(filename))
            {
                return;
            }

            BusinessTier.Business biztier = new BusinessTier.Business(filename);

            var TopNList = biztier.GetTopUsersByNumReviews(Convert.ToInt32(N));

            SubForm frm = new SubForm();

            frm.label_header.Text = "Top Users by Number of Reviews";

            string userName;
            string line;

            foreach (var data in TopNList)
            {
                var count = biztier.GetUserDetail(data.UserID);

                if (data.UserName.IndexOf(data.UserID.ToString()) != -1)
                {
                    userName = "******";
                }
                else
                {
                    userName = data.UserName;
                }

                line = String.Format("{0}: {1}", userName, count.NumReviews);
                frm.listBox1.Items.Add(line);
            }

            frm.ShowDialog();
        }
Ejemplo n.º 6
0
        private void TopNReview_Click(object sender, EventArgs e)
        {
            filename = this.txtFilename.Text;
            if (!fileExists(filename))
            {
                return;
            }
            if (!connectionTest(filename))
            {
                return;
            }
            string N = this.topNtxt1.Text;

            BusinessTier.Business biztier = new BusinessTier.Business(filename);

            var TopNList = biztier.GetTopMoviesByNumReviews(Convert.ToInt32(N));

            SubForm frm = new SubForm();

            frm.label_header.Text = "Top Movies by Number of Reviews";

            string movieName;
            string movieCount;
            string line;

            foreach (var data in TopNList)
            {
                movieName  = data.MovieName.ToString();
                movieCount = biztier.GetMovieDetail(data.MovieID).NumReviews.ToString();

                line = string.Format("{0}: {1}", movieName, movieCount);

                frm.listBox1.Items.Add(line);
            }

            frm.ShowDialog();
        }