private void OnAddButtonClick(object sender, RoutedEventArgs e) { if (rbStock.IsChecked.GetValueOrDefault()) { ComboBoxItem cbItem = (ComboBoxItem)cbMeasurement.SelectedItem; Goods item = new Goods(int.Parse(tbID.Text.Trim()), tbCategory.Text, tbName.Text.Trim(), decimal.Parse(tbSellPrice.Text.Trim()), decimal.Parse(tbDiscount.Text.Trim()), decimal.Parse(tbValue.Text.Trim()), cbItem.Content.ToString().Trim(), 0); List<Goods> goods = DataHandler.Instance.LoadGoods().ToList<Goods>(); goods.Add(item); DataHandler.Instance.SaveGoods(goods); Window artChoice = new ArticleChoice(); artChoice.Show(); this.Close(); } }
/// <summary> /// Loads goods' list from storage. /// </summary> /// <returns>A list of goods on stock.</returns> public IEnumerable<Goods> LoadGoods() { var goods = new Goods(0, null, null, 0m, 0m, 0m, null, 0m); return this.LoadData(PathToGoodsFile, goods).Cast<Goods>(); }