Example #1
0
 private void AddManagerCommandExecute(object obj)
 {
     try
     {
         //if (EntryValidation.ValidateName(Patient.FirstName) == false)
         //{
         //    MessageBox.Show("First Name can only contain letters. Please try again", "Invalid input");
         //    return;
         //}
         //if (EntryValidation.ValidateName(Patient.LastName) == false)
         //{
         //    MessageBox.Show("Last Name can only contain letters. Please try again", "Invalid input");
         //    return;
         //}
         //if (EntryValidation.ValidateJmbg(Patient.JMBG) == false)
         //{
         //    MessageBox.Show("JMBG you entered is not valid. Please try again", "Invalid input");
         //    return;
         //}
         //if (EntryValidation.ValidateMedicalInsuranceNumber(Patient.MedicalInsuranceNumber) == false)
         //{
         //    MessageBox.Show("Medical insurance number entered is not valid, must contain exactly 11 numbers. Please try again", "Invalid input");
         //    return;
         //}
         string password        = (obj as PasswordBox).Password;
         string encryptPassword = EncryptionHelper.Encrypt(password);
         manager.UserPassword = encryptPassword;
         string encryptedReservePassword = manager.ReservedPassword + "WPF";
         manager.ReservedPassword = EncryptionHelper.Encrypt(encryptedReservePassword);
         char userGender = manager.Gender.ElementAt(0);
         manager.Gender = userGender.ToString();
         Debug.WriteLine(manager.FirstName);
         Debug.WriteLine(manager.LastName);
         Debug.WriteLine(manager.JMBG);
         Debug.WriteLine(manager.Gender);
         Debug.WriteLine(manager.Residence);
         Debug.WriteLine(manager.MarriageStatus);
         Debug.WriteLine(manager.Username);
         Debug.WriteLine(manager.UserPassword);
         Debug.WriteLine(manager.Email);
         Debug.WriteLine(manager.ReservedPassword);
         Debug.WriteLine(manager.SuccessfulProjects);
         Debug.WriteLine(manager.OfficeNumber);
         dataBaseService.AddManager(manager);
         MessageBox.Show("New manager registered successfully!", "Info");
         LoginView login = new LoginView();
         addManager.Close();
         login.ShowDialog();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Example #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());
     }
 }