0% found this document useful (0 votes)
44 views17 pages

T Final Cs Project PDF

The document describes a computer project for a theatre management system created by Aayush Pant. The project uses Python and MySQL to create a movie booking system that allows users to add movies to a database, view available movies, book seats, view bookings, and cancel reservations. The system stores movie and booking information in MySQL tables to enable easy data retrieval and management. Source code and output are included to demonstrate how the booking system functions.

Uploaded by

Ayush pant
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views17 pages

T Final Cs Project PDF

The document describes a computer project for a theatre management system created by Aayush Pant. The project uses Python and MySQL to create a movie booking system that allows users to add movies to a database, view available movies, book seats, view bookings, and cancel reservations. The system stores movie and booking information in MySQL tables to enable easy data retrieval and management. Source code and output are included to demonstrate how the booking system functions.

Uploaded by

Ayush pant
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Theatre management system

COMPUTER PROJECT

Aayush Pant Board Roll No.


CERTIFICATE
This is to certify that the Computer Journal has been
completed by Aayush Pant of class XII B, in partial
fulfilment of the curriculum of the CENTRAL BOARD OF
SECONDARY EDUCATION
leading the award of the
SENIOR SECONDARY CERTIFICATE for AISSCE
EXAMINATION
for the year 2023 – 2024.

___________________
___________________
External Examiner Internal
Examiner

__________________
__________________
School Stamp Principal’s
Signature

Board Roll No.


ACKNOWLEDGEMENT

I take this opportunity to express my sincere thanks


and gratitude to Mrs. Avnita Bir, Principal, R.N Podar
school (C.B.S.E) for providing the facilities and
infrastructure for my computer project.

 Aayush Pant
INDEX
 Hardware specification
 Software specification
 Project objective
 Project usage
 Program specifications
 Source code
 Output
 References
Hardware Specifications:
This project was made on the system with the following configuration:
 Intel i3 8 gen processor or above
th

 Windows 7 or higher

Software Specification:
The following are the software specifications of the program:
 Pycharm
 Spyder
 MySQL 8.0 Command Line Client

Project Objective:
To create a theatre data management system that can do as follows:
1. Add movies
2. List movies
3. Make Booking
4. List Bookings
5. Cancel Booking
6. Delete Movie

Project usage:
This project can be used by anyone to test their basic knowledge on
various topics.
PROJECT OUTLINE:
Movie Booking System

Objective:
- The Movie Booking System is a Python-based application designed
to manage movie bookings, allowing users to add movies, book
seats, view bookings, cancel reservations, list movies, and delete
movies from a MySQL database.

Key Functionality:
- Database setup: Establishes a connection to MySQL, creates
essential tables, and populates seat information.
- Movie Management: Enables the addition of movies, listing
available movies, and setting seat prices.
- Booking System: Allows users to make movie bookings, view their
bookings, and cancel reservations.
- Deletion of Movies: Provides an option to delete movies from the
database.
Data Storage:
- Movie and booking information is stored in a MySQL database for
easy retrieval and management.
Conclusion:
- The Movie Booking System streamlines movie reservations and
provides a foundation for building more advanced ticketing systems.
Packages used- MySQL connector
SOURCE CODE:
import mysql.connector

obj = mysql.connector.connect(host="localhost", user="root",


password='admin@123')
mycursor = obj.cursor()
# Create the sys database if it doesn't exist
mycursor.execute("CREATE DATABASE IF NOT EXISTS new1")
mycursor.execute("USE new1")

# Create Tables

def setup_database():
# Setup tables for movies, seats, reservations, and bookings
mycursor.execute("""
CREATE TABLE IF NOT EXISTS movies2 (
id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL UNIQUE,
duration INT NOT NULL,
protagonist VARCHAR(40)
) AUTO_INCREMENT = 1
""")

mycursor.execute("""
CREATE TABLE IF NOT EXISTS seats1 (
id INT AUTO_INCREMENT PRIMARY KEY,
seat_number INT NOT NULL,
is_reserved BOOLEAN DEFAULT 0,
price INT DEFAULT 0,
UNIQUE (seat_number)
)
""")

mycursor.execute("""
CREATE TABLE IF NOT EXISTS reservations (
id INT AUTO_INCREMENT PRIMARY KEY,
seat_number INT NOT NULL,
customer_name VARCHAR(255) NOT NULL,
reservation_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
""")

mycursor.execute("""
CREATE TABLE IF NOT EXISTS booking2 (
id INT AUTO_INCREMENT PRIMARY KEY,
movie_id INT,
seats_id INT,
reservation_id INT,
FOREIGN KEY (movie_id) REFERENCES movies2(id),
FOREIGN KEY (seats_id) REFERENCES seats1(id),
FOREIGN KEY (reservation_id) REFERENCES reservations(id)
)
""")
setup_database()

#Seat numbers from 1-50


for seat_number in range(1, 51):
# Check if the seat number already exists in the table
mycursor.execute("SELECT seat_number FROM seats1 WHERE seat_number = %s",
(seat_number,))
existing_seat = mycursor.fetchone()

# If the seat number doesn't exist, insert it


if not existing_seat:
mycursor.execute("INSERT INTO seats1 (seat_number) VALUES (%s)",
(seat_number,))
# Commit the changes
obj.commit()

# Insert data into the 'movies' table

query = "INSERT IGNORE INTO movies2 (title, duration, protagonist) VALUES (%s,
%s, %s)"
data_movies = [
('RaOne', 155, 'ShahRukhKhan'),
('Dream Girl', 160, 'AayushManKhuranna'),
('DeadPool', 140, 'Ryan Reynolds'),
('Agent Vinod', 159, 'SaifAliKhan'),
('Baby', 170, 'AkkshayKumar')
]
mycursor.executemany(query, data_movies)

# Commit the changes


obj.commit()

#adding seats
def set_seat_prices():
price_brackets = [(1, 10, 500), (11, 20, 400), (21, 30, 300), (31, 40,
200), (41, 50, 100)]
for start, end, price in price_brackets:
mycursor.execute("""
UPDATE seats1
SET price = %s
WHERE seat_number BETWEEN %s AND %s
""", (price, start, end))
obj.commit()
set_seat_prices()

def display_available_seats(movie_title):
# Get the movie's ID based on the title
mycursor.execute("SELECT id FROM movies2 WHERE title = %s",
(movie_title,))
movie_id = mycursor.fetchone()

if not movie_id:
print(f"Movie '{movie_title}' does not exist.")
return []

# Fetch available seats for this movie


mycursor.execute("""
SELECT s.seat_number, s.price
FROM seats1 s
LEFT JOIN booking2 b ON s.seat_number = b.seats_id AND b.movie_id = %s
WHERE s.is_reserved = 0 OR b.seats_id IS NULL
""", (movie_id[0],))

available_seats = mycursor.fetchall()
if available_seats:
print("Available seats (Price):", [(seat[0], int(seat[1])) for seat in
available_seats])
return [seat[0] for seat in available_seats]
else:
print("No available seats.")
return []

# View reservations
# Cancel reservations

def add_movie():
title = input("Enter movie name: ")
duration = int(input("Enter movie duration: "))
protagonist = input("Enter protagonist name: ")

try:
mycursor.execute("INSERT INTO movies2 (title, duration, protagonist)
VALUES (%s, %s, %s)", (title, duration, protagonist))
obj.commit()
print("Movie added successfully!")
except mysql.connector.Error as err:
print(f"Error: {err}")

# Function to list theaters


def list_movie():
mycursor.execute("SELECT * FROM movies2")
movies = mycursor.fetchall()
if movies:
print("\nList of Movies:")
for movie in movies:
print(f"ID: {movie[0]}, Title: {movie[1]}, Duration: {movie[2]}
mins, Protagonist: {movie[3]}")
else:
print("No movies available.")

def make_booking():
list_movie()
movie_title = input("Enter movie title for which you want to book: ")
available_seats = display_available_seats(movie_title)

if not available_seats:
return

seat_choice = int(input("Enter the seat number you want to book from the
available seats: "))
if seat_choice not in available_seats:
print("Invalid choice. Seat not available.")
return

customer_name = input("Enter your name for the booking: ")

# Get the movie's ID based on the title


mycursor.execute("SELECT id FROM movies2 WHERE title = %s",
(movie_title,))
movie_id = mycursor.fetchone()
if not movie_id:
print(f"Movie '{movie_title}' does not exist.")
return

# Reserve the seat


mycursor.execute("""
INSERT INTO reservations (seat_number, customer_name)
VALUES (%s, %s)
""", (seat_choice, customer_name))

reservation_id = mycursor.lastrowid
mycursor.execute("UPDATE seats1 SET is_reserved = 1 WHERE seat_number =
%s", (seat_choice,))

mycursor.execute("""
INSERT INTO booking2 (movie_id, seats_id, reservation_id)
VALUES (%s, %s, %s)
""", (movie_id[0], seat_choice, reservation_id))

obj.commit()

mycursor.execute("SELECT price FROM seats1 WHERE seat_number = %s",


(seat_choice,))
seat_price = mycursor.fetchone()
if seat_price:
print("\nReceipt:")
print("Seat Number | Reservation Date | Title | Duration
(minutes) | Price")
print(f"{seat_choice:11} | CURRENT DATE | {movie_title:14} |
TBD | {int(seat_price[0])}")

def list_bookings():
try:
mycursor.execute("""
SELECT r.seat_number, r.reservation_date, m.title, m.duration, s.price
FROM booking2 b
INNER JOIN reservations r ON b.reservation_id = r.id
INNER JOIN movies2 m ON b.movie_id = m.id
INNER JOIN seats1 s ON r.seat_number = s.seat_number
""")
bookings = mycursor.fetchall()
if not bookings:
print("No bookings found.")
else:
print("Seat Number | Reservation Date | Title | Duration (minutes)
| Price")
for booking in bookings:
print("{:11} | {} | {} | {} | {}".format(
booking[0], booking[1], booking[2], booking[3],
booking[4]))
except mysql.connector.Error as err:
print(f"Error: {err}")

def delete_movie(title):
# Check if the movie with the provided title exists
mycursor.execute("SELECT id FROM movies2 WHERE title = %s", (title,))
movie_id = mycursor.fetchone()

if movie_id:
# Delete the movie from the movies2 table
mycursor.execute("DELETE FROM movies2 WHERE id = %s", (movie_id[0],))
obj.commit()
print(f"Movie with title '{title}' deleted successfully!")
else:
print(f"Movie with title '{title}' not found.")

def cancel_booking():
customer_name = input("Enter your name: ")
movie_title = input("Enter the movie title of your booking: ")

new_cursor = obj.cursor(buffered=True)

# Get the movie's ID based on the title


new_cursor.execute("SELECT id FROM movies2 WHERE title = %s",
(movie_title,))
movie_id = new_cursor.fetchone()
if not movie_id:
print(f"Movie with title '{movie_title}' not found.")
return

# Retrieve the reservation details for the given movie and customer name
new_cursor.execute("""
SELECT r.id, r.seat_number
FROM reservations r
JOIN booking2 b ON r.id = b.reservation_id
WHERE r.customer_name = %s AND b.movie_id = %s
""", (customer_name, movie_id[0]))

reservations = new_cursor.fetchall()

if not reservations:
print(f"No reservations found for {customer_name} for the movie
{movie_title}.")
return

if len(reservations) > 1:
print("You have multiple seats booked for this movie. Here are the
seats:")
for reservation in reservations:
_, seat_number = reservation
print(f"Seat number: {seat_number}")
seat_number_to_cancel = int(input("Enter the seat number you want to
cancel: "))
else:
_, seat_number_to_cancel = reservations[0]

# Get the reservation ID based on customer name and seat number


new_cursor.execute("""
SELECT id FROM reservations
WHERE customer_name = %s AND seat_number = %s
""", (customer_name, seat_number_to_cancel))
reservation_id = new_cursor.fetchone()[0]

# First, delete the reference from the booking2 table


new_cursor.execute("""
DELETE FROM booking2
WHERE reservation_id = %s AND movie_id = %s
""", (reservation_id, movie_id[0]))

# Then, delete the reservation from the reservations table


new_cursor.execute("""
DELETE FROM reservations
WHERE id = %s
""", (reservation_id,))

# Set the seat as available in the seats1 table


new_cursor.execute("""
UPDATE seats1
SET is_reserved = 0
WHERE seat_number = %s
""", (seat_number_to_cancel,))

obj.commit()
print(f"Booking for movie '{movie_title}' seat number
{seat_number_to_cancel} canceled successfully!")
new_cursor.close()

if __name__ == "__main__":

while True:
print("\nOptions:")
print("1. Add movies")
print("2. List movies")
print("3. Make Booking")
print("4. List Bookings")
print("5. Cancel Booking")
print("6. Delete Movie")
print("0. Quit")

choice = input("Enter your choice: ")

if choice == '1':
add_movie()
elif choice == '2':
list_movie()
elif choice == '3':
make_booking()
elif choice == '4':
list_bookings()
elif choice == '5':
cancel_booking()
elif choice == '6':
delete_movie()
elif choice == '0':
break
else:
print("Invalid choice. Please try again.")

obj.close()
OUTPUT:
REFERENCES:
www.wikipedia.org

You might also like