//UCITAVANJE POSTOJECE STATISTIKE private List <Igrac> LoadExisting(List <Igrac> lista, string filepath) { List <Igrac> temp = null; //ucitavanje liste postojecih igraca if (System.IO.File.Exists(filepath)) { temp = new List <Igrac>(); string[] lines = System.IO.File.ReadAllLines(filepath); for (int i = 2; i < lines.Count(); i++) { string[] words = lines[i].Split(','); Igrac novi = new Igrac(words[0], words[1], words[2], words[3], words[4], words[5], words[6], words[7], words[8], words[9], words[10], words[11], words[12], words[13], words[14]); temp.Add(novi); } } else { return(lista); } foreach (Igrac i in temp) { foreach (Igrac j in lista) { if (i.Broj == j.Broj) { i.JoinPlayer(j); break; } } } return(temp); }
private void btnDodajIgraca2_Click(object sender, EventArgs e) { try { Igrac temp = new Igrac(int.Parse(txtIgracBroj2.Text), txtIgracIme2.Text, txtIgracPrezime2.Text); ListaIgraca2.Add(temp); DataBind2(); } catch { } }
private void listIgraci2_SelectedIndexChanged(object sender, EventArgs e) { if (listIgraci2.SelectedIndex == -1) { btnBrisiIgraca2.Enabled = false; } else { SelectedPlayer = ListaIgraca2[listIgraci2.SelectedIndex]; btnBrisiIgraca2.Enabled = true; btnBrisiIgraca1.Enabled = false; listIgraci1.SelectedIndex = -1; } }
public void JoinPlayer(Igrac postojeci) { this.saves += postojeci.saves; this.shots += postojeci.shots; this.shotsOnGoal += postojeci.shotsOnGoal; this.goals += postojeci.goals; this.assists += postojeci.assists; this.groundBalls += postojeci.groundBalls; this.error += postojeci.error; this.interception += postojeci.interception; this.turnover += postojeci.turnover; this.penalty += postojeci.penalty; this.faceoff += postojeci.faceoff; this.faceoffWin += postojeci.faceoffWin; }
private void btnLoad2_Click(object sender, EventArgs e) { if (ListaIgraca2.Any()) { DialogResult dialogResult = MessageBox.Show("Ucitavanje novog popisa ce izbrisati trenutni popis igraca. Nastaviti?", "Upozorenje", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.No) { return; } } Stream myStream = null; OpenFileDialog openLoadDialog = new OpenFileDialog(); openLoadDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory; openLoadDialog.Filter = "Team files (*.team)|*.team|All files (*.*)|*.*"; openLoadDialog.FilterIndex = 1; openLoadDialog.RestoreDirectory = true; if (openLoadDialog.ShowDialog() == DialogResult.OK) { try { SetTeamName(openLoadDialog.FileName, txtTim2Ime); if ((myStream = openLoadDialog.OpenFile()) != null) { ListaIgraca2.Clear(); txtIgraci2Dat.Text = openLoadDialog.FileName; string[] lines = System.IO.File.ReadAllLines(openLoadDialog.FileName); string[] words = new string[3]; foreach (string l in lines) { words = l.Split(';'); Igrac temp = new Igrac(int.Parse(words[0]), words[1], words[2]); ListaIgraca2.Add(temp); } DataBind2(); } myStream.Close(); } catch (Exception ex) { MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message); } } }