private void deleteButton_Click(object sender, RoutedEventArgs e) { try { special = bl.GetSpecialization((int)SpecialNumComboBoxd.SelectedValue); bl.RemoveSpecialization(special.SpecialNum); SpecialNumComboBoxd.ItemsSource = bl.GetAllSpecialization(); SpecialNumComboBoxd.Items.Refresh(); throw new Exception("The contract was removed successfully!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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); } }
public SpecializationsUserControl() { InitializeComponent(); SpecializationData = new Specialization(); DataContext = SpecializationData; foreach (Proffesion x in Enum.GetValues(typeof(BE.Proffesion))) { areaComboBox.Items.Add(x); } foreach (Specialization.Education edu in Enum.GetValues(typeof(Specialization.Education))) { degreeComboBox.Items.Add(edu); } foreach (Specialization sp in FactoryBL.BL_instance.getAllSpecializations()) { IdComboBox.Items.Add(sp.Id); } degreeComboBox.SelectedItem = null; selectedButton = App.SelectedButton.None; }
private void updateButton_Click(object sender, RoutedEventArgs e) { try { special = bl.GetSpecialization((int)specialNumComboBox.SelectedValue); special.TariffMin = Convert.ToDouble(tariffMinTextBox.Text); special.TariffMax = Convert.ToDouble(tariffMaxTextBox.Text); special.Field = ((FieldName)Enum.Parse(typeof(FieldName), (skillComboBox.Text))); //tariffMaxTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); //tariffMinTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); //skillComboBox.GetBindingExpression(ComboBox.SelectedItemProperty).UpdateSource(); // specializationNameTextBox.GetBindingExpression(TextBox.TextProperty).UpdateSource(); bl.UpdateSpecialization(special); throw new Exception("The specialization has been updated successfully!"); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void SearchTextBox_TextChanged(object sender, TextChangedEventArgs e) { if (SearchByComboBox.SelectedItem != null) { string filterBy = SearchByComboBox.SelectedItem.ToString(); SpecializationsListView.Items.Filter = obj => { Specialization spec = obj as Specialization; if (filterBy.Contains("Name")) { return(spec.Name.Contains(SearchTextBox.Text)); } if (filterBy.Contains("Id")) { return(spec.Id.Contains(SearchTextBox.Text)); } if (filterBy.Contains("Area")) { return(spec.Area.ToString().Contains(SearchTextBox.Text)); } return(true); }; } }
private void SaveButton_Click(object sender, RoutedEventArgs e) { if (selectedButton == App.SelectedButton.Add) { if (!Globals.isEverythingNotNull <Specialization>(SpecializationData)) { MessageBox.Show("Fill all fields", "Don't mess with me!!!", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { Specialization addSpecialization = new Specialization(); Globals.copyObject(SpecializationData, addSpecialization); FactoryBL.BL_instance.addSpecialization(addSpecialization); IdComboBox.Items.Clear(); foreach (Specialization spec in FactoryBL.BL_instance.getAllSpecializations()) { IdComboBox.Items.Add(spec.Id); } } catch (Exception err) { MessageBox.Show(err.Message, "Don't mess with me!!!", MessageBoxButton.OK, MessageBoxImage.Error); return; } } if (selectedButton == App.SelectedButton.Edit) { if (!Globals.isEverythingNotNull <Specialization>(SpecializationData)) { MessageBox.Show("Fill all fields", "Don't mess with me!!!", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { Specialization oldSpecialization = FactoryBL.BL_instance.getAllSpecializations().Find(x => x.Id == SpecializationData.Id); Specialization editSpecialization = new Specialization(); Globals.copyObject <Specialization>(SpecializationData, editSpecialization); FactoryBL.BL_instance.updateSpecialization(editSpecialization, oldSpecialization); } catch (Exception err) { MessageBox.Show(err.Message, "Don't mess with me!!!", MessageBoxButton.OK, MessageBoxImage.Error); return; } } if (selectedButton == App.SelectedButton.Remove) { if (SpecializationData.Id == null) { MessageBox.Show("Fill ID", "Don't mess with me!!!", MessageBoxButton.OK, MessageBoxImage.Error); return; } try { Specialization removeSpecialization = new Specialization(); Globals.copyObject(SpecializationData, removeSpecialization); FactoryBL.BL_instance.removeSpecialization(removeSpecialization); IdComboBox.Items.Clear(); foreach (Specialization spec in FactoryBL.BL_instance.getAllSpecializations()) { IdComboBox.Items.Add(spec.Id); } } catch (Exception err) { MessageBox.Show(err.Message, "Don't mess with me!!!", MessageBoxButton.OK, MessageBoxImage.Error); return; } } selectedButton = App.SelectedButton.None; IdComboBox.IsEditable = false; Globals.swapGridsVisibility(SaveCancelGrid, AddEditRemoveGrid); Globals.enableFields(SpecializationsPropertiesGrid, false, null, false); Globals.emptyAllFields(SpecializationsPropertiesGrid); }