private void Lbl_forgotPW_Click(object sender, EventArgs e)
        {
            this.Hide();
            ChangePW ChangePW = new ChangePW();

            ChangePW.Show();
        }
示例#2
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            String username = textBoxUsername.Text;
            String password = textBoxPassword.Text;

            //Set up the username and the Permission level for if Employee or Manager.
            // Only needs to be done THIS ONE TIME - doesn't need to be done again.

            //Needs Try Catch

            if (username.Trim().Equals(""))
            {
                MessageBox.Show("Enter Your Username To Login", "Empty Username", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (password.Trim().Equals(""))
            {
                MessageBox.Show("Enter Your Password To Login", "Empty Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    /* will throw an error if it can't find the username, or pw is incorrect.
                     *
                     * this also keeps a record of incorrect pw logins in the database, and will
                     * throw an error if the count is 3 or greater in the last 15 mins.
                     */

                    SQL.Setup(username, password);

                    //if CurEmp is false then they have been terminated.
                    if (SQL.CurEmp)
                    {
                        if (SQL.PwCorrect)
                        {
                            if (SQL.ChkOldPW())
                            {
                                MainForm mainform = new MainForm();
                                mainform.Show();
                                this.Hide();
                            }
                            else
                            {
                                DialogResult result = MessageBox.Show("It has been more than 90 days since you last changed your password. You will be redirected to the change password form now.", "Out of Date Password", MessageBoxButtons.OK, MessageBoxIcon.Information);

                                if (result == DialogResult.OK)
                                {
                                    var oldPw = new ChangePW();
                                    oldPw.Show();
                                    this.Hide();
                                }
                            }
                        }
                    }
                    else
                    {
                        //catch all error. Shouldn't be needed.
                        MessageBox.Show("Our Records do not match this data. Please Try again.", "Wrong Data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Wrong Data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }