private void saveButton_Click(object sender, RoutedEventArgs e) { UISpec.ID = uint.Parse(ComSpecID.Text); try { switch (specUC_State) { case State.createNew: BE.Specialization addSpec = new BE.Specialization(); Globals.CopyObject(UISpec, addSpec); BL_Object.addSpecialization(addSpec); Spec_DS_Change_Event?.Invoke(); break; case State.modify: BL_Object.updateSpecilization(UISpec); Spec_DS_Change_Event?.Invoke(); break; } Spec_DS_Change_Event?.Invoke(); // refreshes combobox as well restoreButtonVisib(); } catch (Exception ex) { Globals.exceptionHandler(ex); } }
private void saveButton_Click(object sender, RoutedEventArgs e) { try { switch (EmployerUC_State) { case State.createNew: BE.Employer addEmployer = new BE.Employer(); Globals.CopyObject(UIEmployer, addEmployer); BL_Object.addEmployer(addEmployer); break; case State.modify: BL_Object.updateEmployer(UIEmployer); Employer_DS_Change_Event?.Invoke(); break; default: throw new Exception("EmployerUC State not set"); } Employer_DS_Change_Event?.Invoke(); restoreButtonVisib(); } catch (Exception ex) { Globals.exceptionHandler(ex); } }
private void saveNewContract_Click(object sender, RoutedEventArgs e) { try { var emplyer = (BE.Employer)ComboEmployerID.SelectedValue; var employee = (BE.Employee)ComboEmployeeID.SelectedValue; if (emplyer == null || employee == null) { throw new Exception("please fill out all fields"); } UIContract.EmployerID = emplyer.ID; UIContract.EmployeeID = employee.ID; UIContract.contractID = BL_Object.getNextContractID(); BE.Contract copyContract = new BE.Contract(); Globals.CopyObject(UIContract, copyContract); // copy bc otherwise added by reference BL_Object.addContract(copyContract); // exception thrown if failed add Contract_DS_Change_Event?.Invoke(); // refreshes ContractList in ViewUC restoreButtonVisibState(); // restore buttons if add succeeded } catch (Exception ex) { Globals.exceptionHandler(ex); } }
private void ComSpecID_SelectionChanged(object sender, SelectionChangedEventArgs e) { // if selection is not one of the specs in lcombobox if (ComSpecID.SelectedItem == null) { Globals.CopyObject(new BE.Specialization(), UISpec); } else { Globals.CopyObject((BE.Specialization)ComSpecID.SelectedItem, UISpec); } }
private void ComEmplyeeID_SelectionChanged(object sender, SelectionChangedEventArgs e) { BE.Employee foundEmploye = Bl_Object.getEmployeeList().FirstOrDefault(x => x == (BE.Employee)ComEmplyeeID.SelectedItem); // if selected ID not found in DB, reset all fields in UIEmployee, thus resetting all controls in UI if (Equals(foundEmploye, null)) { Globals.CopyObject(new BE.Employee(), UIEmployee); } else // selection exists in DB { Globals.CopyObject(foundEmploye, UIEmployee); ComEmplyeeBranchNum.SelectedItem = Bl_Object.getBankList().Find(b => b.BankName == UIEmployee.bank.BankName && b.Branch == UIEmployee.bank.Branch); } }
// only called when new ID selected from combobox list, if value entered is not in combobox list, not called private void ComEmployerID_SelectionChanged(object sender, SelectionChangedEventArgs e) { BE.Employer foundEmployer = BL_Object.getEmployerList().FirstOrDefault(x => x == (BE.Employer)ComEmployerID.SelectedItem); if (Equals(foundEmployer, null)) // check if null because uint cast potentially on null { // resets UIEmployer fields, in effect reseting all controls in UI bc of binding Globals.CopyObject(new BE.Employer(), UIEmployer); return; } // copy values (by use of property get/set) of foundEmployer to UIEmployer so binding to UIEmployer not reset else { Globals.CopyObject(foundEmployer, UIEmployer); } }
private void saveButton_Click(object sender, RoutedEventArgs e) { try { switch (EmployeeUC_State) { case State.createNew: BE.Employee addEmploye = new BE.Employee(); Globals.CopyObject(UIEmployee, addEmploye); Bl_Object.addEmployee(addEmploye); Employee_DS_Change_Event?.Invoke(); break; case State.modify: Bl_Object.updateEmployee(UIEmployee); Employee_DS_Change_Event?.Invoke(); break; } restoreRegButtonVisib(); EmployeeUC_State = State.view; } catch (Exception ex) { Globals.exceptionHandler(ex); } }
// triggers INotify since copy void updateUIContract(BE.Contract newContract) => Globals.CopyObject(newContract, UIContract);