Пример #1
0
        private void ShowCheckinsButton_Click(object sender, EventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form is ReviewForm)
                {
                    form.Hide();
                }
            }

            // Launch check-in graph UI

            CheckInChart.MainWindow cic = new CheckInChart.MainWindow(currBusId);
            cic.Show();

            // create a new datagridview to pass to the new form that will open to show the reviews.
            DataGridView CheckinsGrid = new DataGridView();

            CheckinsGrid.RowHeadersVisible = false;

            // Build the columns and headers for the new form
            foreach (var column in checkinsCols)
            {
                // Create the column headers for the data grid view.
                DataGridViewTextBoxColumn newColumn = new DataGridViewTextBoxColumn();
                newColumn.HeaderText = column;

                newColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; //make the size fo the columns be only the size of the data inside them

                CheckinsGrid.Columns.Add(newColumn);
            }

            //Query the database for the reviews of the current business
            List <List <string> > checkins = queryEngine.GetCheckins(currBusId, "day, to_char(time, 'HH12:MI AM'), count");

            checkins.RemoveAt(0); //we dont need the headers so we can remove them.

            // Add all the returned reviews to the new datagrid
            foreach (List <string> checkin in checkins)
            {
                CheckinsGrid.Rows.Add(checkin[0], checkin[1], checkin[2]);
            }

            // Make the new form open up and show it to the user.
            ReviewForm checkinsWindow = new ReviewForm(CheckinsGrid);

            checkinsWindow.Show();

            int width = 0; //find the width of all the columns and makes that the size of the window

            foreach (DataGridViewColumn column in CheckinsGrid.Columns)
            {
                if (column.Visible == true)
                {
                    width += column.Width;
                }
            }
            width += 40;
            checkinsWindow.Size = new System.Drawing.Size(width, checkinsWindow.Size.Height);
        }
Пример #2
0
        /**
         * ! Business Page
         * ? Business Info Buttons Functionality
         */

        /// <summary>
        /// When the user clicks the "Show Reviews" Button, it will open a new form displaying all the reviews for the selected business.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ShowReviewsButton_Click(object sender, EventArgs e)
        {
            foreach (Form form in Application.OpenForms)
            {
                if (form is ReviewForm)
                {
                    form.Hide();
                }
            }

            // create a new datagridview to pass to the new form that will open to show the reviews.
            DataGridView ReviewGrid = new DataGridView();

            ReviewGrid.RowHeadersVisible = false;

            // Build the columns and headers for the new form
            foreach (var column in reviewCols)   // Create the column headers for the data grid view.
            {
                DataGridViewTextBoxColumn newColumn = new DataGridViewTextBoxColumn();
                newColumn.HeaderText = column;

                // Set autosize mode
                if (column == "text")
                {
                    newColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                }
                else
                {
                    newColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
                }

                ReviewGrid.Columns.Add(newColumn);  //add the column to the datagridview
            }

            //Query the database for the reviews of the current business
            List <List <string> > reviews = queryEngine.GetReviews(currBusId, "review_stars, date, text, useful_vote, funny_vote, cool_vote");

            reviews.RemoveAt(0);  //we dont need the headers so we can remove them.

            // Add all the returned reviews to the new datagrid
            foreach (List <string> review in reviews)
            {
                ReviewGrid.Rows.Add(review[0], review[1], review[2], review[3], review[4], review[5]);
            }

            // Make the new form open up and show it to the user.
            ReviewForm reviewWindow = new ReviewForm(ReviewGrid);

            reviewWindow.Show();
        }
Пример #3
0
        private void ShowReviewsButton_Click(object sender, EventArgs e)
        {
            ReviewForm reviewWindow = new ReviewForm(currBusId);

            reviewWindow.Show();
        }