Example #1
0
        public void login(String name, String pass)
        {
            if (accountDatabase.checkInfo(name, pass))
            {
                switch (accountDatabase.getAuthorization(name))
                {
                case Authorization.CUSTOMER:
                    Customer f3 = new Customer((CustomerAccount)accountDatabase.getAccount(name), stallDatabase, orderDatabase);
                    this.Hide();
                    f3.ShowDialog();
                    txtName.Text         = "";
                    txtPass.Text         = "";
                    lblNotification.Text = "";
                    this.Show();
                    break;

                case Authorization.ITSTAFF:
                case Authorization.MASTERITSTAFF:
                    ITStaff f4 = new ITStaff((StaffAccount)accountDatabase.getAccount(name), accountDatabase, stallDatabase);
                    this.Hide();
                    f4.ShowDialog();
                    txtName.Text         = "";
                    txtPass.Text         = "";
                    lblNotification.Text = "";
                    this.Show();
                    if (f4.maintenance)
                    {
                        this.Close();
                    }
                    break;

                case Authorization.COOK:
                    Cook f5 = new Cook((StaffAccount)accountDatabase.getAccount(name), orderDatabase);
                    this.Hide();
                    f5.ShowDialog();
                    txtName.Text         = "";
                    txtPass.Text         = "";
                    lblNotification.Text = "";
                    this.Show();
                    break;
                }
            }
            else
            {
                lblNotification.ForeColor = Color.Red;
                lblNotification.Text      = "Tên đăng nhập hoặc mật khẩu không đúng!";
            }
        }
        private void btnLogIn_Click(object sender, EventArgs e)
        {
            if (accountDatabase.checkInfo(txtName.Text, txtPass.Text))
            {
                switch (accountDatabase.getAuthorization(txtName.Text))
                {
                case Authorization.CUSTOMER:
                    Form3 f3 = new Form3();
                    this.Hide();
                    f3.ShowDialog();
                    txtName.Text         = "";
                    txtPass.Text         = "";
                    lblNotification.Text = "";
                    this.Show();
                    break;

                case Authorization.ITSTAFF:
                case Authorization.MASTERITSTAFF:
                    Form4 f4 = new Form4(txtName.Text, accountDatabase, (StaffAccount)accountDatabase.getAccount(txtName.Text));
                    this.Hide();
                    f4.ShowDialog();
                    txtName.Text         = "";
                    txtPass.Text         = "";
                    lblNotification.Text = "";
                    this.Show();
                    if (f4.maintenance)
                    {
                        this.Close();
                    }
                    break;
                }
            }
            else
            {
                lblNotification.ForeColor = Color.Red;
                lblNotification.Text      = "Tên đăng nhập hoặc mật khẩu không đúng!";
            }
        }