public void SaveUpdatedInstrument() { Instrument oldinstrument = _instrument; Instrument updatedInstrument = new Instrument { InstrumentId = LblInstrumentId.Content.ToString(), InstrumentBrandId = CmbBrand.SelectedItem.ToString(), InstrumentStatusId = CmbStatus.SelectedItem.ToString(), InstrumentTypeId = CmbType.SelectedItem.ToString(), Price = Decimal.Parse(TxtPriceAmount.Text, NumberStyles.Currency) }; try { if (_instrumentManager.UpdateInstrumentStatus(oldinstrument, updatedInstrument)) { MessageBox.Show("Instrument Status Updated", "Success", MessageBoxButton.OK); if ((int)MessageBoxResult.OK == 1) { this.NavigationService.Navigate(new PgInventory()); } } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\n" + ex.InnerException.Message); this.NavigationService.Navigate(new PgInventory()); } }
private void btnAddToCart_Click(object sender, RoutedEventArgs e) { Instrument instrument = (Instrument)DgInventoryList.SelectedItem; if (instrument != null) { Instrument instrument2 = new Instrument() { InstrumentId = instrument.InstrumentId, InstrumentStatusId = instrument.InstrumentStatusId, InstrumentTypeId = instrument.InstrumentTypeId, InstrumentBrandId = instrument.InstrumentBrandId, Price = instrument.Price }; if (instrument.InstrumentStatusId == "Available") { var updateStatus = new ChangeStatus(instrument, _instrumentManager); if (updateStatus.ShowDialog() == true) { string status = null; if (updateStatus.RbRent.IsChecked != null && (bool)updateStatus.RbRent.IsChecked) { status = "For Rent"; } if (updateStatus.RbRentToOwn.IsChecked != null && (bool)updateStatus.RbRentToOwn.IsChecked) { status = "For Rent To Own"; } if (updateStatus.RbSale.IsChecked != null && (bool)updateStatus.RbSale.IsChecked) { status = "For Sale"; } instrument2.InstrumentStatusId = status; try { _instrumentManager.UpdateInstrumentStatus(instrument, instrument2); } catch (Exception ex) { MessageBox.Show(ex.Message + "\n\n" + ex.InnerException?.Message); } AddToCart(instrument2); } } else { AddToCart(instrument); } } else { MessageBox.Show("Please select an item", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } }