public bool UpdateGame(Game GameToUpdate)
{
//Update a game in the database with any given value
//If the update succeeds, return true, otherwise false.
LogInstance.WriteToFile(1, "Updating Game " + GameToUpdate.Name, LogSource);
if (!(GameToUpdate.ID == 0) && !(GameToUpdate.InfoXML == null) && !(GameToUpdate.Name == null))
{
if (!connectionopen)
{
DBConnector.Open();
connectionopen = true;
}
FbTransaction DBTransaction = DBConnector.BeginTransaction();
FbCommand DBCommand = new FbCommand("UPDATE games SET GameName ='" + GameToUpdate.Name + "', info_xml = '" + GameToUpdate.InfoXML.InnerText + "' WHERE ID = " + GameToUpdate.ID, DBConnector, DBTransaction);
DBCommand.ExecuteNonQuery();
DBTransaction.Commit();
DBConnector.Close();
connectionopen = false;
return true;
}
else
{
if (!(GameToUpdate.ID == 0) && !(GameToUpdate.InfoXML == null))
{
if (!connectionopen)
{
DBConnector.Open();
connectionopen = true;
}
FbTransaction DBTransaction = DBConnector.BeginTransaction();
FbCommand DBCommand = new FbCommand("UPDATE games SET info_xml = '" + GameToUpdate.InfoXML.InnerText + "' WHERE ID = " + GameToUpdate.ID, DBConnector, DBTransaction);
DBCommand.ExecuteNonQuery();
DBTransaction.Commit();
DBConnector.Close();
connectionopen = false;
return true;
}
else
{
if (!(GameToUpdate.ID == 0) && !(GameToUpdate.Name == null))
{
if (!connectionopen)
{
DBConnector.Open();
connectionopen = true;
}
FbTransaction DBTransaction = DBConnector.BeginTransaction();
FbCommand DBCommand = new FbCommand("UPDATE games SET GameName ='" + GameToUpdate.Name + "' WHERE ID = " + GameToUpdate.ID, DBConnector, DBTransaction);
DBCommand.ExecuteNonQuery();
DBTransaction.Commit();
DBConnector.Close();
connectionopen = false;
}
else
return false;
}
}
return false;
}