Ejemplo n.º 1
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            try
            {
                //Verify credentials
                if (isLoginGood())
                {
                    //makes sure there is only one completeform instantiation
                    if (WelcomeForm.instantiations == 0)
                    {
                        //Close error form on success
                        if (eForm != null)
                        {
                            eForm.Close();
                        }

                        this.Hide();
                        cForm = new WelcomeForm(personName);
                        cForm.Show();
                    }
                }
                else
                {
                    failedAttempts++;

                    //Block user after 5 attempts by not getting MAC address
                    if (failedAttempts >= 5)
                    {
                        mac = "";
                    }

                    if (eForm != null)
                    {
                        eForm.Close();
                        eForm = null;
                    }

                    eForm = new ErrorForm();
                    eForm.Show();
                }
            }

            catch (Exception exp)
            {
                Console.WriteLine(exp);
            }
        }
Ejemplo n.º 2
0
        private void buttonResetPass_Click(object sender, EventArgs e)
        {
            //Clean input
            String oldPass    = DatabaseConnection.CleanString(textBoxCurrentPass.Text);
            String newPass    = DatabaseConnection.CleanString(textBoxNewPass.Text);
            String verifyPass = DatabaseConnection.CleanString(textBoxVerifyNewPass.Text);

            String username = LoginForm.account;
            int    EID      = LoginForm.accountID;

            if (connection.isPasswordChanged(oldPass, newPass, verifyPass, EID))
            {
                //On success
                if (SuccessForm.instantiations == 0)
                {
                    sForm = new SuccessForm(this);
                    //Close others
                    if (eForm != null)
                    {
                        eForm.Close();
                    }
                    if (passwordRequirements != null)
                    {
                        passwordRequirements.Close();
                    }
                    sForm.Show();
                }
            }
            else
            {
                if (ErrorForm.instantiations == 0)
                {
                    eForm = new ErrorForm();
                    eForm.Show();
                }
            }
        }