private void btnConfirm_Click(object sender, EventArgs e) { if (IsBtnConfirmEnabled()) { try { object comboBoxItem = comboBoxFitnessLvl.SelectedItem; FitnessLevel fitnessLevel = (FitnessLevel)comboBoxItem .GetType().GetProperty("Value") .GetValue(comboBoxItem, null); mainController.AddExercise( new Exercise(textBoxExerciseName.Text, fitnessLevel, textBoxExerciseDescription.Text)); DialogResult = DialogResult.OK; } catch (IncompleteDataException) { MessageBox.Show("Nepotpuni ili neispravni podaci", "Greška!", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (NameAlreadyTakenException) { MessageBox.Show("Vježba s unesenim nazivom već postoji", "Greška!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }