Пример #1
0
 public String checkUnlockMap(gameStats x)
 {
     if (x.getID() != -1 && x.getPassed() == 1)
     {
         MySqlCommand queryCommand = new MySqlCommand();
         queryCommand.Connection  = conn;
         queryCommand.CommandText = "IF NOT EXISTS (SELECT unlocked from userMaps WHERE ID = @ID AND mapName = @mapName" +
                                    "AND unlocked = 0) BEGIN INSERT INTO mapStats(personID, mapName, unlocked) VALUES (@ID,@mapName,@unlocked) END;";
         queryCommand.Prepare();
         queryCommand.Parameters.AddWithValue("@ID", x.getID());
         queryCommand.Parameters.AddWithValue("@mapName", x.getMap());
         queryCommand.Parameters.AddWithValue("@unlocked", x.getUnlocked());
         try
         {
             MySqlDataReader reader = queryCommand.ExecuteReader();
             return("Unlocked new map!");
         }
         catch (Exception exc)
         {
             Console.WriteLine(exc.Message);
             return("Failed to save map progress into database");
         }
     }
     return("Map already unlocked");
 }