Beispiel #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Manager   manager   = new Manager();
            Secretary secretary = new Secretary();
            Doctor    doctor    = new Doctor();
            bool      loggedIn  = false;
            ObservableCollection <Account> accounts = AccountController.GetInstance().GetAllAccounts();

            for (int i = 0; i < accounts.Count; i++)
            {
                if (usernameTextBox.Text.TrimEnd() == accounts[i].Username & passwordTextBox.Password.TrimEnd() == accounts[i].Password)
                {
                    if (accounts[i].Person.GetType() == manager.GetType())
                    {
                        loggedIn = true;
                        ManagerMainWindow window = ManagerMainWindow.getInstance();
                        window.Show();
                        //this.Hide();
                    }
                    else if (accounts[i].Person.GetType() == secretary.GetType())
                    {
                        loggedIn = true;
                        MainPatientManagement.Instance.Show();
                        //this.Hide();
                    }
                    else if (accounts[i].Person.GetType() == doctor.GetType())
                    {
                        loggedIn = true;
                        person   = accounts[i].Person;
                        DoctorMainWindow window = DoctorMainWindow.GetInstance((Doctor)person);
                        window.Show();
                        //this.Hide();
                    }
                    else
                    {
                        loggedIn = true;
                        Patient rightPatient = null;
                        foreach (var patient in PatientController.getInstance().getPatient())
                        {
                            if (((Patient)accounts[i].Person).Jmbg == patient.Jmbg)
                            {
                                rightPatient = patient;
                            }
                        }
                        person = accounts[i].Person;
                        PatientMainWindow.GetInstance(rightPatient).Show();
                    }
                }
            }
            if (!loggedIn)
            {
                MessageBox.Show("Lozinka ili korisničko ime nisu validni.", "Greška", MessageBoxButton.OK, MessageBoxImage.Information);
                passwordTextBox.Clear();
            }
        }
Beispiel #2
0
        private void openMainWindow()
        {
            settings.Write("version", version);
            Settings.version = version;

            int idRole = Auth.getInstance().IdRole;

            switch (idRole)
            {
            case 1:
                AdministratorMainWindow administratorWindow =
                    new AdministratorMainWindow();
                administratorWindow.Show();
                break;

            case 2:
                DirectorMainWindow directorWindow =
                    new DirectorMainWindow();
                directorWindow.Show();
                break;

            case 3:
                AccountantMainWindow accountantWindow =
                    new AccountantMainWindow();
                accountantWindow.Show();
                break;

            case 4:
                TechnicalMainWindow technicalWindow =
                    new TechnicalMainWindow();
                technicalWindow.Show();
                break;

            case 5:
                ManagerMainWindow managerWindow =
                    new ManagerMainWindow();
                managerWindow.Show();
                break;

            case 6:
                LogisticianMainWindow logisticanWindow =
                    new LogisticianMainWindow();
                logisticanWindow.Show();
                break;
            }
            Close();
        }