public void Create(Expense pExpense)
        {
            Database db = GetDataBase();

            db.Expenses.InsertOnSubmit(pExpense);
            db.SubmitChanges();
        }
        public void Delete(Expense expense)
        {
            Database db = GetDataBase();
            var query = from exp in db.Expenses where exp.id == exp.id select exp;
            db.Expenses.DeleteOnSubmit(query.ToList()[0]);

            db.SubmitChanges();
        }
 public void Update(Expense pExpense)
 {
     Database db = GetDataBase();
     var query = from exp in db.Expenses
                 where exp.id == pExpense.id
                 select exp;
     var expenseDoBanco = query.ToList()[0];
     expenseDoBanco.description = pExpense.description;
 }
        private void onClickSave(object sender, EventArgs e)
        {
            NavigationService.GoBack();

            if (expUpdate == null)
            {
                Expense expense = new Expense
                {
                    description = txtDescricao.Text,
                    values = decimal.Parse(txtValor.Text)
                };
                ex.Create(expense);
            }
            else
            {
                expUpdate.description = txtDescricao.Text;
                expUpdate.values = decimal.Parse(txtValor.Text);

                ex.Update(expUpdate);
            }
        }
 private void onSelectedChanged(object sender, SelectionChangedEventArgs e)
 {
     expense = (sender as ListBox).SelectedItem as Expense;
 }
 private void onClickNew(object sender, EventArgs e)
 {
     expense = null;
     NavigationService.Navigate(new Uri("/NewExpense.xaml", UriKind.Relative));
 }