public VideoGameScreen(VideoGame selectedGame, User workingUser, bool rentable)
        {
            InitializeComponent();
            this.rentable = rentable; //Rentable tracks where the user clicked, if they can return or rent it
            this.selectedGame = selectedGame;
            this.workingUser = workingUser;
            this.Text = selectedGame.getTitle();
            titleLabel.Text = selectedGame.getTitle();
            genreLabel.Text = selectedGame.getGenre();
            consoleLabel.Text = selectedGame.getConsole();
            inventoryLabel.Text = selectedGame.getInventory().ToString();

            if (rentable)
            {
                returnButton.Enabled = false;
            }
            else
            {
                rentButton.Enabled = false;
            }
        }
Exemplo n.º 2
0
 //Called when user clicks on their "rented games" table
 private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     int index = 0;
     int clickedRow = e.RowIndex;
     foreach (DataRow outerRow in dt.Rows)
     {
         if (index == clickedRow)
         {
             sql = "SELECT * FROM Video_Games WHERE title =  '"
                 + outerRow[0].ToString()
                 + "' AND console = '"
                 + outerRow[1].ToString()
                 + "';";
             DataTable tempDT = managementSystem.fillDataTable(sql);
             foreach (DataRow row in tempDT.Rows)
             {
                 VideoGame selectedGame = new VideoGame(row[0].ToString(), row[1].ToString(), row[2].ToString(), row[3].ToString(), int.Parse(row[4].ToString()));
                 VideoGameScreen gameScreen = new VideoGameScreen(selectedGame, workingUser, false);
                 gameScreen.Show();
             }
         }
         index++;
     }
 }
 //Called when a user clicks the gird
 private void dataGridView1_CellContentDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     int index = 0;
     int clickedRow = e.RowIndex; //The event only saves the row index
     foreach (DataRow row in dt.Rows)
     {
         //Match the index with the clicked index
         if (index == clickedRow)
         {
             //Create a new videogame and launch the video game screen
             VideoGame selectedGame = new VideoGame(row[0].ToString(), row[1].ToString(), row[2].ToString(), row[3].ToString(), int.Parse(row[4].ToString()));
             VideoGameScreen gameScreen = new VideoGameScreen(selectedGame, workingUser, true);
             gameScreen.Show();
         }
         index++;
     }
 }