/// <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"); } }
public void OpenWindowLogin(object obj) { ElevVM elevVM = new ElevVM(); List <ElevVM> elevList = elevVM.ElevList.ToList(); foreach (ElevVM elev in elevList) { if (elev.NumeUtilizator.Equals(userName) && elev.Parola.Equals(password)) { ElevView el = new ElevView(elev.ElevId); el.ShowDialog(); } } ProfesorVM profVM = new ProfesorVM(); List <ProfesorVM> profList = profVM.ProfesorList.ToList(); foreach (ProfesorVM prof in profList) { if (prof.NumeUtilizator.Equals(userName) && prof.Parola.Equals(password) && prof.Diriginte == false) { ProfesorView pr = new ProfesorView(prof.ProfesorId); pr.ShowDialog(); } if (prof.NumeUtilizator.Equals(userName) && prof.Parola.Equals(password) && prof.Diriginte == true) { DiriginteView di = new DiriginteView(); di.ShowDialog(); } } AdministratorVM adminVM = new AdministratorVM(); List <AdministratorVM> adminList = adminVM.AdminList.ToList(); foreach (AdministratorVM admin in adminList) { if (admin.NumeUtilizator.Equals(userName) && admin.Parola.Equals(password)) { AdministratorView ad = new AdministratorView(); ad.ShowDialog(); } } }
/// <summary> /// Method for checking username and password /// </summary> /// <param name="o"></param> private void LoginExecute(object o) { try { StreamReader sr = new StreamReader(@"..\..\ClinicAccess.txt"); string line = ""; List <string> clinic = new List <string>(); while ((line = sr.ReadLine()) != null) { clinic.Add(line); } sr.Close(); string password = (o as PasswordBox).Password; if (userName == clinic[0] && password == clinic[1]) { AddClinicAdministratorView cl = new AddClinicAdministratorView(); view.Close(); cl.ShowDialog(); } else if (service.IsUser(UserName)) { Administrator = service.FindAdmin(UserName); AdministratorView adminView = new AdministratorView(); view.Close(); adminView.ShowDialog(); } else { MessageBox.Show("Incorrect username or password. Please try again."); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void SaveExecute() { if (String.IsNullOrEmpty(Clinic.Name) || String.IsNullOrEmpty(Clinic.DateOfConstruction.ToString()) || String.IsNullOrEmpty(Clinic.Owner) || String.IsNullOrEmpty(Clinic.Address) || String.IsNullOrEmpty(Clinic.NumberOfFloors.ToString()) || String.IsNullOrEmpty(Clinic.NumberOfRoomsPerFloor.ToString()) || String.IsNullOrEmpty(Clinic.Terrace.ToString()) || String.IsNullOrEmpty(Clinic.Yard.ToString()) || String.IsNullOrEmpty(Clinic.NumberOfAccessPointsForAmbulanceCars.ToString()) || String.IsNullOrEmpty(Clinic.NumberOfAccessPointsForInvalids.ToString()) || Clinic.NumberOfRoomsPerFloor == 0) { MessageBox.Show("Please fill all fields.", "Notification"); } else { try { MessageBoxResult result = MessageBox.Show("Are you sure you want to save the clinic?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { bool isCreated = newClinic.CreateClinic(Clinic); if (isCreated) { MessageBox.Show("Clinic is created.", "Notification", MessageBoxButton.OK); clinicView.Close(); AdministratorView adminView = new AdministratorView(); adminView.ShowDialog(); } else { MessageBox.Show("Clinic cannot be created.", "Notification", MessageBoxButton.OK); clinicView.Close(); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }