public ReadOnlyRDViewModel(ReadOnlyRDView viewOpen) { employee = new tblEmployee(); view = viewOpen; EmployeeList = service.GetAllEmployees(); }
private void LogInExecute() { try { if (service.IsEmployee(UserName, Password)) { try { using (EmployeeEntities context = new EmployeeEntities()) { tblEmployee employee = (from x in context.tblEmployees where x.UserName == userName && x.Pass == password select x).First(); File.WriteAllText(@"..\..\ID.txt", Convert.ToString(employee.EmployeeID)); } } catch { } if (service.Role(UserName, Password) == "employee") { Employee employee = new Employee(); employee.ShowDialog(); } else if (service.Role(UserName, Password) == "modify-HR") { ModifyHRView mhr = new ModifyHRView(); mhr.ShowDialog(); } else if (service.Role(UserName, Password) == "modify-R&D") { ModifyRDView mrd = new ModifyRDView(); mrd.ShowDialog(); } else if (service.Role(UserName, Password) == "modify-Finances") { ModifyFinancesView mf = new ModifyFinancesView(); mf.ShowDialog(); } else if (service.Role(UserName, Password) == "read-only-HR") { ReadOnlyHRView rohr = new ReadOnlyHRView(); rohr.ShowDialog(); } else if (service.Role(UserName, Password) == "read-only-R&D") { ReadOnlyRDView rord = new ReadOnlyRDView(); rord.ShowDialog(); } else if (service.Role(UserName, Password) == "read-only-Finances") { ReadOnlyFinancesView rof = new ReadOnlyFinancesView(); rof.ShowDialog(); } } else if (UserName == "WPFadmin" && Password == "WPFadmin") { Admin admin = new Admin(); admin.ShowDialog(); } else { MessageBox.Show("Username or password incorrect."); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }