Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();                        //Hides Form 1/ Login screen
            studentMenu f2 = new studentMenu(); //Create form2 object

            f2.ShowDialog();
        }
Exemple #2
0
        private void but_login_Click(object sender, EventArgs e)
        {
            //Student 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 = 'student'";

            //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 student");
                connection.Close();                 //Close database
                connection.Dispose();               //Releases memory*/
                this.Hide();                        //Hides Form 1/ Login screen
                studentMenu f2 = new studentMenu(); //Create form2 object
                f2.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();
        }
Exemple #3
0
        private void but_submit_Click(object sender, EventArgs e)
        {
            try
            {
                connection.Open();
                OleDbCommand command = new OleDbCommand();
                command.Connection  = connection;
                command.CommandText = "insert into Rate(ScreenName, VendorTitle, Review, Rate) values('" + txt_screenName.Text + "', '" + com_vendorTitle.Text + "', '" + txt_review.Text + "' , '" + com_rate.Text + "')";
                command.ExecuteNonQuery();
                MessageBox.Show("Rating Submitted");
                connection.Close();

                this.Hide();                        //Hides Form 1/ Login screen
                studentMenu f1 = new studentMenu(); //Create form2 object
                f1.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please fill in all fields!", "Submission Error");
                connection.Close();
            }

            updateRate();
        }