/// <summary>
        /// 
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static void InsertGameData(XmlNode node, Player player)
        {
            if (node.ChildNodes.Count != 19) throw new ArgumentException("Invalid number of childred in node. Maybe json has been updated");
            PlayerGameData gameData = new PlayerGameData();
            gameData.player = player.ID;
            gameData.gameweek = int.Parse(node.ChildNodes[1].InnerText);
            int otherTeam = new Team(node.ChildNodes[2].InnerText.Substring(0, 3)).teamID;

            if ((gameData.game = DataAccess.Instance.GetGameIDByTeams(otherTeam, Form1.SEASON, gameData.gameweek, out gameData.team)) == 0)
            {
                throw new ArgumentOutOfRangeException("Game could not be found");
            }
            gameData.played = int.Parse(node.ChildNodes[3].InnerText);
            gameData.goals = int.Parse(node.ChildNodes[4].InnerText);
            gameData.assist = int.Parse(node.ChildNodes[5].InnerText);
            gameData.cleansheets = int.Parse(node.ChildNodes[6].InnerText);
            gameData.conceded = int.Parse(node.ChildNodes[7].InnerText);
            gameData.ownGoal = int.Parse(node.ChildNodes[8].InnerText);
            gameData.pensave = int.Parse(node.ChildNodes[9].InnerText);
            gameData.penmiss = int.Parse(node.ChildNodes[10].InnerText);
            gameData.yellow = int.Parse(node.ChildNodes[11].InnerText);
            gameData.red = int.Parse(node.ChildNodes[12].InnerText);
            gameData.saves = int.Parse(node.ChildNodes[13].InnerText);
            gameData.bonus = int.Parse(node.ChildNodes[14].InnerText);
            gameData.EAsports = int.Parse(node.ChildNodes[15].InnerText);
            gameData.transfer = int.Parse(node.ChildNodes[16].InnerText);
            gameData.value = double.Parse(node.ChildNodes[17].InnerText);
            gameData.total = int.Parse(node.ChildNodes[18].InnerText);

            if(gameData.played>0)gameData.Insert();
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static void InsertGameData(XmlNode node, Player player)
        {
            if (node.ChildNodes.Count != 19)
            {
                throw new ArgumentException("Invalid number of childred in node. Maybe json has been updated");
            }
            PlayerGameData gameData = new PlayerGameData();

            gameData.player   = player.ID;
            gameData.gameweek = int.Parse(node.ChildNodes[1].InnerText);
            int otherTeam = new Team(node.ChildNodes[2].InnerText.Substring(0, 3)).teamID;

            if ((gameData.game = DataAccess.Instance.GetGameIDByTeams(otherTeam, Form1.SEASON, gameData.gameweek, out gameData.team)) == 0)
            {
                throw new ArgumentOutOfRangeException("Game could not be found");
            }
            gameData.played      = int.Parse(node.ChildNodes[3].InnerText);
            gameData.goals       = int.Parse(node.ChildNodes[4].InnerText);
            gameData.assist      = int.Parse(node.ChildNodes[5].InnerText);
            gameData.cleansheets = int.Parse(node.ChildNodes[6].InnerText);
            gameData.conceded    = int.Parse(node.ChildNodes[7].InnerText);
            gameData.ownGoal     = int.Parse(node.ChildNodes[8].InnerText);
            gameData.pensave     = int.Parse(node.ChildNodes[9].InnerText);
            gameData.penmiss     = int.Parse(node.ChildNodes[10].InnerText);
            gameData.yellow      = int.Parse(node.ChildNodes[11].InnerText);
            gameData.red         = int.Parse(node.ChildNodes[12].InnerText);
            gameData.saves       = int.Parse(node.ChildNodes[13].InnerText);
            gameData.bonus       = int.Parse(node.ChildNodes[14].InnerText);
            gameData.EAsports    = int.Parse(node.ChildNodes[15].InnerText);
            gameData.transfer    = int.Parse(node.ChildNodes[16].InnerText);
            gameData.value       = double.Parse(node.ChildNodes[17].InnerText);
            gameData.total       = int.Parse(node.ChildNodes[18].InnerText);

            if (gameData.played > 0)
            {
                gameData.Insert();
            }
        }
        public Boolean InsertPlayerGameData(PlayerGameData pgd, int playerID)
        {
            //TODO: The team information needs to be in here

            SqlCommand verifyCmd = MyConnection.CreateCommand();
            verifyCmd.CommandText = "SELECT * FROM PlayerGame WHERE Player = @PlayerID AND Game = @GameID";
            verifyCmd.Parameters.AddWithValue("@PlayerID", pgd.player);
            verifyCmd.Parameters.AddWithValue("@GameID", pgd.game);
            MyConnection.Open();
            SqlDataReader reader = verifyCmd.ExecuteReader();
            bool hasRows = reader.HasRows;
            MyConnection.Close();
            int returnVal = 0;
            if (!hasRows)
            {
                SqlCommand cmd = MyConnection.CreateCommand();

                cmd.CommandText = "INSERT INTO PlayerGame(Played, Goals, Assists, Conceded, PenSave, PenMiss, Yellow, Red, Saves, Bonus, OwnGoal, Total, Game, Player, Team, NetTransfer, EASport, Value, CleanSheets) VALUES (@Played, @Goals, @Assists, @Conceded, @PenSave, @PenMiss, @Yellow, @Red, @Saves, @Bonus, @OwnGoal, @Total, @Game, @Player, @Team, @NetTransfer, @EASport, @Value, @CleanSheets)";
                cmd.Parameters.Add(new SqlParameter("@Played", pgd.played));
                cmd.Parameters.Add(new SqlParameter("@Goals", pgd.goals));
                cmd.Parameters.Add(new SqlParameter("@Assists", pgd.assist));
                cmd.Parameters.Add(new SqlParameter("@Conceded", pgd.conceded));
                cmd.Parameters.Add(new SqlParameter("@PenSave", pgd.pensave));
                cmd.Parameters.Add(new SqlParameter("@PenMiss", pgd.penmiss));
                cmd.Parameters.Add(new SqlParameter("@Yellow", pgd.yellow));
                cmd.Parameters.Add(new SqlParameter("@Red", pgd.red));
                cmd.Parameters.Add(new SqlParameter("@Saves", pgd.saves));
                cmd.Parameters.Add(new SqlParameter("@Bonus", pgd.bonus));
                cmd.Parameters.Add(new SqlParameter("@OwnGoal", pgd.ownGoal));
                cmd.Parameters.Add(new SqlParameter("@Total", pgd.total));
                cmd.Parameters.Add(new SqlParameter("@Game", pgd.game));
                cmd.Parameters.Add(new SqlParameter("@Player", playerID));
                cmd.Parameters.Add(new SqlParameter("@Team", pgd.team)); //TODO: Fix with actual Team
                cmd.Parameters.AddWithValue("@NetTransfer", pgd.transfer);
                cmd.Parameters.AddWithValue("@EASport", pgd.EAsports);
                cmd.Parameters.AddWithValue("@Value", pgd.value);
                cmd.Parameters.AddWithValue("@CleanSheets", pgd.cleansheets);
                MyConnection.Open();
                returnVal = cmd.ExecuteNonQuery();
                MyConnection.Close();
            }
            return returnVal != 0;
        }