Note - Double Click to Copy Code Contact Us!
Posts

Tour and Travel Management System using Python

Tech Doubility
Tour and Travel Management System




Python Code
  1. #importing tkinter and pyodbc
  2.  
  3. import tkinter as tk
  4. from tkinter import *
  5. # from tkinter import ttk
  6. from tkinter import messagebox
  7. # from tkinter.messagebox import showinfo
  8.  
  9. import pyodbc
  10.  
  11. #Connecting Database
  12. connection = pyodbc.connect('Driver={SQL Server};' 'Server=DESKTOP-QNA2V5M\SQLEXPRESS;'
  13. 'Database=projectTTMS;' 'Trusted_connection=yes;')
  14. cursor = connection.cursor()
  15.  
  16. #Main Menu
  17. root = Tk()
  18. root.wm_title("TOUR MANAGEMENT SYSTEM")
  19. root['background']='#75142B'
  20. Label(root,text="Tour Management System", font=('{Times New Roman} 30 bold underline '), fg='#ffffff', bg= '#75142B').grid()
  21.  
  22. #main menu text
  23. Label(root,text="\nWelcome to the Tour Management System!\nWe are glad to have you here and we are\nexcited to help you in planning your tour.\n",
  24. font=('Montserrat 20 '), fg='#ffffff', bg= '#75142B').grid(row=3,column=0, padx=10, pady=10,sticky=E)
  25. root.geometry('620x450')
  26.  
  27. def fun1():
  28. root.destroy()
  29. root1=Tk()
  30. root1.title("TOUR PACKAGES")
  31. root1.geometry('900x630')
  32. root1['background']='#75142B'
  33. Label(root1,text="Tour Packages", font=('{Times New Roman} 30 bold underline'),fg='#ffffff', bg= '#75142B').grid(columnspan=2)
  34. Label(root1,text="\nThese are the available tour packages:\n", font=('Montserrat 15 italic '), fg='#ffffff', bg= '#75142B').grid(sticky=NSEW, columnspan=2)
  35. cur = connection.cursor()
  36.  
  37. Label(root1,text="PACKAGE 1", font=('Montserrat 15 bold '), fg='#ffffff', bg= '#75142B').grid(sticky=NSEW)
  38. cur.execute("select package_name from Tour_Package where package_id = 1")
  39. m1 = cur.fetchall()
  40. cur.execute("select package_description from Tour_Package where package_id = 1")
  41. m2 = cur.fetchall()
  42. cur.execute("select convert(varchar(20),package_price) from Tour_Package where package_id = 1")
  43. m3 = cur.fetchall()
  44. cur.execute("select package_duration from Tour_Package where package_id = 1")
  45. m4 = cur.fetchall()
  46. M = "Package Name: {s1} \nPackage Description: {s2} \nPackage Price: {s3} \nPackage Duration: {s4}".format(s1=m1,s2=m2,s3=m3,s4=m4)
  47. T = tk.Text(root1, height=5, width=55, wrap=WORD)
  48. T.grid(row=3,column=0)
  49. T.insert(tk.END, M)
  50.  
  51. Label(root1,text="\nPACKAGE 2", font=('Montserrat 15 bold '), fg='#ffffff', bg= '#75142B').grid(row=4,column=0,sticky=NSEW)
  52. cur.execute("select package_name from Tour_Package where package_id = 2")
  53. n1 = cur.fetchall()
  54. cur.execute("select package_description from Tour_Package where package_id = 2")
  55. n2 = cur.fetchall()
  56. cur.execute("select convert(varchar(20),package_price) from Tour_Package where package_id = 2")
  57. n3 = cur.fetchall()
  58. cur.execute("select package_duration from Tour_Package where package_id = 2")
  59. n4 = cur.fetchall()
  60. Na = "Package Name: {s1} \nPackage Description: {s2} \nPackage Price: {s3} \nPackage Duration: {s4}".format(s1=n1,s2=n2,s3=n3,s4=n4)
  61. T = tk.Text(root1, height=5, width=55, wrap=WORD)
  62. T.grid(row=5,column=0)
  63. T.insert(tk.END, Na)
  64.  
  65.  
  66. Label(root1,text="\nPACKAGE 3", font=('Montserrat 15 bold '), fg='#ffffff', bg= '#75142B').grid(row=6,column=0,sticky=NSEW)
  67. cur.execute("select package_name from Tour_Package where package_id = 3")
  68. l1 = cur.fetchall()
  69. cur.execute("select package_description from Tour_Package where package_id = 3")
  70. l2 = cur.fetchall()
  71. cur.execute("select convert(varchar(20),package_price) from Tour_Package where package_id = 3")
  72. l3 = cur.fetchall()
  73. cur.execute("select package_duration from Tour_Package where package_id = 3")
  74. l4 = cur.fetchall()
  75. L = "Package Name: {s1} \nPackage Description: {s2} \nPackage Price: {s3} \nPackage Duration: {s4}".format(s1=l1,s2=l2,s3=l3,s4=l4)
  76. T = tk.Text(root1, height=5, width=55, wrap=WORD)
  77. T.grid(row=7,column=0)
  78. T.insert(tk.END, L)
  79.  
  80.  
  81. Label(root1,text="PACKAGE 4", font=('Montserrat 15 bold '), fg='#ffffff', bg= '#75142B').grid(sticky=NSEW, row=2,column=1)
  82. cur.execute("select package_name from Tour_Package where package_id = 4")
  83. o1 = cur.fetchall()
  84. cur.execute("select package_description from Tour_Package where package_id = 4")
  85. o2 = cur.fetchall()
  86. cur.execute("select convert(varchar(20),package_price) from Tour_Package where package_id = 4")
  87. o3 = cur.fetchall()
  88. cur.execute("select package_duration from Tour_Package where package_id = 4")
  89. o4 = cur.fetchall()
  90. O = "Package Name: {s1} \nPackage Description: {s2} \nPackage Price: {s3} \nPackage Duration: {s4}".format(s1=o1,s2=o2,s3=o3,s4=o4)
  91. T = tk.Text(root1, height=5, width=55, wrap=WORD)
  92. T.grid(row=3,column=1)
  93. T.insert(tk.END, O)
  94.  
  95. Label(root1,text="\nPACKAGE 5", font=('Montserrat 15 bold '), fg='#ffffff', bg= '#75142B').grid(row=4,column=1,sticky=NSEW)
  96. cur.execute("select package_name from Tour_Package where package_id = 5")
  97. p1 = cur.fetchall()
  98. cur.execute("select package_description from Tour_Package where package_id = 5")
  99. p2 = cur.fetchall()
  100. cur.execute("select convert(varchar(20),package_price) from Tour_Package where package_id = 5")
  101. p3 = cur.fetchall()
  102. cur.execute("select package_duration from Tour_Package where package_id = 5")
  103. p4 = cur.fetchall()
  104. P = "Package Name: {s1} \nPackage Description: {s2} \nPackage Price: {s3} \nPackage Duration: {s4}".format(s1=p1,s2=p2,s3=p3,s4=p4)
  105. T = tk.Text(root1, height=5, width=55, wrap=WORD)
  106. T.grid(row=5,column=1)
  107. T.insert(tk.END, P)
  108.  
  109.  
  110. Label(root1,text="\nPACKAGE 6", font=('Montserrat 15 bold '), fg='#ffffff', bg= '#75142B').grid(row=6,column=1,sticky=NSEW)
  111. cur.execute("select package_name from Tour_Package where package_id = 6")
  112. q1 = cur.fetchall()
  113. cur.execute("select package_description from Tour_Package where package_id = 6")
  114. q2 = cur.fetchall()
  115. cur.execute("select convert(varchar(20),package_price) from Tour_Package where package_id = 6")
  116. q3 = cur.fetchall()
  117. cur.execute("select package_duration from Tour_Package where package_id = 6")
  118. q4 = cur.fetchall()
  119. Q = "Package Name: {s1} \nPackage Description: {s2} \nPackage Price: {s3} \nPackage Duration: {s4}".format(s1=q1,s2=q2,s3=q3,s4=q4)
  120. T = tk.Text(root1, height=5, width=55, wrap=WORD)
  121. T.grid(row=7,column=1)
  122. T.insert(tk.END, Q)
  123.  
  124. #Book Button
  125. BB=Button(root1,text="Book Tour", font=('Montserrat 10 bold'), height=0,width=10,fg='#75142B', borderwidth=3, relief="flat",
  126. bg='#ffffff', activebackground='#75142B',activeforeground='#ffffff', command=fun2).grid(row=8,column=0,padx=5, pady=5,sticky=N, columnspan= 2)
  127. root1.mainloop()
  128.  
  129. def fun2():
  130. root2=Tk()
  131. root2.title("BOOKING")
  132. root2.geometry('450x450')
  133. root2['background']='#75142B'
  134. Label(root2,text="Book Tour", font=('{Times New Roman} 30 bold underline'),fg='#ffffff', bg= '#75142B').grid()
  135. Label(root2,text="\nPlease enter the details to book your tour.\n", font=('Montserrat 15 italic '), fg='#ffffff', bg= '#75142B').grid(sticky=NSEW)
  136. cur = connection.cursor()
  137.  
  138. #Name
  139. Label(root2,text="Name: ",font=('Montserrat 15 bold '), fg='#ffffff', bg= '#75142B').grid(row=2,column=0,sticky=W)
  140. def namedropdown():
  141. cur = connection.cursor()
  142. cur.execute("select customer_name from Customer")
  143. data = []
  144. for i in cur.fetchall():
  145. data.append(i[0])
  146. return data
  147. q1 = StringVar()
  148. w1=ttk.Combobox(root2, height=10,width=20,textvariable=q1, state = 'readonly')
  149. w1['values'] = namedropdown()
  150. w1.grid(row=2,column=0)
  151.  
  152. #Hotel
  153. Label(root2,text="Hotel: ",font=('Montserrat 15 bold '), fg='#ffffff', bg= '#75142B').grid(row=3,column=0,sticky=W)
  154. def hoteldropdown():
  155. cur = connection.cursor()
  156. cur.execute("select hotel_name from Hotel")
  157. data = []
  158. for i in cur.fetchall():
  159. data.append(i[0])
  160. return data
  161. q2 = StringVar()
  162. w2=ttk.Combobox(root2, height=10,width=20,textvariable=q2, state = 'readonly')
  163. w2['values'] = hoteldropdown()
  164. w2.grid(row=3,column=0)
  165.  
  166. #Booking date
  167. Label(root2,text="Booking Date: ",font=('Montserrat 13 bold '), fg='#ffffff', bg= '#75142B').grid(row=4,column=0,sticky=W)
  168. bd = Entry(root2, width=23)
  169. bd.grid(row=4, column=0)
  170. Label(root2,text="(YYYY-MM-DD)", font=('{Times New Roman} 10'), fg='#ffffff', bg= '#75142B').grid(row=4,column=0,sticky=E)
  171.  
  172. #Package
  173. Label(root2,text="Package: ",font=('Montserrat 15 bold '), fg='#ffffff', bg= '#75142B').grid(row=5,column=0,sticky=W)
  174. def packagedropdown():
  175. cur = connection.cursor()
  176. cur.execute("select package_name from Tour_Package")
  177. data = []
  178. for i in cur.fetchall():
  179. data.append(i[0])
  180. return data
  181. q3 = StringVar()
  182. w3=ttk.Combobox(root2, height=10,width=20,textvariable=q3, state = 'readonly')
  183. w3['values'] = packagedropdown()
  184. w3.grid(row=5,column=0)
  185.  
  186. #Place
  187. Label(root2,text="Place: ",font=('Montserrat 15 bold '), fg='#ffffff', bg= '#75142B').grid(row=6,column=0,sticky=W)
  188. def placedropdown():
  189. cur = connection.cursor()
  190. cur.execute("select place_name from Tourism_Place")
  191. data = []
  192. for i in cur.fetchall():
  193. data.append(i[0])
  194. return data
  195. q4 = StringVar()
  196. w4=ttk.Combobox(root2, height=10,width=20,textvariable=q4, state = 'readonly')
  197. w4['values'] = placedropdown()
  198. w4.grid(row=6,column=0)
  199.  
  200. #Transport
  201. Label(root2,text="Transport: ",font=('Montserrat 15 bold '), fg='#ffffff', bg= '#75142B').grid(row=7,column=0,sticky=W)
  202. def transportdropdown():
  203. cur = connection.cursor()
  204. cur.execute("select transport_description from Transport")
  205. data = []
  206. for i in cur.fetchall():
  207. data.append(i[0])
  208. return data
  209. q5 = StringVar()
  210. w5=ttk.Combobox(root2, height=10,width=20,textvariable=q5, state = 'readonly')
  211. w5['values'] = transportdropdown()
  212. w5.grid(row=7,column=0)
  213.  
  214. def book_function():
  215. a=w1.get()
  216. b=w2.get()
  217. c=bd.get()
  218. d=w3.get()
  219. e=w4.get()
  220. f=w5.get()
  221. cur=connection.cursor()
  222. if a=='' or b=='' or c=='' or d=='' or e=='' or f=='':
  223. messagebox.showerror("Error","Cant leave any field empty")
  224. else:
  225. def PackageFunc(connection):
  226. cursor = connection.cursor()
  227. cursor.execute(f"SELECT package_id FROM Tour_Package where package_name = '{d}'")
  228. for row in cursor:
  229. row = row[0]
  230. return row
  231. connection.commit()
  232.  
  233. def CustomerFunc(connection):
  234. cursor = connection.cursor()
  235. cursor.execute(f"SELECT customer_id FROM Customer where customer_name = '{a}'")
  236. for row in cursor:
  237. row = row[0]
  238. return row
  239. connection.commit()
  240.  
  241. def TransportFunc(connection):
  242. cursor = connection.cursor()
  243. cursor.execute(f"SELECT transport_id FROM Transport where transport_description like '{f}'")
  244. for row in cursor:
  245. row = row[0]
  246. return row
  247. connection.commit()
  248.  
  249. def HotelFunc(connection):
  250. cursor = connection.cursor()
  251. cursor.execute(f"SELECT hotel_id FROM Hotel where hotel_name = '{b}'")
  252. for row in cursor:
  253. row = row[0]
  254. return row
  255. connection.commit()
  256.  
  257. def PlaceFunc(connection):
  258. cursor = connection.cursor()
  259. cursor.execute(f"SELECT place_id FROM Tourism_Place where place_name = '{e}'")
  260. for row in cursor:
  261. row = row[0]
  262. return row
  263. connection.commit()
  264.  
  265. def PriceFunc(connection):
  266. cursor = connection.cursor()
  267. cursor.execute(f"SELECT package_price FROM Tour_Package where package_name = '{d}'")
  268. for row in cursor:
  269. row = row[0]
  270. return row
  271. connection.commit()
  272.  
  273. package = PackageFunc(connection)
  274. customer = CustomerFunc(connection)
  275. transport = TransportFunc(connection)
  276. hotel = HotelFunc(connection)
  277. place = PlaceFunc(connection)
  278. price = PriceFunc(connection)
  279.  
  280. cur.execute("insert into Tour_Booking (package_id,customer_id,transport_id,hotel_id,place_id,booking_date,booking_total_price,booking_status) values(?,?,?,?,?,?,?,?)",(package,customer,transport,hotel,place,c,price,"Confirmed"))
  281. connection.commit()
  282.  
  283. messagebox.showinfo("BOOKING SUCCESSFUL","Your Tour has been booked! THANK YOU FOR CHOOSING US")
  284.  
  285.  
  286.  
  287. #Book Button
  288. BB=Button(root2,text="Book Tour", font=('Montserrat 10 bold'), height=0,width=10,fg='#75142B', borderwidth=3, relief="flat",
  289. bg='#ffffff', activebackground='#75142B',activeforeground='#ffffff', command=book_function).grid(row=8,column=0,padx=5, pady=5,sticky=N)
  290. root2.mainloop()
  291.  
  292.  
  293.  
  294. #Button Of Search Flight in Main Menu
  295. B1=Button(root,text="Tour Packages", font=('Montserrat 15 bold'),height=0,width=15,fg='#75142B', borderwidth=3, relief="flat",
  296. bg='#ffffff', activebackground='#75142B',activeforeground='#ffffff', command=fun1).grid(row=4,column=0, padx=10, pady=10,sticky=N)
  297.  
  298. #Button Of Book Flight in Main Menu
  299. B2=Button(root,text="Book Tour", font=('Montserrat 15 bold'),height=0,width=15,fg='#75142B', borderwidth=3, relief="flat",
  300. bg='#ffffff', activebackground='#75142B',activeforeground='#ffffff', command=fun2).grid(row=5,column=0, padx=10, pady=10,sticky=N)
  301.  
  302.  
  303. root.mainloop()
SQL Code
  1.  
  2. --Tour and Travel Management System--
  3.  
  4. --Creating Database--
  5. create database projectTTMS
  6.  
  7. --Using Database 'projectTTMS'--
  8. use projectTTMS
  9.  
  10.  
  11. --==============================================================================--
  12.  
  13. --Creating Tables--
  14. CREATE TABLE Tour_Package (
  15. package_id varchar(50) PRIMARY KEY,
  16. package_name VARCHAR(255),
  17. package_description TEXT,
  18. package_price VARCHAR(20),
  19. package_duration INTEGER
  20. );
  21.  
  22. CREATE TABLE Customer (
  23. customer_id varchar(50) PRIMARY KEY,
  24. customer_name VARCHAR(255),
  25. customer_email VARCHAR(255),
  26. customer_phone VARCHAR(255)
  27. );
  28.  
  29. CREATE TABLE Transport (
  30. transport_id varchar(50) PRIMARY KEY,
  31. transport_type VARCHAR(255),
  32. transport_description TEXT,
  33. transport_capacity INTEGER
  34. );
  35.  
  36. CREATE TABLE Hotel (
  37. hotel_id varchar(50) PRIMARY KEY,
  38. hotel_name VARCHAR(255),
  39. hotel_description TEXT,
  40. hotel_location VARCHAR(255),
  41. hotel_rating DECIMAL
  42. );
  43.  
  44. CREATE TABLE Tourism_Place (
  45. place_id varchar(50) PRIMARY KEY,
  46. place_name VARCHAR(255),
  47. place_description TEXT,
  48. place_location VARCHAR(255),
  49. place_category VARCHAR(255)
  50. );
  51.  
  52. CREATE TABLE Tour_Booking (
  53. booking_id INTEGER PRIMARY KEY identity(100,1),
  54. package_id VARCHAR(50),
  55. customer_id VARCHAR(50),
  56. transport_id VARCHAR(50),
  57. hotel_id VARCHAR(50),
  58. place_id VARCHAR(50),
  59. booking_date DATE,
  60. booking_total_price VARCHAR(50),
  61. booking_status VARCHAR(255),
  62. FOREIGN KEY (package_id) REFERENCES Tour_Package (package_id),
  63. FOREIGN KEY (customer_id) REFERENCES Customer (customer_id),
  64. FOREIGN KEY (transport_id) REFERENCES Transport (transport_id),
  65. FOREIGN KEY (hotel_id) REFERENCES Hotel (hotel_id),
  66. FOREIGN KEY (place_id) REFERENCES Tourism_Place (place_id)
  67. );
  68.  
  69.  
  70.  
  71. --==============================================================================--
  72. --INSERTION--
  73.  
  74.  
  75. INSERT INTO Tour_Package (package_id, package_name, package_description, package_price, package_duration)
  76. VALUES ('1', 'Hunza Valley Tour', 'Experience the beauty of Hunza with our comprehensive tour package', '5000', 7),
  77. ('2', 'Simple Swat Tour ', 'Explore the diverse cultures of Asia with our tour package', '4000', 10),
  78. ('3', 'Super Saver Kashmir ', 'Experience the beauty of Kashmir with our comprehensive tour package', '6000', 14),
  79. ('4', 'Inspirational Kaghan' , 'Experience the beauty of kaghan with our comprehensive tour package', '29000' ,5),
  80. ('5', 'Skardu Big Trip' , 'Experience the beauty of Skardu with our comprehensive tour package', '60000' ,4),
  81. ('6', 'Short trip to Kumrat' , 'Experience the beauty of Kumrat with our comprehensive tour package' , '15999' ,7)
  82.  
  83. INSERT INTO Customer (customer_id, customer_name, customer_email, customer_phone)
  84. VALUES ('1', 'John Smith', 'john.smith@gmail.com', '123-456-7890'),
  85. ('2', 'Jane Doe', 'jane.doe@gmail.com', '234-567-8901'),
  86. ('3', 'Bob Johnson', 'bob.johnson@gmail.com', '345-678-9012');
  87.  
  88. INSERT INTO Transport (transport_id, transport_type, transport_description, transport_capacity)
  89. VALUES ('1', 'By Air', 'PIA', 300),
  90. ('2', 'By Air', 'SERENE', 200),
  91. ('3', 'By Air', 'AIR SIAL', 250),
  92. ('4', 'By Air', 'AIR BLUE', 200);
  93.  
  94. INSERT INTO Hotel (hotel_id, hotel_name, hotel_description, hotel_location, hotel_rating)
  95. VALUES ('1', 'Hotel Crown Plaza', 'in the heart of Islamabad', 'Islamabad', 7.1),
  96. ('2', 'Shelton Hotel Johar Town', 'The hotel features elegant rooms', 'Lahore Pakistan', 3.0),
  97. ('3', 'Swat View Hotel', 'The hotel features a garden a restaurant a terrace', 'Sawat Pakistan', 6.8),
  98. ('4', 'Pine Park Hotel','Pine Park Hotel is located in Shogran Naran','Shogran Naran Pakistan' ,8.0),
  99. ('5', 'Hotel Felton',' It is a three Star Hotel','Muree Pakistan',7.0);
  100.  
  101. INSERT INTO Tourism_Place (place_id, place_name, place_description, place_location, place_category)
  102. VALUES ('1', 'Hunza Valley', 'Mountainous Valley', 'Gilgit Baltistan', 'Exotic place'),
  103. ('2', 'Swat', 'Mountainous Valley', 'Malakand, KPK', 'Natural geographic region'),
  104. ('3', 'Kashmir', 'A Land of Unimaginable Beauty ', 'Azad Kashmir', 'Adventurous '),
  105. ('4', 'Kaghan' , 'Alpine Valley' , 'Mansehra KPK' , 'Exotic place'),
  106. ('5', 'Skardu' , 'Mountainous, Cold desert' , 'Gilgit Baltistan' , 'Adventurous'),
  107. ('6', 'Kumrat' , 'Mountainous Valley' , 'Dir, KPK' , 'Natural geographic region');
  108.  
  109. INSERT INTO Tour_Booking (package_id, customer_id, transport_id, hotel_id, place_id, booking_date, booking_total_price, booking_status)
  110. VALUES ('1', '1','1', '1', '1', '2022-01-01', '5000', 'Confirmed'),
  111. ('2', '2', '2', '2', '2', '2022-02-01', '4000', 'Confirmed'),
  112. ('3', '3', '3', '3','3', '2022-03-01', '6000', 'Confirmed');
  113.  
  114.  
  115. --==============================================================================--
  116. --VIEWING--
  117.  
  118.  
  119. select * from Customer
  120.  
  121. select * from Hotel
  122.  
  123. select * from Tour_Booking
  124.  
  125. select * from Tour_Package
  126.  
  127. select * from Tourism_Place
  128.  
  129. select * from Transport

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.