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; } }