Advertisement
skip420

flightres

Sep 12th, 2021
865
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 7.35 KB | None | 0 0
  1. from Tkinter import *
  2. import tkMessageBox
  3. from ttk import *
  4. import sqlite3
  5. con=sqlite3.Connection('hrdb')
  6. rootp=Tk()
  7. Label(rootp,text=" Airline Booking Services",font="Bold 20").pack()
  8. def fun8():
  9.     rootp.destroy()
  10.     root2=Tk()
  11.     root2.title("Welcome,Customer To our Cancellation System")
  12.     Label(root2,text="Enter last 4 digit of your Citizenship Number").grid(row=0,column=0)
  13.     e1=Entry(root2)
  14.     e1.grid(row=0,column=1)
  15.     Label(root2,text="Choose your class").grid(row=1,column=0)
  16.     w2=Combobox(root2,height=5,width=15,values=["BusinessClass","Economic"])
  17.     w2.grid(row=1,column=1)
  18.     Label(root2,text="select boarding").grid(row=2,column=0)
  19.     w3=Combobox(root2,height=5,width=15,values=["New York","Chicago","Dallas","San Francisco"])
  20.     w3.grid(row=2,column=1)
  21.     def fun2():
  22.         d=e1.get()
  23.         b=w2.get()
  24.         c=w3.get()
  25.         cur=con.cursor()
  26.         x=str(d)
  27.         y=str(c)
  28.         con.commit()
  29.         if d=='' or b=='' or c=='':
  30.              tkMessageBox.showerror("Oops","You can't Enter the leave any field empty")
  31.         else:    
  32.              if b=="economic":
  33.                 cur.execute("delete from economic2 where adno=(?) and boarding=(?)",(d,b,))
  34.                 cur.execute("select * from economic2")
  35.                 tkMessageBox.showinfo("your reservation is cancelled",cur.fetchall())
  36.              else:
  37.                     cur.execute("delete from common2 where adno=x and boarding=y")
  38.                     cur.execute("select * from common2")
  39.        
  40.                    
  41.            
  42.     Bc=Button(root2,text="Cancel Reservation",command=fun2).grid(row=4,column=0)
  43.     root2.mainloop()
  44. def fun9():
  45.     rootp.destroy()
  46.     root4=Tk()
  47.     root4.title("Welcome,Search flights")
  48.     Label(root4,text="Enter Boarding").grid(row=0,column=0)
  49.     w1=Combobox(root4,height=5,width=15,values=["New York","Chicago","Dallas","San Francisco"])
  50.     w1.grid(row=0,column=1)
  51.     Label(root4,text="select destination").grid(row=1,column=0)
  52.     w2=Combobox(root4,height=5,width=15,values=["New York","Chicago","Dallas","San Francisco"])
  53.     w2.grid(row=1,column=1)
  54.     Label(root4,text="Choose day of travel").grid(row=2,column=0)
  55.     w3=Combobox(root4,text="choose day",height=5,width=15,values=["sunday","monday","tuesday","wensday","thursday","friday","saturday"])
  56.     w3.grid(row=2,column=1)
  57.     def fun10():
  58.         a=w1.get()
  59.         b=w2.get()
  60.         c=w3.get()
  61.         cur=con.cursor()
  62.         if a=='' or b=='' or c=='':
  63.             tkMessageBox.showerror("Error","Cant leave any field empty")
  64.            
  65.                
  66.         else:
  67.              if a!=b:
  68.                  #cur.execute("create table eco(boarding char(20),destination char(20),day char(20),time number,class char(10),fare number)")
  69.                  cur.execute("insert into eco values('New York','Chicago','Sunday',1.00,'Economic',2500)")
  70.                  cur.execute("insert into eco values('New York','Dallas','Monday',1.00,'Common',4000)")
  71.                  cur.execute("insert into eco values('New York','San Francisco','Tuesday',1.00,'Economic',5500)")
  72.                  cur.execute("insert into eco values('Chicago','New York','Wensday',1.00,'Economic',3500)")
  73.                  cur.execute("insert into eco values('Chicago','New York','Wensday',7.00,'Common',2500)")
  74.                  cur.execute("select * from eco where boarding=? and destination=? and day=?",(a,b,c,))
  75.                  con.commit()
  76.                  e=cur.fetchall()
  77.                  tkMessageBox.showinfo("flights availble are",e)
  78.              else:
  79.                 tkMessageBox.showerror("Oops","boarding and destination can't me same")
  80.        
  81.     Bs=Button(root4,text="search",command=fun10).grid(row=3,column=0)
  82.     root4.mainloop()
  83. def fun5():
  84.     rootp.destroy()
  85.     root=Tk()
  86.     root.title('Flight search And booking')
  87.     Label(root,text="Enter Boarding").grid(row=1,column=0)
  88. #e1=Entry(root,width=20,bd=4,justify="right")
  89. #e1.grid(row=1,column=1)
  90.     w=Combobox(root,height=5,width=15,values=["Dallas","Washington","New York","San Francisco"])
  91.     w.grid(row=1,column=1)
  92.     Label(root,text='Enter Destination').grid(row=2,column=0)
  93. #e2=Entry(root,width=20,justify='right')
  94. #e2.grid(row=2,column=1)
  95.     w1=Combobox(root,height=5,width=15,values=["Dallas","Washington","New York","San Francisco"])
  96.     w1.grid(row=2,column=1)
  97. #e3=Entry(root,width=20,justify='right')
  98. #e3.grid(row=3,column=1)
  99.     Label(root,text='Enter last 4 digit of your Citizenship Number').grid(row=3,column=0)
  100.     e=Entry(root,width=20)
  101.     e.grid(row=3,column=1)
  102.     w2=Combobox(root,text='BusinessClass',height=5,width=15,values=["BusinessClass","Economic"])
  103.     w2.grid(row=4,column=1)
  104.     Label(root,text='Choose Class').grid(row=4,column=0)
  105.     Label(root,text="Choose day of travel").grid(row=5,column=0)
  106.     w3=Combobox(root,text="choose day",height=5,width=15,values=["sunday","monday","tuesday","wensday","thursday","friday","saturday"])
  107.     w3.grid(row=5,column=1)
  108.     Label(root,text="choose time of your flight").grid(row=6,column=0)
  109.     w4=Combobox(root,height=5,width=15,values=["1:00 AM","7:00 AM","1:00 PM","4:00 PM","9:00 PM"])
  110.     w4.grid(row=6,column=1)
  111.     def fun():
  112.         a=w.get()
  113.         b=w1.get()
  114.         c=e.get()
  115.         d=w2.get()
  116.         f=w3.get()
  117.         g=w4.get()
  118.         x=(a,b,c,f,g)
  119.         cur=con.cursor()
  120.        
  121.         if a=='' or b=='' or c=='' or d=='' or f=='' or g=='':
  122.             tkMessageBox.showerror("OOPS","you can't leave any field empty")
  123.         else :
  124.             if d=='Economic':
  125.                
  126.                 if a!=b:
  127.                     #cur.execute("create table economic2(boarding char(20),destination char(20),adno number,day char,time number)")
  128.                     cur.execute("insert into economic2 values(?,?,?,?,?)",x)
  129.                     tkMessageBox.showinfo("congrats","your seat has been reserved")
  130.                     con.commit()
  131.                     cur.execute("select * from economic2 where adno=(?)",(c,))
  132.                     tkMessageBox.showinfo("records",cur.fetchall())
  133.                 else:
  134.                     tkMessageBox.showerror("Error","you can't choose same city")
  135.             if d=='BusinessClass':
  136.                 #cur.execute("create table common2(boarding char(20),destination char(20),adno number,day char,time number)")
  137.                 if a!=b:
  138.                     cur.execute("insert into common2 values(?,?,?,?,?)",x)
  139.                     tkMessageBox.showinfo("congrats","your seat has been reserved")
  140.                     con.commit()
  141.                     cur.execute("select * from common2 where adno=(?)",(c,))
  142.                     tkMessageBox.showinfo("records",cur.fetchall())
  143.                 else :
  144.                     tkMessageBox.showerror("Error","you can't choose same city")
  145.     Bi=Button(root,text="Insert",command=fun).grid(row=7,column=1)
  146. #Bo=Button(root,text="See Flights",command=dis).grid(row=7,column=1)
  147. #Bf=Button(root,text='Set fair range',command=fun1).grid(row=7,column=2)
  148.     root.mainloop()
  149.    
  150. B1=Button(rootp,text="Cancel Booking",command=fun8).pack()
  151. B2=Button(rootp,text="Search Flight",command=fun9).pack()
  152. B3=Button(rootp,text="Book Flight",command=fun5).pack()
  153. #B2=Button(rootp,text="Cancel Booking",height=4,width=35,font="Bold",bg="gray").pack()
  154. #B3=Button(rootp,text="See flights",height=4,width=35,font="Bold",bg="gray").pack()
  155.  
  156.  
  157. rootp.mainloop()
  158.    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement