/// <summary> /// Creates a new expendature. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CreateExpendature(object sender, EventArgs e) { // Get the value from the spinner. var picker = FindViewById <NumberPicker>(Resource.Id.Kilometers); int distanceCovered = this.NumberConverter.ConvertToDistance(picker.Value); // Get the payment. string value = FindViewById <EditText>(Resource.Id.InputNumber).Text; if (!String.IsNullOrEmpty(value)) { // Get the value. int payment = this.NumberConverter.ConvertToDistance(int.Parse(value)); // Get the type. string type = FindViewById <EditText>(Resource.Id.EntryType).Text; // Create the new value. var expendature = new Expendature(type, distanceCovered, payment); // Add to the database. (( CarMonApp )this.Application).ExpendatureHandler.Add(expendature); // We are done. Stop the activity. Finish(); } else { // No value, show an error dialog. ActivityUtilities.Inform(this, "Please enter a number."); } }