public void SaveExecute(object parametar)
        {
            var passwordBox = parametar as PasswordBox;
            var password    = passwordBox.Password;

            User.Password = password;
            User.GenderId = SelectedGender.GenderId;
            User.RoleId   = 3;
            try
            {
                int userId = service.AddClinicUser(User);
                if (userId != 0)
                {
                    UserManager.ClinicUserId = userId;
                    UserManager.ClinicFloor  = SelectedFloor;
                    if (service.AddNewManager(UserManager) != 0)
                    {
                        MessageBox.Show("You have successfully added new manager");
                        Logging.LoggAction("AddManagerViewModel", "Info", "Succesfull added new manager");
                        ManagerView managerView = new ManagerView(UserAdmin);
                        managerView.Show();
                        addManagerView.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                Logging.LoggAction("AddManagerViewModel", "Error", ex.ToString());
            }
        }
 public void SaveExecute()
 {
     if (String.IsNullOrEmpty(ClinicManager.NameAndSurname) || String.IsNullOrEmpty(ClinicManager.IdentityCardNumber) || String.IsNullOrEmpty(ClinicManager.DateOfBirth.ToString()) || String.IsNullOrEmpty(ClinicManager.Gender) ||
         String.IsNullOrEmpty(ClinicManager.Citizenship) || String.IsNullOrEmpty(ClinicManager.Username) || String.IsNullOrEmpty(ClinicManager.Password) || String.IsNullOrEmpty(ClinicManager.Floor.ToString()) ||
         String.IsNullOrEmpty(ClinicManager.MaximumNumberOfSupervisedDoctors.ToString()) || String.IsNullOrEmpty(ClinicManager.MinimumNumberOfSupervisedRooms.ToString()))
     {
         MessageBox.Show("Please fill all fields.", "Notification");
     }
     else
     {
         try
         {
             MessageBoxResult result = MessageBox.Show("Are you sure you want to save the manager?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);
             if (result == MessageBoxResult.Yes)
             {
                 bool isCreated = managers.CreateManager(ClinicManager);
                 if (isCreated)
                 {
                     MessageBox.Show("Manager is created.", "Notification", MessageBoxButton.OK);
                     managerView.Close();
                 }
                 else
                 {
                     MessageBox.Show("Manager cannot be created.", "Notification", MessageBoxButton.OK);
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
 }
 public void SaveExecute()
 {
     if (String.IsNullOrEmpty(Manager.NameAndSurname) || String.IsNullOrEmpty(Manager.DateOfBirth.ToString()) || String.IsNullOrEmpty(Manager.Email) || String.IsNullOrEmpty(Manager.Username) ||
         String.IsNullOrEmpty(Manager.Password) || String.IsNullOrEmpty(Manager.HotelFloor.ToString()) || String.IsNullOrEmpty(Manager.ExperienceWorkingInHotels.ToString()) || String.IsNullOrEmpty(Manager.ProfessionalQualifications) ||
         Manager.DateOfBirth == DateTime.MinValue)
     {
         MessageBox.Show("Please fill all fields.", "Notification");
     }
     else
     {
         try
         {
             MessageBoxResult result = MessageBox.Show("Are you sure you want to save the manager?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);
             if (result == MessageBoxResult.Yes)
             {
                 bool isCreated = managers.AddManager(Manager);
                 if (isCreated)
                 {
                     MessageBox.Show("Manager is created.", "Notification", MessageBoxButton.OK);
                     managerView.Close();
                 }
                 else
                 {
                     MessageBox.Show("Manager cannot be created.", "Notification", MessageBoxButton.OK);
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
 }
Ejemplo n.º 4
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());
     }
 }
Ejemplo n.º 5
0
        public void SaveExecute(object parametar)
        {
            var passwordBox = parametar as PasswordBox;
            var password    = passwordBox.Password;
            var email       = User.Email.ToLower();

            User.Password = password;
            User.Email    = email;
            User.RoleId   = 2;
            try
            {
                if (User.HotelUserId == 0)
                {
                    bool uniqueUserName = service.CheckUsername(User.Username);
                    bool uniqueEmail    = service.CheckEmail(User.Email);
                    bool uniqueFloor    = service.CheckHotelFloor(UserManager.HotelFloor);
                    if (uniqueUserName && uniqueEmail && uniqueFloor)
                    {
                        int userId = service.AddHotelUser(User);
                        if (userId != 0)
                        {
                            UserManager.HotelUserId          = userId;
                            UserManager.QualificationLevelId = selectedQualificationLevel.QualificationLevelId;

                            if (service.AddNewManger(UserManager) != 0)
                            {
                                MessageBox.Show("You have successfully added new manager");

                                OwnerView ownerView = new OwnerView();
                                ownerView.Show();
                                addManagerView.Close();
                            }
                        }
                    }
                    else if (!uniqueUserName)
                    {
                        MessageBox.Show("Username already exists!");
                    }
                    else if (!uniqueEmail)
                    {
                        MessageBox.Show("Email already exists!");
                    }
                    else if (!uniqueFloor)
                    {
                        MessageBox.Show("The floor is occupied select another!");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 6
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());
     }
 }
        /// <summary>
        /// Save execute- how to save admin
        /// </summary>
        private void SaveExecute()
        {
            var result = MessageBox.Show("Are you sure you want to create this manager?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                try
                {
                    service.AddManager(Manager);
                    IsUpdateManager = true;
                    service.GetAllManagerView().ToList();
                    MessageBox.Show("You successfully created manager!", "Notification");
                    view.Close();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Exception" + ex.Message.ToString());
                }
            }
            else
            {
                return;
            }
        }
        private void CancelCommandExecute()
        {
            try
            {
                MessageBoxResult result = MessageBox.Show("Are you sure you want to close window?", "Close Window", MessageBoxButton.YesNo);
                switch (result)
                {
                case MessageBoxResult.Yes:
                    manager.Close();
                    break;

                case MessageBoxResult.No:
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }