-
Notifications
You must be signed in to change notification settings - Fork 2
/
my_project.py
714 lines (585 loc) · 39 KB
/
my_project.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
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
from tkinter import*
import sqlite3
from tkinter.messagebox import *
from datetime import date
con=sqlite3.connect('bus_booking.db')
cur=con.cursor()
cur.execute('create table if not exists bus(bus_id varchar(5) not null primary key,bus_type varchar(10),capacity int,fair int,op_id varchar(5) not null,route_id varchar(5) not null,foreign key(op_id) references operator(opr_id),foreign key(route_id) references route(r_id))')
cur.execute('create table if not exists operator(opr_id varchar(5) primary key,name varchar(20),address varchar(50),phone char(10),email varchar(30))')
cur.execute('create table if not exists running(b_id varchar(5) ,run_date date,seat_avail int,foreign key(b_id) references bus(bus_id))')
cur.execute('create table if not exists route(r_id varchar(5) not null primary key,s_name varchar(20),s_id varchar(5),e_name varchar(20),e_id varchar(5) )')
cur.execute('create table if not exists booking_history(name varchar(20),gender char(1),no_of_seat int,phone char(10),age int,booking_ref varchar(10) not null primary key,booking_date date,travel_date date,bid varchar(5),foreign key(bid) references bus(bus_id))')
class bus_booking:
def home_page(self):
root = Tk()
root.title("HOME PAGE")
root.state("zoomed")
bus = PhotoImage(file='Bus_for_project.png')
h, w = root.winfo_screenheight(), root.winfo_screenwidth()
root.geometry('%dx%d+0+0' % (w, h))
Label(root, image=bus).grid(row=0, column=0, columnspan=10, padx=w // 2.5)
Label(root, text="Online Bus Booking System", font='Arial 30 bold', bg='LightCyan3', fg='red',relief=RAISED,padx=10,pady=10,bd=5).grid(row=2,
column=3,
columnspan=9,
padx=w // 2.5)
def home_to_jouney_detail():
root.destroy()
self.journey_detail_page()
def home_to_check_booking():
root.destroy()
self.check_booking_page()
def home_to_db_add_page():
root.destroy()
self.db_add_page()
Label(root, text='\n\n\n\n\n\n').grid(row=3, column=4)
Button(root, text='Seat Booking', font='Arial 14 bold', bg='Light green', fg='black',command=home_to_jouney_detail).grid(row=4, column=4)
Label(root, text='\n\n\n\n\n\n').grid(row=3, column=6)
Button(root, text='Check Booked Seat', font='Arial 14 bold', bg='green3', fg='black',command=home_to_check_booking).grid(row=4, column=6)
Label(root, text='\n\n\n\n\n\n').grid(row=3, column=8)
Button(root, text='Add Bus Details', font='Arial 14 bold', bg='green', fg='black',command=home_to_db_add_page ).grid(row=4, column=8)
Label(root, text='\n').grid(row=5, column=8)
Label(root, text='For Admin Only', fg='red').grid(row=6, column=8)
root.mainloop()
def cover_page(self):
root = Tk()
root.title("COVER PAGE")
root.state("zoomed")
bus = PhotoImage(file='Bus_for_project.png')
h, w = root.winfo_screenheight(), root.winfo_screenwidth()
root.geometry('%dx%d+0+0' % (w, h))
Label(root, image=bus).pack()
Label(root, text="Online Bus Booking System", font='Arial 30 bold', bg='LightCyan3', fg='red',relief=RAISED,padx=10,pady=10,bd=5).pack()
Label(root, text="\n\n\n\n\nName: Kaushal Kumar", font='Arial 16 bold', fg='blue').pack()
Label(root, text="\nEnr. No. : 221B201", font='Arial 16 bold', fg='blue').pack()
Label(root, text="\nMobile : 7783868382\n\n\n\n", font='Arial 16 bold', fg='blue').pack()
Label(root, text="Submitted to: Dr. Mahesh Kumar", font='Arial 15 bold', bg='LightCyan3',padx=10,pady=10, fg='red').pack()
Label(root, text="Project Based Learning", font='Arial 15 bold', fg='red').pack()
def cover_to_home(event):
root.destroy()
self.home_page()
root.bind("<KeyPress>", cover_to_home)
root.mainloop()
def journey_detail_page(self):
root = Tk()
root.title("SEAT BOOKING PAGE")
root.state("zoomed")
h, w = root.winfo_screenheight(), root.winfo_screenwidth()
root.geometry('%dx%d+0+0' % (w, h))
def journey_to_home():
root.destroy()
self.home_page()
def show_bus():
tp=to_place.get()
fp=from_place.get()
jd=journey_date.get()
if tp.isalpha() and fp.isalpha():
if not jd=='':
tp = tp.lower()
fp = fp.lower()
cur.execute('select r_id from route where s_name=? and e_name=?', (fp, tp))
res_route = cur.fetchall()
if len(res_route)==0:
showerror('no route found','we are currently not running on this route')
else:
for i in res_route:
for j in i:
val_route = str(j)
cur.execute('select bus_id from bus where route_id=?', (val_route))
res_bid = cur.fetchall()
if len(res_bid)==0:
showerror('no bus found','we have not started any bus on this route yet!!')
else:
val_bid = []
for i in res_bid:
for j in i:
val_bid.append(j)
res_new_bid=[]
for i in range(len(val_bid)):
cur.execute('select b_id from running where run_date=? and b_id=? ',(jd, val_bid[i]))
res_new_bid.append(cur.fetchall())
#print(res_new_bid)
b=[]
for i in res_new_bid:
for j in i:
b.append(j[0])
#print(b)
if len(b)==0:
showerror('no running bus',"try another date!!")
else:
Label(root,text='select bus ',font='Arial 10 bold').grid(row=6,column=3)
Label(root, text='operator ', font='Arial 10 bold').grid(row=6, column=4)
Label(root, text='bus_type ', font='Arial 10 bold').grid(row=6, column=5)
Label(root, text='Available Capacity ', font='Arial 10 bold').grid(row=6, column=6)
Label(root, text='fare ', font='Arial 10 bold').grid(row=6, column=7)
r=7
bus_no=IntVar()
bus_select = IntVar()
serial_no=1
for i in b:
bus_no=i
cur.execute('select op_id from bus where bus_id=?',(i))
res_opr_id=cur.fetchall()
for j in res_opr_id:
opr_id=j[0]
cur.execute('select name from operator where opr_id=?',(opr_id))
res_opr_name=cur.fetchall()
for j in res_opr_name:
opr_name=j[0]
cur.execute('select bus_type from bus where bus_id=?',(i))
res_bus_type=cur.fetchall()
for j in res_bus_type:
bus_type=j[0]
cur.execute('select seat_avail from running where run_date=? and b_id=?',(jd,i))
res_seat_avail=cur.fetchall()
for j in res_seat_avail:
seat_avail=j[0]
cur.execute('select fair from bus where bus_id=?',(i))
res_fare=cur.fetchall()
for j in res_fare:
fare=j[0]
def show_button():
Button(root, text='PROCEED', bg='green', fg='black', font='Arial 12 bold',
command=proceed).grid(row=10, column=9, padx=30)
var=Radiobutton(root,value=bus_no,variable=bus_select,command=show_button)
var.grid(row=r,column=3)
Label(root, text=opr_name, font='Arial 10 bold').grid(row=r, column=4)
Label(root, text=bus_type, font='Arial 10 bold').grid(row=r, column=5)
Label(root, text=seat_avail, font='Arial 10 bold').grid(row=r, column=6)
Label(root, text=fare, font='Arial 10 bold').grid(row=r, column=7)
r+=1
serial_no+=1
def proceed():
f_bus_id = bus_select.get()
Label(root,text="\n\n\n").grid(row=10,columnspan=12)
Label(root,text='Fill passenger details to book the bus', bg='light green', fg='dark green', font='Arial 18 bold').grid(row=11,columnspan=12)
Label(root, text="\n\n\n").grid(row=12,columnspan=12)
Label(root,text='name',font='Arial 10 bold').grid(row=13,column=3)
pname = Entry(root, font='Arial 12 bold', fg='black')
pname.grid(row=13,column=4)
gender = StringVar()
gender.set("Select Gender")
opt = ["M", "F", "T"]
g_menu = OptionMenu(root, gender, *opt)
g_menu.grid(row=13, column=6)
Label(root, text='no of seats', font='Arial 10 bold').grid(row=13, column=7)
pseat=Entry(root, font='Arial 12 bold', fg='black')
pseat.grid(row=13,column=8)
Label(root, text='mobile', font='Arial 10 bold').grid(row=14, column=3)
pmobile = Entry(root, font='Arial 12 bold', fg='black')
pmobile.grid(row=14, column=4)
Label(root, text='age', font='Arial 10 bold').grid(row=14, column=5)
page = Entry(root, font='Arial 12 bold', fg='black')
page.grid(row=14, column=6)
def book_seat():
name=pname.get()
gen=gender.get()
seats=pseat.get()
seats=int(seats)
age=page.get()
age=int(age)
mobile=pmobile.get()
bid=bus_select.get()
if len(mobile)==10:
if len(name)>0 and len(name)<20:
if age>0 and age<150:
if seats>0 and seats<60:
#print(name, gen, age, mobile, seats, bid)
booking_ref=1
cur.execute('select booking_ref from booking_history')
res_ref=cur.fetchall()
ref=[]
for i in res_ref:
ref.append(i[0])
booking_ref=len(ref)+1
#print(booking_ref)
cur_date=date.today()
cur.execute('insert into booking_history(name,gender,no_of_seat,phone,age,booking_ref,booking_date,travel_date,bid) values(?,?,?,?,?,?,?,?,?)',(name,gen,seats,mobile,age,booking_ref,cur_date,jd,bid))
con.commit()
cur.execute('select seat_avail from running where b_id=? and run_date=?',(bid,jd))
res_s=cur.fetchall()
s=res_s[0][0]
s=s-seats
cur.execute('update running set seat_avail=? where b_id=? and run_date=?',(s,bid,jd))
con.commit()
showinfo("succefull","booking successfull")
else:
showerror("booking limit exceed","you can only book upto 5 seats")
else:
showerror("incorrect age","enter valid age")
else:
showerror("incorrect name","enter valid name")
else:
showerror("invalid mobile no","enter valid mobile no")
Button(root, text='BOOK SEAT', bg='green', fg='black', font='Arial 12 bold',
command=book_seat).grid(row=16, column=9, padx=30)
else:
showerror('error','enter journey date')
else:
showerror('ERROR',"enter correctly!!")
bus = PhotoImage(file='Bus_for_project.png')
Label(root, image=bus).grid(row=0, column=3, columnspan=12)
Label(root, text="Online Bus Booking System", font='Arial 30 bold', bg='LightCyan3', fg='red',relief=RAISED,padx=10,pady=10,bd=5).grid(row=2,
column=3,
pady=20,
columnspan=12)
Label(root, text='Enter Journey Details', bg='light green', fg='dark green', font='Arial 18 bold').grid(row=3,
column=3,
columnspan=12,
pady=20)
Label(root, text='To', fg='black', font='Arial 12 bold').grid(row=4, column=3, padx=30)
to_place = Entry(root, font='Arial 12 bold', fg='black')
to_place.grid(row=4, column=4, padx=50)
Label(root, text='From', fg='black', font='Arial 12 bold').grid(row=4, column=5, padx=30)
from_place = Entry(root, font='Arial 12 bold', fg='black')
from_place.grid(row=4, column=6, padx=50)
Label(root, text='Journey date', fg='black', font='Arial 12 bold').grid(row=4, column=7, padx=30)
journey_date = Entry(root, font='Arial 12 bold', fg='black')
journey_date.grid(row=4, column=8, padx=50)
Label(root,text="date formate YYYY-MM-DD").grid(row=5,column=8)
Button(root, text='Show Bus', bg='green', fg='black', font='Arial 12 bold',command=show_bus).grid(row=4, column=9, padx=30)
home = PhotoImage(file='home.png')
Button(root, image=home,command=journey_to_home).grid(row=4, column=10)
root.mainloop()
def check_booking_page(self):
root = Tk()
root.title("CHECK BOOKING PAGE")
root.state("zoomed")
h, w = root.winfo_screenheight(), root.winfo_screenwidth()
root.geometry('%dx%d+0+0' % (w, h))
bus = PhotoImage(file='Bus_for_project.png')
home=PhotoImage(file='home.png')
def check_booking_to_home():
root.destroy()
self.home_page()
def check_tkt():
mobile=mob.get()
if len(mobile)==10 and mobile.isdigit():
cur.execute('select * from booking_history where phone=?',[mobile])
res_tkt=cur.fetchall()
for i in res_tkt:
name=i[0]
gen=i[1]
seat=i[2]
phone=i[3]
age=i[4]
ref=i[5]
book_date=i[6]
travel_date=i[7]
b_i_d=i[8]
cur.execute('select fair,route_id from bus where bus_id=?',[b_i_d])
res_bus=cur.fetchall()
fare=res_bus[0][0]
route_id=res_bus[0][1]
cur.execute('select s_name,e_name from route where r_id=?',[route_id])
res_route=cur.fetchall()
s_name=res_route[0][0]
e_name=res_route[0][1]
cur.execute('select booking_ref from booking_history where phone=?',[phone])
res_ref=cur.fetchall()
b_ref=res_ref[0][0]
Label(text="YOUR TICKET", font='Arial 12 bold', bg='blue',fg='white').grid(row=6,columnspan=12 )
Label(text="booking ref = "+b_ref,font='Arial 12 bold', fg='blue').grid(row=7,column=4)
Label(text="name = " + name, font='Arial 12 bold', fg='blue').grid(row=7, column=5)
Label(text="gender = " + gen, font='Arial 12 bold', fg='blue').grid(row=7, column=6)
Label(text="no of seats = " + str(seat), font='Arial 12 bold', fg='blue').grid(row=7, column=7)
Label(text="age = " + str(age), font='Arial 12 bold', fg='blue').grid(row=7, column=8)
Label(text="booked on = " + book_date, font='Arial 12 bold', fg='blue').grid(row=8, column=4)
Label(text="travel date = " + travel_date, font='Arial 12 bold', fg='blue').grid(row=8, column=5)
Label(text="fare = " + str(fare), font='Arial 12 bold', fg='blue').grid(row=8, column=6)
Label(text="total fare = " + str(fare*seat), font='Arial 12 bold', fg='blue').grid(row=8, column=7)
Label(root, image=bus).grid(row=0, column=0, columnspan=12, padx=80)
Label(root, text="Online Bus Booking System", font='Arial 30 bold', bg='LightCyan3', fg='red',relief=RAISED,padx=10,pady=10,bd=5).grid(row=2,
column=0,
columnspan=12,
pady=20)
Label(root, text="Check Your Booking", font='Arial 22 bold', bg='LightGreen').grid(row=3,
column=0,
pady=20,
columnspan=12,
padx=600)
Label(root, text="Enter your mobile no.", font='Arial 12 bold', fg='black').grid(row=4, column=5)
mob=Entry(root, font='Arial 12 bold')
mob.grid(row=4, column=6)
Button(root, text='Check Booking', font='Arial 12',command=check_tkt).grid(row=4, column=7)
Button(root, image=home,command=check_booking_to_home).grid(row=5, column=7,pady=20)
root.mainloop()
def db_add_page(self):
root = Tk()
root.title("ADMIN PAGE")
root.title('Database Add Page')
root.state("zoomed")
h, w = root.winfo_screenheight(), root.winfo_screenwidth()
root.geometry('%dx%d+0+0' % (w, h))
bus = PhotoImage(file='.\\Bus_for_project.png')
def db_add_to_add_op():
root.destroy()
self.add_bus_op_details_page()
def db_add_to_add_bus():
root.destroy()
self.add_bus_page()
def db_add_to_add_route():
root.destroy()
self.add_route_page()
def db_add_to_add_running():
root.destroy()
self.add_bus_running_page()
Label(root, image=bus).grid(row=1, column=1, columnspan=12, padx=w // 2.5)
Label(root, text="Online Bus Booking System", font='Arial 30 bold', bg='LightCyan3', fg='red',relief=RAISED,padx=10,pady=10,bd=5).grid(row=2,
column=2,
columnspan=9,
padx=w // 2.5)
Label(root, text='\n').grid(row=3, column=2)
Label(root, text="Add New Details To Database", font='Arial 16 bold', bg='LightGreen').grid(row=4,
column=2,
columnspan=9,
padx=w // 2.5)
Label(root, text='\n').grid(row=5, column=2)
Button(root, text='New Operator', fg='black', bg='light green', font='Arial 12',command=db_add_to_add_op).grid(row=6, column=1,
columnspan=7)
Button(root, text='New Bus', fg='black', bg='orange', font='Arial 12',command=db_add_to_add_bus).grid(row=6, column=5, columnspan=2)
Button(root, text='New Route', fg='black', bg='light blue', font='Arial 12',command=db_add_to_add_route).grid(row=6, column=6, columnspan=2)
Button(root, text='New Run', fg='black', bg='rosy brown', font='Arial 12',command=db_add_to_add_running).grid(row=6, column=7, columnspan=2)
root.mainloop()
def add_bus_op_details_page(self):
root = Tk()
root.title("ADD BUS OPERATOR PAGE")
root.state("zoomed")
h, w = root.winfo_screenheight(), root.winfo_screenwidth()
root.geometry('%dx%d+0+0' % (w, h))
bus = PhotoImage(file='Bus_for_project.png')
home=PhotoImage(file='home.png')
def op_add():
iid = opr_id.get()
iname = name.get()
iaddress = address.get()
iphone = phone.get()
iemail = email.get()
cur.execute('select opr_id from operator')
res=cur.fetchall()
if len(iid) > 0 and len(iid) <= 5 and iid.isnumeric():
if len(iname) < 20 and len(iname) > 0:
if len(iaddress) < 50 and len(iaddress) > 0:
if iphone.isnumeric() and len(iphone) == 10:
if len(iemail) > 0 and len(iemail) < 30:
if (iid,) in res:
showerror("ERROR","operator id already exists!!")
else:
cur.execute('insert into operator (opr_id,name,address,phone,email)values(?,?,?,?,?)',(iid, iname, iaddress, iphone, iemail))
con.commit()
showinfo('success', "operator added successfully!!")
else:
showerror("invalid input", "enter email correctly")
else:
showerror("invalid input", "enter phone correctly")
else:
showerror("invalid input", "enter address correctly")
else:
showerror("invalid input", "enter name correctly")
else:
showerror("invalid input", "enter id correctly")
def db_add_to_home():
root.destroy()
self.home_page()
Label(root, image=bus).grid(row=0, column=0, columnspan=12)
Label(root, text="Online Bus Booking System", font='Arial 30 bold', bg='LightCyan3', fg='red',relief=RAISED,padx=10,pady=10,bd=5).grid(row=1,
column=0,
columnspan=12)
Label(root, text="Add Bus Operator Details", font='Arial 20 bold', bg='gainsboro', fg='green4').grid(row=2,
column=0,
pady=20,
columnspan=12)
Label(root, text="Operator ID", font='Arial 12 bold', fg='black').grid(row=3, column=0, pady=50)
opr_id = Entry(root, font="Arial 12")
opr_id.grid(row=3, column=1)
Label(root, text="Name", font='Arial 12 bold', fg='black').grid(row=3, column=2)
name = Entry(root, font="Arial 12")
name.grid(row=3, column=3)
Label(root, text="Address", font='Arial 12 bold', fg='black').grid(row=3, column=4)
address = Entry(root, font="Arial 12")
address.grid(row=3, column=5)
Label(root, text="Phone", font='Arial 12 bold', fg='black').grid(row=3, column=6)
phone = Entry(root, font="Arial 12")
phone.grid(row=3, column=7)
Label(root, text="Email", font='Arial 12 bold', fg='black').grid(row=3, column=8)
email = Entry(root, font="Arial 12")
email.grid(row=3, column=9)
Button(root, text="Add", font='Arial 12 bold', bg='green2', fg='black',command=op_add).grid(row=3, column=10, padx=10)
Button(root, text="Edit", font='Arial 12 bold', bg='green2', fg='black').grid(row=3, column=11, padx=10)
Button(root, image=home,command=db_add_to_home).grid(row=7, column=11)
root.mainloop()
def add_bus_page(self):
root = Tk()
root.title("ADD BUS PAGE")
root.state("zoomed")
h, w = root.winfo_screenheight(), root.winfo_screenwidth()
root.geometry('%dx%d+0+0' % (w, h))
bus = PhotoImage(file='Bus_for_project.png')
def bus_add():
bid=b_id.get()
dmenu=bus_type.get()
capa=capacity.get()
fare_rs=fare.get()
opid=op_id.get()
route_id=r_id.get()
cur.execute('select bus_id from bus')
res=cur.fetchall()
if (bid,) in res:
showerror("error","bus id already exists!!!")
else:
data="bus_id="+bid+" bus_type="+dmenu+" capacity="+capa+" fare="+fare_rs+" op_id="+opid+" route_id="+route_id
cur.execute('insert into bus(bus_id,bus_type,capacity,fair,op_id,route_id) values(?,?,?,?,?,?)',(bid,dmenu,capa,fare_rs,opid,route_id))
con.commit()
showinfo('success', "bus added successfully!!")
Label(root,text=data).grid(row=6,columnspan=12)
'''def edit_bus():
bid=b_id.get()
dmenu=bus_type.get()
capa=capacity.get()
fare_rs=fare.get()
opid=op_id.get()
route_id=r_id.get()
cur.execute('select bus_id from bus')
res=cur.fetchall()
if (bid,) in res:
data="bus_id="+bid+" bus_type="+dmenu+" capacity="+capa+" fare="+fare_rs+" op_id="+opid+" route_id="+route_id
cur.execute('update bus set bus_type=dmenu, capacity=capa, fair=fare_rs, route_id=route_id where bus_id==bid')
con.commit()
Label(root,text=data).grid(row=6,columnspan=12)
else:
showerror("error","no such bus id exists, add new bus !!!")'''
def add_bus_to_home():
root.destroy()
self.home_page()
Label(root, image=bus).grid(row=0, column=0, columnspan=12)
Label(root, text="Online Bus Booking System", font='Arial 30 bold', bg='LightCyan3', fg='red',relief=RAISED,padx=10,pady=10,bd=5).grid(row=1,
column=0,
columnspan=12)
Label(root, text="Add Bus Details", font='Arial 20 bold', bg='gainsboro', fg='green4').grid(row=2, column=0,
pady=20,
columnspan=12)
Label(root, text="Bus ID", font='Arial 12 bold', fg='black').grid(row=3, column=1, pady=50)
b_id = Entry(root, font="Arial 12")
b_id.grid(row=3, column=2)
bus_type = StringVar()
bus_type.set("Select Bus Type")
opt = ["2x2", "AC 2x2", "3x2", "AC 3x2"]
d_menu = OptionMenu(root, bus_type, *opt)
d_menu.grid(row=3, column=3)
Label(root, text="Capacity", font='Arial 12 bold', fg='black').grid(row=3, column=4)
capacity = Entry(root, font="Arial 12")
capacity.grid(row=3, column=5)
Label(root, text="Fare Rs", font='Arial 12 bold', fg='black').grid(row=3, column=6)
fare = Entry(root, font="Arial 12")
fare.grid(row=3, column=7)
Label(root, text="Operator ID", font='Arial 12 bold', fg='black').grid(row=3, column=8)
op_id = Entry(root, font="Arial 12")
op_id.grid(row=3, column=9)
Label(root, text="Route ID", font='Arial 12 bold', fg='black').grid(row=3, column=10)
r_id = Entry(root, font="Arial 12")
r_id.grid(row=3, column=11)
Button(root, text="Add Bus", font='Arial 12 bold', bg='green2', fg='black',command=bus_add).grid(row=5, column=4, pady=20,
columnspan=4)
Button(root, text="Edit Bus", font='Arial 12 bold', bg='green2', fg='black').grid(row=5, column=5, pady=20,
columnspan=4)
home = PhotoImage(file='home.png')
Button(root, image=home,command=add_bus_to_home).grid(row=5, column=6, columnspan=3)
root.mainloop()
def add_route_page(self):
root=Tk()
root.title("ADD ROUTE PAGE")
root.state("zoomed")
def add_route_to_home():
root.destroy()
self.home_page()
def add_route():
route_id=r_id.get()
start_station=s_station.get()
start_id=s_id.get()
end_station=e_station.get()
end_id=e_id.get()
cur.execute('select r_id from route')
res=cur.fetchall()
if (route_id,) in res:
showerror('ERROR',"Route id already exists")
else:
start_station=start_station.lower()
end_station=end_station.lower()
cur.execute('insert into route(r_id,s_name,s_id,e_name,e_id) values(?,?,?,?,?)',(route_id,start_station,start_id,end_station,end_id))
con.commit()
showinfo('success',"route added successfully!!")
h,w = root.winfo_screenheight(), root.winfo_screenwidth()
root.geometry('%dx%d+0+0' % (w, h))
bus = PhotoImage(file='Bus_for_project.png')
Label(root, image=bus).grid(row=0, column=0, columnspan=12)
Label(root, text="Online Bus Booking System", font='Arial 30 bold', bg='LightCyan3', fg='red',relief=RAISED,padx=10,pady=10,bd=5).grid(row=1,
column=0,
columnspan=12)
Label(root, text="Add Bus Route Details", font='Arial 20 bold', bg='gainsboro', fg='green4').grid(row=2,
column=0,
pady=20,
columnspan=12)
Label(root, text="Route ID", font='Arial 12 bold', fg='black').grid(row=3, column=0, pady=50)
r_id=Entry(root, font="Arial 12")
r_id.grid(row=3, column=1, padx=50)
Label(root, text="starting station", font='Arial 12 bold', fg='black').grid(row=3, column=2)
s_station=Entry(root, font="Arial 12")
s_station.grid(row=3, column=3, padx=50)
Label(root, text="Station ID", font='Arial 12 bold', fg='black').grid(row=3, column=4)
s_id=Entry(root, font="Arial 12")
s_id.grid(row=3, column=5, padx=50)
Label(root, text="ending station", font='Arial 12 bold', fg='black').grid(row=4, column=2)
e_station=Entry(root, font="Arial 12")
e_station.grid(row=4, column=3, padx=50)
Label(root, text="Station ID", font='Arial 12 bold', fg='black').grid(row=4, column=4)
e_id=Entry(root, font="Arial 12")
e_id.grid(row=4, column=5, padx=50)
Button(root, text="Add Route", font='Arial 12 bold', bg='green2', fg='black',command=add_route).grid(row=3, column=7, pady=20,
padx=10)
Button(root, text="Delete Route", font='Arial 12 bold', bg='green2', fg='black').grid(row=3, column=9, pady=20,
padx=10)
home = PhotoImage(file='home.png')
Button(root, image=home,command=add_route_to_home).grid(row=4, column=9)
root.mainloop()
def add_bus_running_page(self):
root = Tk()
root.title("ADD RUNNING PAGE")
root.state("zoomed")
h, w = root.winfo_screenheight(), root.winfo_screenwidth()
root.geometry('%dx%d+0+0' % (w, h))
bus = PhotoImage(file='Bus_for_project.png')
def add_bus_running_to_home():
root.destroy()
self.home_page()
def add_run():
bid=bus_id.get()
run_date=running_date.get()
s_avail=seat_avail.get()
cur.execute('insert into running(b_id,run_date,seat_avail) values (?,?,?)',(bid,run_date,s_avail))
con.commit()
showinfo('sucess','run added successfully!!')
Label(root, image=bus).grid(row=0, column=0, columnspan=12)
Label(root, text="Online Bus Booking System", font='Arial 30 bold', bg='LightCyan3', fg='red',relief=RAISED,padx=10,pady=10,bd=5).grid(row=1,
column=0,
columnspan=12)
Label(root, text="Add Bus Running Details", font='Arial 20 bold', bg='gainsboro', fg='green4').grid(row=2,
column=0,
pady=20,
columnspan=12)
Label(root, text="Bus ID", font='Arial 12 bold', fg='black').grid(row=3, column=0, pady=50)
bus_id=Entry(root, font="Arial 12")
bus_id.grid(row=3, column=1, padx=50)
Label(root, text="Running Date", font='Arial 12 bold', fg='black').grid(row=3, column=2)
running_date=Entry(root, font="Arial 12")
running_date.grid(row=3, column=3, padx=50)
Label(root,text="date format YYYY-MM-DD").grid(row=4,column=3)
Label(root, text="Seat Available", font='Arial 12 bold', fg='black').grid(row=3, column=4)
seat_avail=Entry(root, font="Arial 12")
seat_avail.grid(row=3, column=5, padx=50)
Button(root, text="Add Run", font='Arial 12 bold', bg='green2', fg='black',command=add_run).grid(row=3, column=6, pady=20,
padx=10)
Button(root, text="Delete Run", font='Arial 12 bold', bg='green2', fg='black').grid(row=3, column=7, pady=20,padx=10)
home = PhotoImage(file='home.png')
Button(root, image=home,command=add_bus_running_to_home).grid(row=4, column=7)
root.mainloop()
obj=bus_booking()
obj.cover_page()