Пример #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Employee employee = new EmployeeDAO().getEmployeeByEmail(txtemail.Text);

            if (employee != null)
            {
                if (matchHashes(txtPassword.Text, employee.password))
                {
                    UI.Properties.Settings.Default.email    = txtemail.Text;
                    UI.Properties.Settings.Default.password = txtPassword.Text;
                    UI.Properties.Settings.Default.Save();

                    if (this.dashboard == null)
                    {
                        frmdashboard dashboard = new frmdashboard(employee);
                        dashboard.Show();
                        this.Hide();
                    }
                    else
                    {
                        this.dashboard.setUser(employee);
                        this.dashboard.Show();
                        this.Hide();
                    }
                }
                else
                {
                    MessageBox.Show("Error in login. Check credentials", "Login error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            else
            {
                MessageBox.Show("Error in login. Check credentials", "Login error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Пример #2
0
        private void btnSignup_Click(object sender, EventArgs e)
        {
            Employee emp;

            //get matching branch for the user by its address
            Branch branch = new BranchDAO().getBranch(comboBranchAddress.Text);

            if (branch == null)
            {
                MessageBox.Show("Error on signup", "Signup error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                return;
            }

            //sign up user according to its user type
            switch (comboSignupRole.Text)
            {
            case "cashier":
                emp = new Cashier
                {
                    first_name = txtSignupFIrstName.Text,
                    last_name  = txtSignupLastName.Text,
                    email      = txtSignupEmail.Text,
                    role       = comboSignupRole.Text,
                    branch     = branch,
                    password   = hashPassword(txtSignupPassword.Text)
                };
                break;

            case "admin":
                emp = new Admin
                {
                    first_name = txtSignupFIrstName.Text,
                    last_name  = txtSignupLastName.Text,
                    email      = txtSignupEmail.Text,
                    role       = comboSignupRole.Text,
                    branch     = branch,
                    password   = hashPassword(txtSignupPassword.Text)
                };
                break;

            default:
                emp = null;
                break;
            }
            emp = new EmployeeDAO().saveEmployee(emp);
            if (emp != null)
            {
                frmdashboard dashboard = new frmdashboard(emp);
                dashboard.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("Error on signup", "Signup error", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            };
        }
Пример #3
0
 public frmLogin(frmdashboard dashboard)
 {
     InitializeComponent();
     this.dashboard = dashboard;
 }