C.S Project
C.S Project
C.S Project
Acknowledgement
Introduction
Hardware and Software requirements
Why Python ?
Source Code
Out Put Series
Further Development
Acknowledgment
Backend: MySQL
MySQL is employed to store and manage user data, movie details, and
booking information.
SQL queries are executed to check login credentials, retrieve movie
details, and update seat bookings
How to Run:
Ensure Python, Tkinter, and MySQL Connector/Python are installed. Set
up the MySQL database and table as specified in the code.
Update the database connection parameters in the code.
Run the Python script.
This Movie Ticket Booking System provides a seamless and user-friendly
experience for customers to browse, select, and book movie tickets,
enhancing the efficiency of the ticket booking process. Users can enjoy
the convenience of reserving their preferred seats with just a few clicks.
Hardware And Software Requirements
Hardware Requirements:
Computer: Any standard desktop or laptop computer should be sufficient.
MySQL Server: Since the code connects to a MySQL database, you need
access to a MySQL server. If you don't have one installed locally, you
might consider using a remote MySQL server.
Internet Connection: If you are using a remote MySQL server, you will
need an internet connection to connect to it.
Software Requirements:
Python: Ensure you have Python installed on your system. You can
download the latest version of Python from the official website.
It is used in :
1. Software Development
2. Web Development
3. System Scripting
4. Mathematics
Python is Interpreted
Python is Interactive
It means that you can actually sit at a Python prompt and interact with the
interpreter directly, to write and execute your programs.
import tkinter as tk
from tkinter import messagebox
import mysql.connector
from tkinter import ttk
try:
# Connect to the MySQL database
db = mysql.connector.connect(
host="localhost",
user="root",
password="",
database="MovieTicketDB"
)
cursor = db.cursor()
db.close()
except mysql.connector.Error as err:
messagebox.showerror("Database Error", f"Error: {err}")
except Exception as e:
messagebox.showerror("Error", f"An error occurred: {e}")
label_movie_selection = tk.Label(movie_selection_window,
text="Select a Movie", font=("Helvetica", 20))
label_movie_selection.pack(pady=20)
label_time_selection = tk.Label(movie_selection_window,
text="Select Time", font=("Helvetica", 16))
label_time_selection.pack(pady=10)
def open_seat_booking_screen():
selected_movie = movie_combobox.get()
selected_date = date_combobox.get()
selected_time = time_combobox.get()
seat_booking_window = tk.Toplevel(movie_selection_window)
seat_booking_window.title("Seat Booking")
seat_booking_window.geometry("800x600")
label_seat_booking = tk.Label(seat_booking_window, text="Select
Your Seats", font=("Helvetica", 20))
label_seat_booking.grid(row=0, column=0, columnspan=7,
pady=20)
num_rows = 7
num_cols = 7
def confirm_selection():
nonlocal selected_seats
selected_seats = [f"Seat {r * num_cols + c + 1}" for r in
range(num_rows) for c in range(num_cols) if seats[r * num_cols + c]
["bg"] == "red"]
if not selected_seats:
messagebox.showinfo("Selection Confirmation", "No seats
selected.")
else:
messagebox.showinfo("Selection Confirmation", f"Selected
Seats for {selected_movie} on {selected_date} at {selected_time}:\n" +
"\n".join(selected_seats))
open_payment_screen()
def open_payment_screen():
payment_window = tk.Toplevel(seat_booking_window)
payment_window.title("Payment")
payment_window.geometry("400x300")
def process_payment():
messagebox.showinfo("Payment Successful", "Payment
completed successfully. Enjoy the movie!")
payment_window.destroy()
def register_user():
new_username = entry_new_username.get()
new_password = entry_new_password.get()
try:
# Connect to the MySQL database
db = mysql.connector.connect(
host="localhost",
user="root",
password="",
database="MovieTicketDB"
)
cursor = db.cursor()
# Check if the new username already exists in the database
query = "SELECT * FROM users WHERE username=%s"
cursor.execute(query, (new_username,))
result = cursor.fetchone()
if result:
messagebox.showerror("Registration Failed", "Username
already exists.")
else:
# Insert the new user into the database
query = "INSERT INTO users (username, password) VALUES
(%s, %s)"
cursor.execute(query, (new_username, new_password))
db.commit()
messagebox.showinfo("Registration Successful", "Registration
completed successfully.")
db.close()
except mysql.connector.Error as err:
messagebox.showerror("Database Error", f"Error: {err}")
except Exception as e:
messagebox.showerror("Error", f"An error occurred: {e}")