Exemple #1
0
 public LocalAdministratorViewModel(LocalAdministrator open)
 {
     la = open;
     //manager
     manager     = new vwManager();
     managerList = Service.Service.GetVwManagerList();
     //employee
     employee     = new vwEmployee();
     employeeList = Service.Service.GetVwEmployeeList();
     //admin
     administrator     = new vwAdministrator();
     administratorList = Service.Service.GetVwAdministratorList();
 }
 private void LoginExecute(object obj)
 {
     try
     {
         person.password = (obj as PasswordBox).Password;
         tblUser user = Service.Service.GetUser(person.username, person.password);
         if (user == null)
         {
             if (person.username == "WPFMaster" && person.password == "WPFAccess")
             {
                 Owner owner = new Owner();
                 login.Close();
                 owner.Show();
             }
             else
             {
                 MessageBox.Show("Invalid username or password.Try again");
             }
         }
         else
         {
             if (Service.Service.isAdministrator(user) != null)
             {
                 tblAdministrator a = Service.Service.isAdministrator(user);
                 if (a.expiryDate < DateTime.Now)
                 {
                     MessageBox.Show("The expiration date of your access has expired. Please conntact the company mannagment");
                 }
                 else
                 {
                     string type = Service.Service.TypeOfAdmin(a);
                     if (type == "Local")
                     {
                         LocalAdministrator la = new LocalAdministrator();
                         login.Close();
                         la.ShowDialog();
                     }
                     else if (type == "Team")
                     {
                         TeamAdministrator ta = new TeamAdministrator();
                         ta.ShowDialog();
                     }
                     else
                     {
                         SystemAdministrator sa = new SystemAdministrator();
                         login.Close();
                         sa.ShowDialog();
                     }
                 }
             }
             else if (Service.Service.isEmployee(user) != null)
             {
                 tblEmployee e        = Service.Service.isEmployee(user);
                 Employee    employee = new Employee();
                 employee.Show();
             }
             else if (Service.Service.isManager(user) != null)
             {
                 tblManager m = Service.Service.isManager(user);
                 if (m.levelOfResponsibility != null)
                 {
                     Manager manager = new Manager();
                     manager.Show();
                 }
                 else
                 {
                     MessageBox.Show("Please wait until the Local administrator assigns a level of responsibility");
                 }
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }