//Update list object in GUI public void UpdateListView() { List<Pelaaja> players = new List<Pelaaja>(); Pelaaja player = new Pelaaja(); Seura seura = new Seura(); //cbTeam.Items.Clear(); //clear list lstPelaajat.Items.Clear(); int i = GetSelectedTeam(); if (NHL.Count > 0) { seura = NHL.ElementAt(i); //cbTeam.Items.Add(seura.SeuraNimi); //Add Seura players = seura.GetPlayers(); for (int j = 0; j < players.Count(); j++) //For every player in players list in Seura { player = players.ElementAt(j); lstPelaajat.Items.Add(player.KokoNimi); //Add player to list } } }
private void WriteToFile() { string strRow = ""; File.WriteAllText(fileName, "Etunimi;Sukunimi;Seura;Siirtohinta\n"); List<Pelaaja> players = new List<Pelaaja>(); Pelaaja player = new Pelaaja(); Seura seura = new Seura(); //int i = GetSelectedTeam(); for (int i = 0; i < NHL.Count(); i++) //For every Seura { seura = NHL.ElementAt(i); players = seura.GetPlayers(); for (int j = 0; j < players.Count(); j++) //For every player in players list in Seura { player = players.ElementAt(j); strRow = player.Etunimi; strRow += ";"; strRow += player.Sukunimi; strRow += ";"; strRow += player.Seura; strRow += ";"; strRow += player.Siirtohinta; strRow += "\n"; File.AppendAllText(fileName, strRow); } } }
public bool AddPlayer(string n_firstName, string n_lastName, string n_team, float n_price) { Pelaaja n_player = new Pelaaja(); n_player.Etunimi = n_firstName; n_player.Sukunimi = n_lastName; n_player.Seura = n_team; n_player.Siirtohinta = n_price; Pelaaja old_player = new Pelaaja(); for (int x = 0; x < team.Count; x++) { old_player = team.ElementAt(x); if (old_player.KokoNimi == n_player.KokoNimi) { //Same name player found! exit return true; } } //no same name player found, add player to database team.Add(n_player); return false; }