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"); } }
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()); } }