Example #1
0
        private void AsEmployeeExecute()
        {
            try
            {
                if (managerService.GetManagers().Count == 0)
                {
                    string str = string.Format("You can't create emplooye account\n" +
                                               "There are no managers in database");
                    MessageBox.Show(str);
                    return;
                }

                if (sectorService.GetSectors().Count == 0)
                {
                    string str = string.Format("You can't create emplooye account\n" +
                                               "There are no sectors in database");
                    MessageBox.Show(str);
                    return;
                }
                EmployeeRegisterView registerView = new EmployeeRegisterView();
                registerView.ShowDialog();
                view.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
 private void SaveExecute()
 {
     try
     {
         if (CheckUsername(User.Username))
         {
             if (CheckPassword(User.Password))
             {
                 try
                 {
                     using (AudioPlayerDbEntities db = new AudioPlayerDbEntities())
                     {
                         db.tblUsers.Add(User);
                         db.SaveChanges();
                     }
                     MessageBox.Show("Registrated Successfully!");
                     main.Close();
                 }
                 catch (Exception ex)
                 {
                     System.Diagnostics.Debug.WriteLine(ex.Message);
                 }
             }
             else
             {
                 MessageBox.Show("Password Min Lenght 6 and password must contain at least 2 Upper Letters");
             }
         }
         else
         {
             MessageBox.Show("Username is already in use, please try another one.");
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine(ex.Message);
     }
 }
Example #3
0
        private void SaveExecute(object parameter)
        {
            try
            {
                tblUser userInDb = service.GetUserByUserName(User.Username);

                if (userInDb != null)
                {
                    string str1 = string.Format("User with this username exists\n" +
                                                "Enter another username");
                    MessageBox.Show(str1);
                    return;
                }

                if (!IsTelephoneNumberValid(User.TelephoneNumber))
                {
                    MessageBox.Show("Telephone number is not valid");
                    return;
                }

                var passwordBox = parameter as PasswordBox;
                var password    = passwordBox.Password;

                string encryptedString = EncryptionHelper.Encrypt(password);
                User.UserPassword = encryptedString;

                service.AddUser(User);
                MessageBox.Show("You successfully registered.");
                LoginView loginView = new LoginView();
                loginView.Show();
                view.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Example #4
0
 private void CloseView()
 {
     view.Close();
 }