/// <summary>
 /// This method checks if username and password valid.
 /// </summary>
 /// <param name="password">User input for password.</param>
 public void LogInExecute(object password)
 {
     Password = (password as PasswordBox).Password;
     if (Username == OwnerUsername && Password == OwnerPassword)
     {
         OwnerView ownerView = new OwnerView();
         ownerView.ShowDialog();
     }
     else if (users.FindManager(Username, Password) != null)
     {
         Manager = users.FindManager(Username, Password);
         ManagerView managerView = new ManagerView(Manager);
         managerView.ShowDialog();
     }
     else if (users.FindEmployee(Username, Password) != null)
     {
         Employee = users.FindEmployee(Username, Password);
         EmployeeView employeeView = new EmployeeView(Employee);
         employeeView.ShowDialog();
     }
     else
     {
         MessageBox.Show("Wrong username or password. Please, try again.", "Notification");
     }
 }
        /// <summary>
        /// Method for deciding which View will open according to logged in Employee credentials
        /// </summary>
        private void LoginExecute(object o)
        {
            try
            {
                string password = (o as PasswordBox).Password;
                if (Username == "Mag2019" && password == "Mag2019")
                {
                    EmployeeView employee = new EmployeeView();
                    logInView.Close();
                    employee.ShowDialog();
                }
                else if (Username == "Man2019" && password == "Man2019")
                {
                    ManagerView manager = new ManagerView();
                    logInView.Close();
                    manager.ShowDialog();
                    return;
                }
                else
                {
                    MessageBox.Show("Username or password not correct.");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Ejemplo n.º 3
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            GetOwnerCredentials();
            if (txtUsername.Text == _ownerUsername && txtPassword.Password == _ownerPassword)
            {
                _logged = true;
                OwnerView view = new OwnerView();
                view.ShowDialog();
            }
            else
            {
                List <IUser> allusers = new List <IUser>();
                try
                {
                    using (HotelEntities db = new HotelEntities())
                    {
                        foreach (tblManager manager in db.tblManagers)
                        {
                            allusers.Add(manager as IUser);
                        }

                        foreach (tblStaff staff in db.tblStaffs)
                        {
                            allusers.Add(staff as IUser);
                        }
                    }
                    foreach (IUser user in allusers)
                    {
                        if (user.Username == txtUsername.Text && user.HashedPassword == txtPassword.Password)
                        {
                            if (user is tblManager)
                            {
                                _logged = true;
                                ManagerView view = new ManagerView();
                                view.ShowDialog();
                                break;
                            }
                            else
                            {
                                _logged = true;
                                StaffView view = new StaffView();
                                view.ShowDialog();
                                break;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }
            }
            if (_logged == false)
            {
                MessageBox.Show("Username or Password Not Valid");
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// This method checks if username and password valid.
 /// </summary>
 /// <param name="password">User input for password.</param>
 public void LogInExecute(object password)
 {
     Password = (password as PasswordBox).Password;
     if (Username == MasterUsername && Password == MasterPassword)
     {
         MasterView masterView = new MasterView(Username, Password);
         masterView.ShowDialog();
     }
     else if (users.FindAdministrator(Username, Password) != null)
     {
         Administrator = users.FindAdministrator(Username, Password);
         if (clinic.CheckIfClinicExists())
         {
             AdministratorView administratorView = new AdministratorView();
             administratorView.ShowDialog();
         }
         else
         {
             CreateClinicView clinicView = new CreateClinicView();
             clinicView.ShowDialog();
         }
     }
     else if (users.FindMaintenance(Username, Password) != null)
     {
         Maintenance = users.FindMaintenance(Username, Password);
         MaintenanceView maintenanceView = new MaintenanceView(Maintenance);
         maintenanceView.ShowDialog();
     }
     else if (users.FindManager(Username, Password) != null)
     {
         Manager = users.FindManager(Username, Password);
         ManagerView managerView = new ManagerView();
         managerView.ShowDialog();
     }
     else if (users.FindDoctor(Username, Password) != null)
     {
         Doctor = users.FindDoctor(Username, Password);
         DoctorView doctorView = new DoctorView();
         doctorView.ShowDialog();
     }
     else if (users.FindPatient(Username, Password) != null)
     {
         Patient = users.FindPatient(Username, Password);
         PatientView patientView = new PatientView();
         patientView.ShowDialog();
     }
     else
     {
         MessageBox.Show("Wrong username or password. Please, try again.", "Notification");
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Method for checking username and password
        /// </summary>
        /// <param name="o"></param>
        private void LoginExecute(object o)
        {
            try
            {
                StreamReader  sr    = new StreamReader(@"..\..\OwnerAccess.txt");
                string        line  = "";
                List <string> owner = new List <string>();

                while ((line = sr.ReadLine()) != null)
                {
                    owner.Add(line);
                }
                sr.Close();
                string password = (o as PasswordBox).Password;
                if (userName == owner[0] && password == owner[1])
                {
                    OwnerView ow = new OwnerView();
                    view.Close();
                    ow.ShowDialog();
                }

                else if (service.IsUser(UserName))
                {
                    Manager = service.FindManager(UserName);
                    ManagerView managerView = new ManagerView();
                    view.Close();
                    managerView.ShowDialog();
                }

                else if (service.IsUser(UserName))
                {
                    Employee = service.FindEmployee(UserName);
                    EmployeeView employeeView = new EmployeeView();
                    view.Close();
                    employeeView.ShowDialog();
                }


                else
                {
                    MessageBox.Show("Incorrect username or password");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        /// <summary>
        /// method for checking username and password and opening the windows
        /// </summary>
        private void SaveExecute()
        {
            string adminType = AdminType(Username, UserPassword);

            if (username == "WPFMaster" && userPassword == "WPFAccess")
            {
                MasterView master = new MasterView();
                master.ShowDialog();
            }
            else if (adminType == "TEAM")
            {
                TeamAdminView team = new TeamAdminView();
                team.ShowDialog();
            }
            else if (adminType == "SYSTEM")
            {
                SystemAdminView system = new SystemAdminView();
                system.ShowDialog();
            }
            else if (adminType == "LOCAL")
            {
                LocalAdminView local = new LocalAdminView();
                local.ShowDialog();
            }
            else if (IsManager(username, userPassword))
            {
                try
                {
                    using (CompanyDBEntities context = new CompanyDBEntities())
                    {
                        // getting the manager for later actions with projects
                        tblUser user = (from x in context.tblUsers where x.Username == username select x).First();
                        manager = (from y in context.tblManagers where y.UserID == user.UserID select y).First();

                        ManagerView managerView = new ManagerView(manager);
                        managerView.ShowDialog();
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
                }
            }
            else
            {
                MessageBox.Show("Wrong username or password, please try again.");
            }
        }
 /// <summary>
 /// method for checking username and password and opening the windows
 /// </summary>
 private void SaveExecute()
 {
     if (username == "Mag2019" && password == "Mag2019")
     {
         StorekeeperView storekeeper = new StorekeeperView();
         storekeeper.ShowDialog();
     }
     else if (username == "Man2019" && password == "Man2019")
     {
         ManagerView manager = new ManagerView();
         manager.ShowDialog();
     }
     else
     {
         MessageBox.Show("Wrong username or password, please try again.");
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// This method checks if username and password valid.
 /// </summary>
 /// <param name="password">User input for password.</param>
 public void LogInExecute(object password)
 {
     Password = (password as PasswordBox).Password;
     if (Username == "Man2019" && Password == "Man2019")
     {
         ManagerView managerView = new ManagerView();
         managerView.ShowDialog();
     }
     else if (Username == "Mag2019" && Password == "Mag2019")
     {
         WarehouseClerkView warehouseClerkView = new WarehouseClerkView();
         warehouseClerkView.ShowDialog();
     }
     else
     {
         MessageBox.Show("Wrong username or password. Please, try again.", "Notification");
     }
 }
Ejemplo n.º 9
0
 public void LogInExecute()
 {
     if (Username == "WPFadmin" && Password == "WPFadmin")
     {
         AdminView admin = new AdminView();
         admin.ShowDialog();
     }
     else if (employees.FindEmployee(Username, Password) != null)
     {
         Employee = employees.FindEmployee(Username, Password);
         EmployeeView employeeView = new EmployeeView(Employee);
         employeeView.ShowDialog();
     }
     else
     {
         Manager = managers.FindManager(Username, Password);
         ManagerView managerView = new ManagerView(Manager);
         managerView.ShowDialog();
     }
 }
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            if (txtUsername.Text == "WPFMaster" && txtPassword.Password == "WPFAccess")
            {
                _logged = true;
                MasterView view = new MasterView();
                view.Show();
            }
            else
            {
                try
                {
                    using (CompanyDBEntities db = new CompanyDBEntities())
                    {
                        foreach (tblUser user in db.tblUsers)
                        {
                            if (user.Username == txtUsername.Text && user.UserPassword == txtPassword.Password)
                            {
                                foreach (tblAdmin admin in db.tblAdmins)
                                {
                                    if (admin.UserID == user.UserID)
                                    {
                                        AdminView view = new AdminView();
                                        view.ShowDialog();
                                        _logged = true;
                                        return;
                                    }
                                }

                                foreach (tblManager manager in db.tblManagers)
                                {
                                    if (manager.UserID == user.UserID)
                                    {
                                        ManagerView view = new ManagerView();
                                        view.ShowDialog();
                                        _logged = true;
                                        return;
                                    }
                                }

                                foreach (tblWorker worker in db.tblWorkers)
                                {
                                    if (worker.UserID == user.UserID)
                                    {
                                        WorkerView view = new WorkerView();
                                        view.ShowDialog();
                                        _logged = true;
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message);
                }
            }
            if (_logged == false)
            {
                MessageBox.Show("Username or Password Incorrect.");
            }
        }
        public void ManagerExecute()
        {
            ManagerView managerView = new ManagerView();

            managerView.ShowDialog();
        }