예제 #1
0
        public static List <Game> SelectAllGameInfo()
        {
            List <Game> games = new List <Game>();

            string query = "SELECT * FROM games";

            OleDbCommand selectCommand = new OleDbCommand(query, conn);

            try
            {
                if (conn.State != ConnectionState.Open)
                {
                    conn.Open();
                }

                OleDbDataReader reader = selectCommand.ExecuteReader();

                while (reader.Read())
                {
                    Game game = new Game();
                    game.Id                      = Convert.ToInt32(reader["Id"]);
                    game.GameName                = Convert.ToString(reader["GameName"]);
                    game.QuestionTimeLimit       = TimeSpan.FromSeconds(Convert.ToInt32(reader["QuestionTimeLimit"]));
                    game.NumCategories           = Convert.ToInt32(reader["NumCategories"]);
                    game.NumQuestionsPerCategory = Convert.ToInt32(reader["NumQuestionsPerCategory"]);

                    games.Add(game);
                }
                reader.Close();
                //don't select categories or questions or choices, just top level info, SelectAllGames will select everything
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception\n\n" + ex.ToString());

                //tell the user to install Access Runtime
                DialogResult dialog = MessageBox.Show("Error trying to load games. Access Database Engine needs to be installed.\n\nClick OK to launch a troubleshooting window that has an option to install the database engine.", "Access Database Error");
                Forms.Admin.frmTroubleshooter troubleshooterForm = new Forms.Admin.frmTroubleshooter();
                troubleshooterForm.ShowDialog();

                return(games);
            }
            finally
            {
                if (conn != null && conn.State == ConnectionState.Open)
                {
                    conn.Close();
                }
            }

            return(games);
        }
예제 #2
0
 private void troubleshootToolStripMenuItem_Click(object sender, EventArgs e)
 {
     Forms.Admin.frmTroubleshooter TroubleshooterForm = new Forms.Admin.frmTroubleshooter();
     TroubleshooterForm.ShowDialog();
     bwLoadGames.RunWorkerAsync();
 }