예제 #1
0
        private void cancelButton_Click(object sender, EventArgs e)
        {
            ManagerPortal manager = new ManagerPortal();

            manager.Show();

            this.Close();
        }
예제 #2
0
        private void cancelButton_Click(object sender, EventArgs e)
        {
            this.Close();

            ManagerPortal portal = new ManagerPortal();

            portal.Show();
        }
예제 #3
0
        private void loginManagerButton_Click(object sender, EventArgs e)
        {
            // The following Connection, Command and DataReader objects will be used to access the jt_genre_movie table
            NpgsqlConnection dbConnection1 = CreateDBConnection(DbServerHost, DbUsername, DbUuserPassword, DbName);
            NpgsqlCommand    dbCommand1;
            NpgsqlDataReader dataReader1;

            string username = usernameTextBox.Text;
            string password = passwordTextBox.Text;
            int    usertype = 2;

            dbConnection1.Open();

            string sqlQuery = "select * from movietheaterschema.user_account;";

            Console.WriteLine("SQL Query: " + sqlQuery);

            //This is the actual SQL containing the query to be executed
            dbCommand1 = new NpgsqlCommand(sqlQuery, dbConnection1);

            dataReader1 = dbCommand1.ExecuteReader();

            while (dataReader1.Read())
            {
                if (usertype == dataReader1.GetInt32(5))
                {
                    if (username == dataReader1.GetString(2))
                    {
                        if (password == dataReader1.GetString(3))
                        {
                            this.Hide();

                            ManagerPortal f1 = new ManagerPortal();
                            f1.Show();
                        }

                        else
                        {
                            errorMessageLabel.Visible = true;
                        }
                    }

                    else
                    {
                        errorMessageLabel.Visible = true;
                    }
                }
            }

            dbConnection1.Close();
        }
예제 #4
0
        private void diplayNewMovie()
        {
            // The following Connection, Command and DataReader objects will be used to access the jt_genre_movie table
            NpgsqlConnection dbConnection1 = CreateDBConnection(DbServerHost, DbUsername, DbUuserPassword, DbName);
            NpgsqlCommand    dbCommand1;
            NpgsqlDataReader dataReader1;

            NpgsqlConnection dbConnection2 = CreateDBConnection(DbServerHost, DbUsername, DbUuserPassword, DbName);
            NpgsqlCommand    dbCommand2;
            NpgsqlDataReader dataReader2;

            dbConnection1.Open();

            string sqlQuery = "SELECT * FROM movietheaterschema.movie;";

            //This is the actual SQL containing the query to be executed
            dbCommand1 = new NpgsqlCommand(sqlQuery, dbConnection1);

            dataReader1 = dbCommand1.ExecuteReader();

            int[] thenumbers = { };

            while (dataReader1.Read())
            {
                int[] numbers = { dataReader1.GetInt32(0) };

                thenumbers = numbers;
            }

            dbConnection1.Close();

            int biggestNumber = thenumbers.Max();

            biggestNumber++;

            if (string.IsNullOrEmpty(titleTextBox.Text) || string.IsNullOrEmpty(yearTextBox.Text) || string.IsNullOrEmpty(lengthTextBox.Text) ||
                string.IsNullOrEmpty(audienceRatingTextBox.Text) || string.IsNullOrEmpty(imageFilePathTextBox.Text))
            {
                errorMessageLabel.Visible = true;
                errorlabel2.Visible       = true;
                errorlabel3.Visible       = true;
                errorlabel4.Visible       = true;
                errorlabel5.Visible       = true;
                errorlabel6.Visible       = true;
                errorlabel7.Visible       = true;
            }
            else
            {
                // ADD NEW MOVIE TO MOVIE

                string sqlQuery2 = "INSERT INTO movietheater_db.movietheaterschema.movie VALUES ('" + biggestNumber + "', '" + titleTextBox.Text + "', '" +
                                   yearTextBox.Text + "', '" + lengthTextBox.Text + "', '" + audienceRatingTextBox.Text + "', '" + imageFilePathTextBox.Text + "'" + ");";

                dbConnection2.Open();

                dbCommand2 = new NpgsqlCommand(sqlQuery2, dbConnection2);

                dbCommand2.ExecuteNonQuery();

                dbConnection2.Close();

                MessageBox.Show("Movie Modified Succsefully.");

                this.Close();

                ManagerPortal portal = new ManagerPortal();

                portal.Show();
            }
        }
예제 #5
0
        private void createAccount()
        {
            // The following Connection, Command and DataReader objects will be used to access the jt_genre_movie table
            NpgsqlConnection dbConnection1 = CreateDBConnection(DbServerHost, DbUsername, DbUuserPassword, DbName);
            NpgsqlCommand    dbCommand1;
            NpgsqlDataReader dataReader1;

            NpgsqlConnection dbConnection2 = CreateDBConnection(DbServerHost, DbUsername, DbUuserPassword, DbName);
            NpgsqlCommand    dbCommand2;
            NpgsqlDataReader dataReader2;

            dbConnection1.Open();

            string sqlQuery = "SELECT * FROM movietheaterschema.user_account;";

            Console.WriteLine("SQL Query: " + sqlQuery);

            //This is the actual SQL containing the query to be executed
            dbCommand1 = new NpgsqlCommand(sqlQuery, dbConnection1);

            dataReader1 = dbCommand1.ExecuteReader();

            int[] thenumbers = { };

            while (dataReader1.Read())
            {
                int[] numbers = { dataReader1.GetInt32(0) };

                thenumbers = numbers;
            }

            dbConnection1.Close();

            int biggestNumber = thenumbers.Max();

            Console.WriteLine(biggestNumber);

            biggestNumber++;

            Console.WriteLine("Added one: " + biggestNumber);

            // Get the current date.
            string dateformat = DateTime.Now.ToString("yyyy-MM-dd h:mm");


            if (string.IsNullOrEmpty(nameTextBox.Text) || string.IsNullOrEmpty(usernameTextBox.Text) || string.IsNullOrEmpty(emailTextBox.Text) || string.IsNullOrEmpty(passwordTextBox.Text))
            {
                errorMessageLabel.Visible = true;
                errorlabel1.Visible       = true;
                errorlabel2.Visible       = true;
                errorlabel3.Visible       = true;
                errorlabel4.Visible       = true;
            }

            else
            {
                string sqlQuery2 = "INSERT INTO movietheater_db.movietheaterschema.user_account VALUES ('" + biggestNumber + "', '" + nameTextBox.Text + "', '" + usernameTextBox.Text + "', '" +
                                   passwordTextBox.Text + "', '" + emailTextBox.Text + "', '2', '" + dateformat + "'" + ");";

                Console.WriteLine("SQL Query: " + sqlQuery2);

                dbConnection2.Open();

                //This is the actual SQL containing the query to be executed
                dbCommand2 = new NpgsqlCommand(sqlQuery2, dbConnection2);

                dbCommand2.ExecuteNonQuery();

                MessageBox.Show("Account Created Succsefully.");

                this.Close();

                ManagerPortal portal = new ManagerPortal();

                portal.Show();
            }
        }