コード例 #1
0
        private void LoginExecute()
        {
            try
            {
                StreamReader  sr   = new StreamReader(@"..\..\OwnerAcces.txt");
                string        line = "";
                List <string> list = new List <string>();

                while ((line = sr.ReadLine()) != null)
                {
                    list.Add(line);
                }
                sr.Close();

                if (Username == list[0] && Password == list[1])
                {
                    MasterView mv = new MasterView();
                    mv.ShowDialog();
                }


                else
                {
                    MessageBox.Show("InvalidParametres");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                throw;
            }
        }
コード例 #2
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");
     }
 }
コード例 #3
0
        /// <summary>
        /// It is possible to log in as: master account (credentials in file), employe or manager
        /// </summary>
        private void LoginExecute()
        {
            try
            {
                //take credentials from file and compare with input
                StreamReader  sr   = new StreamReader(@"..\..\OwnerAcces.txt");
                string        line = "";
                List <string> list = new List <string>();

                while ((line = sr.ReadLine()) != null)
                {
                    list.Add(line);
                }
                sr.Close();

                //if master credentials equals input
                if (Username == list[0] && Password == list[1])
                {
                    MasterView mv = new MasterView();
                    mv.ShowDialog();
                    Username = "";
                    Password = "";
                }
                //if manager is logged
                else if (ManagerLoged(Username, Password) == true)
                {
                    MessageBox.Show("Welcome manager");
                    Username = "";
                    Password = "";
                }
                //if employe is logged
                else if (EmployeLoged(Username, Password) == true)
                {
                    MessageBox.Show("Welcome employe");
                    Username = "";
                    Password = "";
                }
                else
                {
                    MessageBox.Show("Invalid Parametres");
                    Username = "";
                    Password = "";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                throw;
            }
        }
コード例 #4
0
        /// <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.");
            }
        }
コード例 #5
0
        /// <summary>
        /// Method for checking username and password
        /// </summary>
        /// <param name="o"></param>
        private void LoginExecute(object o)
        {
            try
            {
                string password = (o as PasswordBox).Password;
                if (userName == "WPFMaster" && password == "WPFAccess")
                {
                    MasterView masterView = new MasterView();
                    masterView.ShowDialog();
                }


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

            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }