Пример #1
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            this.Hide();
            ExamMenuForm ss = new ExamMenuForm();

            ss.Show();
        }
Пример #2
0
        }     //close for passBox_KeyDown

        /* private void loginButton_Click(object sender, EventArgs e)
         *
         * loginButton_Click will check the user credentials based on what
         * text is inside userNameBox and passBox.
         */
        private void loginButton_Click(object sender, EventArgs e)
        {
            //Check to see if anything is entered in the textBox
            //(1) if nothing is entered and user pressed/click login,
            //show error message.
            //(2) else  validate the user using ValidateUser from DatabaseManager.
            if (userNameBox.Text == "" || passBox.Text == "")
            {
                MessageBox.Show("Username and Password can not be empty. Please enter credentials.");
                userNameBox.Text = "";
                passBox.Text     = "";
            }
            else
            {
                //ValidateUser returns a user object.
                user = db.ValidateUser(userNameBox.Text, passBox.Text);

                //ValidateUser returns null if validation was unsuccessful.
                //Print error message if null was returned.
                if (user == null)
                {
                    MessageBox.Show("Username/Password is incorrect. Try again.");
                    userNameBox.Text = "";
                    passBox.Text     = "";
                    userNameBox.Focus();
                }
                //else hide the login form and go to mainMenuForm.
                else
                {
                    this.Hide();
                    ExamMenuForm ss = new ExamMenuForm(user);
                    ss.Show();
                }
            } //second else
        }     //loginButton_Click