public bool DeleteGame(Game GameToDelete)
{
//Delete a game from the database
//Check if the game is valid, otherwise return "false" (i.e.: Error!)
LogInstance.WriteToFile(1, "Deleting Game with ID " + GameToDelete.ID + " from the database.", LogSource);
if (!(GameToDelete.ID == 0))
{
if (!connectionopen)
{
DBConnector.Open();
connectionopen = true;
}
FbTransaction DBTransaction = DBConnector.BeginTransaction();
LogInstance.WriteToFile(4, "Executing SQL Command " + "DELETE FROM games WHERE ID = '" + GameToDelete.ID + "'", LogSource);
FbCommand DBCommand = new FbCommand("DELETE FROM games WHERE ID = '" + GameToDelete.ID + "'", DBConnector, DBTransaction);
DBCommand.ExecuteNonQuery();
DBTransaction.Commit();
DBConnector.Close();
connectionopen = false;
return true;
}
else
{
LogInstance.WriteToFile(3, "Error while deleting " + GameToDelete.Name + ". No valid ID given.", LogSource);
return false;
}
}