protected void GenTeam_Click(object sender, EventArgs e)
        {
            if (Session["seasonid"] == null) return;
            if (Convert.ToInt32(Session["seasonid"]) == 0) return;
            var seasonList = SeasonHelper.GetChampionLeagueGroupSeasonList(SeasonHelper.CheckIsEuropaSeasonId(Convert.ToInt32(Session["seasonid"])));
            foreach (var season in seasonList)
            {
                var isFinished = SeasonHelper.CheckGroupSeasonIsFinnish(season.SeasonId);
                if (!isFinished)
                {
                    JavaScriptHelper.Alert("ยังใส่ผล Champion League ไม่ครบทุก Group");
                    return;
                }
            }

            using (var dc = ThaitaeDataDataContext.Create())
            {
                var checkRecord = dc.TeamSeasons.Any(item => item.SeasonId == Convert.ToInt32(Session["seasonid"]));
                if (checkRecord)
                {
                    JavaScriptHelper.Alert("ต้องลบทีมออกให้หมดก่อนถึงจะกดปุ่มนี้ได้"); return;
                }

            }
            foreach (var season in seasonList)
            {
                List<TeamSeason> teamSeasonList;
                var leagueId = Convert.ToInt32(Session["leagueid"]);
                int i;
                if (leagueId == 14)
                {
                    teamSeasonList = TeamSeasonHelper.GetChampionsLeagueFinalTeamList(season.SeasonId);
                    i = 1;
                }
                else
                {
                    teamSeasonList = TeamSeasonHelper.GetEuropaLeagueFinalTeamList(season.SeasonId);
                    i = 2;
                }

                foreach (var teamSeason in teamSeasonList)
                {
                    using (var dc = ThaitaeDataDataContext.Create())
                    {
                        var teamFinalSelected =
                            TeamSeasonHelper.GetChampionsLeagueFinalTeamFromGroupSeasonId(teamSeason.SeasonId,
                                                                                          teamSeason.TeamId);
                        if (teamFinalSelected == null)
                        {
                            var teamFinal = new TeamSeason
                            {
                                TeamDrew = 0,
                                TeamGoalAgainst = 0,
                                TeamGoalDiff = 0,
                                TeamGoalFor = 0,
                                TeamLoss = 0,
                                TeamMatchPlayed = 0,
                                TeamPts = 0,
                                TeamRedCard = 0,
                                TeamWon = 0,
                                TeamYellowCard = 0,
                                GroupSeasonId = 0,
                                GroupSeasonOrder = leagueId == 14 ? i++ : i--,
                                TeamId = teamSeason.TeamId,
                                SeasonId = Convert.ToInt32(Session["seasonid"])
                            };
                            dc.TeamSeasons.InsertOnSubmit(teamFinal);
                        }
                        else
                        {
                            teamFinalSelected.GroupSeasonOrder = leagueId == 14 ? i++ : i--;
                        }

                        dc.SubmitChanges();
                    }
                }
            }
        }
		private void detach_TeamSeasons(TeamSeason entity)
		{
			this.SendPropertyChanging();
			entity.Season = null;
		}
		private void attach_TeamSeasons(TeamSeason entity)
		{
			this.SendPropertyChanging();
			entity.Season = this;
		}
 partial void DeleteTeamSeason(TeamSeason instance);
 partial void UpdateTeamSeason(TeamSeason instance);
 partial void InsertTeamSeason(TeamSeason instance);