public static void Read_Championships() { Containers.championship_list.Clear(); XmlDocument doc = new XmlDocument(); doc.Load("Championships.xml"); XmlNodeList list = doc.GetElementsByTagName("Championship"); BinaryFormatter f = new BinaryFormatter(); FileStream w = new FileStream("Championships.xml", FileMode.Open); for (int i = 0; i < list.Count; i++) { XmlNodeList list_2 = list[i].ChildNodes; string type = list_2[0].Name; string tvalue = list_2[0].InnerText; string place = list_2[1].Name; string pvalue = list_2[1].InnerText; string senior = list_2[1].Name; string svalue = list_2[1].InnerText; string numberofresults = list_2[2].Name; string nvval = list_2[2].InnerText; Championships c = new Championships(tvalue, pvalue, bool.Parse(svalue)); championship_list.Add(c); } w.Close(); }
public static void Read_Championships() { //Containers.championship_list.Clear(); XmlDocument doc = new XmlDocument(); doc.Load("Championships.xml"); XmlNodeList list = doc.GetElementsByTagName("Championship"); FileStream w = new FileStream("Championships.xml", FileMode.Open); for (int i = 0; i < list.Count; i++) { XmlNodeList list_2 = list[i].ChildNodes; string type = list_2[0].Name; string tvalue = list_2[0].InnerText; string place = list_2[1].Name; string pvalue = list_2[1].InnerText; string senior = list_2[2].Name; string svalue = list_2[2].InnerText; string name = list_2[3].Name; string nameval = list_2[3].InnerText; Championships c = new Championships(pvalue, tvalue, svalue, nameval); championship_list.Add(c); } w.Close(); }
private void button_Click(object sender, RoutedEventArgs e) { if (Max_res.IsChecked == true) { Championships max = new Championships(); int maxx_res = 0; for (int i = 0; i < Containers.championship_list.Count(); i++) { if (Containers.championship_list[i].Getresults() >= maxx_res) { maxx_res = Containers.championship_list[i].Getresults(); max = Containers.championship_list[i]; } } MessageBox.Show(max.getName() + ' ' + max.GetPlace()); } if (Min_Res.IsChecked == true) { Championships min = new Championships(); int minn_res = 1000000; for (int i = 0; i < Containers.championship_list.Count(); i++) { if (Containers.championship_list[i].Getresults() <= minn_res) { minn_res = Containers.championship_list[i].Getresults(); min = Containers.championship_list[i]; } } MessageBox.Show(min.getName() + ' ' + min.GetPlace()); } }
public static Championships operator +(Championships b, Championships c) { Championships championship = b; championship.Settotalresults(b.Gettotalresults() + c.Gettotalresults()); return(championship); }
public static void write_PlayerResult(Championships c) { if (!File.Exists("Results.xml")) { XmlTextWriter document = new XmlTextWriter("Results.xml", Encoding.UTF8); document.Formatting = Formatting.Indented; document.WriteStartDocument(); document.WriteStartElement("Results"); document.WriteStartElement("Result"); document.WriteStartElement("Player_ID"); document.WriteString(Enter_ID.playerid); document.WriteEndElement(); document.WriteStartElement("Championship_Type"); document.WriteString(c.GetType().ToString()); document.WriteEndElement(); document.WriteStartElement("Championship_Place"); document.WriteString(c.GetPlace()); document.WriteEndElement(); document.WriteStartElement("Results"); document.WriteString(c.Getresults().ToString()); document.WriteEndElement(); document.WriteEndElement(); document.WriteEndElement(); document.WriteEndDocument(); document.Close(); } else { XmlDocument doc = new XmlDocument(); doc.Load("Results.xml"); XmlNode resultt = doc.CreateElement("Result"); XmlNode typee = doc.CreateElement("Championship_Type"); typee.InnerText = c.GetType().ToString(); resultt.AppendChild(typee); XmlNode placee = doc.CreateElement("Championship_Place"); placee.InnerText = c.GetPlace(); resultt.AppendChild(placee); XmlNode res = doc.CreateElement("Results"); res.InnerText = (c.Getresults().ToString()); resultt.AppendChild(res); doc.DocumentElement.AppendChild(resultt); doc.Save("Results.xml"); } }
public static void read_players_results() { Containers.Players_results.Clear(); XmlDocument doc = new XmlDocument(); doc.Load("Results.xml"); XmlNodeList list = doc.GetElementsByTagName("Result"); FileStream w = new FileStream("Results.xml", FileMode.Open); for (int i = 0; i < list.Count; i++) { XmlNodeList list_2 = list[i].ChildNodes; string player_ID = list_2[0].Name; string ivalue = list_2[0].InnerText; string Championship_type = list_2[1].Name; string ctvalue = list_2[1].InnerText; string Championship_place = list_2[2].Name; string cpvalue = list_2[2].InnerText; string results = list_2[3].Name; string reval = list_2[3].InnerText; string name = list_2[4].Name; string naval = list_2[4].InnerText; for (int l = 0; l < Player_list.Count; l++) { if (Player_list[l].getId() == ivalue) { Championships c = new Championships(cpvalue, ctvalue, int.Parse(reval), naval); Player_list[l].champion.Add(c); Player_list[l].set_results(Player_list[l].get_results() + int.Parse(reval)); } } } w.Close(); }
public static void read_players_results() { Containers.Players_results.Clear(); XmlDocument doc = new XmlDocument(); doc.Load("Results.xml"); XmlNodeList list = doc.GetElementsByTagName("Result"); FileStream w = new FileStream("Results.xml", FileMode.Open); for (int i = 0; i < list.Count; i++) { XmlNodeList list_2 = list[i].ChildNodes; string player_ID = list_2[0].Name; string ivalue = list_2[0].InnerText; string Championship_type = list_2[1].Name; string ctvalue = list_2[1].InnerText; string Championship_place = list_2[2].Name; string cpvalue = list_2[2].InnerText; string results = list_2[3].Name; string reval = list_2[3].InnerText; string name = list_2[4].Name; string naval = list_2[4].InnerText; for (int l = 0; l < Player_list.Count; l++) { if (Player_list[l].getId() == ivalue) { Championships c = new Championships(cpvalue, ctvalue, int.Parse(reval), naval); Player_list[l].champion.Add(c); Player_list[l].set_results(Player_list[l].get_results() + int.Parse(reval)); } } for (int l = 0; l < Player_list.Count; l++) { bool done = false; if (Player_list[l].getId() == ivalue) { for (int z = 0; z < Club_list.Count; z++) { if (Player_list[l].getClubName() == Club_list[z].getClubName()) { for (int m = 0; m < Club_list[z].champList.Count; m++) { if (Club_list[z].champList[m].getName() == naval) { Club_list[z].champList[m].Setresults(Club_list[z].champList[m].Getresults() + int.Parse(reval)); done = true; break; } } if (!done) { Championships c = new Championships(cpvalue, ctvalue, int.Parse(reval), naval); Club_list[z].champList.Add(c); } } } } } for (int k = 0; k < championship_list.Count; k++) { if (championship_list[k].getName() == naval) { championship_list[k].Settotalresults(championship_list[k].Gettotalresults() + int.Parse(reval)); break; } } for (int l = 0; l < Player_list.Count; l++) { if (Player_list[l].getId() == ivalue) { for (int k = 0; k < Team_list.Count; k++) { if (Team_list[k].getTeam() == Player_list[l].get_teamname()) { for (int a = 0; a < Club_list.Count; a++) { if (Club_list[a].getClubName() == Player_list[l].getClubName()) { Team_list[k].Settotalresults(Team_list[k].Gettotalresults() + int.Parse(reval)); Club_list[a].Settotalresults(Club_list[a].Gettotalresults() + int.Parse(reval)); } } } } } } } w.Close(); }
private void add_Click(object sender, RoutedEventArgs e) { string sen; if (Senior.IsChecked == true) { sen = "Senior"; } else { sen = "Junior"; } bool found = false; if (type.Text == "" || (Senior.IsChecked == false && junior.IsChecked == false) || place.Text == "" || name.Text == "") { MessageBox.Show("Please fill the required information !"); } else { for (int i = 0; i < Containers.championship_list.Count; i++) { if ((type.Text == Containers.championship_list[i].Gettype()) && (place.Text == Containers.championship_list[i].GetPlace()) && (sen == Containers.championship_list[i].getSenior()) && (name.Text == Containers.championship_list[i].getName())) { found = true; } } if (found == true) { MessageBox.Show("Championship Already Exists !"); } else { Championships added = new Championships(place.Text, type.Text, sen, name.Text); Containers.championship_list.Add(added); if (!File.Exists("Championships.xml")) { XmlTextWriter document = new XmlTextWriter("Championships.xml", Encoding.UTF8); document.Formatting = Formatting.Indented; document.WriteStartDocument(); document.WriteStartElement("Championships"); document.WriteStartElement("Championship"); document.WriteStartElement("Type_of_Championship"); document.WriteString(type.Text); document.WriteEndElement(); document.WriteStartElement("Place_of_Championship"); document.WriteString(place.Text); document.WriteEndElement(); document.WriteStartElement("Senior"); document.WriteString(sen); document.WriteEndElement(); document.WriteStartElement("Name"); document.WriteString(name.Text); document.WriteEndElement(); document.WriteEndElement(); document.WriteEndElement(); document.WriteEndDocument(); document.Close(); MessageBox.Show("Championship Successfuly Added."); } else { XmlDocument doc = new XmlDocument(); doc.Load("Championships.xml"); XmlNode Championshipp = doc.CreateElement("Championship"); XmlNode typee = doc.CreateElement("Type_of_Championship"); typee.InnerText = type.Text; Championshipp.AppendChild(typee); XmlNode placee = doc.CreateElement("Place_of_Championship"); placee.InnerText = place.Text; Championshipp.AppendChild(placee); XmlNode senior = doc.CreateElement("Senior"); senior.InnerText = sen; Championshipp.AppendChild(senior); XmlNode na = doc.CreateElement("Name"); na.InnerText = name.Text; Championshipp.AppendChild(na); doc.DocumentElement.AppendChild(Championshipp); doc.Save("Championships.xml"); MessageBox.Show("Championship Successfuly Added."); } } } }