Esempio n. 1
0
 private void AddEmployeeCommandExecute(object obj)
 {
     try
     {
         if (EntryValidation.ValidateForLetters(employee.FullName) == false)
         {
             MessageBox.Show("Name can only contain letters. Please try again", "Invalid input");
             return;
         }
         if (EntryValidation.ValidateDate(employee.DateOfBirth) == false)
         {
             MessageBox.Show("Person must be at least 16 years old. Please try again", "Invalid input");
             return;
         }
         if (EntryValidation.ValidateEmail(employee.Email) == false)
         {
             MessageBox.Show("Invalid Email format. Please try again", "Invalid input");
             return;
         }
         if (employee.UserName.Length < 8)
         {
             MessageBox.Show("Username must be at least 8 characters", "Invalid input");
             return;
         }
         if (EntryValidation.ValidateNumber(employee.FloorNumber.ToString()) == false)
         {
             MessageBox.Show("Floor must be a number", "Invalid input");
             return;
         }
         if (EntryValidation.ValidateForLetters(employee.Citizenship) == false)
         {
             MessageBox.Show("Citizenship can only contain letters. Please try again", "Invalid input");
             return;
         }
         if (IsManagerOnGivenFloor(employee.FloorNumber) == false)
         {
             MessageBox.Show("No manager present on a given floor, please choose another floor number.", "Invalid input");
             return;
         }
         string password        = (obj as PasswordBox).Password;
         string encryptPassword = EncryptionHelper.Encrypt(password);
         employee.Password = encryptPassword;
         dataBaseService.AddEmployee(employee);
         MessageBox.Show("New employee registered successfully!", "Info");
         employeeView.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Esempio n. 2
0
 private void AddManagerCommandExecute(object obj)
 {
     try
     {
         if (EntryValidation.ValidateForLetters(manager.FullName) == false)
         {
             MessageBox.Show("Name can only contain letters. Please try again", "Invalid input");
             return;
         }
         if (EntryValidation.ValidateDate(manager.DateOfBirth) == false)
         {
             MessageBox.Show("Person must be at least 16 years old. Please try again", "Invalid input");
             return;
         }
         if (EntryValidation.ValidateEmail(manager.Email) == false)
         {
             MessageBox.Show("Invalid Email format. Please try again", "Invalid input");
             return;
         }
         if (manager.UserName.Length < 8)
         {
             MessageBox.Show("Username must be at least 8 characters", "Invalid input");
             return;
         }
         if (EntryValidation.ValidateNumber(manager.FloorNumber.ToString()) == false)
         {
             MessageBox.Show("Floor must be a number", "Invalid input");
             return;
         }
         if (EntryValidation.ValidateNumber(manager.WorkExperience.ToString()) == false)
         {
             MessageBox.Show("Work experience must be a number", "Invalid input");
             return;
         }
         string password        = (obj as PasswordBox).Password;
         string encryptPassword = EncryptionHelper.Encrypt(password);
         manager.Password = encryptPassword;
         dataBaseService.AddManager(manager);
         MessageBox.Show("New manager registered successfully!", "Info");
         managerView.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }