Exemplo n.º 1
0
        public void ToXMLSortedMilkProducts()
        {
            List <IProduct> lm = new List <IProduct>();

            foreach (var item in prod)
            {
                if (item.GetType() == typeof(Milk) || item.GetType() == typeof(Kefir))
                {
                    TextBox textBox = new TextBox();
                    textBox.Text = "  ";

                    MilkProducts l = (MilkProducts)item;
                    l.PriceNotHigher(300, textBox);

                    lm.Add(l);
                }
            }
            try
            {
                var xEle = new XElement("Products",
                                        from ll in lm
                                        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("SortedMilkProducts.xml");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemplo n.º 2
0
        public void SortedMilkProducts(TextBox textBox)
        {
            textBox.Text += "\r\nThe list of milk products with price less than set\r\n";

            foreach (var item in prod)
            {
                if (item.GetType() == typeof(Milk) || item.GetType() == typeof(Kefir))
                {
                    MilkProducts l = (MilkProducts)item;
                    l.PriceNotHigher(300, textBox);
                }
            }
        }