Ejemplo n.º 1
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                string  uname   = txtUsername.Text;
                string  pwd     = txtPassword.Text;
                Account account = accountData.CheckLogin(uname, pwd);

                if (account == null)
                {
                    MessageBox.Show("Check your username or password again");
                }
                else
                {
                    UserID = account.ID;
                    if (account.role == 0)
                    {
                        this.Hide();
                        Thread t = new Thread(new ThreadStart(ShowAdminForm));
                        t.SetApartmentState(ApartmentState.STA);
                        t.Start();
                        this.Close();
                    }
                    else if (account.role == 1)
                    {
                        this.Hide();
                        Thread t = new Thread(new ThreadStart(ShowCashierForm));
                        t.SetApartmentState(ApartmentState.STA);
                        t.Start();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Invalid Role");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }