protected async void ButtonAddPart_Click(object sender, EventArgs e) { _vm.PartToEdit.Warehouse = _pickerWarehouse.Items[_pickerWarehouse.SelectedIndex]; if (_entryUnitOfMeasure.SelectedIndex < 0) { await DisplayAlert("Unit of Measure", "You haven't selected a unit of measure.", "OK"); return; } // puke switch (_pageMode) { case PageMode.Add: _vm.AddPartToPartsList(); //await Navigation.PopAsync(); break; case PageMode.Edit: _vm.UpdatePartOnPartsList(); break; } await Navigation.PopAsync(); }
private void ButtonAddPart_Click(object sender, RoutedEventArgs e) { // dch rkl 01/23/2017 Change U/M to picklist string UM = ""; if (_pickerUnitOfMeasure != null && _pickerUnitOfMeasure.SelectedIndex > -1) { UM = _pickerUnitOfMeasure.SelectedValue.ToString(); } if (UM.Length <= 0) { MessageBoxResult result = System.Windows.MessageBox.Show("You must select a unit of measure.", "Unit of Measure", MessageBoxButton.OK); if (result == MessageBoxResult.OK) { return; } } // dch rkl 11/27/2016 Make Sure Value in Unit Cost is Numeric decimal dPrice; if (decimal.TryParse(_entryUnitPrice.Text.Replace("$", ""), out dPrice) == false) { MessageBoxResult result = System.Windows.MessageBox.Show("Unit Price must be numeric.", "Invalid Unit Price", MessageBoxButton.OK); if (result == MessageBoxResult.OK) { return; } } // dch rkl 11/27/2016 Make Sure Value in Unit Cost is Numeric decimal dCost; if (decimal.TryParse(_entryUnitCost.Text.Replace("$", ""), out dCost) == false) { MessageBoxResult result = System.Windows.MessageBox.Show("Unit Cost must be numeric.", "Invalid Unit Cost", MessageBoxButton.OK); if (result == MessageBoxResult.OK) { return; } } // dch rkl 12/06/2016 make sure sufficient inventory is available // dch rkl 12/05/2016 If Lot(5) or Serial (6) Controlled, show Lot/Serial Selection if (_vm.PartToEdit.Valuation == "5" || _vm.PartToEdit.Valuation == "6") { _lotSerNo = _vm.GetMfgSerialNumbersForPart(); // dch rkl 01/13/2017 Make Sure Serial Number Count is >= Quantity Being Entered decimal dQty; decimal.TryParse(_entryQuantity.Text, out dQty); //if (_lotSerNo == null || _lotSerNo.Count == 0) if (_lotSerNo == null || _lotSerNo.Count < dQty) { MessageBoxResult result = System.Windows.MessageBox.Show("Insufficient Inventory Available for this Item/Whse", "Insufficient Inventory", MessageBoxButton.OK); if (result == MessageBoxResult.OK) { return; } } } // dch rkl 11/02/2016 make sure _pickerWarehouse has at least one value if (_pickerWarehouse != null && _pickerWarehouse.Items.Count > 0 && _pickerWarehouse.SelectedIndex > -1) { // dch rkl 12/01/2016 Picker is now bound to type of IM_Warehouse //_vm.PartToEdit.Warehouse = (string)_pickerWarehouse.Items[_pickerWarehouse.SelectedIndex]; IM_Warehouse whse = (IM_Warehouse)_pickerWarehouse.Items[_pickerWarehouse.SelectedIndex]; _vm.PartToEdit.Warehouse = whse.WarehouseCode; } else { _vm.PartToEdit.Warehouse = ""; } _vm.PartToEdit.Quantity = Convert.ToDouble(_entryQuantity.Text); // dch rkl 10/13/2016 remove $ sign before saving //_vm.PartToEdit.UnitPrice = Convert.ToDouble(_entryUnitPrice.Text); _vm.PartToEdit.UnitPrice = Convert.ToDouble(_entryUnitPrice.Text.Replace("$", "")); // dch rkl 11/21/2016 Unit Cost is editable for misc items _vm.PartToEdit.UnitCost = Convert.ToDouble(_entryUnitCost.Text.Replace("$", "")); // dch rkl 01/23/2017 Change U/M to picklist //_vm.PartToEdit.UnitOfMeasure = _entryUnitOfMeasure.Text; _vm.PartToEdit.UnitOfMeasure = UM; var ciOptions = App.Database.GetCIOptions(); if (ciOptions.AllowExpandedItemCodes == "Y") { _vm.PartToEdit.PartItemCode = _labelPartNumber.Text.Substring(0, _labelPartNumber.Text.Length > 30 ? 30 : _labelPartNumber.Text.Length); } else { _vm.PartToEdit.PartItemCode = _labelPartNumber.Text.Substring(0, _labelPartNumber.Text.Length > 15 ? 15 : _labelPartNumber.Text.Length); } _vm.PartToEdit.ItemCodeDesc = _labelPartDescription.Text; _vm.PartToEdit.IsChargeable = (bool)_switchIsChargeable.IsChecked; _vm.PartToEdit.IsPrintable = (bool)_switchIsPrintable.IsChecked; _vm.PartToEdit.IsPurchased = (bool)_switchIsPurchased.IsChecked; _vm.PartToEdit.IsOverhead = (bool)_switchIsOverhead.IsChecked; _vm.PartToEdit.Comment = _entryComments.Text; // dch rkl 02/03/2017 Per Jeanne, Set Quantity Required to Quantity entered _vm.PartToEdit.QuantityReqd = (decimal)_vm.PartToEdit.Quantity; switch (_pageMode) { case PageMode.Add: // dch rkl 01/13/2017 Return the ID of the Inserted Part int iId = _vm.AddPartToPartsList(); _vm.PartToEdit.ID = iId; //_vm.AddPartToPartsList(); //await Navigation.PopAsync(); break; case PageMode.Edit: _vm.UpdatePartOnPartsList(); break; } // dch rkl 12/05/2016 If Lot(5) or Serial (6) Controlled, show Lot/Serial Selection if (_vm.PartToEdit.Valuation == "5" || _vm.PartToEdit.Valuation == "6") { ShowLotSerNoSelection(); } else { // If not lot controlled/ ContentControl contentArea = (ContentControl)this.Parent; contentArea.Content = new PartsListPage(_vm.WorkTicket, _scheduledAppointment); } }