protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Add action bar SupportRequestWindowFeature(WindowCompat.FeatureActionBar); // Set our view from the "activity_view_entry" layout resource SetContentView(Resource.Layout.activity_view_entry); bookKeeperManager = BookKeeperManager.Instance; // Get our views from the layout resource date = FindViewById <TextView>(Resource.Id.view_date_text); description = FindViewById <TextView>(Resource.Id.view_entry_description_text); transactionAccount = FindViewById <TextView>(Resource.Id.view_type_text); moneyAccount = FindViewById <TextView>(Resource.Id.view_to_from_account_text); amount = FindViewById <TextView>(Resource.Id.view_total_with_tax_text); taxRate = FindViewById <TextView>(Resource.Id.view_tax_text); receiptImage = FindViewById <ImageView>(Resource.Id.view_receipt_image); entryId = Intent.GetIntExtra("EntryId", -1); if (entryId != -1) { Entry e = bookKeeperManager.GetEntry(entryId); Account account = bookKeeperManager.GetAccount(e.AccountNumber); Account cashAccount = bookKeeperManager.GetAccount(e.MoneyAccountNumber); TaxRate rate = bookKeeperManager.GetTaxRate(e.TaxId); date.Text = e.Date; description.Text = e.Description; transactionAccount.Text = account.ToString(); moneyAccount.Text = cashAccount.ToString(); amount.Text = e.TotalAmount.ToString(); taxRate.Text = rate.ToString(); if ((e.ImagePath != null) && (e.ImagePath.Length > 0)) { int height = Resources.DisplayMetrics.HeightPixels; int width = receiptImage.Width; Bitmap bitmap = ImageUtils.LoadAndScaleBitmap(e.ImagePath, width, height); receiptImage.SetImageBitmap(bitmap); } } }
private void SetUpEntryDataForUpdate() { date = DateTime.Today; // Get entry via id and populate fields entry = bookKeeperManager.GetEntry(entryId); entryDescription.Text = entry.Description; dateOfEntry.Text = entry.Date; totalWithTax.Text = entry.TotalAmount.ToString(); Account account = bookKeeperManager.GetAccount(entry.AccountNumber); if (account.Type == Account.AccountType.Expense) { cost_radio.Checked = true; populateTypeSpinner(); typeSpinner.SetSelection(bookKeeperManager.ExpenseAccounts.FindIndex(a => a.Number == account.Number), true); } else if (account.Type == Account.AccountType.Income) { income_radio.Checked = true; populateTypeSpinner(); typeSpinner.SetSelection(bookKeeperManager.MoneyAccounts.FindIndex(a => a.Number == account.Number), true); } PopulateAccountSpinner(); account = bookKeeperManager.GetAccount(entry.MoneyAccountNumber); accountSpinner.SetSelection(bookKeeperManager.MoneyAccounts.FindIndex(a => a.Number == account.Number), true); PopulateTaxSpinner(); TaxRate taxRate = bookKeeperManager.GetTaxRate(entry.TaxId); taxSpinner.SetSelection(bookKeeperManager.TaxRates.FindIndex(a => a.Id == taxRate.Id), true); if (entry.ImagePath != null && entry.ImagePath.Length > 0) { int height = Resources.DisplayMetrics.HeightPixels; int width = receiptImage.Width; Bitmap bitmap = ImageUtils.LoadAndScaleBitmap(entry.ImagePath, width, height); receiptImage.SetImageBitmap(bitmap); } else { imagePathUri = null; } }
private void setEntryVal(object sender, EventArgs e) { bool income; type = (Account)typeOfAccountSpinner.SelectedItem; money = (Account)moneyAccountsSpinner.SelectedItem; taxRate = (TaxRate)taxRatesSpinner.SelectedItem; int amount = int.Parse(number.Text); desc = FindViewById <EditText>(Resource.Id.editDesc).Text; date = FindViewById <EditText>(Resource.Id.editDatum).Text; //if (type.typeOfAccount.Equals("Inkomst")) if (incomeButton.Checked) { income = true; } else { income = false; } //sätt det nya entryt till sina properties där id skall ändras Entry eg = new Entry() { idTypeAccount = type.Id, idMoneyAccount = money.Id, idTaxrate = taxRate.Id, TaxRate = taxRate.Moms, isIncome = income, date = date, desciption = desc, total = amount }; Console.WriteLine(eg.idTaxrate); BookkeeperManager.Instance.AddEntry(eg); }
private BookKeeperManager() { DBPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); DBPath += "\\database.db"; SQLiteConnection db = new SQLiteConnection(DBPath); db.CreateTable <TaxRate>(); if (db.Table <TaxRate>().Count() == 0) { TaxRate t = new TaxRate() { Tax = 6 }; db.Insert(t); t = new TaxRate() { Tax = 12 }; db.Insert(t); t = new TaxRate() { Tax = 25 }; db.Insert(t); } db.CreateTable <Account>(); if (db.Table <Account>().Count() == 0) { Account a = new Account() { Number = 3000, Name = "Försäljning", Type = Account.AccountType.Income }; db.Insert(a); a = new Account() { Number = 3040, Name = "Försäljning av tjänster", Type = Account.AccountType.Income }; db.Insert(a); a = new Account() { Number = 5400, Name = "Förbrukningsinventarier och förbrukningsmaterial", Type = Account.AccountType.Expense }; db.Insert(a); a = new Account() { Number = 2013, Name = "Övriga egna uttag", Type = Account.AccountType.Expense }; db.Insert(a); a = new Account() { Number = 5900, Name = "Reklam och PR", Type = Account.AccountType.Expense }; db.Insert(a); a = new Account() { Number = 1910, Name = "Kassa", Type = Account.AccountType.Money }; db.Insert(a); a = new Account() { Number = 1930, Name = "Företagskonto", Type = Account.AccountType.Money }; db.Insert(a); a = new Account() { Number = 2018, Name = "Egna insättningar", Type = Account.AccountType.Money }; db.Insert(a); } db.CreateTable <Entry>(); if (db.Table <Entry>().Count() == 0) { Entry e = new Entry() { Date = "2015-02-02", Description = "Faktura", AccountNumber = 3000, MoneyAccountNumber = 1930, TotalAmount = 30000, TaxId = 1, ImagePath = "" }; db.Insert(e); e = new Entry() { Date = "2015-02-03", Description = "Faktura", AccountNumber = 3000, MoneyAccountNumber = 1930, TotalAmount = 24109, TaxId = 2, ImagePath = "" }; db.Insert(e); e = new Entry() { Date = "2015-02-04", Description = "Köp av misosoppa", AccountNumber = 5400, MoneyAccountNumber = 2018, TotalAmount = 299, TaxId = 1, ImagePath = "" }; db.Insert(e); e = new Entry() { Date = "2015-02-05", Description = "Köpte annons i aftonbladet", AccountNumber = 5900, MoneyAccountNumber = 1930, TotalAmount = 10000, TaxId = 2, ImagePath = "" }; db.Insert(e); } db.Close(); }
private BookkeeperManager() { //skapa databaskoppling i konstruktorn dbPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); dbPath += "\\database.db"; db = new SQLiteConnection(dbPath); //skapa tabellen Account db.CreateTable <Account>(); //entries = new List<Entry>(); //Entries.Add(new Entry() { Id = 10 }); db.DeleteAll <Account>(); Account a1 = new Account() { Name = "Lön (3000)", typeOfAccount = "Income" }; Account a2 = new Account() { Name = "PRintäkter (2001)", typeOfAccount = "Income" }; Account a3 = new Account() { Name = "Underhåll (4000)", typeOfAccount = "Outcome" }; Account a4 = new Account() { Name = "Kassa (5000)", typeOfAccount = "Money" }; db.Insert(a1); db.Insert(a2); db.Insert(a3); db.Insert(a4); outcomeAccounts = db.Table <Account>().Where(a => a.typeOfAccount == "Outcome").ToList(); incomeAccounts = db.Table <Account>().Where(a => a.typeOfAccount == "Income").ToList(); moneyAccounts = db.Table <Account>().Where(a => a.typeOfAccount == "Money").ToList(); db.Close(); db = new SQLiteConnection(dbPath); db.CreateTable <TaxRate>(); db.DeleteAll <TaxRate>(); TaxRate t1 = new TaxRate() { Moms = 0.05 }; TaxRate t2 = new TaxRate() { Moms = 0.25 }; TaxRate t3 = new TaxRate() { Moms = 0.50 }; db.Insert(t1); db.Insert(t2); db.Insert(t3); taxrates = db.Table <TaxRate>().ToList(); db.Close(); db = new SQLiteConnection(dbPath); db.CreateTable <Entry>(); entries = db.Table <Entry>().ToList(); db.Close(); }