コード例 #1
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++;
     }
 }
コード例 #2
0
 //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++;
     }
 }