/// <summary> /// Callback for when the Add Expense button is clicked. /// </summary> /// <param name="sender">Object that triggered the event.</param> /// <param name="e">Arguments for the click event.</param> private async void AddExpenseButton_Clicked(object sender, EventArgs e) { // Check if the maximum number of entries for the day is // already reached if (this.entries.Count >= MAX_ENTRIES_PER_DAY) { ToastController.ShortToast("Cannot add any more records for the day!"); return; } // Create a new record book entry and insert it into the // database to obtain a unique Id ExpenseRecordEntry entry = new ExpenseRecordEntry() { HorseId = HorseManager.GetInstance().ActiveHorse.Id, Date = date }; await AppDatabase.GetInstance().Save <ExpenseRecordEntry>(entry); // Add a new record view to the stack this.entries.Add(entry); ExpenseRecordView view = new ExpenseRecordView(entry); this.ExpenseRecordStack.Children.Add(view); }
/// <summary> /// Default constructor for the page. /// </summary> public ExpenseRecordEditPage(ExpenseRecordEntry entry) { // Initialize the component NavigationPage.SetHasNavigationBar(this, false); this.BindingContext = this.entry = entry; InitializeComponent(); // Set the modified property of the page to "false" this._modified = false; }