protected void Page_Load(object sender, EventArgs e) { leagueID = (int)((SiteMaster)this.Master).LeagueID; currentSeasonID = DatabaseFunctions.GetCurrentSeasonID(leagueID.ToString()); Dictionary <int, string> allTeamNames = DatabaseFunctions.GetTeamNames(leagueID); Dictionary <int, string> teamNames = new Dictionary <int, string>(); List <int> activeTeams = DatabaseFunctions.GetTeamsActiveInSeason(leagueID, currentSeasonID); foreach (int teamID in activeTeams) { teamNames.Add(teamID, allTeamNames[teamID]); } Dictionary <int, EventInfo> events = DatabaseFunctions.GetEventsWithScoresPosted(leagueID, currentSeasonID); Dictionary <int, decimal> teamTotalScores = new Dictionary <int, decimal>(); Dictionary <int, Dictionary <int, decimal> > weekByWeekScores = new Dictionary <int, Dictionary <int, decimal> >(); var settings = DatabaseFunctions.GetLeagueSettings(leagueID); bool useCurrentRound = settings.ContainsKey("UseCurrentRoundForHandicap") ? bool.Parse(settings["UseCurrentRoundForHandicap"]) : true; Dictionary <int, Dictionary <int, int> > handicaps = Scoring.GetHandicaps(leagueID, useCurrentRound); ChartWeeklyStandings.ImageStorageMode = ImageStorageMode.UseImageLocation; ChartWeeklyStandings.Legends[0].Font = new System.Drawing.Font("Arial", 12, FontStyle.Bold); ChartWeeklyStandings.Palette = ChartColorPalette.Bright; ChartWeeklyStandings.ChartAreas[0].AxisY.Maximum = 5; foreach (KeyValuePair <int, EventInfo> eventPair in events.OrderBy(x => x.Value.Date)) { Dictionary <int, int> handicapsForEvent = Scoring.GetHandicapsForEventFromHandicapByGolferIDDictionary(handicaps, eventPair.Key); Dictionary <int, decimal> eventPoints = Scoring.GetEventResults(leagueID, eventPair.Key, handicapsForEvent).teamPts; weekByWeekScores.Add(eventPair.Key, eventPoints); foreach (int teamID in eventPoints.Keys) { if (teamTotalScores.ContainsKey(teamID)) { teamTotalScores[teamID] += eventPoints[teamID]; } else { teamTotalScores.Add(teamID, eventPoints[teamID]); } } } BuildStandingsTable(teamTotalScores, teamNames); BuildChart(weekByWeekScores, teamNames, events); BuildWeeklyResultsTable(weekByWeekScores, teamNames, events); }
private void AddScrollBarContent() { EventInfo lastEventWithScores = DatabaseFunctions.GetMostRecentEventWithScoresPosted(leagueID.ToString()); if (lastEventWithScores.EventID == 0) { return; } Scoring.EventStats eventStats = Scoring.GetEventResults(leagueID, lastEventWithScores.EventID, null); Dictionary <int, Golfer> golfers = DatabaseFunctions.GetGolfersInfo(leagueID.ToString()); Dictionary <int, string> teams = DatabaseFunctions.GetTeamNames(leagueID); ScrollLabel1.Text += "Last Event: " + lastEventWithScores.EventName + " (" + lastEventWithScores.Date + "): "; var items = from pair in eventStats.grossScores orderby pair.Value ascending select pair; ScrollLabel1.Text += " Scores: "; foreach (KeyValuePair <int, int> pair in items) { ScrollLabel1.Text += golfers[pair.Key].firstName + " " + golfers[pair.Key].lastName + " - " + pair.Value.ToString() + " |"; //AddTableRowLeaderboard(Table_GrossScoreLeaderboard, DatabaseFunctions.GetGolferName(pair.Key), (decimal)pair.Value); } items = from pair in eventStats.netScores orderby pair.Value ascending select pair; ScrollLabel1.Text += "|^|Net Scores: "; foreach (KeyValuePair <int, int> pair in items) { ScrollLabel1.Text += golfers[pair.Key].firstName + " " + golfers[pair.Key].lastName + " - " + pair.Value.ToString() + " |"; //AddTableRowLeaderboard(Table_NetScoreLeaderboard, DatabaseFunctions.GetGolferName(pair.Key), (decimal)pair.Value); } var items2 = from pair in eventStats.teamPts orderby pair.Value descending select pair; ScrollLabel1.Text += "|^|Team Scores: "; foreach (KeyValuePair <int, decimal> pair in items2) { ScrollLabel1.Text += teams[pair.Key] + " " + pair.Value.ToString() + " |"; //AddTableRowLeaderboard(Table_TeamPts, teamNames[pair.Key], pair.Value); } }
private void DisplayWeeklyLeaderboard() { int selectedEventID = int.Parse(Dropdown_LeagueEvent.SelectedValue); if (selectedEventID != 0) { Scoring.EventStats eventStats = Scoring.GetEventResults(leagueID, selectedEventID, null); Dictionary <int, string> teamNames = DatabaseFunctions.GetTeamNames(leagueID); //Clear Tables and Add Title Rows Table_GrossScoreLeaderboard.Rows.Clear(); Table_NetScoreLeaderboard.Rows.Clear(); Table_TeamPts.Rows.Clear(); AddLeaderboardTitleRow(Table_GrossScoreLeaderboard, "Gross Score"); AddLeaderboardTitleRow(Table_NetScoreLeaderboard, "Net Score"); AddLeaderboardTitleRow(Table_TeamPts, "Team Points"); var items = from pair in eventStats.grossScores orderby pair.Value ascending select pair; foreach (KeyValuePair <int, int> pair in items) { AddTableRowLeaderboard(Table_GrossScoreLeaderboard, DatabaseFunctions.GetGolferName(pair.Key), (decimal)pair.Value); } items = from pair in eventStats.netScores orderby pair.Value ascending select pair; foreach (KeyValuePair <int, int> pair in items) { AddTableRowLeaderboard(Table_NetScoreLeaderboard, DatabaseFunctions.GetGolferName(pair.Key), (decimal)pair.Value); } var items2 = from pair in eventStats.teamPts orderby pair.Value descending select pair; foreach (KeyValuePair <int, decimal> pair in items2) { AddTableRowLeaderboard(Table_TeamPts, teamNames[pair.Key], pair.Value); } } }
private void DisplayWeeklyResults() { int selectedEventID = int.Parse(Dropdown_LeagueEvent.SelectedValue); if (selectedEventID != 0) { ViewState["EventID"] = selectedEventID; Dictionary <int, string> teamNames = DatabaseFunctions.GetTeamNames(leagueID); Dictionary <int, int> matchups = DatabaseFunctions.GetMatchups(selectedEventID); Dictionary <int, List <byte> > scores = DatabaseFunctions.GetScores(selectedEventID); var handicaps = Scoring.GetPlayerHandicapsForEvent(leagueID, selectedEventID, scores.Keys.ToList()); var results = Scoring.GetEventResults(leagueID, selectedEventID, handicaps); CourseInfo courseInfo = DatabaseFunctions.GetCourseInfo(selectedEventID); int index = 0; foreach (int team1ID in results.matchupResultsA.Keys) { //build info for display GolferInfo golferInfo = GetGolferNames(results.matchupResultsA[team1ID].Team1PlayerID, results.matchupResultsA[team1ID].Team2PlayerID, results.matchupResultsB[team1ID].Team1PlayerID, results.matchupResultsB[team1ID].Team2PlayerID); golferInfo.Team1Name = teamNames[team1ID]; golferInfo.Team2Name = teamNames[matchups[team1ID]]; golferInfo.Aplayer1Hcp = handicaps[results.matchupResultsA[team1ID].Team1PlayerID]; golferInfo.Aplayer2Hcp = handicaps[results.matchupResultsA[team1ID].Team2PlayerID]; golferInfo.Bplayer1Hcp = handicaps[results.matchupResultsB[team1ID].Team1PlayerID]; golferInfo.Bplayer2Hcp = handicaps[results.matchupResultsB[team1ID].Team2PlayerID]; AddCollapsablePanel(index.ToString(), golferInfo, results.matchupResultsA[team1ID], results.matchupResultsB[team1ID], courseInfo); index++; } //Dictionary<int, int> matchups = DatabaseFunctions.GetMatchups(selectedEventID); //Dictionary<int, string> teamNames = DatabaseFunctions.GetTeamNames(leagueID); //Dictionary<int, List<byte>> scores = DatabaseFunctions.GetScores(selectedEventID); //CourseInfo courseInfo = DatabaseFunctions.GetCourseInfo(selectedEventID); //Dictionary<int, int> subs = DatabaseFunctions.GetSubs(selectedEventID); //List<int> noShows = new List<int>(); //DatabaseFunctions.GetNoShows(selectedEventID); //Dictionary<int, int> handicaps = DatabaseFunctions.GetHandicapOverrides(selectedEventID); //int Team1PlayerA_ID, Team1PlayerB_ID, Team2PlayerA_ID, Team2PlayerB_ID; ////Add No shows to Handicaps and scores //scores.Add(0, Scoring.GetNoShowScores(courseInfo)); //handicaps.Add(0, 0); //int index = 0; ////foreach matchup //foreach (int team1ID in matchups.Keys) //{ // Scoring.GetGolferIDs(team1ID, selectedEventID, subs, handicaps, scores, out Team1PlayerA_ID, out Team1PlayerB_ID); // Scoring.GetGolferIDs(matchups[team1ID],selectedEventID , subs, handicaps, scores, out Team2PlayerA_ID, out Team2PlayerB_ID); // GolferInfo golferInfo = GetGolferNames(Team1PlayerA_ID, Team2PlayerA_ID, Team1PlayerB_ID, Team2PlayerB_ID); // golferInfo.Team1Name = teamNames[team1ID]; // golferInfo.Team2Name = teamNames[matchups[team1ID]]; // Scoring.MatchupResults results_A = Scoring.GetMatchupResults(scores[Team1PlayerA_ID], scores[Team2PlayerA_ID], handicaps[Team1PlayerA_ID], handicaps[Team2PlayerA_ID], courseInfo); // Scoring.MatchupResults results_B = Scoring.GetMatchupResults(scores[Team1PlayerB_ID], scores[Team2PlayerB_ID], handicaps[Team1PlayerB_ID], handicaps[Team2PlayerB_ID], courseInfo); // //Add handicaps to golferNames // golferInfo.Aplayer1Hcp = handicaps[Team1PlayerA_ID]; // golferInfo.Aplayer2Hcp = handicaps[Team2PlayerA_ID]; // golferInfo.Bplayer1Hcp = handicaps[Team1PlayerB_ID]; // golferInfo.Bplayer2Hcp = handicaps[Team2PlayerB_ID]; // AddCollapsablePanel(index.ToString(), golferInfo, results_A, results_B, courseInfo); // index++; //} } }