public void update() { DataTable table = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutSessions); DataTable teamsTable = AccessDatabaseUtilities.getDataTable(m_databaseFileName, Constants.TableName.KnockoutTeams); if (numberOfRounds > oldNumberOfRounds) { for (int i = oldNumberOfRounds + 1; i <= numberOfRounds; ++i) { DataRow dRow = table.NewRow(); string sessionName = (Constants.KnockoutSessionNames.Length >= i ? Constants.KnockoutSessionNames[i - 1] : "Round_of_" + Math.Pow(2, i)); dRow["Round_Number"] = i; dRow["Round_Name"] = sessionName; dRow["Number_Of_Sessions"] = 3; table.Rows.Add(dRow); createRoundScoresTable(i); } AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutSessions); for (int i = oldNumberOfTeams + 1; i <= numberOfTeams; ++i) { DataRow dRow = teamsTable.NewRow(); string sessionName = (Constants.KnockoutSessionNames.Length >= i ? Constants.KnockoutSessionNames[i - 1] : "Round_of_" + Math.Pow(2, i)); dRow["Team_Number"] = i; dRow["Team_Name"] = "Team " + i; teamsTable.Rows.Add(dRow); } AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutTeams); } else if (numberOfRounds < oldNumberOfRounds) { for (int i = numberOfRounds + 1; i <= oldNumberOfRounds; ++i) { table.Rows.Find(i).Delete(); AccessDatabaseUtilities.dropTable(m_databaseFileName, Constants.TableName.KnockoutScores + "_" + i); m_oldNumberOfSessions.Remove(i); } AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutSessions); for (int i = numberOfTeams + 1; i <= oldNumberOfTeams; ++i) { teamsTable.Rows.Find(i).Delete(); } AccessDatabaseUtilities.saveTableToDatabase(m_databaseFileName, Constants.TableName.KnockoutTeams); } oldNumberOfRounds = numberOfRounds; oldNumberOfTeams = numberOfTeams; }