private void IdComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (selectedButton != App.SelectedButton.Add && IdComboBox.SelectedItem != null)
     {
         Specialization selectedSpecialization = FactoryBL.BL_instance.getAllSpecializations().Find(spec => spec.Id == IdComboBox.SelectedItem.ToString());
         if (selectedSpecialization != null)
         {
             Globals.copyObject <Specialization>(selectedSpecialization, SpecializationData);
         }
     }
 }
Esempio n. 2
0
 private void IdComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (selectedButton != App.SelectedButton.Add && IdComboBox.SelectedItem != null)
     {
         Contract selectedContract = FactoryBL.BL_instance.getAllContracts().Find(c => c.Id == IdComboBox.SelectedItem.ToString());
         if (selectedContract != null)
         {
             Globals.copyObject <Contract>(selectedContract, ContractData);
         }
     }
 }
Esempio n. 3
0
 private void IdComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (selectedButton != App.SelectedButton.Add && IdComboBox.SelectedItem != null)
     {
         Employee selectedEmployee = FactoryBL.BL_instance.getAllEmployees().Find(em => em.Id == IdComboBox.SelectedItem.ToString());
         if (selectedEmployee != null)
         {
             Globals.copyObject <Employee>(selectedEmployee, EmployeeData);
             phoneNumberPrefixComboBox.Text = selectedEmployee.PhoneNumber.Substring(0, 3);
             phoneNumberTextBox.Text        = selectedEmployee.PhoneNumber.Substring(3);
         }
     }
 }
Esempio n. 4
0
 private void SaveButton_Click(object sender, RoutedEventArgs e)
 {
     if (selectedButton == App.SelectedButton.Add)
     {
         if (!Globals.isEverythingNotNull <Employee>(EmployeeData))
         {
             MessageBox.Show("Fill all fields", "Don't mess with me!!!", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         try
         {
             Employee addEmployee = new Employee();
             Globals.copyObject(EmployeeData, addEmployee);
             FactoryBL.BL_instance.addEmployee(addEmployee);
             IdComboBox.Items.Clear();
             foreach (Employee emp in FactoryBL.BL_instance.getAllEmployees())
             {
                 IdComboBox.Items.Add(emp.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 <Employee>(EmployeeData))
         {
             MessageBox.Show("Fill all fields", "Don't mess with me!!!", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         try
         {
             Employee oldEmployee  = FactoryBL.BL_instance.getAllEmployees().Find(x => x.Id == EmployeeData.Id);
             Employee editEmployee = new Employee();
             Globals.copyObject <Employee>(EmployeeData, editEmployee);
             FactoryBL.BL_instance.updateEmployee(editEmployee, oldEmployee);
         }
         catch (Exception err)
         {
             MessageBox.Show(err.Message, "Don't mess with me!!!", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
     }
     if (selectedButton == App.SelectedButton.Remove)
     {
         if (EmployeeData.Id == null)
         {
             MessageBox.Show("Fill ID", "Don't mess with me!!!", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         try
         {
             Employee removeEmployee = new Employee();
             Globals.copyObject(EmployeeData, removeEmployee);
             FactoryBL.BL_instance.removeEmployee(removeEmployee);
             IdComboBox.Items.Clear();
             foreach (Employee emp in FactoryBL.BL_instance.getAllEmployees())
             {
                 IdComboBox.Items.Add(emp.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(EmployeesPropertiesGrid, false, null, false);
     Globals.emptyAllFields(EmployeesPropertiesGrid);
 }
 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);
 }
Esempio n. 6
0
 private void SaveButton_Click(object sender, RoutedEventArgs e)
 {
     if (selectedButton == App.SelectedButton.Add)
     {
         if (!Globals.isEverythingNotNull <Contract>(ContractData))
         {
             MessageBox.Show("Fill all fields", "Don't mess with me!!!", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         try
         {
             Contract addContract = new Contract();
             Globals.copyObject(ContractData, addContract);
             FactoryBL.BL_instance.addContract(addContract);
             IdComboBox.Items.Clear();
             foreach (Contract contract in FactoryBL.BL_instance.getAllContracts())
             {
                 IdComboBox.Items.Add(contract.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 <Contract>(ContractData))
         {
             MessageBox.Show("Fill all fields", "Don't mess with me!!!", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         try
         {
             Contract oldContract  = FactoryBL.BL_instance.getAllContracts().Find(x => x.Id == ContractData.Id);
             Contract editContract = new Contract();
             Globals.copyObject <Contract>(ContractData, editContract);
             FactoryBL.BL_instance.updateContract(editContract, oldContract);
         }
         catch (Exception err)
         {
             MessageBox.Show(err.Message, "Don't mess with me!!!", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
     }
     if (selectedButton == App.SelectedButton.Remove)
     {
         if (ContractData.Id == null)
         {
             MessageBox.Show("Fill ID", "Don't mess with me!!!", MessageBoxButton.OK, MessageBoxImage.Error);
             return;
         }
         try
         {
             Contract removeContract = new Contract();
             Globals.copyObject(ContractData, removeContract);
             FactoryBL.BL_instance.removeContract(removeContract);
             IdComboBox.Items.Clear();
             foreach (Contract contract in FactoryBL.BL_instance.getAllContracts())
             {
                 IdComboBox.Items.Add(contract.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(ContractsPropertiesGrids, false, null, false);
     Globals.emptyAllFields(ContractsPropertiesGrids);
 }