Exemplo n.º 1
0
        //Back button returns to GamesList
        private void backButton_Click(object sender, EventArgs e)
        {
            this.Hide();
            GamesList list = new GamesList();

            list.ShowDialog();
        }
Exemplo n.º 2
0
        private void gamesButton_Click(object sender, EventArgs e)
        {
            this.Hide();
            GamesList gamesListForm = new GamesList();

            gamesListForm.ShowDialog();
        }
Exemplo n.º 3
0
        //Edit Button brings up EditGame form. This should also send all data for selected game to the EditGame form
        private void editButton_Click(object sender, EventArgs e)
        {
            this.Hide();
            string   location = GamesList.getLocation();
            EditGame edit     = new EditGame(titleBox.Text, ratingBox.Text, statusBox.Text, genresBox.Text, reviewBox.Text, location);

            edit.ShowDialog();
        }
Exemplo n.º 4
0
        //Submit Button updates all new information in the database (even if unchanged)
        private void submitButton_Click(object sender, EventArgs e)
        {
            //Set Game information from form
            string        newTitle   = titleTextBox.Text;
            string        newRating  = ratingComboBox.Text;
            string        newStatus  = statusComboBox.Text;
            string        newGenres  = "";
            List <string> genresList = new List <string>();

            for (int i = 0; i < genresCheckedListBox.Items.Count; i++)
            {
                if (genresCheckedListBox.GetItemChecked(i))
                {
                    genresList.Add((string)genresCheckedListBox.Items[i]);
                }
            }
            for (int i = 0; i < genresList.Count; i++)
            {
                newGenres += genresList[i] + " ";
            }
            string newReview   = reviewRichTextBox.Text;
            string newLocation = locationLabel.Text;

            //Update Game
            try
            {
                string          connectionInfo = "datasource = 127.0.0.1; port = 3306; username = root; password = password";
                MySqlConnection connect        = new MySqlConnection(connectionInfo);

                string mySelectQuery = "use mydb; update games set Title = @0, Rating = @1, Status = @2, Genres = @3, Review = @4, Location = @5 where Title = '"
                                       + originalTitle + "';";

                connect.Open();
                MySqlCommand command = new MySqlCommand(mySelectQuery, connect);
                command.Parameters.AddWithValue("@0", newTitle);
                command.Parameters.AddWithValue("@1", newRating);
                command.Parameters.AddWithValue("@2", newStatus);
                command.Parameters.AddWithValue("@3", newGenres);
                command.Parameters.AddWithValue("@4", newReview);
                command.Parameters.AddWithValue("@5", newLocation);

                command.Prepare();
                command.ExecuteNonQuery();
                connect.Close();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            this.Hide();
            GamesList gamesListForm = new GamesList();

            gamesListForm.ShowDialog();
        }
Exemplo n.º 5
0
        public Game()
        {
            InitializeComponent();
            //Get and set everything
            string title    = GamesList.getTitle();
            string rating   = GamesList.getRating();
            string genres   = GamesList.getGenres();
            string status   = GamesList.getStatus();
            string review   = GamesList.getReview();
            string location = GamesList.getLocation();

            pictureBox.ImageLocation = location;
            pictureBox.SizeMode      = PictureBoxSizeMode.StretchImage;

            setTitle(title);
            setRating(rating);
            setGenres(genres);
            setStatus(status);
            setReview(review);
        }
Exemplo n.º 6
0
        //Delete Button. Removes game from database by matching title. Make sure AddGame form blocks adding games with matching titles.
        private void deleteButton_Click(object sender, EventArgs e)
        {
            //Confirm Delete
            var confirmDelete = MessageBox.Show("Are you sure you want to delete?", "Confirm Delete", MessageBoxButtons.YesNo);

            //If yes, delete from database then return to GamesList
            if (confirmDelete == DialogResult.Yes)
            {
                string title = titleBox.Text;
                try
                {
                    string          connectionInfo = "datasource = 127.0.0.1; port = 3306; username = root; password = password";
                    MySqlConnection connect        = new MySqlConnection(connectionInfo);

                    string mySelectQuery = "use mydb; delete from games where title = '" + title + "';";

                    connect.Open();
                    MySqlCommand myCommand = new MySqlCommand(mySelectQuery, connect);
                    myCommand.ExecuteNonQuery();

                    connect.Close();
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                this.Hide();
                GamesList gamesListForm = new GamesList();
                gamesListForm.ShowDialog();
            }
            //If no, do nothing
            else
            {
                //Nothing
            }
        }
Exemplo n.º 7
0
        //Submit Button adds the game to the database. Title is made to be unique in the database (Duplicate entry popup, returns to GamesList)
        private void submitButton_Click(object sender, EventArgs e)
        {
            //Set Game information from form
            string title  = titleTextBox.Text;
            string rating = ratingComboBox.Text;
            string status = statusComboBox.Text;
            string genres = "";

            //Genres starts off as a list and is converted to a single string
            List <string> genresList = new List <string>();

            //loop to add each item in the checkedListBox to genresList
            for (int i = 0; i < genresCheckedListBox.Items.Count; i++)
            {
                if (genresCheckedListBox.GetItemChecked(i))
                {
                    genresList.Add((string)genresCheckedListBox.Items[i] + " ");
                }
            }

            //loop to add each item of genresList to a single string
            for (int i = 0; i < genresList.Count; i++)
            {
                genres += genresList[i];
            }

            string review   = reviewRichTextBox.Text;
            string location = pictureLocation.Text;

            //Add Game to database
            try
            {
                string          connectionInfo = "datasource = 127.0.0.1; port = 3306; username = root; password = password";
                MySqlConnection connect        = new MySqlConnection(connectionInfo);


                string mySelectQuery = "use mydb; insert into games (Title, Rating, Status, Genres, Review, Location) Values( @0, @1, @2, @3, @4, @5);";

                connect.Open();
                MySqlCommand command = new MySqlCommand(mySelectQuery, connect);
                command.Parameters.AddWithValue("@0", title);
                command.Parameters.AddWithValue("@1", rating);
                command.Parameters.AddWithValue("@2", status);
                command.Parameters.AddWithValue("@3", genres);
                command.Parameters.AddWithValue("@4", review);
                command.Parameters.AddWithValue("@5", location);

                command.Prepare();
                command.ExecuteNonQuery();
                connect.Close();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            this.Hide();
            GamesList gamesListForm = new GamesList();

            gamesListForm.ShowDialog();
        }