public void LoadForm() { _countries = _db.GetCountries(); _dgvCountries = new List <DGVCountry>(_countries.Count); foreach (DBCountry country in _countries) { _dgvCountries.Add(new DGVCountry(country, CountryFlags.GetFlagImage(country.CountryName))); } _form.FillDGV(_dgvCountries); }
private void CalculateAndSortPlayersScores() { _playersRankings = new List <PlayerRanking>(_players.Count); foreach (DBPlayer player in _players) { string teamName = string.Empty; if (_tournament.IsTeams) { teamName = _teams.Find(x => x.TeamId == player.PlayerTeamId).TeamName; } string countryImageUrl = _db.GetCountryImageUrl(player.PlayerCountryName); PlayerRanking playerRanking = new PlayerRanking(player.PlayerId, player.PlayerName, player.PlayerTeamId, teamName, player.PlayerCountryName, countryImageUrl, CountryFlags.GetFlagImage(player.PlayerCountryName)); List <DBTable> playerTables = _tables.FindAll(x => player.PlayerId == x.Player1Id || player.PlayerId == x.Player2Id || player.PlayerId == x.Player3Id || player.PlayerId == x.Player4Id); foreach (DBTable table in playerTables) { if (player.PlayerId.ToString().Equals(table.PlayerEastId)) { playerRanking.PlayerPoints += table.PlayerEastPoints.Equals(string.Empty) ? 0 : float.Parse(table.PlayerEastPoints); playerRanking.PlayerScore += table.PlayerEastScore.Equals(string.Empty) ? 0 : int.Parse(table.PlayerEastScore); } else if (player.PlayerId.ToString().Equals(table.PlayerSouthId)) { playerRanking.PlayerPoints += table.PlayerSouthPoints.Equals(string.Empty) ? 0 : float.Parse(table.PlayerSouthPoints); playerRanking.PlayerScore += table.PlayerSouthScore.Equals(string.Empty) ? 0 : int.Parse(table.PlayerSouthScore); } else if (player.PlayerId.ToString().Equals(table.PlayerWestId)) { playerRanking.PlayerPoints += table.PlayerWestPoints.Equals(string.Empty) ? 0 : float.Parse(table.PlayerWestPoints); playerRanking.PlayerScore += table.PlayerWestScore.Equals(string.Empty) ? 0 : int.Parse(table.PlayerWestScore); } else { playerRanking.PlayerPoints += table.PlayerNorthPoints.Equals(string.Empty) ? 0 : float.Parse(table.PlayerNorthPoints); playerRanking.PlayerScore += table.PlayerNorthScore.Equals(string.Empty) ? 0 : int.Parse(table.PlayerNorthScore); } } _playersRankings.Add(playerRanking); } _playersRankings = _playersRankings.OrderByDescending(x => x.PlayerPoints).ThenByDescending(x => x.PlayerScore).ToList(); for (int i = 0; i < _playersRankings.Count; i++) { _playersRankings[i].Order = i + 1; } }
private void ShowCountriesSelector(int rowIndex) { using (var countrySelectorForm = new CountrySelectorForm()) { if (countrySelectorForm.ShowDialog() == DialogResult.OK) { int playerId = (int)dgv.Rows[rowIndex].Cells[DBPlayer.COLUMN_PLAYERS_ID].Value; if (countrySelectorForm.ReturnValue != null && !countrySelectorForm.ReturnValue.Equals(string.Empty)) { _presenter.SaveNewPlayerCountry(playerId, countrySelectorForm.ReturnValue); dgv.Rows[rowIndex].Cells[DBPlayer.COLUMN_PLAYERS_COUNTRY_NAME].Value = countrySelectorForm.ReturnValue; dgv.Rows[rowIndex].Cells[DGVPlayer.COLUMN_PLAYERS_COUNTRY_FLAG].Value = CountryFlags.GetFlagImage(countrySelectorForm.ReturnValue); } } } }
public void LoadForm(int tournamentId) { _tournament = _db.GetTournament(tournamentId); _players = _db.GetTournamentPlayers(tournamentId); if (_tournament.IsTeams) { _teams = _db.GetTournamentTeams(tournamentId); } _countries = _db.GetCountries(); List <DGVPlayer> dgvPlayers = new List <DGVPlayer>(_players.Count); foreach (DBPlayer player in _players) { dgvPlayers.Add(new DGVPlayer(player, getPlayerTeamName(player.PlayerTeamId), CountryFlags.GetFlagImage(player.PlayerCountryName))); } _form.FillDGV(dgvPlayers, _tournament.IsTeams); CheckWrongPlayersTeams(); }