private void btnBack_Click(object sender, EventArgs e)
        {
            switch (ProgOps.access)
            {
            case "Customer":
                frmMainMenu main = new frmMainMenu();
                this.Hide();
                main.ShowDialog();
                break;

            case "Employee":
                frmEmployeeMenu emp = new frmEmployeeMenu();
                this.Hide();
                emp.ShowDialog();
                break;

            case "Admin":
                frmAdminMenu admin = new frmAdminMenu();
                this.Hide();
                admin.ShowDialog();
                break;

            default:
                break;
            }
        }
Пример #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            username = tbxUsername.Text;
            password = tbxPassword.Text;

            if (username == String.Empty || password == String.Empty)
            {
                MessageBox.Show("Username and Password are required", "Incomplete Fields", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        if (dr["USERNAME"].ToString() != username)
                        {
                            continue;
                        }
                        else
                        {
                            //Determine access level; access determines menu type to load
                            ProgOps.access = dr.Field <String>("DESIGNATION") != null?dr.Field <String>("DESIGNATION") : String.Empty;

                            String pwCheck = dr.Field <String>("PASSWORD") != null?dr.Field <String>("PASSWORD") : String.Empty;

                            String user = dr.Field <String>("FNAME") != null?dr.Field <String>("FNAME") + " " + dr.Field <String>("LNAME") : String.Empty;

                            user_id = dr.Field <Int32>("USER_ID");
                            //Check credentials against DB
                            if (password == pwCheck)
                            {
                                flag = true;
                                MessageBox.Show("Welcome to Nuts Bolts and Beyond, " + user, "Login Successful", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

                                //Determine form to open based on access level
                                switch (ProgOps.access)
                                {
                                case "Customer":
                                    frmMainMenu main = new frmMainMenu();
                                    this.Hide();
                                    main.ShowDialog();
                                    break;

                                case "Employee":
                                    frmEmployeeMenu emp = new frmEmployeeMenu();
                                    this.Hide();
                                    emp.ShowDialog();
                                    break;

                                case "Admin":
                                    frmAdminMenu admin = new frmAdminMenu();
                                    this.Hide();
                                    admin.ShowDialog();
                                    break;

                                default:
                                    break;
                                }
                            }
                            else
                            {
                                MessageBox.Show("Please check your information and try again", "Please try again", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                tbxUsername.Text = String.Empty;
                                tbxPassword.Text = String.Empty;
                            }
                            break;
                        }
                    }
                    if (flag == false)
                    {
                        MessageBox.Show("Please check your information and try again", "Please try again", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        tbxUsername.Text = String.Empty;
                        tbxPassword.Text = String.Empty;
                    }
                    else
                    {
                    }
                }
            }
        }