protected async void ButtonAddEditExpense_Click(object sender, EventArgs e) { double quantity; double unitPrice; double unitCost; string pickerCategory = ""; //if(_pickerCategory.SelectedIndex < 0) //{ //await DisplayAlert("Category", "Please enter a valid Category.", "OK"); //return; //} try { quantity = double.Parse(_entryQuantity.Text); } catch { await DisplayAlert("Quantity", "Please enter a valid Quantity.", "OK"); return; } try { unitPrice = double.Parse(_entryUnitPrice.Text); } catch { await DisplayAlert("Unit Price", "Please enter a valid Unit Price.", "OK"); return; } try { unitCost = double.Parse(_entryUnitCost.Text); } catch { await DisplayAlert("Unit Cost", "Please enter a valid Unit Cost.", "OK"); return; } _vm.ExpenseDate = _datePickerExpenseDate.Date; // dch rkl 10/14/2016 Show Code + Description in Expense Category Dropdown BEGIN try { pickerCategory = _pickerCategory.Items[_pickerCategory.SelectedIndex].ToString().Split(' ')[0].ToString().Trim(); } catch (Exception ex) { } _vm.ExpenseCategory = pickerCategory; //_vm.ExpenseCategory = (_pickerCategory.Items[_pickerCategory.SelectedIndex]); // dch rkl 10/14/2016 Show Code + Description in Expense Category Dropdown END // dch rkl 10/14/2016 Show Code + Description in Charge Code Dropdown BEGIN string pickerChargeCode = ""; try { pickerChargeCode = _pickerChargeCode.Items[_pickerChargeCode.SelectedIndex].ToString().Split(' ')[0].ToString().Trim(); } catch (Exception ex) { } //_vm.ExpenseChargeCode = (_pickerChargeCode.Items[_pickerChargeCode.SelectedIndex]); _vm.ExpenseChargeCode = pickerChargeCode; // dch rkl 10/14/2016 Show Code + Description in Charge Code Dropdown END _vm.ExpenseQuantity = quantity; _vm.ExpenseUnitOfMeasure = _entryUnitOfMeasure.Text; _vm.ExpenseUnitCost = unitCost; _vm.ExpenseUnitPrice = unitPrice; _vm.ExpenseIsReimbursable = _switchIsReimbursable.IsToggled; _vm.ExpenseIsChargeableToCustomer = _switchChargeCustomer.IsToggled; _vm.ExpenseBillingDescription = _editorDescription.Text; _vm.SaveExpenseItem(); await Navigation.PopAsync(); }
private void ButtonAddEditExpense_Click(object sender, RoutedEventArgs e) { double quantity; double unitPrice; double unitCost; // dch rkl 11/21/2016 Per Jeanne, do not require a category //if (_pickerCategory.SelectedIndex < 0) //{ // //await DisplayAlert("Category", "Please enter a valid Category.", "OK"); // var result = MessageBox.Show("Please entery a valid category.", "Category", MessageBoxButton.OK); // return; //} try { decimal markup = decimal.Parse(_entryMarkupPercentage.Text); } catch { var result = MessageBox.Show("Please enter a valid markup percentage", "Markup Percent", MessageBoxButton.OK); return; } try { quantity = double.Parse(_entryQuantity.Text); } catch { //await DisplayAlert("Quantity", "Please enter a valid Quantity.", "OK"); var result = MessageBox.Show("Please enter a valid quantity.", "Quantity", MessageBoxButton.OK); return; } try { unitPrice = double.Parse(_entryUnitPrice.Text); } catch { //await DisplayAlert("Unit Price", "Please enter a valid Unit Price.", "OK"); var result = MessageBox.Show("Please enter a valid unit price.", "Unit Price", MessageBoxButton.OK); return; } try { unitCost = double.Parse(_entryUnitCost.Text); } catch { //await DisplayAlert("Unit Cost", "Please enter a valid Unit Cost.", "OK"); var result = MessageBox.Show("Please enter a valid unit cost.", "Unit Cost", MessageBoxButton.OK); return; } if (_pickerChargeCode.SelectedIndex == -1) { var result = MessageBox.Show("Please select a valid charge code.", "Charge Code", MessageBoxButton.OK); return; } _vm.ExpenseDate = (DateTime)_datePickerExpenseDate.SelectedDate; // dch rkl 10/14/2016 Show Code + Description in Expense Category Dropdown BEGIN string pickerCategory = ""; try { pickerCategory = _pickerCategory.Items[_pickerCategory.SelectedIndex].ToString().Split(' ')[0].ToString().Trim(); } catch (Exception ex) { } //_vm.ExpenseCategory = ((string)_pickerCategory.Items[_pickerCategory.SelectedIndex]); _vm.ExpenseCategory = pickerCategory; // dch rkl 10/14/2016 Show Code + Description in Expense Category Dropdown END // dch rkl 10/14/2016 Show Code + Description in Charge Code Dropdown BEGIN string pickerChargeCode = ""; try { pickerChargeCode = _pickerChargeCode.Items[_pickerChargeCode.SelectedIndex].ToString().Split(' ')[0].ToString().Trim(); } catch (Exception ex) { } //_vm.ExpenseChargeCode = ((string)_pickerChargeCode.Items[_pickerChargeCode.SelectedIndex]); _vm.ExpenseChargeCode = pickerChargeCode; // dch rkl 10/14/2016 Show Code + Description in Charge Code Dropdown END _vm.ExpenseQuantity = quantity; _vm.ExpenseUnitOfMeasure = _entryUnitOfMeasure.Text; _vm.ExpenseUnitCost = unitCost; _vm.ExpenseUnitPrice = unitPrice; _vm.ExpenseIsReimbursable = (bool)_switchIsReimbursable.IsChecked; _vm.ExpenseIsChargeableToCustomer = (bool)_switchIsChargeCustomer.IsChecked; _vm.ExpenseBillingDescription = _editorDescription.Text; _vm.SaveExpenseItem(); var endresult = MessageBox.Show("Expense saved.", "Expense", MessageBoxButton.OK); ContentControl contentArea = (ContentControl)this.Parent; if (_workticket != null) { contentArea.Content = new ExpensesEditPage(_workticket); } else { contentArea.Content = new ExpensesListPage(); } }