Beispiel #1
0
        /*
         * Method: SetPasswordButton_Click
         * Parameters: object Sender, EventArgs e
         * Output: N/A
         * Created By: Riley Smith
         * Date: 4/15/2015
         * Modified By: Riley Smith
         * 
         * Description: Event handler for the Set Password Button.
         */
        private void SetPasswordButton_Click(object sender, EventArgs e)
        {
            UserList userList = new UserList();
            Regex pwdEx = new Regex("^[a-z]{1}([a-z0-9\\*#\\$]){6,8}$");

            if (passwordTextBox.Text != "" && confirmTextBox.Text != "")
            {
                if (passwordTextBox.Text == confirmTextBox.Text)
                {
                    if (pwdEx.IsMatch(passwordTextBox.Text.ToLower()))
                    {
                        userList.ChangePassword(username, passwordTextBox.Text);
                        MessageBox.Show("Password for " + username + " changed to: " + passwordTextBox.Text);
                        this.Close();
                    }

                    else
                    {
                        MessageBox.Show("Passwords must be between 7-9\n" +
                            "characters, start with a letter, all be in the\n" +
                            "same case and must contain any of the following\n"+
                            "numbers/leters/#*$");
                    }
                }

                else
                {
                    MessageBox.Show("Please ensure the passwords match.");
                }
            }
        }
Beispiel #2
0
        public DeleteUserForm()
        {
            InitializeComponent();

            userList = new UserList();
         
            FillTable();
                
        }
Beispiel #3
0
        /*
         * Method: Login
         * Parameters: object sender, EventArgs s
         * Output: N/A
         * Created By: Scott Smoke
         * Date: 4/12/2015
         * Modified By: JordanB Beck
         * 
         * Description: This will grab the username and password
         * from their respective text boxes and see if they are valid. 
         */ 
        private void Login(object sender, EventArgs e)
        {
            string userName = userNameTextBox.Text;
            string pwd = passwordTextBox.Text;
            UserList users = new UserList();

            //Added to reset the default admin, if he is locked out.
            if (userName == "HARDRESET")
            {
                users.ChangeFilePassword("AlanTuring", "06231912");
            }

            if (users.IsUser(userName))
            {
                if (!users.IsLocked(userName))
                {

                    if (users.TestPassword(userName, pwd))
                    {
                        isAdmin = users.IsAdmin(userName);
                        if (isAdmin)
                        {
                            adminMenu.Visible = true;
                            callingForm.Show();
                            logedIn = true;
                        }
                        else
                        {
                            callingForm.Show();
                            adminMenu.Visible = false;
                            logedIn = true;

                        }
                        Close();
                    }

                    else
                    {
                        MessageBox.Show("Incorrect Password");
                    }
                }
                else
                {
                    MessageBox.Show("User account is Locked");
                }
            }
            else
            {
                MessageBox.Show("Incorrect Username");
            }

        }
Beispiel #4
0
        public CreateUserForm()
        {
            InitializeComponent();
            users = new UserList();
            usersList = users.GetUserNames();
            numAdmins = 0;

            foreach (string ele in usersList)
            {
                string userName = ele;
                if (users.IsAdmin(userName))
                {
                    numAdmins = numAdmins + 1;
                }
            }
        }
Beispiel #5
0
        /*
         * Method: FillTable
         * Parameters: N/A
         * Output: N/A
         * Created By: Riley Smith
         * Date: 4/13/2015
         * Modified By: Riley Smith
         * 
         * Description: Fills the Users Table with a list of users.
         */
        private void FillTable()
        {

            userList = new UserList();

            ArrayList users = userList.GetUserNames();

            int line = 0;
            foreach (string ele in users)
            {
                usersGridView.Rows.Add();
                usersGridView.Rows[line].Cells[0].Value = ele;
                DataGridViewRow row = usersGridView.Rows[line];
                if (userList.IsLocked(ele))
                {
                    row.DefaultCellStyle.BackColor = Color.Red;
                }
                line++;
            }
        }
Beispiel #6
0
        /*
         * Method: ResetPasswordButton_Click
         * Parameters: object Sender, EventArgs e
         * Output: N/A
         * Created By: Riley Smith
         * Date: 4/13/2015
         * Modified By: Riley Smith
         * 
         * Description: Event handler for the Reset Password Button. 
         */
        private void ResetPasswordButton_Click(object sender, EventArgs e)
        {
            if (usersGridView.CurrentCell != null)
            {
                userList = new UserList();
                string userName = usersGridView.CurrentCell.Value.ToString();

                GetNewPasswordForm setPassword = new GetNewPasswordForm(userName);
                setPassword.StartPosition = FormStartPosition.CenterParent;
                setPassword.ShowDialog();

                int selectedIndex = usersGridView.CurrentCell.RowIndex;
                DataGridViewRow row = usersGridView.Rows[selectedIndex];
                if (!userList.IsLocked(userName))
                {
                    row.DefaultCellStyle.BackColor = Color.White;

                }
            }
        }