Esempio n. 1
0
        private void btnSignIn_Click(object sender, EventArgs e)
        {
            string username = txtUsername.Text;
            string password = txtPassword.Text;

            if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(password))             //make sure both fields are filled in
            {
                MessageBox.Show("Please enter in both a username and password.");
            }
            else if (isValidUser(username, password)) //checks to see if the account is valid
            {
                if (username.Contains('?'))           //usernames can't contain '?'
                {
                    lblErrMsg.Text = "Invalid Username or Password. Try again.";
                }
                else
                {
                    string accType = getAccType(username);
                    int    accID   = getID(username);
                    //lblErrMsg.Text = accType + accID.ToString();
                    switch (accType)
                    {
                    case "Student":
                        //send ID to student form
                        StudentMain a = new StudentMain(accID);
                        a.Show();
                        this.Hide();
                        break;

                    case "Faculty":
                        //send ID to faculty form
                        FacultyMain g = new FacultyMain(accID);

                        g.Show();
                        this.Hide();
                        break;

                    default:            //Admin account
                        //open admin form (shouldn't need ID?)
                        AdminMain f = new AdminMain();
                        f.Show();
                        this.Hide();
                        break;
                    }
                }
            }
            else
            {
                lblErrMsg.Text = "Invalid Username or Password. Try again.";
            }
        }
Esempio n. 2
0
 private void backToMain(string accountType)
 {                                                                                                                                     //check the user's accountType and use that to take them to the right main form
     if (accountType == "Student")
     {
         StudentMain g = new StudentMain(id);
         g.Show();
         this.Dispose();
     }
     else if (accountType == "Faculty")
     {
         FacultyMain g = new FacultyMain(id);
         g.Show();
         this.Dispose();
     }
     else if (accountType == "Administrator")
     {
         AdminMain g = new AdminMain();
         g.Show();
         this.Dispose();
     }
 }