Exemple #1
0
        /*
         * Sets up the Save button for creating a new entry, so that the new entry
         * is added in the database.
         */
        private void SetSaveButton()
        {
            Button saveButton = FindViewById <Button>(Resource.Id.save_button);

            saveButton.Click += delegate {
                double  amount       = Double.Parse(FindViewById <EditText>(Resource.Id.amount_edit).Text);
                string  description  = FindViewById <EditText>(Resource.Id.description_edit).Text;
                Account moneyAccount = bookkeeperManager.MoneyAccounts[moneyAccountSpinner.SelectedItemPosition];
                Account incomeOrExpenseAccount;
                if (isIncomeAccount)
                {
                    incomeOrExpenseAccount = bookkeeperManager.IncomeAccounts[typeSpinner.SelectedItemPosition];
                }
                else
                {
                    incomeOrExpenseAccount = bookkeeperManager.ExpenseAccounts[typeSpinner.SelectedItemPosition];
                }
                TaxRate  rate = bookkeeperManager.TaxRates[taxSpinner.SelectedItemPosition];
                DateTime date = selectedDate;

                Entry entry = new Entry(amount, description, isIncomeAccount, moneyAccount.Nr, incomeOrExpenseAccount.Nr,
                                        rate.Rate, date);
                bookkeeperManager.AddEntry(entry);
                StartActivity(new Intent(this, typeof(MainActivity)));
            };
        }
        public CustomListAdapter(Activity context, SQLiteConnection db)
        {
            this.context        = context;
            bookkeeper.database = db;

            //Must create temp-reference to database
            Entry tempEntry = new Entry();

            bookkeeper.AddEntry(tempEntry);
            bookkeeper.database.Delete(tempEntry);

            //Create a list of entries to satisfy the Count method
            TableQuery <Entry> query = bookkeeper.database.Table <Entry>().Where(x => x.Id >= 1);

            foreach (Entry e in query)
            {
                entryList.Add(e);
            }
        }
Exemple #3
0
        void SaveInput()
        {
            Button addEntryButton = FindViewById <Button>(Resource.Id.addEntryButton);

            addEntryButton.Click += delegate
            {
                EditText dateEditText = FindViewById <EditText>(Resource.Id.dateEditText);
                string   date         = dateEditText.Text;

                EditText descriptionEditText = FindViewById <EditText>(Resource.Id.descriptionEditText);
                string   description         = descriptionEditText.Text;

                EditText totalAmmountEditText = FindViewById <EditText>(Resource.Id.totalTaxEditText);
                string   totalAmmount         = totalAmmountEditText.Text;

                Entry newEntry = new Entry(date, description, typeOfAccount, toFromAccount, totalAmmount, Convert.ToDouble(taxRate));
                bookkeeper.AddEntry(newEntry);

                //TODO: Reset method with "New entry added" or "Saved" toast and exit activity
            };
        }