public int SaveDebtSync(Debt debt) { var result = database.Table <Debt>().ToList(); foreach (Debt i in result) { if (debt.ID == i.ID) { return(database.Update(debt)); } } return(database.Insert(debt)); }
public AddPage(ItemsList itemsList) { InitializeComponent(); this.itemsList = itemsList; item = new Item(); transaction = new Transaction(); if (itemsList.Type == 0) { txtBlkHeader.Text = "Přidat výdaj"; } else { debt = new Debt(); txtBlkHeader.Text = "Přidat dluh"; ShowRaiseField(); } }
private void btnSend_Click(object sender, RoutedEventArgs e) { Item newItem = item; newItem.Name = txtName.Text; newItem.Cost = int.Parse(txtCost.Text); App.Database.SaveItemSync(newItem); newItem = App.Database.GetAllItemsSync().Last(); Transaction newTransaction = transaction; newTransaction.IDItem = newItem.ID; newTransaction.DateTransaction = dpDate.SelectedDate.Value; App.Database.SaveTransactionSync(newTransaction); if (itemsList.Type == 1) { Debt newDebt = debt; newDebt.IDTransaction = newTransaction.ID; newDebt.NextDateToPay = newTransaction.DateTransaction; newDebt.RaiseCounter = 0; newDebt.RaisePercentage = int.Parse(txtRaise.Text); App.Database.SaveDebtSync(newDebt); } if (itemsList.ID != 0) { ItemTies newItemTies = new ItemTies(); newItemTies.IDItem = newItem.ID; newItemTies.IDItemsList = itemsList.ID; App.Database.SaveItemTiesSync(newItemTies); } NavigationServiceSingleton.GetNavigationService().NavigateBack(); }