0% found this document useful (0 votes)
8 views8 pages

Travel Agency Management System Code

The document is a Python script for a Travel Agency Management System that allows users to manage customers, travel packages, and bookings. It includes functions to add, view, search, delete bookings, and generate receipts. The main menu provides options for user interaction and utilizes text files to store customer, package, and booking data.

Uploaded by

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

Travel Agency Management System Code

The document is a Python script for a Travel Agency Management System that allows users to manage customers, travel packages, and bookings. It includes functions to add, view, search, delete bookings, and generate receipts. The main menu provides options for user interaction and utilizes text files to store customer, package, and booking data.

Uploaded by

T M Mithun
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

import os

CUSTOMER_FILE = "[Link]"

PACKAGE_FILE = "[Link]"

BOOKING_FILE = "[Link]"

# ----------- Customer Management --------------

def add_customer():

print("\n--- Add Customer ---")

customer_id = input("Enter Customer ID: ")

name = input("Enter Customer Name: ")

contact = input("Enter Contact Number: ")

email = input("Enter Email: ")

with open(CUSTOMER_FILE, "a") as f:

[Link](f"{customer_id},{name},{contact},{email}\n")

print("✅ Customer added successfully!")

def view_customers():

print("\n--- Customer List ---")

if [Link](CUSTOMER_FILE):

with open(CUSTOMER_FILE, "r") as f:

for line in f:

customer_id, name, contact, email = [Link]().split(",")

print(f"ID: {customer_id}, Name: {name}, Contact: {contact}, Email: {email}")


else:

print("❌ No customer data found.")

# ----------- Package Management --------------

def add_package():

print("\n--- Add Travel Package ---")

package_id = input("Enter Package ID: ")

name = input("Enter Package Name: ")

destination = input("Enter Destination: ")

duration = input("Enter Duration (e.g., 5 days): ")

price = input("Enter Price: ")

with open(PACKAGE_FILE, "a") as f:

[Link](f"{package_id},{name},{destination},{duration},{price}\n")

print("✅ Package added successfully!")

def view_packages():

print("\n--- Available Packages ---")

if [Link](PACKAGE_FILE):

with open(PACKAGE_FILE, "r") as f:

for line in f:

package_id, name, destination, duration, price = [Link]().split(",")

print(f"ID: {package_id}, Name: {name}, To: {destination}, Duration: {duration}, Price: ₹{price}")

else:

print("❌ No packages found.")


# ----------- Booking Management --------------

def book_package():

print("\n--- Book Travel Package ---")

booking_id = input("Enter Booking ID: ")

customer_id = input("Enter Customer ID: ")

package_id = input("Enter Package ID: ")

with open(BOOKING_FILE, "a") as f:

[Link](f"{booking_id},{customer_id},{package_id}\n")

print("✅ Booking recorded successfully!")

def view_bookings():

print("\n--- Booking Records ---")

if [Link](BOOKING_FILE):

with open(BOOKING_FILE, "r") as f:

for line in f:

booking_id, customer_id, package_id = [Link]().split(",")

print(f"Booking ID: {booking_id}, Customer ID: {customer_id}, Package ID: {package_id}")

else:

print("❌ No bookings found.")

# ----------- Search Booking --------------

def search_booking():

bid = input("Enter Booking ID to search: ")


found = False

with open(BOOKING_FILE, "r") as f:

for line in f:

booking_id, customer_id, package_id = [Link]().split(",")

if booking_id == bid:

print(f"✔ Booking Found: Customer ID: {customer_id}, Package ID: {package_id}")

found = True

if not found:

print("❌ Booking not found.")

# ----------- Delete Booking --------------

def delete_booking():

bid = input("Enter Booking ID to delete: ")

updated_lines = []

found = False

with open(BOOKING_FILE, "r") as f:

for line in f:

if not [Link](bid + ","):

updated_lines.append(line)

else:

found = True

with open(BOOKING_FILE, "w") as f:

[Link](updated_lines)
if found:

print(" Booking deleted.")

else:

print("❌ Booking ID not found.")

# ----------- Generate Receipt --------------

def generate_receipt():

bid = input("Enter Booking ID for receipt: ")

with open(BOOKING_FILE, "r") as bfile:

for line in bfile:

booking_id, customer_id, package_id = [Link]().split(",")

if booking_id == bid:

with open(CUSTOMER_FILE, "r") as cfile:

customer_info = None

for cline in cfile:

cid, name, contact, email = [Link]().split(",")

if cid == customer_id:

customer_info = (name, contact, email)

break

with open(PACKAGE_FILE, "r") as pfile:

package_info = None

for pline in pfile:

pid, pname, dest, duration, price = [Link]().split(",")


if pid == package_id:

package_info = (pname, dest, duration, price)

break

if customer_info and package_info:

print("\n----- Travel Booking Receipt -----")

print(f"Booking ID: {booking_id}")

print(f"Customer Name: {customer_info[0]}")

print(f"Contact: {customer_info[1]}")

print(f"Email: {customer_info[2]}")

print(f"Package Name: {package_info[0]}")

print(f"Destination: {package_info[1]}")

print(f"Duration: {package_info[2]}")

print(f"Total Amount: ₹{package_info[3]}")

print("-----------------------------------")

return

print("❌ Receipt data not found.")

# ----------- Main Menu --------------

def main():

while True:

print("\n====== Travel Agencies Management System ======")

print("1. Add Customer")

print("2. View Customers")

print("3. Add Package")


print("4. View Packages")

print("5. Book Package")

print("6. View Bookings")

print("7. Search Booking")

print("8. Delete Booking")

print("9. Generate Receipt")

print("10. Exit")

print("===============================================")

choice = input("Enter your choice (1-10): ")

if choice == '1':

add_customer()

elif choice == '2':

view_customers()

elif choice == '3':

add_package()

elif choice == '4':

view_packages()

elif choice == '5':

book_package()

elif choice == '6':

view_bookings()

elif choice == '7':

search_booking()
elif choice == '8':

delete_booking()

elif choice == '9':

generate_receipt()

elif choice == '10':

print("Thank you for using the Travel Agency System!")

break

else:

print("❌ Invalid choice. Try again!")

main()

You might also like