public void Login(string username, string password, LoginView view)
        {
            List <Employee> employees = empmod.GetAllEmployees();

            if (username == "Master" && password == "Master")
            {
                OwnerView ov = new OwnerView();
                view.Close();
                ov.Show();
            }
            else if (employees.Contains((from e in employees where e.Username == username && e.Password == password select e).FirstOrDefault()))
            {
                Employee employee = (from e in employees where e.Username == username && e.Password == password select e).FirstOrDefault();
                if (employee.Responsibility != null)
                {
                    WorkerView wv = new WorkerView();
                    view.Close();
                    wv.Show();
                }
                else
                {
                    ManagerView mv = new ManagerView();
                    view.Close();
                    mv.Show();
                }
            }
            else
            {
                MessageBox.Show("Username or Password was incorrect ", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Esempio n. 2
0
 private void SubmitCommandExecute(object obj)
 {
     try
     {
         string password = (obj as PasswordBox).Password;
         if (UserName.Equals("Mag2019") && password.Equals("Mag2019"))
         {
             WorkerView workerView = new WorkerView();
             login.Close();
             workerView.Show();
             return;
         }
         else if (UserName.Equals("Man2019") && password.Equals("Man2019"))
         {
             ManagerView managerView = new ManagerView();
             login.Close();
             managerView.Show();
             return;
         }
         else
         {
             MessageBox.Show("Wrong usename or password");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
        private void LoginExecute(object parametar)
        {
            var passwordBox = parametar as PasswordBox;
            var password    = passwordBox.Password;

            try
            {
                if (service.LoginMaster(username, password) != null)
                {
                    MessageBox.Show("Successful login");
                    MasterAdminView window = new MasterAdminView();
                    window.Show();
                    main.Close();
                }
                else if (service.LoginUserPass(username, password) != null)
                {
                    if (ServiceCode.CurrentUser.RoleId == 1)
                    {
                        Menager menager = service.GetMenagerByUserId(ServiceCode.CurrentUser.UserId);
                        if (menager.LevelOfResponsibility == 4)
                        {
                            MessageBox.Show("Your account is not yet available.\nWait for the admin to assign you \na level of responsibility ");
                        }
                        else
                        {
                            ManagerView managerView = new ManagerView(menager);
                            managerView.Show();
                            main.Close();
                        }
                    }
                    else if (ServiceCode.CurrentUser.RoleId == 2)
                    {
                        Administrator admin = service.GetAdminByUserId(ServiceCode.CurrentUser.UserId);
                        if (admin.ExpirationDate < DateTime.Now)
                        {
                            MessageBox.Show("You need to contact company's menagment\nTo extend your access to acount!");
                        }
                        else
                        {
                            AdminView adminView = new AdminView();
                            adminView.Show();
                            main.Close();
                        }
                    }
                    else if (ServiceCode.CurrentUser.RoleId == 3)
                    {
                        WorkerView workerView = new WorkerView();
                        workerView.Show();
                        main.Close();
                    }
                }
                else if (service.LoginManagerBackUpPass(username, password) != null)
                {
                    Menager menager = service.GetMenagerByUserId(ServiceCode.CurrentUser.UserId);
                    if (menager.LevelOfResponsibility == 4)
                    {
                        MessageBox.Show("Your account is not yet available.\nWait for the admin to assign you \na level of responsibility ");
                    }
                    else
                    {
                        ManagerView managerView = new ManagerView(menager);
                        managerView.Show();
                        main.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Wrong credentials");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }