private void Button_Click(object sender, RoutedEventArgs e) { int.TryParse(AmountBox.Text, out int amount); if (TypeOfProblemList.SelectedIndex == -1 || VehicleComboBox.SelectedIndex == -1 || amount <= 0) { MessageBox.Show(_purchaseFail); ClearAll(); PrintAllDropDown(); return; } else { Component component = (Component)TypeOfProblemList.SelectedItem; VehiclesAsEnum vehicle = (VehiclesAsEnum)VehicleComboBox.SelectedItem; manageStock.AddComponents(component, vehicle, amount); MessageBox.Show(_purchaseSuccess); ClearAll(); PrintAllDropDown(); PrintStockStatus(); return; } }