private void AddButton_Click(object sender, RoutedEventArgs e) { try { if (expertiseNameTextBox.Text == "") { throw new Exception("you must enter a name"); } bl.AddSpecialization(specialization); specialization = new Specialization(); this.DataContext = specialization; throw new Exception("Add Specializiation successfully!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void button_Click(object sender, RoutedEventArgs e) { if (boxSpecializationName.Text.Equals("")) { MessageBox.Show("Please enter a specialization name", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } else if (boxMinWage.Text.Equals("")) { MessageBox.Show("Please enter a minimum wage", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } else if (boxMaxWage.Text.Equals("")) { MessageBox.Show("Please enter a maximum wage", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } else if (comboBoxSpecField.SelectedValue == null) { MessageBox.Show("Please choose a field", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } else { string spec = comboBoxSpecField.SelectedItem.ToString(); switch (spec) { case "Data structures": spec = "dataStructures"; break; case "Computer communications": spec = "computerCommunications"; break; case "Information security": spec = "informationSecurity"; break; case "Server programming": spec = "serverProgramming"; break; case "Mobile programming": spec = "mobileProgramming"; break; case "User interface designing": spec = "userInterfaceDesigning"; break; } try { int specNumber = bl.AddSpecialization(boxSpecializationName.Text, Double.Parse(boxMinWage.Text), Double.Parse(boxMaxWage.Text), (Field)Enum.Parse(typeof(Field), spec), 0); MessageBox.Show("Specialization has been succesfully added.\nYour specialization number is: " + specNumber); boxSpecializationName.Clear(); boxMinWage.Clear(); boxMaxWage.Clear(); comboBoxSpecField.SelectedItem = null; } catch (FormatException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } } }