Beispiel #1
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            string username = txtUsername.Text.Trim();
            string password = txtPassword.Text.Trim();

            if (txtUsername.Text != "" && txtPassword.Text != "")
            {
                Employee employee = fitness.Employees.Where(f => f.Username == username).FirstOrDefault();

                if (employee == null)
                {
                    MessageBox.Show("Invalid username or password");
                    return;
                }
                if (!checkedHashCode(employee.Password, password))
                {
                    MessageBox.Show("Invalid username or password");
                    return;
                }
                if (employee.HasVerify == false)
                {
                    VerifyPass verifyPass = new VerifyPass(employee, fitness);
                    verifyPass.Show();
                    return;
                }
                if (employee.RoleId == 1)
                {
                    Admin admin = new Admin(fitness, employee);
                    admin.Show();
                }
                else
                {
                    EmployeeForm employeeForm = new EmployeeForm(fitness, employee);
                    employeeForm.Show();
                }
                if (employee == null)
                {
                    MessageBox.Show("Invalid username or password");
                    return;
                }
                if (!checkedHashCode(employee.Password, password))
                {
                    MessageBox.Show("Invalid username or password");
                    return;
                }
                if (employee.HasVerify == false)
                {
                    VerifyPass verifyPass = new VerifyPass(employee, fitness);
                    verifyPass.Show();
                    return;
                }
            }
            else
            {
                MessageBox.Show("Username or password invalid");
            }
            txtPassword.Text = "";
            txtUsername.Text = "";
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            User user = new User();

            user.Login    = textBox1.Text;
            user.Password = textBox2.Text;
            if (user.IsValidUser(user))
            {
                EmployeeForm empForm = new EmployeeForm();
                empForm.Show();
            }
            else
            {
                MessageBox.Show("User and/or password incorrect or does not exist!", "Error");
            }
        }