Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtEmail.Text != "" && txtPassword.Text != "")
                {
                    List <vwUserDetail> user = UserRepo.login(txtEmail.Text, txtPassword.Text);

                    if (user.Count > 0)
                    {
                        if (user[0].UserRole == "cashier" && user[0].UserStatus == "active")
                        {
                            Cashier cashier = new Cashier(user);
                            cashier.Show();
                            this.Hide();
                        }
                        else if (user[0].UserRole == "admin" && user[0].UserStatus == "active")
                        {
                            Admin admin = new Admin(user);
                            admin.Show();
                            this.Hide();
                        }
                    }
                    else
                    {
                        lblWarning.Visible = true;
                        lblWarning.Text    = ("Login has failed, please try again.");
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An erro has occured. Please contact your system administrator" + ex.Message);
            }
        }
        private void UnitOfMeasurement_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Are you sure you want to exit?", "Exit", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                Cashier cashier = new Cashier();
                cashier.Show();
                this.Hide();
            }
        }