private void AddItemBtn_Click(object sender, RoutedEventArgs e) { try { if (Int32.Parse(AmountUpdate.Text) > 0) { DBGetItems db = new DBGetItems(); List <Entity.ExtendedItem> item_list = db.GetItems(); foreach (ExtendedItem i in item_list) { if (i.name.Equals(Items.SelectedItem.ToString())) { i.amount = Int32.Parse(AmountUpdate.Text); i.UpdateValues(); invoice.items.Add(i); } } SetDataGrid(); } }catch (Exception ex) { Debug.WriteLine(ex.Message); } }
private void AddItemBtn_Click(object sender, RoutedEventArgs e) { try { if (Int32.Parse(Amount.Text) > 0) { DBUpdateInvoice db_update = new DBUpdateInvoice(); DBGetItems db_items = new DBGetItems(); ExtendedItem chosen_item = null; List <Entity.ExtendedItem> items = db_items.GetItems(); foreach (ExtendedItem i in items) { if (i.name.Equals(AvaiableItems.SelectedItem)) { chosen_item = i; chosen_item.amount = Int32.Parse(Amount.Text); } } if (chosen_item != null) { chosen_item.UpdateValues(); invoice.items.Add(chosen_item); } db_update.UpdateItemList(invoice, chosen_item); SetComboboxItem(); Amount.Text = "" + 0; } }catch (Exception ex) { Debug.WriteLine(ex.Message); } }