Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();                          //Hides Form 1/ Login screen
            Administator f2 = new Administator(); //Create form2 object

            f2.ShowDialog();
        }
Exemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            //Admin Login
            connection.Open();
            //Create command to validate database
            OleDbCommand command = new OleDbCommand();

            command.Connection = connection;   //Give "command" the conncection
            //Create a query
            command.CommandText = "select * from LogIn where Username= '******' and Pass= '******' and Privilege = 'administrator'";
            //Excecute query
            command.ExecuteNonQuery();     //Do non-query when want to get data from database (Don't want a return)


            OleDbDataReader reader = command.ExecuteReader(); //Read data from a dabase
            int             count  = 0;                       //Variable to count values in command

            while (reader.Read())
            {
                count++;        //Finds number of found results for the query executed
            }
            if (count == 1)
            {
                //MessageBox.Show("Username and Password is correct for admin");
                connection.Close();                   //Close database
                connection.Dispose();                 //Releases memory*/
                this.Hide();                          //Hides Form 1/ Login screen
                Administator f5 = new Administator(); //Create form2 object
                f5.ShowDialog();                      //Opens Form 2
            }

            else if (count > 1)      //Finds duplicate entry
            {
                MessageBox.Show("Duplicate Username and Password ");
            }

            else
            {
                MessageBox.Show("Username and Password NOT correct");
            }
            connection.Close();
        }