private void SubmitCommandExecute(object obj)
 {
     try
     {
         string password = (obj as PasswordBox).Password;
         if (UserName.Equals("Admin") && password.Equals("Admin123"))
         {
             if (!users.IsUser("Admin"))
             {
                 User.Username       = UserName;
                 User.Password       = password;
                 User.NameAndSurname = "Administrator";
                 users.AddUser(User);
                 AdminView admin = new AdminView();
                 loginScreen.Close();
                 admin.ShowDialog();
             }
             else
             {
                 AdminView admin = new AdminView();
                 loginScreen.Close();
                 admin.ShowDialog();
             }
         }
         else if (users.IsUser(UserName))
         {
             User = users.FindUser(UserName);
             if (SecurePasswordHasher.Verify(password, User.Password))
             {
                 UserView userWindow = new UserView(User);
                 loginScreen.Close();
                 userWindow.ShowDialog();
             }
             else
             {
                 MessageBox.Show("Wrong password!");
             }
         }
         else
         {
             if (PasswordValidation.PasswordOk(password))
             {
                 NameAndSurnameView nameAndSurnameView = new NameAndSurnameView(UserName, password);
                 loginScreen.Close();
                 nameAndSurnameView.ShowDialog();
             }
             else
             {
                 MessageBox.Show("Password must contain at least 5 characters!");
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
 private void SubmitCommandExecute(object obj)
 {
     try
     {
         string password = (obj as PasswordBox).Password;
         if (UserName.Equals(userPass.ElementAt(1)) && password.Equals(userPass.ElementAt(3)))
         {
             OwnerWindow master = new OwnerWindow();
             loginScreen.Close();
             master.ShowDialog();
         }
         else if (serviceManager.IsUser(UserName))
         {
             Manager = serviceManager.FindManager(UserName);
             if (SecurePasswordHasher.Verify(password, Manager.Password))
             {
                 ManagerWindow managerWindow = new ManagerWindow(Manager);
                 loginScreen.Close();
                 managerWindow.ShowDialog();
             }
             else
             {
                 MessageBox.Show("Wrong usename or password!");
             }
         }
         //else if (serviceAdmin.IsUser(UserName))
         //{
         //    Admin = serviceAdmin.FindAdmin(UserName);
         //    if (SecurePasswordHasher.Verify(password, Admin.UserPassword))
         //    {
         //        clinicList = serviceClinic.GetAllClinics().ToList();
         //        if (clinicList.Count == 0)
         //        {
         //            CreateClinic createClinic = new CreateClinic();
         //            loginScreen.Close();
         //            createClinic.ShowDialog();
         //        }
         //        else
         //        {
         //            AdminWindow adminWindow = new AdminWindow();
         //            loginScreen.Close();
         //            adminWindow.ShowDialog();
         //        }
         //    }
         //}
         else
         {
             MessageBox.Show("Wrong usename or password!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
示例#3
0
        private void SubmitCommandExecute(object obj)
        {
            try
            {
                string password = (obj as PasswordBox).Password;

                if (UserName.Equals("WPFMaster") && password.Equals("WPFAccess"))
                {
                    MasterWindow master = new MasterWindow();
                    loginScreen.Close();
                    master.ShowDialog();
                }
                else if (serviceManager.IsUser(UserName))
                {
                    Manager = serviceManager.FindManager(UserName);
                    if (SecurePasswordHasher.Verify(password, Manager.UserPassword) || password == Manager.ReservedPassword)
                    {
                        if (Manager.LevelOfResponsibility == null)
                        {
                            MessageBox.Show("Can't login until the Admin assigns you a level of Responsability.");
                        }
                        else
                        {
                            ManagerWindow managerWindow = new ManagerWindow();
                            loginScreen.Close();
                            managerWindow.ShowDialog();
                        }
                    }
                }
                else if (seerviceAdmin.IsUser(UserName))
                {
                    Admin = seerviceAdmin.FindAdmin(UserName);
                    if (SecurePasswordHasher.Verify(password, Admin.UserPassword))
                    {
                        ManagerWindow managerWindow = new ManagerWindow();
                        loginScreen.Close();
                        managerWindow.ShowDialog();
                    }
                }
                else
                {
                    MessageBox.Show("Wrong usename or password!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
示例#4
0
        public bool Login(string userName, string password)
        {
            SQL s = new SQL();

            if (s.loginCheck(userName, password))
            {
                SQL.selectID("select userid from users where username='******'");
                LoginScreen l = new LoginScreen();
                l.Hide();
                MainWindow win = new MainWindow();
                win.Show();
                l.Close();
                win.Main.Content = new ProfileOwner();
                return(true);
            }
            else
            {
                return(false);
            }
            //else
            //{
            //    LoginScreen l = new LoginScreen();

            //    ("Wrong username or password...");
            //}
        }
示例#5
0
 void bgCheckUserSession_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     try
     {
         if (e.Error == null && Utility.SettingHelpers.IsReconciled)
         {
             IsBusy = false;
             //only for cashier role
             var window = Application.Current.Windows.OfType <POSWindow>().Any();
             if (!window)
             {
                 var poswindow = new POSWindow();
                 _loginScreen.Close();
                 poswindow.TxtBarcode.Focus();
                 var resultLogin = poswindow.ShowDialog();
                 if (resultLogin == true)
                 {
                 }
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
示例#6
0
        private void SubmitCommandExecute(object obj)
        {
            try
            {
                string password = (obj as PasswordBox).Password;

                if (!string.IsNullOrEmpty(UserName) && passwordValidation.PasswordOk(password))
                {
                    string hash = SecurePasswordHasher.Hash(password);
                    User.Username = UserName;
                    User.Password = hash;
                    service.AddUser(User);

                    MainWindow employeeView = new MainWindow();
                    loginScreen.Close();
                    employeeView.Show();
                }
                else
                {
                    MessageBox.Show("Wrong usename or password! You must have at least 6 characters with 2 uppercase letters! ");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }