Beispiel #1
0
        private void removeUser1Btn_Click(object sender, EventArgs e)
        {
            string userName = removeUser1Txt.Text.Trim(' ');

            if (!Check.areValidInputs(userName))
            {
                Prompt.enterValidInput();
                return;
            }
            if (currentUser.getUserName().ToLower().Equals(userName.ToLower()))
            {
                Prompt.cannotDeleteSelf();
                return;
            }


            try
            {
                EmployeesTable.delete(userName);
                clearTextBoxes(removeUserPnl);
            }
            catch {
                EmployeesTable.adapter.Dispose();
                Prompt.dbError();
            }
        }
Beispiel #2
0
        public void setupAdminPnl()
        {
            //fill the data tables with info
            if (isFirstSetup)
            {
                try
                {
                    admin1Data.DataSource = EmployeesTable.getAll();
                    admin1Data.Columns["password"].Visible = false;
                    admin1Data.Columns["deleted"].Visible  = false;

                    admin2Data.DataSource = CustomersTable.getAll();
                    admin2Data.Columns["deleted"].Visible = false;

                    admin3Data.DataSource = MoviesTable.getAll();
                    admin3Data.Columns["deleted"].Visible = false;
                    sortBy(admin3Data, 1, true);

                    admin4Data.DataSource = CopiesTable.getAll();
                    admin4Data.Columns["deleted"].Visible = false;
                    sortBy(admin4Data, 0, true);
                }catch
                {
                    EmployeesTable.adapter.Dispose();
                    CustomersTable.adapter.Dispose();
                    MoviesTable.adapter.Dispose();
                    CopiesTable.adapter.Dispose();
                    Prompt.dbError();
                }
            }

            Reposition.setControl(adminTitleLbl, .4, .7, 0, .1);

            Reposition.setControl(adminTab, .1, .9, .1, .9);

            Reposition.setNestedControlPosition(admin1Data, .05, .95, 0, .8);
            Reposition.setNestedControlPosition(admin2Data, .05, .95, 0, .8);
            Reposition.setNestedControlPosition(admin3Data, .05, .95, 0, .8);
            Reposition.setNestedControlPosition(admin4Data, .05, .95, 0, .8);

            //user Buttons
            Reposition.setNestedControlLocation(admin1Btn, .1, .85);
            Reposition.setNestedControlLocation(adminPasswordBtn, .4, .85);
            Reposition.setNestedControlLocation(admin2Btn, .7, .85);

            //customer buttons
            Reposition.setNestedControlLocation(admin3Btn, .3, .85);
            Reposition.setNestedControlLocation(admin4Btn, .6, .85);

            //movie buttons
            Reposition.setNestedControlLocation(admin5Btn, .3, .85);
            Reposition.setNestedControlLocation(admin6Btn, .6, .85);

            //upc buttons
            Reposition.setNestedControlLocation(admin7Btn, .3, .85);
            Reposition.setNestedControlLocation(admin8Btn, .6, .85);
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            string userName = usernameTxt.Text.Trim(' ');
            string password = passwordTxt.Text.Trim(' ');

            if (!Check.areValidInputs(userName, password))
            {
                Prompt.enterValidInput();
                return;
            }
            try
            {
                if (!EmployeesTable.validCredentials(userName, password))
                {
                    MessageBox.Show("Incorrect username and/or password.", "Failed Authentication", MessageBoxButtons.OK);
                    return;
                }

                Object[] i          = EmployeesTable.getEmployee(userName, password);
                string   firstName  = (string)i[0];
                string   lastName   = (string)i[1];
                bool     isAdmin    = (bool)i[2];
                string   dbPassword = (string)i[4];

                if (!password.Equals(dbPassword.Trim(' ')))
                {
                    MessageBox.Show("Incorrect username and/or password.", "Failed Authentication", MessageBoxButtons.OK);
                    return;
                }

                User user = new User(isAdmin, userName, firstName, lastName);

                startMainMenu(user);
            }catch
            {
                EmployeesTable.adapter.Dispose();
                Prompt.dbError();
            }
        }
Beispiel #4
0
        private void addUserBtn_Click(object sender, EventArgs e)
        {
            string firstName = addUser1Txt.Text.Trim(' ');
            string lastName  = addUser2Txt.Text.Trim(' ');
            string userName  = addUser3Txt.Text.Trim(' ');
            bool   isAdmin   = addUserRdb.Checked;

            if (!Check.areValidInputs(firstName, lastName, userName))
            {
                Prompt.enterValidInput();
                return;
            }

            try
            {
                //userName already in DB
                if (EmployeesTable.hasEverHadEmployee(userName))
                {
                    Prompt.alreadyInDB("user");
                    return;
                }


                EmployeesTable.add(lastName, firstName, isAdmin, userName, "<NA>");

                clearTextBoxes(addUserPnl);

                //moves to the password page
                password1Txt.Text = userName;
                setCurrentMainPanel(passwordPnl);
            }catch
            {
                EmployeesTable.adapter.Dispose();
                Prompt.dbError();
            }
        }
Beispiel #5
0
        private void password1Btn_Click(object sender, EventArgs e)
        {
            string userName  = password1Txt.Text.Trim(' ');
            string password1 = password2Txt.Text.Trim(' ');
            string password2 = password3Txt.Text.Trim(' ');

            if (!Check.areValidInputs(userName, password1, password2))
            {
                Prompt.enterValidInput();
                return;
            }
            if (!password1.Equals(password2))
            {
                Prompt.enterPasswordMatch();
                return;
            }

            try
            {
                if (!EmployeesTable.hasEmployee(userName))
                {
                    Prompt.notInDB("user", "userName");
                    return;
                }

                EmployeesTable.setPassword(password1, userName);

                clearTextBoxes(passwordPnl);
                setCurrentMainPanel(adminPnl);
            }
            catch
            {
                EmployeesTable.adapter.Dispose();
                Prompt.dbError();
            }
        }