Пример #1
0
        private void Authentication()
        {
            Alumnus  Alumnus  = Alumnuses.Where(x => x.PersonCode == PersonCodeBox && x.Password == PasswordBox).FirstOrDefault();
            Employee employee = Employees.Where(x => x.PersonCode == PersonCodeBox && x.Password == PasswordBox).FirstOrDefault();


            if (Alumnus is Alumnus)
            {
                AlumnusViewModel.AlumnusOnline = Alumnus;
                AlumnusView Oppen = new AlumnusView();
                Oppen.Show();
            }
            else if (employee is Employee)
            {
                EmployeeViewModel.OnlineEmployee = employee;
                EmployeeView Open = new EmployeeView();
                Open.Show();
            }
            else
            {
                ErrorMessage = "Incorrect login";
            }
            PersonCodeBox = string.Empty;
            PasswordBox   = string.Empty;
            OnPropertyChanged("PersonCodeBox");
            OnPropertyChanged("PasswordBox");
            OnPropertyChanged("ErrorMessage");
        }
Пример #2
0
        private void MoveToEmployees()
        {
            var employees = new EmployeeView();

            employees.Show();
            CloseAction();
        }
Пример #3
0
 private void SubmitCommandExecute(object obj)
 {
     try
     {
         string password = (obj as PasswordBox).Password;
         if (ValidationClass.JMBGisValid(UserName) && password.Equals("Gost"))
         {
             GuestMainView guestMain = new GuestMainView(UserName);
             view.Close();
             guestMain.Show();
             return;
         }
         else if (UserName.Equals("Zaposleni") && password.Equals("Zaposleni"))
         {
             EmployeeView employeeView = new EmployeeView();
             view.Close();
             employeeView.Show();
         }
         else
         {
             MessageBox.Show("Wrong usename or password");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
        public void ShowEmployee()
        {
            EmployeeView employeeView = new EmployeeView();

            employeeView.Show();
            CloseMainMenu();
        }
Пример #5
0
        public void ShowWerknemer()
        {
            var currentWindow = Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive);

            _employeeView = new EmployeeView();
            _employeeView.Show();
            currentWindow.Close();
        }
Пример #6
0
        private void buttonLogIn_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tbUser.Text))
            {
                MessageBox.Show("Please enter your username.", "Message", MessageBoxButton.OK, MessageBoxImage.Warning);
                tbUser.Focus();
                return;
            }
            try
            {
                using (InventoryDBEntitiesFK login = new InventoryDBEntitiesFK())
                {
                    var query = from user in login.Users
                                where user.EmployeeName == tbUser.Text && user.Password == passwBox.Password && user.Role == ComboBoxRole.Text
                                select user;

                    if (query.SingleOrDefault() != null)
                    {
                        switch (ComboBoxRole.Text)
                        {
                        case "Admin":
                            AdminView admin = new AdminView();
                            admin.Show();
                            break;

                        case "Manager":
                            ManagerView manager = new ManagerView();
                            manager.Show();
                            break;

                        case "Employee":
                            EmployeeView empl = new EmployeeView();
                            empl.Show();
                            break;

                        case "Supplier":
                            SupplierView supplier = new SupplierView();
                            supplier.Show();
                            break;
                        }
                        // Just for testing purpose, I'll keep this message here for now
                        MessageBox.Show("You have been successfully logged in.", "Message", MessageBoxButton.OK, MessageBoxImage.Information);
                        Globals.currentUser = (User)query.SingleOrDefault();
                    }
                    else
                    {
                        MessageBox.Show("Your username or password is incorrect.", "Message", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("We messed up the code here!!! Please ask PROF to HELP!!! " + ex.Message, "Message", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            tbUser.Clear();
            passwBox.Clear();
            ComboBoxRole.SelectedIndex = -1;
        }
        private void btnSignIn_Click(object sender, RoutedEventArgs e)
        {
            consoleViewModel.InitializeViewModelData();
            List <Employee> Employees = new List <Employee>();

            Employees = consoleViewModel.EmployeeList();

            if (!_MainWindowViewModel.ManagerEnabled &&
                _MainWindowViewModel.UserName == "admin" && _MainWindowViewModel.Password == "x123xadmin")
            {
                MainMenuWindow mainMenuWindow = new MainMenuWindow();
                mainMenuWindow.Show();
                this.Close();
                return;
            }

            if (!_MainWindowViewModel.EmployeeEnabled && Employees.Exists(x => x.UserName == _MainWindowViewModel.UserName))
            {
                Employee found = Employees.Find(x => x.UserName == _MainWindowViewModel.UserName);

                if (found.PIN == _MainWindowViewModel.Password && found.IsManager == false)
                {
                    //Window needs to be changed to employee UI
                    EmployeeView employeeView = new EmployeeView(found);
                    employeeView.Show();
                    this.Close();
                    return;
                }
                else
                {
                    MessageBox.Show("Wrong Password");
                    return;
                }
            }
            if (!_MainWindowViewModel.ManagerEnabled &&
                Employees.Exists(x => x.UserName == _MainWindowViewModel.UserName))
            {
                Employee ManagerFound = Employees.Find(x => x.UserName == _MainWindowViewModel.UserName);
                if (ManagerFound.PIN == _MainWindowViewModel.Password && ManagerFound.IsManager == true)
                {
                    MainMenuWindow mainMenuWindow = new MainMenuWindow();
                    mainMenuWindow.Show();
                    this.Close();
                    return;
                }
                else
                {
                    MessageBox.Show("Wrong Password");
                    return;
                }
            }


            MessageBox.Show("\r\nWrong Login Username/ Password (Case Sensitivity)\r\n" + "\nCheck User Preference");
            return;
        }
        void Submit(object obj)
        {
            string encryptedString = (obj as PasswordBox).Password;

            string password = EncryptionHelper.Encrypt(encryptedString);

            if (string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(password))
            {
                MessageBox.Show("Wrong user name or password");
                return;
            }
            if (UserName.Equals(ownerData["username"]) &&
                encryptedString.Equals(ownerData["password"]))
            {
                OwnerView ownerView = new OwnerView();
                view.Close();
                ownerView.Show();
                return;
            }


            foreach (var user in users)
            {
                if (user.Username.Equals(UserName) || user.Passwd.Equals(password))
                {
                    tblEmployee employee = hotelService.GetEmloyeByUserId(user.ID);
                    if (employee != null)
                    {
                        EmployeeView empView = new EmployeeView();
                        empView.Show();
                        view.Close();
                    }
                    else
                    {
                        ManagerView manView = new ManagerView();
                        manView.Show();
                        view.Close();
                    }
                    return;
                }
            }
            MessageBox.Show("Wrong user name or password");


            //else if (UserName.Equals(UserConstants.STOREKEEPER_USER_NAME) &&
            //    password.Equals(UserConstants.STOREKEEPER_PASSWORD))
            //{
            //    StorekeeperMainView storekeeperView = new StorekeeperMainView();
            //    view.Close();
            //    storekeeperView.Show();

            //}
        }
Пример #9
0
        private void EmployyesTile_Click(object sender, EventArgs e)
        {
            if (ev == null)
            {
                ev = new EmployeeView(this);
            }
            else
            {
            }

            this.Hide();
            ev.Show();
        }
Пример #10
0
        void Submit(object obj)
        {
            string password  = (obj as PasswordBox).Password;
            var    validate  = new Validations.Validations();
            var    constants = new Constants();

            if (UserName == "Zaposleni" && SecurePasswordHasher.Verify(password, constants.passwordEmployeeHashed))
            {
                EmployeeView employeeView = new EmployeeView(UserName);
                loginView.Close();
                employeeView.Show();
                return;
            }

            else if (validate.IsValidPersonalNoFormat(UserName) && SecurePasswordHasher.Verify(password, constants.passwordGuestHashed))
            {
                DataAccess dataAccess = new DataAccess();
                if (validate.IsPersonalNoInDb(UserName, dataAccess.LoadPersonalNumbers()))
                {
                    OrderStatusView oldQuestView = new OrderStatusView(UserName);

                    //loginView.Close();
                    oldQuestView.Show();
                    var timer = new DispatcherTimer {
                        Interval = TimeSpan.FromSeconds(2)
                    };
                    timer.Start();
                    timer.Tick += (sender, args) =>
                    {
                        timer.Stop();
                        NewGuestView guestView = new NewGuestView(UserName);
                        loginView.Close();
                        oldQuestView.Close();
                        guestView.Show();
                    };

                    return;
                }
                NewGuestView newGuestView = new NewGuestView(UserName);
                loginView.Close();
                newGuestView.Show();
                return;
            }
            else
            {
                WarningView warning = new WarningView(loginView);
                warning.Show("User name or password are not correct!");
                return;
            }
        }
        void Submit(object obj)
        {
            string password = (obj as PasswordBox).Password;

            ownerUserName = ReadOwnerUsername();
            ownerPassword = ReadOwnerPasword();
            DataAccess dataAccess = new DataAccess();

            if (UserName == ownerUserName && password == ownerPassword)
            {
                HotelOwnerView hotelOwnerView = new HotelOwnerView();
                loginView.Close();
                hotelOwnerView.Show();
                return;
            }
            else if (dataAccess.IsCorrectUser(userName, password))
            {
                int userDataId = dataAccess.GetUserDataId(userName);
                if (userDataId != 0)
                {
                    if (dataAccess.GetTypeOfUser(userDataId) == nameof(tblManager))
                    {
                        var         manager     = dataAccess.LoadManagerByUsername(UserName);
                        int         managerId   = manager.ManagerID;
                        ManagerView managerView = new ManagerView(managerId);
                        loginView.Close();
                        managerView.Show();
                        return;
                    }
                    if (dataAccess.GetTypeOfUser(userDataId) == nameof(tblEmployee))
                    {
                        var          employee     = dataAccess.LoadEmployeeByUsername(UserName);
                        EmployeeView employeeView = new EmployeeView(employee);
                        loginView.Close();
                        employeeView.Show();
                        return;
                    }
                    return;
                }
            }
            else if (!dataAccess.IsCorrectUser(userName, password))
            {
                WarningView warning = new WarningView(loginView);
                warning.Show("User name or password are not correct!");
                UserName = null;
                (obj as PasswordBox).Password = null;
                return;
            }
        }
 private void SubmitCommandExecute(object obj)
 {
     try
     {
         List <string> strList  = Utility.PasswordLoader.LoadPassword();
         string        password = (obj as PasswordBox).Password;
         employee = dataBaseService.FindEmployeeCredentials(UserName, password);
         manager  = dataBaseService.FindManagerCredentials(UserName, password);
         if (UserName.Equals(strList.ElementAt(0)) && password.Equals(strList.ElementAt(1)))
         {
             OwnerView ownerView = new OwnerView();
             login.Close();
             ownerView.Show();
             return;
         }
         else if (manager != null)
         {
             ManagerView managerView = new ManagerView(manager);
             login.Close();
             managerView.Show();
             return;
         }
         else if (employee != null)
         {
             EmployeeView employeeView = new EmployeeView(employee);
             login.Close();
             employeeView.Show();
             return;
         }
         else
         {
             MessageBox.Show("Wrong usename or password");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Пример #13
0
        private void Login()
        {
            if (Validators.ValidateEmail(User.Email) && Validators.ValidatePassword(User.Password))
            {
                UserDAL userDAL    = new UserDAL();
                User    loggedUser = userDAL.Login(User);
                if (loggedUser != null)
                {
                    switch (loggedUser.UserType)
                    {
                    case UserType.Client:
                        ClientView clientView = new ClientView();
                        (clientView.DataContext as ClientViewModel).User = loggedUser;
                        clientView.Show();
                        break;

                    case UserType.Employee:
                        EmployeeView employeeView = new EmployeeView();
                        (employeeView.DataContext as EmployeeViewModel).User = loggedUser;
                        employeeView.Show();
                        break;

                    case UserType.Admin:
                        AdminView adminView = new AdminView();

                        adminView.Show();
                        break;

                    default:
                        break;
                    }
                    Application.Current.MainWindow.Close();
                }
                else
                {
                    UserDialog.MessageDialog(message: "Login failed!", type: DialogType.Alert);
                }
            }
        }