private void AddItem_Click(object sender, RoutedEventArgs e)
        {
            ShopItem shopItem = new ShopItem();

            shopItem.Name = Iname.Text;
            Int32.TryParse(Icost.Text, out int price);
            shopItem.Price = price;

            shopItem.Description = Idescr.Text;

            if (Photo.FileName != string.Empty)
            {
                shopItem.Photo = Photo.FileName;
            }

            ShopItemsList.Add((ShopItem)shopItem);

            var results = new List <ValidationResult>();
            var context = new ValidationContext(shopItem);

            string filename = @"F:\OOP\ShopItemList.xml";

            XmlSerializeWrapper.Serialize(ShopItemsList, filename);

            MessageBox.Show("Информация добавлена в файл ShopItemList.xml");
        }
        private static List <Fuel> ReadData()
        {
            string filename = @"F:\OOP\FuelList.xml";

            List <Fuel> deserializeDisciplines = new List <Fuel>();

            deserializeDisciplines = XmlSerializeWrapper.Deserialize <List <Fuel> >(filename);//.ToString();
            return(deserializeDisciplines);
        }
        public ShowItemsPage()
        {
            InitializeComponent();

            try
            {
                items = XmlSerializeWrapper.Deserialize <BindingList <Fuel> >(@"F:\OOP\FuelList.xml");
                fuelGrid.ItemsSource = items;
            }
            catch
            { MessageBox.Show($"Десериализация была прервана."); }
        }
Beispiel #4
0
        public ShowShopItemsPage()
        {
            InitializeComponent();

            try
            {
                shopItems = XmlSerializeWrapper.Deserialize <BindingList <ShopItem> >(@"F:\OOP\ShopItemList.xml");
                shopItemsGrid.ItemsSource = shopItems;
            }
            catch
            { MessageBox.Show($"Десериализация была прервана."); }
        }
        //public int r;
        private void AddFuel_Click(object sender, RoutedEventArgs e)
        {
            Fuel fuel = new Fuel();

            fuel.Name = Fname.Text;
            Int32.TryParse(Fcost.Text, out int price);
            fuel.Price = price;

            FuelList.Add(fuel);

            var results = new List <ValidationResult>();
            var context = new ValidationContext(fuel);

            string filename = @"F:\OOP\FuelList.xml";

            XmlSerializeWrapper.Serialize(FuelList, filename);

            MessageBox.Show("Информация добавлена в файл FuelList.xml");
        }