private void button_Click(object sender, RoutedEventArgs e) { List <Sponsers> x = Containers.Sponsor_list; for (int i = 0; i < x.Count; i++) { for (int j = i + 1; j < x.Count; j++) { if (x[i].GetSponsor_price() > x[j].GetSponsor_price()) { Sponsers tmp = x[i]; x[i] = x[j]; x[j] = tmp; } } } }
public static void Read_Sponsor() { Containers.Sponsor_list.Clear(); XmlDocument doc = new XmlDocument(); doc.Load("Sponsers.xml"); XmlNodeList list = doc.GetElementsByTagName("Sponser"); FileStream w = new FileStream("Sponsers.xml", FileMode.Open); for (int i = 0; i < list.Count; i++) { XmlNodeList list_2 = list[i].ChildNodes; string Name = list_2[0].Name; string nvalue = list_2[0].InnerText; String price = list_2[1].Name; String pvalue = list_2[1].InnerText; Sponsers t = new Sponsers(nvalue, int.Parse(pvalue)); Sponsor_list.Add(t); } w.Close(); }
private void button_Click(object sender, RoutedEventArgs e) { List <Sponsers> x = Containers.Sponsor_list; for (int i = 0; i < x.Count; i++) { for (int j = i + 1; j < x.Count; j++) { if (x[i].GetSponsor_price() < x[j].GetSponsor_price()) { Sponsers tmp = x[i]; x[i] = x[j]; x[j] = tmp; } } } List <string> tName = new List <string>(); List <int> tprice = new List <int>(); List <int> tindex = new List <int>(); for (int i = 0; i < x.Count; i++) { tindex.Add(i + 1); tName.Add(x[i].GetSponser_name()); tprice.Add(x[i].GetSponsor_price()); } listBox.ItemsSource = tName; listBox1.ItemsSource = tprice; listBox2.ItemsSource = tindex; textBox.Text = tName[0]; best_sponsor = tprice[0]; }