Пример #1
0
 private void SaveExecute()
 {
     try
     {
         if (EntryValidation.ValidateName(Worker.FirstName) == false)
         {
             MessageBox.Show("First Name can only contain letters. Please try again", "Invalid input");
             return;
         }
         if (EntryValidation.ValidateName(Worker.LastName) == false)
         {
             MessageBox.Show("Last Name can only contain letters. Please try again", "Invalid input");
             return;
         }
         if (EntryValidation.ValidateDate(Worker.DateOfBirth) == false)
         {
             MessageBox.Show("Person Must be at least 16 years of age. Please try again", "Invalid input");
             return;
         }
         if (EntryValidation.ValidatePersonalIDNumber(Worker.PersonalIDNumber) == false)
         {
             MessageBox.Show("Personal ID nubmer you entered is not valid. Please try again", "Invalid input");
             return;
         }
         if (EntryValidation.ValidateJmbg(Worker.JMBG) == false)
         {
             MessageBox.Show("JMBG you entered is not valid. Please try again", "Invalid input");
             return;
         }
         if (EntryValidation.ValidatePhone(Worker.PhoneNumber) == false)
         {
             MessageBox.Show("Phone number you entered is not in correct format. Please try again", "Invalid input");
             return;
         }
         Worker.GenderID   = Gender.GenderID;
         Worker.SectorID   = Sector.SectorID;
         Worker.ManagerID  = Manager.WorkerID;
         Worker.LocationID = Location.LocationID;
         _dbService.EditWorker(Worker);
         IsUpdateWorker = true;
         string logMessage = string.Format("Worker {0} {1} - JMBG:{2}, data was edited to {3} {4} JMBG:{5}.", FirstNameBeforeEdit,
                                           LastNameBeforeEdit, JMBGBeforeEdit, _worker.FirstName, _worker.LastName, _worker.JMBG);
         actionEventObject.OnActionPerformed(logMessage);
         MessageBox.Show("Worker Edited Successfully!", "Info");
         _editWorker.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }