public MainWindow() { InitializeComponent(); FilePath = new DBProcessing(_myConnectionString); var teams = FilePath.GetTeams(); var players = FilePath.GetBasketballPlayers(); var image = new MenuImagesProcessing(); foreach (var item in teams) { item.BasketballPlayers = players; } var basketballPlayer = new BasketballPlayers(); var team = new Teams(); foreach (var item in players) { basketballPlayer.CheckPlayerPicture(item); } foreach (var item in teams) { team.CheckTeamPicture(item); } foreach (var item in teams) { item.BasketballPlayers = basketballPlayer.RelatePlayerToATeam(item, players);; } _teamsList = teams; _teamsToSort = teams; connection = new MySqlConnection(_myConnectionString); _positions = FilePath.GetPositions(); //_menuImages = image.GetImagesFromFile(); }
public void ImportPlayerDataToDB(bool selected = false, params Teams[] team) { BindingList <BasketballPlayers> playersToImport = _storage.GetPlayersFromFile(); _connection.Open(); var currentplayers = DBPath.GetBasketballPlayers(); if (selected) { foreach (var item in playersToImport) { item.Current_team = team[0].TeamName; } } var refer = new MainWindow(); for (int i = playersToImport.Count - 1; i != -1; i--) { foreach (var item1 in currentplayers) { if (playersToImport[i].Name == item1.Name && playersToImport[i].Current_team == item1.Current_team) { playersToImport.Remove(playersToImport[i]); break; } } } DBPath.Append(playersToImport.ToArray()); refer.ToLog($"{playersToImport.Count} players were inserted into database", MessageBoxImage.Information); _connection.Close(); }
private void UpdateInterface() { _toCompleteEvent = true; var teams = FilePath.GetTeams(); var players = FilePath.GetBasketballPlayers(); foreach (var item in players) { item.CheckPlayerPicture(item); } foreach (var item in teams) { item.BasketballPlayers = players; } var basketballPlayer = new BasketballPlayers(); foreach (var item in teams) { item.BasketballPlayers = basketballPlayer.RelatePlayerToATeam(item, players);; } lvTeamsOutput.ItemsSource = null; lvTeamsOutput.ItemsSource = teams; _toCompleteEvent = false; }