Ejemplo n.º 1
0
        private void flatButton1_Click(object sender, EventArgs e)
        {
            EmployeeDA.BinaryReader(listofemployee);
            this.Hide();
            MIS_Manager nmis = new MIS_Manager();

            nmis.Show();
        }
Ejemplo n.º 2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string loginUser, loginPass;
            int    empJobCode;

            loginUser = txtBoxUName.Text.Trim().ToLower();
            loginPass = txtUPass.Text.Trim();
            //MessageBox.Show(System.Text.Encoding.UTF8.EncodeBase64(loginPass));
            //txtBoxUName.Text = System.Text.Encoding.UTF8.EncodeBase64(loginPass);

            if (loginUser == "")
            {
                MessageBox.Show("Can not login! \nUser name must be specified to login!", "Warning!");
                return;
            }
            if (loginPass == "")
            {
                MessageBox.Show("Can not login! \nPassword must be specified to login!", "Warning!");
                return;
            }
            //verify employee and password

            if (Employee.isLoginPwOfEmp(loginUser, loginPass))
            {
                empJobCode = Employee.isPowerEmp(loginUser);
                Employee employee;
                switch (empJobCode)
                {
                case 0:
                {
                    //MessageBox.Show("The user has ReadOnly status!\n" +
                    //    "Access level: " + Employee.DecodeEmpJobCode(empJobCode), "Access granted!",
                    //    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    employee = new ReadOnlyEmployee(empJobCode, loginUser, loginPass);
                    break;
                }

                case 1:
                {
                    //  MessageBox.Show("The user is an Employee!\n" +
                    //    "Access level: " + Employee.DecodeEmpJobCode(empJobCode), "Access granted!",
                    //MessageBoxButtons.OK, MessageBoxIcon.Information);
                    employee = new MIS_Manager(empJobCode, loginUser, loginPass);
                    break;
                }

                case 2:
                {
                    //MessageBox.Show("The user is an Employee!\n" +
                    //    "Access level: " + Employee.DecodeEmpJobCode(empJobCode), "Access granted!",
                    //    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    employee = new Sales_Manager(empJobCode, loginUser, loginPass);
                    break;
                }

                case 3:
                {
                    //MessageBox.Show("The user is an Employee!\n" +
                    //    "Access level: " + Employee.DecodeEmpJobCode(empJobCode), "Access granted!",
                    //    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    employee = new Inventory_Controller(empJobCode, loginUser, loginPass);
                    break;
                }

                case 4:
                {
                    //MessageBox.Show("The user is an Employee!\n" +
                    //    "Access level: " + Employee.DecodeEmpJobCode(empJobCode), "Access granted!",
                    //    MessageBoxButtons.OK, MessageBoxIcon.Information);
                    employee = new Order_Clerk(empJobCode, loginUser, loginPass);

                    break;
                }

                default:
                {
                    MessageBox.Show("The is not a user, account not found!\n" +
                                    "Access level: " + Employee.DecodeEmpJobCode(empJobCode), "Access Denied!",
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    employee = null;
                    break;
                }
                }
                //Employee employee = Employee.getEmp(loginUser, loginPass);
                //to show another windows form
                FrmManageAccount manageFrm = new FrmManageAccount(employee);
                manageFrm.Show();
                this.Hide();
            }
            else
            {
                MessageBox.Show("Access denied! \nNo such user name or password incorrect!");
            }

            //exit
        }