-
Notifications
You must be signed in to change notification settings - Fork 1
/
booking_history.py
122 lines (100 loc) · 5.23 KB
/
booking_history.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import tkinter as tk
from tkinter import ttk
from tkinter.font import Font
import mysql.connector as mysql
from mysql.connector import Error
from functools import partial
from tkinter import messagebox
import datetime
def history_screen(cust_id, homepage):
def on_closing():
root.destroy()
cursor.execute("SELECT CUSTOMER_NAME, CREDIT_POINTS, EMAIL_ID FROM CUSTOMER WHERE CUSTOMER_ID=%s;", [cust_id])
records = cursor.fetchall()
user_name = records[0][0]
credit_points = records[0][1]
email = records[0][2]
import homepage
homepage.homepage_screen(cust_id, email, user_name, credit_points)
con = mysql.connect(
host="localhost",
user="root",
password="testpassword",
database="FMS",
port = 3306
)
dict_data = {
'journey_ids':[],
'date_book':[],
'date_journey':[],
'price':[],
'seat_type':[],
'seat_num':[],
'start':[],
'dest':[]
}
cursor = con.cursor()
cursor.execute("SELECT JOURNEY_ID, DATE_OF_BOOKING, PRICE, SEAT_TYPE, SEAT_NO FROM BOOKS_FLIGHT WHERE CUSTOMER_ID=%s ORDER BY DATE_OF_BOOKING;", [cust_id])
res = cursor.fetchall()
if len(res)==0:
messagebox.showwarning("Record not found!", "No bookings done yet.")
else:
homepage.destroy()
dict_data['journey_ids']=[str(id[0]) for id in res]
dict_data['date_book']=[str(id[1].strftime("%d-%m-%Y")) for id in res]
dict_data['price']=[str(id[2]) for id in res]
dict_data['seat_type']=[str(id[3]) for id in res]
dict_data['seat_num']=[str(id[4]) for id in res]
for journey in dict_data['journey_ids']:
cursor.execute("SELECT START_CITY, DEST_CITY FROM ROUTE WHERE ROUTE_ID=(SELECT ROUTE_ID FROM FLIGHT WHERE FLIGHT_NO=(SELECT FLIGHT_NO FROM JOURNEY_FLIGHT WHERE JOURNEY_ID=%s));", [journey])
cities=cursor.fetchmany(size=1)
dict_data["start"].append(cities[0][0])
dict_data["dest"].append(cities[0][1])
cursor.execute("SELECT JOURNEY_DATE FROM JOURNEY_FLIGHT WHERE JOURNEY_ID=%s;", [journey])
jdate=cursor.fetchmany(size=1)
dict_data["date_journey"].append(jdate[0][0])
root = tk.Tk()
root.title('Flight Management System')
root.geometry('720x420')
root.resizable(height = False, width = False)
container = tk.Frame(root, width=720, height=420, bg="blue")
canvas = tk.Canvas(container, width=700, height=400)
scrollbar = ttk.Scrollbar(container, orient="vertical", command=canvas.yview)
scrollable_frame = ttk.Frame(canvas)
scrollable_frame.bind(
"<Configure>",
lambda e: canvas.configure(
scrollregion=canvas.bbox("all")
)
)
canvas.create_window((0, 0), window=scrollable_frame, anchor="nw")
canvas.configure(yscrollcommand=scrollbar.set)
font10 = Font(family='Arial', size=10)
font15 = Font(family='Arial', size=15)
font20 = Font(family='Arial', size=20)
font30 = Font(family='Arial', size=30, weight='bold')
for i in range(len(dict_data['journey_ids'])):
tk.Label(scrollable_frame, text="Booking No: "+str(i+1), font=font20).grid(column=0, row=0+(6*i), padx=50)
tk.Label(scrollable_frame, text="Journey ID: "+dict_data['journey_ids'][i], font=font15).grid(column=0, row=1+(6*i), padx=50)
tk.Label(scrollable_frame, text="Date of Booking: "+dict_data['date_book'][i], font=font10).grid(column=4, row=1+(6*i))
tk.Label(scrollable_frame, text=dict_data['start'][i], font=font15).grid(column=0, row=2+(6*i))
tk.Label(scrollable_frame, text=dict_data['dest'][i], font=font15).grid(column=4, row=2+(6*i))
tk.Label(scrollable_frame, text=dict_data['date_journey'][i]).grid(column=2, row=1+(6*i), padx=(0, 50))
tk.Label(scrollable_frame, text="---------------->", font=font20).grid(column=2, row=2+(6*i), padx=(0, 50))
tk.Label(scrollable_frame, text="Seat: "+dict_data['seat_type'][i]+" "+dict_data['seat_num'][i], font=font10).grid(column=2, row=3+(6*i), padx=(0, 50), pady=(0, 30))
tk.Label(scrollable_frame, text="Price: "+dict_data['price'][i], font=font10).grid(column=0, row=3+(6*i), pady=(0, 30))
#tk.Label(scrollable_frame, text=dict_data['seat_num'][i]).grid(column=4, row=0+(6*i), padx=70)
# tk.Label(scrollable_frame, text=dict_data['dest_airport'], font=font10).grid(column=4, row=3+(6*i))
# tk.Label(scrollable_frame, text=dict_data['flight_id'][i], font=font10).grid(column=2, row=3+(6*i), sticky="N")
n_rows = 30
n_columns = 10
for i in range(n_rows):
root.grid_rowconfigure(i, weight =1)
for i in range(n_columns):
root.grid_columnconfigure(i, weight =1)
container.pack()
canvas.pack(side="left", fill="both", expand=True)
scrollbar.pack(side="right", fill="y")
root.protocol("WM_DELETE_WINDOW", on_closing)
root.mainloop()
# history_screen(1)