Example #1
0
        private void back_btn_Click(object sender, EventArgs e)
        {
            this.Hide();
            Cashier cashier = new Cashier();

            cashier.Show();
        }
        private void back_btn_Click(object sender, EventArgs e)
        {
            if (Global.UserID.Trim().Equals("Admin"))
            {
                this.Hide();
                Main main = new Main();
                main.Show();
            }

            else if (Global.UserID.Trim().Equals("Cashier"))
            {
                this.Hide();
                Cashier cashier = new Cashier();
                cashier.Show();
            }

            else if (Global.UserID.Trim().Equals("Rider"))
            {
                this.Hide();
                Rider rider = new Rider();
                rider.Show();
            }

            else if (Global.UserID.Trim().Equals("Waiter"))
            {
                this.Hide();
                Waiter waiter = new Waiter();
                waiter.Show();
            }

            else if (Global.UserID.Trim().Equals("Chef"))
            {
                this.Hide();
                Chef chef = new Chef();
                chef.Show();
            }
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            DB db = new DB();

            String username = txtUsername.Text;
            String password = txtPassword.Text;

            Global.Gusername = txtUsername.Text.ToString();
            DataTable table = new DataTable();

            MySqlDataAdapter adapter = new MySqlDataAdapter();

            MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE  username = @usn and password = @pass", db.getConnection());

            command.Parameters.Add("@usn", MySqlDbType.VarChar).Value  = username;
            command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = password;

            adapter.SelectCommand = command;

            adapter.Fill(table);

            //check if the user exists or not
            if (table.Rows.Count > 0)
            {
                string type = comboBox1.Text;
                Global.UserID = comboBox1.Text.ToString();
                if (type.Trim().Equals("Admin"))
                {
                    this.Hide();
                    Main main = new Main();
                    main.Show();
                }

                else if (type.Trim().Equals("Cashier"))
                {
                    this.Hide();
                    Cashier cashier = new Cashier();
                    cashier.Show();
                }

                else if (type.Trim().Equals("Chef"))
                {
                    this.Hide();
                    Chef chef = new Chef();
                    chef.Show();
                }

                else if (type.Trim().Equals("Rider"))
                {
                    this.Hide();
                    Rider rider = new Rider();
                    rider.Show();
                }

                else if (type.Trim().Equals("Waiter"))
                {
                    this.Hide();
                    Waiter waiter = new Waiter();
                    waiter.Show();
                }

                else
                {
                    MessageBox.Show("Select a Type", "Empty Type", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                if (username.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Your Username to Login", "Empty Username", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                else if (password.Trim().Equals(""))
                {
                    MessageBox.Show("Enter Your Password to Login", "Empty Password", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                else
                {
                    MessageBox.Show("Wrong Username or Password", "Wrong Data", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }