/// <summary> /// This method invokes a methods for editing employee achecks if sector of employee exists. If not exist, invokes a method for adding sector. /// </summary> public void SaveExecute() { if (String.IsNullOrEmpty(Employee.NameAndSurname) || String.IsNullOrEmpty(Employee.NumberOfIdentityCard) || String.IsNullOrEmpty(Employee.JMBG) || Gender == null || String.IsNullOrEmpty(Employee.PhoneNumber) || String.IsNullOrEmpty(Sector) || Location == null) { MessageBox.Show("Please fill all fields.", "Notification"); } else { try { MessageBoxResult result = MessageBox.Show("Are you sure you want to save the changes?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { if (sectors.IsSectorExists(Sector) == false) { sectors.AddSector(sector); } //invoking method to find sector and setting that sector to employee sector Employee.Sector = sectors.FindSector(sector); Employee.LocationId = Convert.ToInt32(Location.LocationId); Employee.Gender = Convert.ToInt32(Gender.GenderId); if (Manager != null) { Employee.Manager = Convert.ToInt32(Manager.EmployeeId); } bool isEdited = employees.EditEmployee(Employee); if (isEdited) { MessageBox.Show("Employee is edited.", "Notification", MessageBoxButton.OK); sectors.DeleteSector(OldEmployee.SectorName); editEmployeeView.Close(); } else { MessageBox.Show("Employee cannot be edited.", "Notification", MessageBoxButton.OK); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
/// <summary> /// This method invokes a methods for editing employee achecks if sector of employee exists. If not exist, invokes a method for adding sector. /// </summary> public void SaveExecute() { try { if (sectors.IsSectorExists(Sector) == false) { sectors.AddSector(sector); } Employee.Sector = sectors.FindSector(sector); Employee.LocationID = Convert.ToInt32(Location.LocationID); Employee.Gender = Convert.ToInt32(Gender.GenderID); if (Manager != null) { Employee.Manager = Convert.ToInt32(Manager.EmployeeID); } employees.EditEmployee(employee); editEmployeeView.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }