-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_dashboard.py
More file actions
163 lines (126 loc) · 5.49 KB
/
admin_dashboard.py
File metadata and controls
163 lines (126 loc) · 5.49 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
from tkinter import *
from tkinter.font import BOLD
import time
import sys
from tkinter import ttk, messagebox
import time
import sqlite3
class admin_dashboard:
def __init__(self, root):
self.root = root
self.root.geometry('1200x550+50+50')
self.root.title('Taxi Booking Service -Welcome Admin')
self.root.config(bg='white')
self.root.resizable(0, 0)
# Photos/Icons
photo_icon = PhotoImage(file='Image/small.png')
self.root.iconphoto(False, photo_icon)
# headline
admin_headline_label = Label(self.root, text='Admin Dashboard', fg='Black', bg="Yellow", font=(
"Times New Roman", 50, BOLD)).place(x=10, y=10, width=1178)
# label
status_label = Label(self.root, text="Status ", fg='Black', bg="white",
font=("Times New Roman", 30, BOLD)).place(x=600, y=100, width=200)
# all variable
self.var_trip_ID = StringVar()
self.var_Booking_date = StringVar()
self.var_Pickup_date = StringVar()
self.var_Pickup_time = StringVar()
self.var_Pickup_address = StringVar()
self.var_Drop_off_address = StringVar()
self.var_Status = StringVar()
# text box
status_txt_box = Entry(self.root, textvariable=self.var_Status, bg='white', font=(
"Times New ROman", 30)).place(x=850, y=100, width=200)
# Button
update_btn = Button(self.root, text="Halt", command=self.HaltTrip, font=(
"Times New Roman", 40, 'bold'), bg="black", fg="yellow", cursor='hand2', ).place(x=10, y=100, width=380, height=90)
table_frame = Frame(self.root, bd=3, relief=RIDGE)
table_frame.place(x=5, y=300, width=1189, height=245)
# Scrool bar
scrolly = Scrollbar(table_frame, orient=VERTICAL)
scrollx = Scrollbar(table_frame, orient=HORIZONTAL)
self.detailTable = ttk.Treeview(table_frame, columns=("trip_ID", "Booking_date", "Pickup_date", "Pickup_time",
"Pickup_address", "Drop_off_address", "Status"), yscrollcommand=scrolly.set, xscrollcommand=scrollx.set)
scrollx.pack(side=BOTTOM, fill=X)
scrolly.pack(side=RIGHT, fill=Y)
scrollx.config(command=self.detailTable.xview)
scrolly.config(command=self.detailTable.yview)
self.detailTable.heading("trip_ID", text='Trip ID')
self.detailTable.heading("Booking_date", text='Booking Date')
self.detailTable.heading("Pickup_date", text='Pickup date')
self.detailTable.heading("Pickup_time", text='Pickup time')
self.detailTable.heading("Pickup_address", text='Pickup Address')
self.detailTable.heading("Drop_off_address", text='Drop off address')
self.detailTable.heading("Status", text='Status')
self.detailTable["show"] = "headings"
self.detailTable.column("trip_ID", width=150)
self.detailTable.column("Booking_date", width=150)
self.detailTable.column("Pickup_date", width=150)
self.detailTable.column("Pickup_time", width=150)
self.detailTable.column("Pickup_address", width=150)
self.detailTable.column("Drop_off_address", width=150)
self.detailTable.column("Status", width=150)
self.detailTable.pack(fill=BOTH, expand=1)
self.detailTable.bind("<ButtonRelease-1>", self.get_data)
self.show()
def clear(self):
self.var_trip_ID.set(""),
self.var_Booking_date.set(""),
self.var_Pickup_date.set(""),
self.var_Pickup_time.set(""),
self.var_Pickup_address.set(""),
self.var_Drop_off_address.set(""),
self.var_Status.set(""),
self.show()
def show(self):
try:
cur.execute("select * from trip")
rows = cur.fetchall()
self.detailTable.delete(*self.detailTable.get_children())
for row in rows:
self.detailTable.insert("", END, values=row)
except Exception as ex:
messagebox.showerror(
"Error ", f"Save error: {str(ex)}", parent=self.root)
def get_data(self, ev):
f = self.detailTable.focus()
content = (self.detailTable.item(f))
row = content['values']
self.var_trip_ID.set(row[0])
self.var_Booking_date.set(row[1])
self.var_Pickup_date.set(row[2])
self.var_Pickup_time.set(row[3])
self.var_Pickup_address.set(row[4])
self.var_Drop_off_address.set(row[5])
self.var_Status.set(row[6])
def HaltTrip(self):
connection
if self.var_trip_ID.get() == "":
messagebox.showerror(
"Error", "Trip ID must be required", parent=self.root)
else:
cur.execute("Select * from trip where trip_ID =?",
(self.var_trip_ID.get(), ))
row = cur.fetchone()
if row == None:
messagebox.showerror(
"Error", " There is no trip id u entered", parent=self.root)
else:
cur.execute("Update trip set status='Hold' where trip_ID=?", (
self.var_trip_ID.get(),
))
con.commit()
messagebox.showinfo(
"Booking", "Successfullly Booking Done", parent=self.root)
self.clear()
self.show()
con = sqlite3.connect(database=r'taxi_booking_data.db')
cur = con.cursor()
def connection():
con.commit
connection
if __name__ == '__main__':
root = Tk()
obj = admin_dashboard(root)
root.mainloop()