Beispiel #1
0
        public void login_user()
        {
            classConnection dbaseConnect = new classConnection();

            try
            {
                UserData[] loginCredential = dbaseConnect.login(txtUsername.Text, txtPass.Text).ToArray();


                if (loginCredential[0].userAccLevel.ToString() == "ADMIN")
                {
                    frmMainMenu mainmenu = new frmMainMenu();

                    mainmenu.tlpGUEST.Enabled = false;
                    mainmenu.tlpGUEST.Visible = false;

                    mainmenu.tlpADMIN.Enabled = true;
                    mainmenu.tlpADMIN.Visible = true;

                    mainmenu.tlpADMIN.Dock = DockStyle.Fill;
                    mainmenu.pnlNAVIGATOR.Controls.Add(mainmenu.tlpADMIN);

                    mainmenu.lblUSERLEVEL.Text = "ADMINISTRATOR: " + loginCredential[0].userFname.ToString().ToUpper() + " " + loginCredential[0].userLname.ToString().ToUpper();
                    mainmenu.currentUserID     = loginCredential[0].userID.ToString();
                    mainmenu.Show();

                    this.Hide();
                }
                else
                {
                    frmMainMenu mainmenu = new frmMainMenu();

                    mainmenu.tlpGUEST.Enabled = true;
                    mainmenu.tlpGUEST.Visible = true;

                    mainmenu.tlpADMIN.Enabled = false;
                    mainmenu.tlpADMIN.Visible = false;

                    mainmenu.tlpGUEST.Dock = DockStyle.Fill;
                    mainmenu.pnlNAVIGATOR.Controls.Add(mainmenu.tlpGUEST);

                    mainmenu.lblUSERLEVEL.Text = "GUEST: " + loginCredential[0].userFname.ToString().ToUpper() + " " + loginCredential[0].userLname.ToString().ToUpper();
                    mainmenu.currentUserID     = loginCredential[0].userID.ToString();
                    mainmenu.Show();

                    this.Hide();
                }
            }
            catch
            {
                logErrorCount += 1;
                MessageBox.Show("No data found!\n" + (3 - logErrorCount).ToString() + " attempts left.", "Invalid Credential");
            }

            if (logErrorCount >= 3)
            {
                Application.Exit();
            }
        }
Beispiel #2
0
        public void Users_Load_UserDefine()
        {
            classConnection loginCredential = new classConnection();

            try
            {
                UserData[] myCredential = loginCredential.readUser_byID(currentUserID).ToArray();
                txtUsername.Text   = myCredential[0].userUsername;
                txtPassword.Text   = myCredential[0].userPassword;
                txtRetypePass.Text = myCredential[0].userPassword;
                txtFirstname.Text  = myCredential[0].userFname;
                txtLastname.Text   = myCredential[0].userLname;
            }
            catch
            {
            }
        }
Beispiel #3
0
        private void btnChange_Click(object sender, EventArgs e)
        {
            if (btnChange.Text == "CHANGE")
            {
                btnChange.Text    = "SAVE";
                btnCancel.Visible = true;
                EnableTextBox();
            }
            else if (btnChange.Text == "SAVE")
            {
                if (txtPassword.Text == txtRetypePass.Text)
                {
                    if (txtFirstname.Text == "" || txtLastname.Text == "" || txtPassword.Text == "" || txtRetypePass.Text == "" || txtUsername.Text == "")
                    {
                        MessageBox.Show("Complete all the required fields!");
                    }
                    else
                    {
                        classConnection connect = new classConnection();

                        UserData myCredential = new UserData();
                        myCredential.userID       = this.currentUserID;
                        myCredential.userFname    = txtFirstname.Text;
                        myCredential.userLname    = txtLastname.Text;
                        myCredential.userPassword = txtPassword.Text;
                        myCredential.userUsername = txtUsername.Text;
                        if (connect.updateUser(myCredential))
                        {
                            MessageBox.Show("Successfully Saved!");
                            DisableTextBox();
                            btnCancel.Visible = false;
                            btnChange.Text    = "CHANGE";
                        }
                        else
                        {
                            MessageBox.Show("Failed!");
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Password Mismatch!");
                }
            }
        }