Beispiel #1
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            //All Data is validated, run login info
            UserClass user = new UserClass();

            user = user.login(emailTextBox.Text, passwordTextBox.Text);
            if (user.intUserID > 0)
            {
                this.Hide();
                //send to appropriate form: Admin, User, Therapist
                //TODO: Call appropriate forms.
                switch (user.strRole)
                {
                case UserClass.ADMIN_ROLE:
                    AdminForm adminForm = new AdminForm();
                    adminForm.ShowDialog();
                    break;

                case UserClass.THERAPIST_ROLE:
                    ResultsReportingForm resultForm = new ResultsReportingForm();
                    resultForm.ShowDialog();
                    break;

                case UserClass.USER_ROLE:
                    TestSelectionForm selectionForm = new TestSelectionForm();
                    selectionForm.currentUser = user;
                    selectionForm.ShowDialog();
                    break;
                }
                this.Show();
                this.Activate();
                loginButton.Enabled  = false;
                passwordTextBox.Text = null;
                emailTextBox.Text    = null;
                emailTextBox.Focus();
            }
            else
            {
                MetroMessageBox.Show(this, "Username/Password Combination not found. Please try again!", "Login Failed",
                                     MessageBoxButtons.OK, MessageBoxIcon.Error);
                passwordTextBox.Focus();
                passwordTextBox.SelectAll();
            }
        }
Beispiel #2
0
 private void createButton_Click(object sender, EventArgs e)
 {
     if (validateAllInput())
     {
         UserClass user = new UserClass();
         user = user.createUser(emailTextBox.Text.Trim(), passwordTextBox.Text.Trim(), nameTextBox.Text.Trim());
         //TODO send User to Taking Test Screen.
         if (user == null)
         {
             MetroMessageBox.Show(this, "You are already registered!", "User Already Exists", MessageBoxButtons.OK,
                                  MessageBoxIcon.Error);
             return;
         }
         TestSelectionForm testSelectionForm = new TestSelectionForm();
         testSelectionForm.currentUser = user;
         testSelectionForm.ShowDialog();
         this.Close();
     }
 }