public void ToXMLSortedMeatProducts() { List <IProduct> mp = new List <IProduct>(); foreach (var item in prod) { if (item.GetType() == typeof(Meat) || item.GetType() == typeof(Sausage)) { TextBox textBox = new TextBox(); textBox.Text = " "; MeatProducts mm = (MeatProducts)item; mm.HigherQuantity(1, textBox); mp.Add(mm); } } try { var xEle = new XElement("Products", from ll in mp select new XElement("Product", new XElement("Name", ll.Name), new XElement("Price", ll.Price), new XElement("Quantity", ll.Quantity), new XElement("ID", ll.ID) )); xEle.Save("SortedMeatProducts.xml"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void SortedMeatProducts(TextBox textBox) { textBox.Text += "\r\nThe list of Meat Products with quantity highter than set\r\n"; foreach (var item in prod) { if (item.GetType() == typeof(Sausage) || item.GetType() == typeof(Meat)) { MeatProducts l = (MeatProducts)item; l.HigherQuantity(1, textBox); } } }