private void LoadPlayerLevelHistory() { XMLUtils xmlUtils = new XMLUtils() { FilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Properties.Resources.XMLDBName.ToString()) }; DataSet ds = xmlUtils.ReadXMLfile(); DataTable dt = ds.Tables[(int)SaveGameHelper.XMLTbls.player_history]; string maxLvl = ds.Tables[(int)SaveGameHelper.XMLTbls.level].AsEnumerable() .OrderByDescending(k => k.Field <string>("level_ID")) .First().Field <string>("level_ID").ToString(); int count = dt.AsEnumerable() .Where(i => i.Field <string>("player_ID") == StartScreen.PlayerID.ToString() && !string.IsNullOrWhiteSpace(i.Field <string>("completed").ToString())) .Count(); if (count > 0) { DataTable lvlsCompleted = (from lc in dt.AsEnumerable() where lc.Field <string>("player_ID") == StartScreen.PlayerID.ToString() && !string.IsNullOrWhiteSpace(lc.Field <string>("completed").ToString()) orderby lc.Field <string>("level_ID") select lc).CopyToDataTable(); DisplayLevels(lvlsCompleted); string maxPlayerLvl = lvlsCompleted.AsEnumerable() .OrderByDescending(j => j.Field <string>("level_ID")) .First().Field <string>("level_ID").ToString(); if (maxPlayerLvl != maxLvl) { int.TryParse(maxPlayerLvl, out int retVal); retVal += 1; DisplayNextLevel(retVal.ToString()); } } count = dt.AsEnumerable() .Where(i => i.Field <string>("player_ID") == StartScreen.PlayerID.ToString() && !string.IsNullOrWhiteSpace(i.Field <string>("last_played")) && i.Field <string>("level_id") == dt.AsEnumerable() .OrderByDescending(t => t.Field <string>("last_played")) .OrderByDescending(k => k.Field <string>("level_ID")) .First().Field <string>("level_id").ToString()) .Count(); if (count > 0) { DataRow lastPlayed = (from lp in dt.AsEnumerable() where lp.Field <string>("player_ID") == StartScreen.PlayerID.ToString() && lp.Field <string>("level_id") == dt.AsEnumerable() .OrderByDescending(t => t.Field <string>("last_played")) .OrderByDescending(k => k.Field <string>("level_ID")) .First().Field <string>("level_id").ToString() select lp).SingleOrDefault(); DisplayLastLevel(lastPlayed); } }