daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Oct 17th, 2017 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pymysql
  2. from tkinter import *
  3. from tkinter import messagebox
  4. import re
  5. import random
  6. import time
  7. import datetime
  8. from datetime import timedelta
  9. import copy
  10. from datetime import datetime
  11. import re
  12. import urllib.request
  13. import json
  14.  
  15.  
  16.  
  17. class Project():
  18.  
  19.     def __init__(self, rootWin):
  20.  
  21.         self.loginW=rootWin
  22.         self.loginPage()
  23.         self.studentEmail=""
  24.         self.classCost=""
  25.  
  26.     def connect(self):
  27.  
  28.         try:
  29.             db = pymysql.connect(host = 'academic-mysql.cc.gatech.edu',passwd = '_RlK9cnm', user = 'cs4400_Team_65', db='cs4400_Team_65')
  30.             return(db)
  31.  
  32.         except:
  33.             messagebox.showerror("Internet Connection", "Please check your internet connection!")
  34.  
  35.  
  36.  
  37.     def loginPage(self):
  38.  
  39.  
  40.         self.l1 = Label(self.loginW, text="Login", fg="goldenrod", font=("Helventica","24"))
  41.         self.l1.grid(row=1, column=2, padx=40,pady =7, sticky=W)
  42.  
  43.         self.l2 = Label(self.loginW, text="Username")
  44.         self.l2.grid(row=2, column=0, columnspan=2,padx=40, pady=10, sticky=E)
  45.  
  46.         self.v1 = StringVar()
  47.         self.e1 = Entry(self.loginW, textvariable = self.v1, state="normal")
  48.         self.e1.grid(row=2, column=2, columnspan=3, padx=40,sticky=W)
  49.  
  50.         self.l3 = Label(self.loginW, text="Password")
  51.         self.l3.grid(row=3, column=0, columnspan=2,padx=40, pady=10, sticky=E)
  52.        
  53.         self.v2 = StringVar()
  54.         self.e2 = Entry(self.loginW, textvariable = self.v2, state="normal")
  55.         self.e2.grid(row=3, column=2, columnspan=3, padx=40, pady=10,sticky=W)
  56.  
  57.         self.b1 = Button(self.loginW, text="Login")
  58.         self.b1.grid(row=4, column=1,pady=10, sticky=E)
  59.  
  60.         self.b2 = Button(self.loginW, text="Register")
  61.         self.b2.grid(row=4, column =2,padx=60, pady=10, sticky=W)
  62. ##
  63. ##        self.l4 = Label(self.loginW, text="")
  64. ##        self.l4.grid(row=9, column=0, columnspan=7, sticky=E+W)
  65.  
  66.  
  67.         self.f4 = Entry(self.loginW, textvariable="")#, relief="raised")
  68.         self.f4.grid(row=9, column=0, columnspan=7, sticky=E+W)
  69.        
  70.         self.f1 = Entry(self.loginW, textvariable="")#, relief="raised")
  71.         self.f1.grid(row=0, column=0, columnspan=7, sticky=E+W)
  72.        
  73.         pic = PhotoImage(file='buzzpic.gif')
  74.         pic1 = Label(self.loginW, image=pic)
  75.         pic1.image = pic
  76.         pic1.grid(row=8, column=4, columnspan=3, sticky=E)
  77.  
  78.         self.b1.configure(command=self.logincheck)
  79.         self.b2.configure(command=self.register)
  80.  
  81.     def register(self):
  82.  
  83.         self.loginW.withdraw()
  84.         self.registerW = Toplevel()
  85.         self.registerW.title("New User Registration")
  86.        
  87.        
  88.  
  89.  
  90.         l1 = Label(self.registerW, text="New User Registration", fg="goldenrod", font=("Helventica","24"))
  91.         l1.grid(row=1, column=2, padx=40,pady =7, sticky=W)
  92.  
  93.         l2 = Label(self.registerW, text="Username")
  94.         l2.grid(row=2, column=0, columnspan=2,padx=40, pady=10, sticky=E)
  95.  
  96.         self.v12 = StringVar()
  97.         self.e12 = Entry(self.registerW, textvariable = self.v12, state="normal")
  98.         self.e12.grid(row=2, column=2, columnspan=3, padx=40,sticky=W)
  99.  
  100.         self.l2 = Label(self.registerW, text="Email Address")
  101.         self.l2.grid(row=3, column=0, columnspan=2,padx=40, pady=10, sticky=E)
  102.        
  103.         self.v22 = StringVar()
  104.         self.e22 = Entry(self.registerW, textvariable = self.v22, state="normal")
  105.         self.e22.grid(row=3, column=2, columnspan=3, padx=40, pady=10,sticky=W)
  106.  
  107.  
  108.  
  109.         self.l42 = Label(self.registerW, text="Password")
  110.         self.l42.grid(row=4, column=0, columnspan=2,padx=40, pady=10, sticky=E)
  111.        
  112.         self.v32 = StringVar()
  113.         self.e32 = Entry(self.registerW, textvariable = self.v32, state="normal")
  114.         self.e32.grid(row=4, column=2, columnspan=3, padx=40, pady=10,sticky=W)
  115.  
  116.  
  117.  
  118.         self.l52 = Label(self.registerW, text="Confirm Password")
  119.         self.l52.grid(row=5, column=0, columnspan=2,padx=40, pady=10, sticky=E)
  120.        
  121.         self.v42 = StringVar()
  122.         self.e42 = Entry(self.registerW, textvariable = self.v42, state="normal")
  123.         self.e42.grid(row=5, column=2, columnspan=3, padx=40, pady=10,sticky=W)
  124.  
  125.  
  126.         self.b12 = Button(self.registerW, text="Create")
  127.         self.b12.grid(row=7, column=2,pady=10, sticky=W
  128.                       )
  129.  
  130. ##        self.l4 = Label(self.loginW, text="")
  131. ##        self.l4.grid(row=9, column=0, columnspan=7, sticky=E+W)
  132.  
  133.  
  134.         self.f42 = Entry(self.registerW, textvariable="")#, relief="raised")
  135.         self.f42.grid(row=9, column=0, columnspan=7, sticky=E+W)
  136.        
  137.         self.f12 = Entry(self.registerW, textvariable="")#, relief="raised")
  138.         self.f12.grid(row=0, column=0, columnspan=7, sticky=E+W)
  139.        
  140.         pic = PhotoImage(file='buzzpic.gif')
  141.         pic1 = Label(self.registerW, image=pic)
  142.         pic1.image = pic
  143.         pic1.grid(row=8, column=4, columnspan=3, sticky=E)
  144.  
  145.         self.b12.configure(command=self.create)
  146.  
  147.     def create(self):
  148.         db=self.connect()
  149.         self.username = self.v12.get()
  150.         self.email = self.v22.get()
  151.         self.password1 = self.v32.get()
  152.         self.password2 = self.v42.get()
  153.  
  154.  
  155.  
  156.  
  157.         if self.password1 != self.password2:
  158.             messagebox.showerror("Password", "Password entries do not match. Please try again!")
  159.  
  160.         elif self.password1 == self.password2 and re.match("(?=.*[A-Z])", self.password1) and re.match("(?=.*[0-9])", self.password1):
  161.             self.answerYN = 7
  162.  
  163.         else:
  164.             messagebox.showerror("Password", "Password must contain at least one capital letter and at least one number!")
  165.  
  166.  
  167.         if self.username =="":
  168.             messagebox.showerror("Username", "Please enter a username!")
  169.  
  170.                                                        
  171.  
  172.         cursor = db.cursor()
  173.         sql = "SELECT Username FROM USER WHERE username = %s"
  174.         userInput = self.username
  175.         found = cursor.execute(sql, (self.username))
  176.  
  177.         allFound = cursor.fetchall()
  178.  
  179.         sql = "SELECT email FROM CUSTOMER WHERE email = %s" #was where email
  180.         userInput2 = self.email #was email
  181.         found2 = cursor.execute(sql, (self.email)) #was email
  182.  
  183.         allFound2 = cursor.fetchall()
  184.  
  185.  
  186.         if found ==1:
  187.             messagebox.showerror("Username", "Username already exists in database!")
  188. ##
  189.         if found2 ==1:
  190.             messagebox.showerror("Email", "Email already exists in database!")
  191.        
  192.         if found ==0 and self.username!="" and self.password1==self.password2 and re.match("(?=.*[A-Z])", self.password1) and re.match("(?=.*[0-9])", self.password1):
  193.  
  194.             cursor = db.cursor()
  195.             sql = "INSERT INTO USER (username, password) VALUES (%s, %s)"
  196.             cursor.execute(sql, (self.username, self.password1))
  197.  
  198.             cursor.close()
  199.             db.commit()
  200.             db.close()
  201.  
  202.             messagebox.showinfo("Registered!", "You are now registered!")
  203.  
  204.             self.goLogin()
  205.  
  206. #        self.goLogin()
  207.  
  208.     def goLogin(self):
  209.         self.registerW.withdraw()
  210.         self.loginW.deiconify()
  211.     def logincheck(self):
  212.  
  213.         db = self.connect()
  214.  
  215.         self.usernameL = self.v1.get()
  216.         self.passwordL = self.v2.get()
  217.        
  218.        
  219.  
  220.         cursor = db.cursor()
  221.         sql = "SELECT username, password FROM USER WHERE username = %s and password= %s"
  222.         userInput = self.usernameL, self.passwordL
  223.         found = cursor.execute(sql, (self.usernameL, self.passwordL))
  224.  
  225.         db.close()
  226.  
  227.         allFound = cursor.fetchall()
  228.        
  229.  
  230.         if found ==1:
  231.  #           messagebox.showinfo("Successful Login", "Congratulations!! You logged in successfully!")
  232.             self.custCheck()
  233.  #          self.login()
  234.  
  235.         elif found==0:
  236.             messagebox.showerror("Invalid username/password", "Sorry, you entered an unrecognizable username/password combination. Please try again!")
  237.  
  238.  #       self.login()
  239.  
  240.     def custCheck(self):
  241.         db = self.connect()
  242.  
  243.         cursor = db.cursor()
  244.         sql = "SELECT username FROM MANAGER WHERE username = %s"
  245.         userInput = self.usernameL, self.passwordL
  246.         found = cursor.execute(sql, (self.usernameL))
  247.  
  248.         allFound = cursor.fetchall()
  249.  
  250.         if found==1:
  251.            
  252.             messagebox.showinfo("Successful Login", "Congratulations!! You're a Manager!!")
  253.             self.managerLogin()
  254.  
  255.         else:
  256.             messagebox.showinfo("Successful Login", "Congratulations!! You logged in successfully!")
  257.             self.login()
  258.  
  259.     def managerLogin(self):
  260.         self.loginW.withdraw()
  261.         self.managerF = Toplevel()
  262.         self.managerF.title("Successful Login: Manager")
  263.  
  264.  
  265.         l1 = Label(self.managerF, text="Choose Functionality", fg="goldenrod", font=("Helventica","24"))
  266.         l1.grid(row=1, column=2, columnspan=3, padx=60,pady =7)
  267.  
  268.  
  269.  
  270.  
  271.  
  272.         b24 = Button(self.managerF, text="View revenue report", underline=1, fg="steel blue")
  273.         b24.grid(row=2, column=2, columnspan=2,padx=60, pady=5)
  274.  
  275.         b34 = Button(self.managerF, text="View popular route report", underline=1, fg="steel blue")
  276.         b34.grid(row=3, column=2, columnspan=2,padx=60, pady=5)
  277.  
  278.         b84 = Button(self.managerF, text="Log out", relief="raised")
  279.         b84.grid(row=11, column=3, padx=125,sticky=E)
  280.  
  281.         pic = PhotoImage(file='buzzpic.gif')
  282.         pic1 = Label(self.managerF, image=pic)
  283.         pic1.image = pic
  284.         pic1.grid(row=10, column=3, rowspan=2, sticky=E)
  285.  
  286.         b24.configure(command=self.viewRev)
  287.  
  288.         b84.configure(command=self.logoutNow2)
  289.  
  290.     def logoutNow2(self):
  291.         self.managerF.withdraw()
  292.  
  293.  
  294.     def viewRev(self):
  295.         self.managerF.withdraw()
  296.         self.viewRevW = Toplevel()
  297.         self.viewRevW.title("View Revenue Report")
  298.  
  299.         l1=Label(self.viewRevW, text="View Revenue Report", fg="goldenrod", font=("Helventica","24"))
  300.         l1.grid(row=1, column=0, columnspan=3, pady=30, sticky=E+W)
  301.  
  302.         l2 = Label(self.viewRevW, text="Month")
  303.         l2.grid(row=2, column=0, padx=50)
  304.  
  305.         l3 = Label(self.viewRevW, text="Revenue",width=20)
  306.         l3.grid(row=2, column=1, padx=50)
  307.  
  308.         db=self.connect()
  309.         cursor=db.cursor()
  310.  
  311.         sql="SELECT resvID from RESV_RESERVES_TRAINROUTE WHERE departureDATE=0000-00-00"
  312.         found=cursor.execute(sql)
  313.  
  314.         for record in cursor:
  315.             print(record)
  316.  
  317.         cursor=db.cursor()
  318.         sql="SELECT resvID, SUM(totalCOST) FROM RESERVATION WHERE isCancelled=%s"
  319.         found=cursor.execute(sql, ("0"))
  320.  
  321.         for record in cursor:
  322.             print(record)
  323.         b1=Button(self.viewRevW, text="Back", relief="raised")
  324.         b1.grid(row=6, column=0, pady=10)
  325.  
  326.         b1.configure(command=self.viewRevW)
  327.  
  328.     def viewRevW(self):
  329.         pass
  330.     def login(self):
  331.  
  332.         self.loginW.withdraw()
  333.         self.functionW = Toplevel()
  334.         self.functionW.title("Successful Login: Choose Functionality")
  335.  
  336.  
  337.         l1 = Label(self.functionW, text="Choose Functionality", fg="goldenrod", font=("Helventica","24"))
  338.         l1.grid(row=1, column=2, columnspan=3, padx=60,pady =7)
  339.  
  340. ### I can't tell if below is underlining because it isn't doing so on Mac . . .
  341.  
  342.  
  343.         self.b24 = Button(self.functionW, text="View Train Schedule", underline=1, fg="steel blue")
  344.         self.b24.grid(row=2, column=2, columnspan=2,padx=60, pady=5)
  345.  
  346.  
  347.         self.b34 = Button(self.functionW, text="Make a new reservation", fg="steel blue")
  348.         self.b34.grid(row=3, column=2, columnspan=2,padx=60, pady=5)
  349.        
  350.         self.b44 = Button(self.functionW, text="Update a reservation", fg="steel blue")
  351.         self.b44.grid(row=4, column=2, columnspan=2,padx=60,pady=5)
  352.  
  353.         self.b54 = Button(self.functionW, text="Cancel a reservation", fg="steel blue")
  354.         self.b54.grid(row=5, column =2, columnspan=2,padx=60, pady=5)
  355.  
  356.         self.b64 = Button(self.functionW, text="Give review", fg="steel blue")
  357.         self.b64.grid(row=6, column =2, columnspan=2,padx=60, pady=5)
  358.  
  359.         self.b74 = Button(self.functionW, text="Add school information (student discount)", fg="steel blue")
  360.         self.b74.grid(row=7, column =2, columnspan=2,padx=60, pady=5)
  361.  
  362.         f4 = Entry(self.functionW, textvariable="")#, relief="raised")
  363.         f4.grid(row=13, column=0, columnspan=5, sticky=E+W)
  364.        
  365.         f1 = Entry(self.functionW, textvariable="")#, relief="raised")
  366.         f1.grid(row=0, column=0, columnspan=5, sticky=E+W)
  367.        
  368.         pic = PhotoImage(file='buzzpic.gif')
  369.         pic1 = Label(self.functionW, image=pic)
  370.         pic1.image = pic
  371.         pic1.grid(row=10, column=3, rowspan=2, sticky=E)
  372.  
  373.         self.b84 = Button(self.functionW, text="Log out", relief="raised")
  374.         self.b84.grid(row=11, column=3, padx=125,sticky=E)
  375.  
  376. ##        self.b1.configure(command=self.logincheck)
  377. ##        self.b2.configure(command=self.register)
  378.         self.b74.configure(command=self.addSchool)
  379.         self.b24.configure(command=self.viewTrain)
  380.         self.b34.configure(command=self.makeRes)
  381.         self.b44.configure(command=self.updateRes)
  382.         self.b84.configure(command=self.logoutNow)
  383.         self.b64.configure(command=self.submitreview)
  384.  
  385.  #       self.b64.configure(command=submit_review)
  386.  
  387.     def logoutNow(self):
  388.         self.functionW.withdraw()
  389.        
  390.  
  391.     def addSchool(self):
  392.  
  393.  
  394.         self.functionW.withdraw()
  395.         self.schoolW = Toplevel()
  396.         self.schoolW.title("Add School Info")
  397.  
  398.         self.l15 = Label(self.schoolW, text= "Add School Info", fg="goldenrod", font=("Helventica","24"))
  399.         self.l15.grid(row=1, column=1, columnspan=2, pady=30, sticky=E+W)
  400.  
  401.         self.l25 = Label(self.schoolW, text= "School Email Address", font=("Helventica", "22"))
  402.         self.l25.grid(row=2, column=0, columnspan=2, padx=20, sticky=E+W)
  403.  
  404.         self.v15 = StringVar()
  405.         self.e15 = Entry(self.schoolW, textvariable=self.v15)#relief="raised")
  406.         self.e15.grid(row=2, column=2, columnspan=2,padx=20, sticky=E+W)
  407.  
  408.         self.l35 = Label(self.schoolW, text="Your school email address ends with .edu",font=("Helventica","10"))
  409.         self.l35.grid(row=3, column=0, columnspan=3, padx=20, sticky=W)
  410.  
  411.         self.b15 = Button(self.schoolW, text="Back", relief="raised")
  412.         self.b15.grid(row=4, column=0, padx=15, pady=50, sticky=E)
  413.  
  414.         self.b25 = Button(self.schoolW, text="Submit", relief="raised")
  415.         self.b25.grid(row=4, column=1, pady=50, sticky=W)
  416.  
  417.         pic = PhotoImage(file='buzzpic.gif')
  418.         pic1 = Label(self.schoolW, image=pic)
  419.         pic1.image = pic
  420.         pic1.grid(row=4, column=3, rowspan=2, sticky=E)
  421.  
  422.         self.b15.configure(command=self.logincheck)
  423.         self.b25.configure(command=self.submitEmail)
  424.  
  425.  
  426.     def submitEmail(self):
  427.        
  428.         db = self.connect()
  429.  
  430.         self.schoolEmail=self.v15.get()
  431.    
  432.         cursor = db.cursor()
  433.         sql = "INSERT INTO CUSTOMER (email) VALUES (%s)"
  434.         cursor.execute(sql, (self.schoolEmail))
  435.  
  436.         cursor.close()
  437.         db.commit()
  438.         db.close()
  439.  
  440.  
  441.         self.goLogin2()
  442.        
  443.  
  444.     def goLogin2(self):
  445.         self.functionW.withdraw()
  446.         self.loginW.deiconify()
  447.  
  448.     def viewTrain(self):
  449.  
  450.         self.functionW.withdraw()
  451.         self.viewTrainW = Toplevel()
  452.         self.viewTrainW.title("View Train Schedule")
  453.  
  454.         l1 = Label(self.viewTrainW, text="View Train Schedule", fg="goldenrod", font=("Helventica","24"))
  455.         l1.grid(row=1, column=0, columnspan=3, pady=30, sticky=E+W)
  456.  
  457.         l2 = Label(self.viewTrainW, text="Train Number")
  458.         l2.grid(row=2, column=0, padx=50)
  459.  
  460.         self.v16 = StringVar()
  461.         self.e16 = Entry(self.viewTrainW, textvariable = self.v16, state="normal")
  462.         self.e16.grid(row=2, column=2)
  463.  
  464.         b1 = Button(self.viewTrainW, text="Search", relief="raised")
  465.         b1.grid(row=5, column=0, padx=50, pady=50)
  466.  
  467.    
  468.         pic = PhotoImage(file='buzzpic.gif')
  469.         pic1 = Label(self.viewTrainW, image=pic)
  470.         pic1.image = pic
  471.         pic1.grid(row=4, column=2, rowspan=2, sticky=E)
  472.  
  473.         b1.configure(command=self.trainSchedule)
  474.  
  475.     def trainSchedule(self):
  476.  
  477.         self.viewTrainW.withdraw()
  478.         self.trainScheduleW = Toplevel()
  479.  
  480.         self.trainNum = self.v16.get()
  481.         self.arrivalTimeSched = []
  482.         self.departureTimeSched = []
  483.         self.stationSched = []
  484.  
  485.  
  486.  
  487.         l1 = Label(self.trainScheduleW, text="View Train Schedule", fg="goldenrod", font=("Helventica","24"))
  488.         l1.grid(row=1, column=0, columnspan=4, pady=30, sticky=E+W)
  489.  
  490.         l2 = Label(self.trainScheduleW, text="Train Number", width=40)
  491.         l2.grid(row=2, column=0, sticky=W)
  492.  
  493.         l3 = Label(self.trainScheduleW, text="Arrival Time", width=40)
  494.         l3.grid(row=2, column=1, sticky=W)
  495.  
  496.         l4 = Label(self.trainScheduleW, text="Departure Date", width=40)
  497.         l4.grid(row=2, column=2, sticky=W)
  498.  
  499.         l5 = Label(self.trainScheduleW, text="Station", width=40)
  500.         l5.grid(row=2, column=3, sticky=W)
  501.  
  502.         db = self.connect()
  503.  
  504.         cursor = db.cursor()
  505.         sql = "SELECT arrivalTime, departureTime, stationName,trainNum FROM TRAIN_STOPBY_STATION WHERE trainNum=%s"
  506.  
  507.         found = cursor.execute(sql, (self.trainNum))
  508.  
  509.         for record in cursor:
  510.             self.arrivalTimeSched.append(record[0])
  511.             self.departureTimeSched.append(record[1])
  512.             self.stationSched.append(record[2])
  513.             self.trainNumFound = record[3]
  514.  
  515.        
  516.         self.tracker1 = 2
  517.         self.tracker2 = 2
  518.         self.tracker3 = 2
  519.  
  520.         lTrainNum = Label(self.trainScheduleW, text=self.trainNumFound, width=40
  521.                           )
  522.         lTrainNum.grid(row=3, column=0, sticky=W)
  523.  
  524.         for i in self.arrivalTimeSched:
  525.             self.tracker1 = self.tracker1+1
  526.  
  527.             li = Label(self.trainScheduleW, text=i, width=40)
  528.             li.grid(row=self.tracker1, column=1)
  529.  
  530.            
  531.            
  532.  
  533.         for i in self.departureTimeSched:
  534.             self.tracker2 = self.tracker2+1
  535.  
  536.             li = Label(self.trainScheduleW, text=i, width=40)
  537.             li.grid(row=self.tracker2, column=2)
  538.            
  539.  
  540.  
  541.         for i in self.stationSched:
  542.             self.tracker3 = self.tracker3+1
  543.  
  544.             li = Label(self.trainScheduleW, text=i, width=40)
  545.             li.grid(row=self.tracker3, column=3)
  546.  
  547.         self.tracker1 = self.tracker1+1
  548.  
  549.         b1 = Button(self.trainScheduleW, text="Back")
  550.         b1.grid(row=self.tracker1, column=0, pady=30)
  551.  
  552.         b1.configure(command= self.loginSchedule)
  553.  
  554.     def loginSchedule(self):
  555.         self.trainScheduleW.withdraw()
  556.  
  557.         self.login()
  558.  
  559.    
  560.     def makeRes(self):
  561.  
  562.  
  563.         self.departFromSched = []
  564.         self.arriveToSched = []
  565.         self.departureDate = []
  566.        
  567.         self.functionW.withdraw()
  568.  
  569.         self.makeResW = Toplevel()
  570.  
  571.  
  572.         l1 = Label(self.makeResW,  text="View Train Schedule", fg="goldenrod", font=("Helventica","24"))
  573.         l1.grid(row=1, column=0, columnspan=5, pady=30, sticky=E+W)
  574.        
  575.    
  576.         l2 = Label(self.makeResW, text="Departs From")
  577.         l2.grid(row=2, column=0)
  578.  
  579.    
  580.         l3 = Label(self.makeResW, text="Arrives At")
  581.         l3.grid(row=3, column=0)
  582.        
  583.    
  584.         l4 = Label(self.makeResW, text="Departure Date")
  585.         l4.grid(row=4, column=0)
  586.  
  587.         db = self.connect()
  588.  
  589.         cursor = db.cursor()
  590.         sql = "SELECT departFrom, arriveTo, departureDate FROM RESV_RESERVES_TRAINROUTE"
  591.  
  592.         found = cursor.execute(sql)
  593.  
  594.         for record in cursor:
  595.             self.departFromSched.append(record[0])
  596.             self.arriveToSched.append(record[1])
  597.             self.departureDate.append(record[2])
  598.  
  599.         print(self.departureDate)
  600. ##        
  601. ##        var = StringVar()
  602. ##        w = OptionMenu(self.makeResW, var, *self.arriveToSched)
  603. ##        w.grid(row=2, column=2)
  604.  
  605.         for i in self.arriveToSched:
  606.  #           self.option1 = OptionMenu(
  607.             pass
  608.  
  609.         for i in self.departFromSched:
  610. ##            self.option2 = OptionMenu(self.makeResW, *self.departFromSched)
  611. ##            self.option2.grid(row=2, column=1)
  612.             pass
  613. ##
  614.         self.stvar = StringVar()
  615.         self.option = OptionMenu(self.makeResW, self.stvar, *self.departFromSched)
  616.         self.option.grid(row=2, column=1)
  617.  
  618.         self.stvar2 = StringVar()
  619.         self.option2 = OptionMenu(self.makeResW, self.stvar2, *self.arriveToSched)
  620.         self.option2.grid(row=3, column=1)      
  621.  
  622.         self.v18 = StringVar()
  623.         self.e18 = Entry(self.makeResW, textvariable = self.v18,width=50)
  624.         self.e18.grid(row=4, column=1)
  625.  
  626.         b1 = Button(self.makeResW, text="Find Trains")
  627.         b1.grid(row=6, column=2, sticky=E+W)
  628.  
  629.  
  630.  
  631.        
  632.  
  633.  
  634.         pic = PhotoImage(file='buzzpic.gif')
  635.         pic1 = Label(self.makeResW, image=pic)
  636.         pic1.image = pic
  637.         pic1.grid(row=5, column=3, rowspan=2, sticky=E)
  638.  
  639.         l2=Label(self.makeResW, text="Type in the form of MM/DD/YYYY")
  640.         l2.grid(row=5, column=1)
  641.        
  642.  
  643.         #for i in range(0, len(self.arriveToSched)):
  644.             #optionMenuWidget["menu"].addcommand(label=i, command=lambda temp=i: optionMenuWidget.setvar(optionMenuWidget.setvar(optionMenuWidget.cget("textvariable"), value=temp))
  645.         b1.configure(command=self.findTrains)
  646.  
  647.     def findTrains(self):
  648.         self.trainDate = datetime.strptime(self.v18.get(),'%m/%d/%Y')
  649.  
  650.         self.makeResW.withdraw()
  651.         self.findTrainW = Toplevel()
  652.        
  653.         self.trainMatch = []
  654.         self.trainMatch3 =[]
  655.         self.trainNumMatch = []
  656.         self.buyTicket=[]
  657.         self.trainNumChoose=[""]
  658.         self.classChoose1=[""]
  659.         self.classChoose2=[""]
  660.  
  661.        
  662.  #       self.departTime =
  663.          
  664.  
  665.         self.departStation = self.stvar.get()
  666.         self.arrivalStation = self.stvar2.get()
  667.  #       print(self.arrivalStation)
  668.  #       print(self.departStation)
  669.         db = self.connect()
  670.  
  671.         cursor = db.cursor()
  672.         sql = "SELECT trainNum, departFrom, arriveTo, departureDate FROM RESV_RESERVES_TRAINROUTE"
  673.  
  674.         found = cursor.execute(sql)
  675.         for record in cursor:
  676.             temp=[]
  677.             temp.append(record[0])
  678.             temp.append(record[1])
  679.             temp.append(record[2])
  680.             temp.append(record[3])
  681.             self.trainMatch.append(temp)
  682.            
  683.         cursor3 = db.cursor()
  684.         sql3 = "SELECT trainNum, stationName, arrivalTime, departureTime FROM TRAIN_STOPBY_STATION"
  685.  
  686.         found3 = cursor3.execute(sql3)
  687.  
  688.         for record in cursor3:
  689.             temp=[]
  690.             temp.append(record[0])
  691.             temp.append(record[1])
  692.             temp.append(record[2])
  693.             temp.append(record[3])
  694.             self.trainMatch3.append(temp)
  695.    
  696.  
  697.  
  698.        # print(self.trainMatch)
  699.         self.trackCost1 = 1
  700.         self.trackCost2 = 1
  701.         self.trackCost3 = 1
  702.  #       print("trainmatch")
  703.        # print(self.trainMatch3)
  704.  
  705.         for i in range(len(self.trainMatch3)):
  706.             for j in range(i+1, len(self.trainMatch3)):
  707.                 if self.trainMatch3[i][1]==self.departStation and self.trainMatch3[j][1]==self.arrivalStation and self.trainMatch3[i][0]==self.trainMatch3[j][0]:
  708. ##                    print("1")
  709. ##                    print(self.trainMatch3[i],self.trainMatch3[j])
  710. ##                    print("")
  711. ##                    print(self.trainMatch3[i])
  712. ##                    print(self.trainMatch3[j])
  713.                     self.trainNumMatch.append(self.trainMatch3[i][0])
  714.  
  715.                 elif self.trainMatch3[i][1]==self.arrivalStation and self.trainMatch3[j][1]==self.departStation and self.trainMatch3[i][0]==self.trainMatch3[j][0]:
  716.                    
  717. ##                    print("2")
  718. ##                    print(self.trainMatch3[i],self.trainMatch3[j])
  719. ##                    print("")
  720. ##                    print(self.trainMatch3[i])
  721. ##                    print(self.trainMatch3[j])
  722.                     self.trainNumMatch.append(self.trainMatch3[i][0])
  723.  
  724.        # print("self.trainNumMatch")
  725.         #print(self.trainNumMatch)
  726.         for i in self.trainNumMatch:
  727.             self.trackCost1 = self.trackCost1+1
  728.             cursor3 = db.cursor()
  729.             sql3 = "SELECT 1st_Class_Price, 2nd_Class_Price FROM TRAIN_ROUTE WHERE trainNum=%s"
  730.            
  731.  
  732.             found3 = cursor3.execute(sql3, (i))
  733.             for j in cursor3:
  734.                
  735. ##                li = Label(self.findTrainW, text=j[0])
  736. ##                li.grid(row=self.trackCost1, column=2)
  737.  
  738.                
  739.                 self.vb=IntVar()
  740.  
  741.                 bi = Radiobutton(self.findTrainW, text=j[0], variable=self.vb, value=1)
  742.                 bi.grid(row=self.trackCost1, column=2)
  743.                 self.val=j[0]
  744.                 self.numChosen=i
  745.                 self.trainNumChoose.append(i)
  746.                 self.classChoose1.append(j[0])
  747.                 self.classChoose2.append(j[1])
  748. ##                lj= Label(self.findTrainW, text=j[1]
  749. ##                          )
  750. ##                lj.grid(row=self.trackCost1, column=3)
  751. ##
  752.                 lk = Label(self.findTrainW, text=i)
  753.                 lk.grid(row=self.trackCost1, column=0)
  754.            
  755.                 self.vb2=IntVar()
  756.                 bj = Radiobutton(self.findTrainW, text=j[1], variable=self.vb2, value=1)
  757.                 bj.grid(row=self.trackCost1, column=3)
  758.                 self.val2=j[1]
  759. ##                if self.vb.get() ==0:
  760. ##    #                self.buyTicket = []
  761. ##                    self.buyTicket.append(i)
  762. ##                    self.buyTicket.append(j[0])
  763. ##
  764. ##                elif seflf.vb2.get() ==0:
  765. ##                    
  766. ##  #                  self.buyTicket = []
  767. ##                    self.buyTicket.append(i)
  768. ##                    self.buyTicket.append(j[0])
  769. ##
  770. ##
  771. ##
  772.                
  773. ##        
  774. ##
  775. ##        print(self.buyTicket)
  776.  
  777.         track=self.trackCost1+1
  778.         self.stvar3 = StringVar()
  779.         self.option3 = OptionMenu(self.findTrainW, self.stvar3, *self.trainNumChoose)
  780.         self.option3.grid(row=track, column=0)
  781.         self.stvar4 = StringVar()
  782.         self.option4 = OptionMenu(self.findTrainW, self.stvar4, *self.classChoose1)
  783.         self.option4.grid(row=track, column=2)
  784.  
  785.  
  786.         self.stvar5=StringVar()
  787.         self.option5 = OptionMenu(self.findTrainW, self.stvar5, *self.classChoose2)
  788.         self.option5.grid(row=track, column=3)
  789.  
  790.         l1 = Label(self.makeResW,  text="Select Departure", fg="goldenrod", font=("Helventica","24"))
  791.         l1.grid(row=0, column=0, columnspan=5, pady=30, sticky=E+W)
  792.  
  793.         l2 = Label(self.findTrainW, text="Train Number")
  794.         l2.grid(row=1, column=0)
  795.  
  796.         l3 = Label(self.findTrainW, text="Time/Duration")
  797.         l3.grid(row=1, column=1)
  798.  
  799.         l4 = Label(self.findTrainW, text="1st Class Price")
  800.         l4.grid(row=1, column=2)
  801.  
  802.         l5 = Label(self.findTrainW, text="2nd Class Price")
  803.         l5.grid(row=1, column=3)
  804.  
  805.         self.trackCost1=self.trackCost1+1
  806.  
  807.         bnext=Button(self.findTrainW, text="Next")
  808.         bnext.grid(row=self.trackCost1, column=4)
  809.  
  810.         bnext.configure(command=self.goNext)
  811.  
  812.     def goNext(self):
  813. ##
  814. ##        if self.vb.get()==1:
  815. ##            self.classCost=self.val
  816. ##            print(self.classCost)
  817. ##        
  818. ##        elif self.vb2.get() ==1:
  819. ##            self.classCost=self.val2
  820. ##            print(self.classCost)
  821.  
  822.         if self.stvar4.get() != "" and self.stvar5.get() != "":
  823.             messagebox.showinfo("Pick Only One Class", "Please Pick only one class")
  824.             self.findTrains()
  825.  
  826.         elif self.stvar3.get() == "":
  827.             messagebox.showinfo("Train Number", "Please Pick a Train Number")
  828.         elif self.stvar4.get() != "":
  829.             self.classCost=self.stvar4.get()
  830.             self.classNumb="1st Class"
  831.  
  832.         else:
  833.  
  834.         #elif self.stvar4.get() != "":
  835.             self.classCost=self.stvar5.get()
  836.             self.classNumb="2nd Class"
  837.         print(self.stvar3.get())
  838.         print(self.stvar4.get())
  839.         print(self.stvar5.get())
  840.            
  841.         print(self.classCost)
  842.  
  843.         self.findTrainW.withdraw()
  844.         self.extrasW=Toplevel()
  845.        
  846.         l1 = Label(self.extrasW, text="Travel Extras & Passenger Info", fg="goldenrod", font=("Helventica","24"))
  847.         l1.grid(row=1, column=0, columnspan=3, pady=30, sticky=E+W)
  848.  
  849.         l2 = Label(self.extrasW, text="Number of Baggage")
  850.         l2.grid(row=2, column=0, padx=50)
  851.  
  852.        
  853.         l3 = Label(self.extrasW, text="Every passenger can bring up to 4 baggage 2 free of charge, 2 for $30 per bag")
  854.         l3.grid(row=3, column=0, padx=50)
  855.  
  856.         l4 = Label(self.extrasW, text="Passenger Name")
  857.         l4.grid(row=4, column=0, padx=50)
  858.  
  859.         self.stvar6 = IntVar()
  860.         self.option6 = OptionMenu(self.extrasW, self.stvar6, 1,2,3,4)
  861.         self.option6.grid(row=2, column=1)
  862.  
  863.         self.var6 = StringVar()
  864.         self.ent6 = Entry(self.extrasW, textvariable=self.var6, state="normal", width=50)
  865.         self.ent6.grid(row=4, column=1)
  866.  
  867.         b=Button(self.extrasW, text="Next")
  868.         b.grid(row=6, column=2)
  869.         b.configure(command=self.goRes)
  870.  
  871.     def goRes(self):
  872.  
  873.         self.cardsFound=["None"]
  874.         self.name = self.var6.get()
  875.         self.numBag=self.stvar6.get()
  876.  
  877.         self.extrasW.withdraw()
  878.         self.goResW=Toplevel()
  879.  
  880.         l1 = Label(self.goResW,  text="Make Reservation", fg="goldenrod", font=("Helventica","24"))
  881.         l1.grid(row=0, column=0, columnspan=7, pady=30, sticky=E+W)
  882.  
  883.         l2 = Label(self.goResW, text="Train Number")
  884.         l2.grid(row=1, column=0)
  885.  
  886.         l3 = Label(self.goResW, text="Time/Duration")
  887.         l3.grid(row=1, column=1)
  888.  
  889.         l4 = Label(self.goResW, text="Departs From")
  890.         l4.grid(row=1, column=2)
  891.  
  892.         l5 = Label(self.goResW, text="Arrives At")
  893.         l5.grid(row=1, column=3)
  894.  
  895.         l6 = Label(self.goResW,  text="Class")
  896.         l6.grid(row=1, column=4)
  897.  
  898.         l7 = Label(self.goResW, text="Price")
  899.         l7.grid(row=1, column=5)
  900.  
  901.         l8 = Label(self.goResW, text="# of Baggage")
  902.         l8.grid(row=1, column=6)
  903.  
  904.         l9 = Label(self.goResW, text="Passenger Name")
  905.         l9.grid(row=1, column=7)
  906.         l10 = Label(self.goResW, text="Remove")
  907.         l10.grid(row=1, column=8)
  908.  
  909.  
  910.         l11 = Label(self.goResW, text=self.stvar3.get())
  911.         l11.grid(row=2, column=0)
  912.  
  913.         l12 = Label(self.goResW, text="time")
  914.         l12.grid(row=2, column=1)
  915.  
  916.         l13 = Label(self.goResW, text=self.departStation)
  917.         l13.grid(row=2, column=2)
  918.  
  919.  
  920.         l14 = Label(self.goResW, text=self.arrivalStation)
  921.         l14.grid(row=2, column=3)
  922.  
  923.         l15 = Label(self.goResW, text=self.classNumb)
  924.         l15.grid(row=2, column=4)
  925.  
  926.  
  927.         if self.studentEmail!="":
  928.             l18=Label(self.goResW, text="Student Discount Applied")
  929.             l17.grid(row=3, column=0)
  930.  
  931.             self.classCost=self.classCost*.8
  932.            
  933.  
  934.         l16 = Label(self.goResW, text=self.classCost)
  935.         l16.grid(row=2, column=5)
  936.         self.classCost = float(self.classCost)
  937.         if self.stvar6.get() ==3:
  938.             self.classCost=self.classCost+30
  939.  
  940.         if self.stvar6.get() ==4:
  941.             self.classCost=self.classCost+60
  942.  
  943.  
  944.         l36=Label(self.goResW, text=self.stvar6.get())
  945.         l36.grid(row=2, column=6)
  946.  #       l26= Label(self.goResW, text=
  947.         l17 = Label(self.goResW, text=self.name)
  948.         l17.grid(row=2, column=7)
  949.  
  950.         b18=Button(self.goResW, text="Remove")
  951.         b18.grid(row=2, column=8)
  952.  
  953.  
  954. #        b18.configure(command=self.cancelRes)
  955.  
  956.  
  957.         l19 = Label(self.goResW, text="Total Cost")
  958.         l19.grid(row=3, column=0)
  959.  
  960.  
  961.         l20 = Label(self.goResW, text=self.classCost)
  962.         l20.grid(row=3, column=1)
  963.         l21 = Label(self.goResW, text="Use Card")
  964.         l21.grid(row=4, column=0)
  965.  
  966.         db = self.connect()
  967.  
  968.         cursor = db.cursor()
  969.         sql = "SELECT cardNum FROM PAYMENT_INFO WHERE username=%s"
  970.  
  971.         found = cursor.execute(sql,(self.usernameL))
  972.  
  973.         for record in cursor:
  974.             self.cardsFound.append(record)
  975.        
  976.        
  977.         self.stvar7 = StringVar()
  978.         self.option7 = OptionMenu(self.goResW, self.stvar7, *self.cardsFound)
  979.         self.option7.grid(row=5, column=1)
  980.  
  981.         b3 = Button(self.goResW, text="Add Card")
  982.         b3.grid(row=5, column=4)
  983.  
  984.         b4 = Button(self.goResW, text="Continue adding a train")
  985.         b4.grid(row=6, column=0)
  986.  
  987.         b5=Button(self.goResW,text= "Back")
  988.         b5.grid(row=7, column=1)
  989.         b6=Button(self.goResW, text="Submit")
  990.         b6.grid(row=7, column=2)
  991.  
  992.         b6.configure(command=self.submitRes)
  993.  #       b4.configure(command=self.)
  994.         b3.configure(command=self.addPayment)
  995.  
  996.     def submitRes(self):
  997.  
  998.        
  999.  
  1000.         if self.stvar7.get() =="None":
  1001.  
  1002.             messagebox.showerror("Credit Card", "Please add a credit card number!")
  1003.             self.goRes()
  1004.  
  1005.         else:
  1006.  
  1007.  
  1008.  
  1009.            
  1010.             card = self.stvar7.get()
  1011.  
  1012.             self.newCard = ""
  1013.             for i in range(2,len(card)-3):
  1014.                 self.newCard=self.newCard+card[i]
  1015.             self.classCost=str(self.classCost)
  1016.             print(self.classCost)
  1017.             print(card)
  1018.             print(self.newCard)
  1019.             num="0"
  1020.  
  1021.             print(self.classCost)
  1022.             print(num)
  1023.             print(self.usernameL)
  1024.             print(self.newCard)
  1025.             reservationID=random.randrange(0,10000000)
  1026.             reservatID=str(reservationID)
  1027.             self.reservationID = reservatID
  1028.             db=self.connect()
  1029.             cursor = db.cursor()
  1030.             sql = "INSERT INTO RESERVATION (resvID, totalCost, isCancelled, username, cardNum) VALUES (%s, %s, %s, %s, %s)"
  1031.  
  1032.             cursor.execute(sql, (reservatID, self.classCost, num, self.usernameL, self.newCard))
  1033.             cursor.close()
  1034.  
  1035.             db.commit()
  1036.             db.close()
  1037.  
  1038.             db=self.connect()
  1039.             cursor = db.cursor()
  1040.             sql = "INSERT INTO RESV_RESERVES_TRAINROUTE (resvID, trainNum, departureDate, departFrom, arriveTo, class, baggageNum,passengerName) VALUES (%s, %s, %s, %s, %s,%s,%s,%s)"
  1041.  
  1042.             cursor.execute(sql, (reservatID, self.stvar3.get(), self.trainDate, self.departStation, self.arrivalStation, self.classNumb, self.stvar6.get(), self.name))
  1043.             cursor.close()
  1044.  
  1045.             db.commit()
  1046.             db.close()
  1047.            
  1048.  #                                self.classCost, num, self.usernameL, self.newCard))
  1049.             self.confirmation()
  1050.  
  1051.     def confirmation(self):
  1052.         self.goResW.withdraw()
  1053.  
  1054.         self.confirmW=Toplevel()
  1055.         self.confirmW.title("Confirmation Number")
  1056.  
  1057.        
  1058.         l1 = Label(self.confirmW,  text="Confirmation", fg="goldenrod", font=("Helventica","24"))
  1059.         l1.grid(row=0, column=0, columnspan=5, pady=30, sticky=E+W)
  1060.        
  1061.         l11=Label(self.confirmW, text="Reservation ID")
  1062.         l11.grid(row=1, column=0)
  1063.        
  1064.         l2 = Label(self.confirmW, text="Thank you for your purchase! Please save reservation ID for your records!")                  
  1065.         l2.grid(row=2, column=0)
  1066.        
  1067.  
  1068.  
  1069.         l3 = Label(self.confirmW, text=self.reservationID)                  
  1070.         l3.grid(row=1, column=3)
  1071.  
  1072.         b1 = Button(self.confirmW, text="Go Back to Choose Functionality")
  1073.         b1.grid(row=4, column=1, columnspan=2)
  1074.  
  1075.         b1.configure(command=self.goChoose)
  1076.  
  1077.     def goChoose(self):
  1078.         self.confirmW.withdraw()
  1079.         self.login()
  1080.                    
  1081.                        
  1082.            
  1083.     def addPayment(self):
  1084.  
  1085.         self.goResW.withdraw()
  1086.         self.payW =Toplevel()
  1087.        
  1088.         l1 = Label(self.payW,  text="Payment Information", fg="goldenrod", font=("Helventica","24"))
  1089.         l1.grid(row=0, column=0, columnspan=5, pady=30, sticky=E+W)
  1090.         l11=Label(self.payW, text="Add Card")
  1091.         l11.grid(row=1, column=0)
  1092.         l2 = Label(self.payW, text="Name on Card")
  1093.                    
  1094.         l2.grid(row=2, column=0)
  1095.         l3 = Label(self.payW, text="Card Number")
  1096.         l3.grid(row=3, column=0)
  1097.  
  1098.         l4 = Label(self.payW, text="CVV")
  1099.         l4.grid(row=4, column=0)
  1100.  
  1101.         l5 = Label(self.payW, text="Expiration Date")
  1102.         l5.grid(row=5, column=0)
  1103.  
  1104.         l6 = Label(self.payW,  text="Delete Card")
  1105.         l6.grid(row=1, column=3)
  1106.  
  1107.         l7 = Label(self.payW,  text="Card Number")
  1108.         l7.grid(row=2, column=3)
  1109.  
  1110.         self.var7 = StringVar()
  1111.         self.ent7=Entry(self.payW, textvariable=self.var7, state="normal", width=50)
  1112.         self.ent7.grid(row=2, column=1)
  1113.  
  1114.         self.var8 = StringVar()
  1115.         self.ent8=Entry(self.payW, textvariable=self.var8, state="normal", width=50)
  1116.         self.ent8.grid(row=3, column=1)
  1117.  
  1118.         self.var9 = StringVar()
  1119.         self.ent9=Entry(self.payW, textvariable=self.var9, state="normal")
  1120.         self.ent9.grid(row=4, column=1)
  1121.  
  1122.         self.var10 = StringVar()
  1123.         self.ent10=Entry(self.payW, textvariable=self.var10, state="normal")
  1124.         self.ent10.grid(row=5, column=1)
  1125.        
  1126.         self.stvar9 = StringVar()
  1127.         self.option9 = OptionMenu(self.payW, self.stvar9, *self.cardsFound)
  1128.         self.option9.grid(row=2, column=4)
  1129.  
  1130.         b1 = Button(self.payW, text="Submit")
  1131.         b1.grid(row=7, column=1)
  1132.  
  1133.  
  1134.         b2 = Button(self.payW, text="Submit")
  1135.         b2.grid(row=7, column=3)
  1136.  
  1137.         b3 =Button(self.payW, text="Back")
  1138.         b3.grid(row=9, column=0)
  1139.  
  1140.         b1.configure(command=self.addCard)
  1141.         b2.configure(command=self.deleteCard)
  1142.         b3.configure(command=self.goBackPay)
  1143.  
  1144.     def goBackPay(self):
  1145.         self.payW.withdraw()
  1146.         self.goResW.deiconify()
  1147.     def deleteCard(self):
  1148.         db=self.connect()
  1149.         cursor = db.cursor()
  1150.  
  1151.         card = self.stvar9.get()
  1152.         print(card)
  1153.         print(card[5])
  1154.         self.newCard = ""
  1155.         for i in range(2,len(card)-3):
  1156.             self.newCard=self.newCard+card[i]
  1157.    
  1158.         print(self.usernameL)
  1159.         print(self.newCard)
  1160.        
  1161.         sql = "DELETE FROM PAYMENT_INFO WHERE cardNum=%s AND username=%s"
  1162.  
  1163.         cursor.execute(sql, (self.newCard, self.usernameL))#)
  1164.  
  1165.         cursor.close()
  1166.  
  1167.         db.commit()
  1168.         db.close()
  1169.        
  1170.  
  1171.     def addCard(self):
  1172.         self.carddate = datetime.strptime(self.var10.get(),'%m/%d/%Y')
  1173.  
  1174.  
  1175.         db=self.connect()
  1176.         cursor = db.cursor()
  1177.         sql = "INSERT INTO PAYMENT_INFO (cardNum, cardName, cvv, expDate, username) VALUES (%s, %s, %s, %s, %s)"
  1178.  
  1179.         cursor.execute(sql, (self.var8.get(), self.var7.get(), self.var9.get(), self.carddate, self.usernameL))
  1180.         cursor.close()
  1181.  
  1182.         db.commit()
  1183.         db.close()
  1184.  
  1185.     def finalizeRes(self):
  1186.  
  1187.  
  1188.         l1 = Label(self.goResW,  text="Make Reservation", fg="goldenrod", font=("Helventica","24"))
  1189.         l1.grid(row=0, column=0, columnspan=5, pady=30, sticky=E+W)
  1190.  
  1191.         l2 = Label(self.goResW, text="Train Number")
  1192.         l2.grid(row=1, column=0)
  1193.  
  1194.         l3 = Label(self.goResW, text="Time/Duration")
  1195.         l3.grid(row=1, column=1)
  1196.  
  1197.         l4 = Label(self.goResW, text="Departs From")
  1198.         l4.grid(row=1, column=2)
  1199.  
  1200.         l5 = Label(self.goResW, text="Arrives At")
  1201.         l5.grid(row=1, column=3)
  1202.  
  1203.         l6 = Label(self.goResW,  text="Class")
  1204.         l6.grid(row=1, column=4)
  1205.  
  1206.         l7 = Label(self.goResW, text="Price")
  1207.         l7.grid(row=1, column=5)
  1208.  
  1209.         l8 = Label(self.goResW, text="# of Baggage")
  1210.         l8.grid(row=1, column=6)
  1211.  
  1212.         l9 = Label(self.goResW, text="Passenger Name")
  1213.         l9.grid(row=1, column=7)
  1214.         l10 = Label(self.goResW, text="Remove")
  1215.         l10.grid(row=1, column=8)
  1216.  
  1217.  
  1218.         l11 = Label(self.goResW, text=self.stvar3.get())
  1219.         l11.grid(row=2, column=0)
  1220.  
  1221.         l12 = Label(self.goResW, text="time")
  1222.         l12.grid(row=2, column=1)
  1223.  
  1224.         l13 = Label(self.goResW, text=self.departStation)
  1225.         l13.grid(row=2, column=2)
  1226.  
  1227.  
  1228.         l14 = Label(self.goResW, text=self.arrivalStation)
  1229.         l14.grid(row=2, column=3)
  1230.  
  1231.         l15 = Label(self.goResW, text=self.classNumb)
  1232.         l15.grid(row=2, column=4)
  1233.  
  1234.         cursor = db.cursor()
  1235.         sql = "SELECT isStudent FROM CUSTOMER WHERE Username = %s"
  1236.         userInput = self.username
  1237.         found = cursor.execute(sql, (self.usernameL))
  1238.         print(cursor)
  1239.        
  1240.         if self.studentEmail!="":
  1241.             l18=Label(self.goResW, text="Student Discount Applied")
  1242.             l17.grid(row=3, column=0)
  1243.  
  1244.             self.classCost=self.classCost*.8
  1245.  
  1246.  #       if
  1247.            
  1248.  
  1249.         l16 = Label(self.goResW, text=self.classCost)
  1250.         l16.grid(row=2, column=5)
  1251.  
  1252.         l36=Label(self.goResW, text=self.stvar6.get())
  1253.         l36.grid(row=2, column=6)
  1254.  #       l26= Label(self.goResW, text=
  1255.         l17 = Label(self.goResW, text=self.name)
  1256.         l17.grid(row=2, column=7)
  1257.  
  1258.         b18=Button(self.goResW, text="Remove")
  1259.         b18.grid(row=2, column=8)
  1260. #        b18.configure(command=self.cancelRes)
  1261.  
  1262.  
  1263.         l19 = Label(self.goResW, text="Total Cost")
  1264.         l19.grid(row=3, column=0)
  1265.  
  1266.  
  1267.         l20 = Label(self.goResW, text=self.classCost)
  1268.         l20.grid(row=3, column=3)
  1269.         l21 = Label(self.goResW, text="Use Card")
  1270.         l21.grid(row=4, column=0)
  1271.  
  1272.         db = self.connect()
  1273.  
  1274.         cursor = db.cursor()
  1275.         sql = "SELECT cardNum FROM PAYMENT_INFO WHERE username=%s"
  1276.  
  1277.         found = cursor.execute(sql,(self.usernameL))
  1278.  
  1279.         for record in cursor:
  1280.             self.cardsFound.append(record)
  1281.        
  1282.        
  1283.         self.stvar8 = StringVar()
  1284.         self.option8 = OptionMenu(self.goResW, self.stvar8, *self.cardsFound)
  1285.         self.option8.grid(row=5, column=3)
  1286.  
  1287.         b3 = Button(self.goResW, "Add Card")
  1288.         b3.grid(row=5, column=4)
  1289.  
  1290.  
  1291.         b5=Button(self.goResW, "Back")
  1292.         b5.grid(row=7, column=1)
  1293.         b6=Button(self.goResW, "Submit")
  1294.         b6.grid(row=7, column=2)
  1295.            
  1296.  
  1297. ####
  1298. ##        self.stvar = StringVar()
  1299. ##        self.option = OptionMenu(self.makeResW, self.stvar, *self.departFromSched)
  1300. ##        self.option.grid(row=2, column=1
  1301.    
  1302.        # print(
  1303. ####    def updateRes(self):
  1304. ####        self.functionW.withdraw()
  1305. ####        self.updateResW = Toplevel()
  1306. ####        self.updateResW.title("Update Train Reservation")
  1307. ####
  1308. ####        l1 = Label(self.updateResW, text="Update Reservation", fg="goldenrod", font=("Helventica","24"))
  1309. ####        l1.grid(row=1, column=0, columnspan=3, pady=30, sticky=E+W)
  1310. ####
  1311. ####        l2 = Label(self.updateResW, text="Reservation ID")
  1312. ####        l2.grid(row=2, column=0, padx=50)
  1313. ####
  1314. ####        self.v17 = StringVar()
  1315. ####        self.e17 = Entry(self.updateResW, textvariable = self.v17, state="normal")
  1316. ####        self.e17.grid(row=2, column=2)
  1317. ####
  1318. ####        b1 = Button(self.updateResW, text="Back", relief="raised")
  1319. ####        b1.grid(row=5, column=0, padx=50, pady=50)
  1320. ####
  1321. ####        b2 = Button(self.updateResW, text="Search", relief="raised")
  1322. ####        b2.grid(row=6, column=0, padx=50, pady=50)
  1323. ####    
  1324. ####        pic = PhotoImage(file='buzzpic.gif')
  1325. ####        pic1 = Label(self.updateResW, image=pic)
  1326. ####        pic1.image = pic
  1327. ####        pic1.grid(row=4, column=2, rowspan=2, sticky=E)
  1328. ####
  1329. ####        b1.configure(command=self.login)
  1330. ####        b2.configure(command=self.updateRes1)
  1331. ####
  1332. ####    def updateRes1(self):
  1333. ####        self.updateResW.withdraw()
  1334. ####        self.updateRes1W = Toplevel()
  1335. ####
  1336. ####        self.reservationID = self.v17.get()
  1337. ####        self.trainNumber = []
  1338. ####        self.time = []
  1339. ####        self.departsFrom = []
  1340. ####        self.arrivesAt = []
  1341. ####        self.classStatus = []
  1342. ####        self.price = []
  1343. ####        self.numbOfBags = []
  1344. ####        self.passengerName = []
  1345. ####
  1346. ####
  1347. ####
  1348. ####        l1 = Label(self.updateRes1W, text="Update Train Reservation", fg="goldenrod", font=("Helventica","24"))
  1349. ####        l1.grid(row=1, column=0, columnspan=4, pady=30, sticky=E+W)
  1350. ####
  1351. ####        l2 = Label(self.updateRes1W, text="Train Number", width=20)
  1352. ####        l2.grid(row=2, column=0, sticky=W)
  1353. ####
  1354. ####        l3 = Label(self.updateRes1W, text="Time (Duration)", width=20)
  1355. ####        l3.grid(row=2, column=1, sticky=W)
  1356. ####
  1357. ####        l4 = Label(self.updateRes1W, text="Departs From", width=20)
  1358. ####        l4.grid(row=2, column=2, sticky=W)
  1359. ####
  1360. ####        l5 = Label(self.updateRes1W, text="Arrives At", width=20)
  1361. ####        l5.grid(row=2, column=3, sticky=W)
  1362. ####
  1363. ####        l6 = Label(self.updateRes1W, text="Class", width=20)
  1364. ####        l6.grid(row=2, column=4, sticky=W)
  1365. ####
  1366. ####        l7 = Label(self.updateRes1W, text="Price", width=20)
  1367. ####        l7.grid(row=2, column=5, sticky=W)
  1368. ####
  1369. ####        l8 = Label(self.updateRes1W, text="# of Bags", width=20)
  1370. ####        l8.grid(row=2, column=6, sticky=W)
  1371. ####
  1372. ####        l9 = Label(self.updateRes1W, text="Passenger Name", width=20)
  1373. ####        l9.grid(row=2, column=7, sticky=W)
  1374. ####
  1375. ####        db = self.connect()
  1376. ####
  1377. ####        cursor = db.cursor()
  1378. ####        sql = "SELECT trainNumb, departureDate, departFrom, arriveTo, class, baggageNum, passengerName FROM RESV_RESERVES_TRAINROUTE WHERE resvID=%s"
  1379. ####
  1380. ####        found = cursor.execute(sql, (self.reservationID))
  1381. ####
  1382. ####        for record in cursor:
  1383. ####            self.trainNumb.append(record[0])
  1384. ####            self.departureDate.append(record[1])
  1385. ####            self.departFrom.append(record[2])
  1386. ####            self.arriveTo.append(record[3])
  1387. ####            self.classStatus.append(record[4])
  1388. ####            self.price.append(record[5])
  1389. ####            self.numbOfBags.append(record[6])
  1390. ####            self.passengerName.append(record[7])
  1391. ####
  1392. ####            self.arrivalTimeSched.append(record[0])
  1393. ####            self.departureTimeSched.append(record[1])
  1394. ####            self.stationSched.append(record[2])
  1395. ####
  1396. ####        
  1397. ####        self.tracker1 = 2
  1398. ####        self.tracker2 = 2
  1399. ####        self.tracker3 = 2
  1400. ####        self.tracker3 = 2
  1401. ####        self.tracker4 = 2
  1402. ####        self.tracker5 = 2
  1403. ####        self.tracker6 = 2
  1404. ####        self.tracker7 = 2
  1405. ####        self.tracker8 = 2
  1406. ####
  1407. ####        for i in self.trainNum:
  1408. ####            self.tracker1 = self.tracker1+1
  1409. ####
  1410. ####            li = Label(self.trainScheduleW, text=i, width=40)
  1411. ####            li.grid(row=self.tracker1, column=1)
  1412. ####
  1413. ####            
  1414. ####            
  1415. ####
  1416. ####        for i in self.departureTimeSched:
  1417. ####            self.tracker2 = self.tracker2+1
  1418. ####
  1419. ####            li = Label(self.trainScheduleW, text=i, width=40)
  1420. ####            li.grid(row=self.tracker2, column=2)
  1421. ####            
  1422. ####
  1423. ####
  1424. ####        for i in self.stationSched:
  1425. ####            self.tracker3 = self.tracker3+1
  1426. ####
  1427. ####            li = Label(self.trainScheduleW, text=i, width=40)
  1428. ####            li.grid(row=self.tracker3, column=3)
  1429. ####
  1430. ####        self.tracker1 = self.tracker1+1
  1431. ####
  1432. ####        b1 = Button(self.updateRes1W, text="Back")
  1433. ####        b1.grid(row=self.tracker1, column=0, pady=30)
  1434. ####        b2 = Button(self.updateResW, text="Next")
  1435. ####        b2.grid(row=self.tracker1, column=1, pady=30)
  1436. ####
  1437. ####        b1.configure(command= self.updateRes)
  1438. ####        b2.configure(command= self.updateRes2)
  1439. ####
  1440. ####        def updateRes2(self):
  1441. ####            self.updateRe1W.withdraw()
  1442. ####            self.updateRes2W = Toplevel()
  1443. ####
  1444. ####            self.reservationID = self.v17.get()
  1445. ####            self.arrivalTimeSched = []
  1446. ####            self.departureTimeSched = []
  1447. ####            self.stationSched = []
  1448. ####
  1449. ####
  1450. ####
  1451. ####            l1 = Label(self.updateRes1W, text="Update Train Reservation", fg="goldenrod", font=("Helventica","24"))
  1452. ####            l1.grid(row=1, column=0, columnspan=4, pady=30, sticky=E+W)
  1453. ####
  1454. ####            l2 = Label(self.updateRes1W, text="Train Number", width=20)
  1455. ####            l2.grid(row=2, column=0, sticky=W)
  1456. ####
  1457. ####            l3 = Label(self.updateRes1W, text="Time (Duration)", width=20)
  1458. ####            l3.grid(row=2, column=1, sticky=W)
  1459. ####
  1460. ####            l4 = Label(self.updateRes1W, text="Departs From", width=20)
  1461. ####            l4.grid(row=2, column=2, sticky=W)
  1462. ####
  1463. ####            l5 = Label(self.updateRes1W, text="Arrives At", width=20)
  1464. ####            l5.grid(row=2, column=3, sticky=W)
  1465. ####
  1466. ####            l6 = Label(self.updateRes1W, text="Class", width=20)
  1467. ####            l6.grid(row=2, column=4, sticky=W)
  1468. ####
  1469. ####            l7 = Label(self.updateRes1W, text="Price", width=20)
  1470. ####            l7.grid(row=2, column=5, sticky=W)
  1471. ####
  1472. ####            l8 = Label(self.updateRes1W, text="# of Bags", width=20)
  1473. ####            l8.grid(row=2, column=6, sticky=W)
  1474. ####
  1475. ####            l9 = Label(self.updateRes1W, text="Passenger Name", width=20)
  1476. ####            l9.grid(row=2, column=7, sticky=W)
  1477. ####
  1478. ####
  1479. ####            
  1480. ####
  1481. ####rootWin = Tk()
  1482. ####app = Project(rootWin)
  1483. ####rootWin.mainloop()
  1484.  
  1485.  
  1486.    
  1487.     def updateRes(self):
  1488.         self.functionW.withdraw()
  1489.         self.updateResW = Toplevel()
  1490.         self.updateResW.title("Update Train Reservation")
  1491.  
  1492.         l1 = Label(self.updateResW, text="Update Reservation", fg="goldenrod", font=("Helventica","24"))
  1493.         l1.grid(row=1, column=0, columnspan=3, pady=30, sticky=E+W)
  1494.  
  1495.         l2 = Label(self.updateResW, text="Reservation ID")
  1496.         l2.grid(row=2, column=0, padx=50)
  1497.  
  1498.         self.v17 = StringVar()
  1499.         self.e17 = Entry(self.updateResW, textvariable = self.v17, state="normal")
  1500.         self.e17.grid(row=2, column=2)
  1501.  
  1502.         b1 = Button(self.updateResW, text="Back", relief="raised")
  1503.         b1.grid(row=5, column=0, padx=50, pady=50)
  1504.  
  1505.         b2 = Button(self.updateResW, text="Search", relief="raised")
  1506.         b2.grid(row=6, column=0, padx=50, pady=50)
  1507.    
  1508.         pic = PhotoImage(file='buzzpic.gif')
  1509.         pic1 = Label(self.updateResW, image=pic)
  1510.         pic1.image = pic
  1511.         pic1.grid(row=4, column=2, rowspan=2, sticky=E)
  1512.  
  1513.         b1.configure(command=self.login)
  1514.         b2.configure(command=self.updateRes1)
  1515.  
  1516.     def updateRes1(self):
  1517.         self.updateResW.withdraw()
  1518.         self.updateRes1W = Toplevel()
  1519.  
  1520.         self.reservationID = self.v17.get()
  1521.         self.trainNum = []
  1522.         self.departureDate = []
  1523.         self.departFrom = []
  1524.         self.arriveTo = []
  1525.         self.classStatus = []
  1526.         self.numbOfBags = []
  1527.         self.passengerName = []
  1528.  
  1529.  
  1530.  
  1531.         l1 = Label(self.updateRes1W, text="Update Train Reservation", fg="goldenrod", font=("Helventica","24"))
  1532.         l1.grid(row=1, column=0, columnspan=4, pady=30, sticky=E+W)
  1533.  
  1534.         l2 = Label(self.updateRes1W, text="Train Number", width=20)
  1535.         l2.grid(row=2, column=0, sticky=W)
  1536.  
  1537.         l3 = Label(self.updateRes1W, text="Time (Duration)", width=20)
  1538.         l3.grid(row=2, column=1, sticky=W)
  1539.  
  1540.         l4 = Label(self.updateRes1W, text="Departs From", width=20)
  1541.         l4.grid(row=2, column=2, sticky=W)
  1542.  
  1543.         l5 = Label(self.updateRes1W, text="Arrives At", width=20)
  1544.         l5.grid(row=2, column=3, sticky=W)
  1545.  
  1546.         l6 = Label(self.updateRes1W, text="Class", width=20)
  1547.         l6.grid(row=2, column=4, sticky=W)
  1548.  
  1549.         l7 = Label(self.updateRes1W, text="Price", width=20)
  1550.         l7.grid(row=2, column=5, sticky=W)
  1551.  
  1552.         l8 = Label(self.updateRes1W, text="# of Bags", width=20)
  1553.         l8.grid(row=2, column=6, sticky=W)
  1554.  
  1555.         l9 = Label(self.updateRes1W, text="Passenger Name", width=20)
  1556.         l9.grid(row=2, column=7, sticky=W)
  1557.  
  1558.         db = self.connect()
  1559.  
  1560.         cursor = db.cursor()
  1561.         sql = "SELECT trainNum, departureDate, departFrom, arriveTo, class, baggageNum, passengerName FROM RESV_RESERVES_TRAINROUTE WHERE resvID=%s"
  1562.  
  1563.         found = cursor.execute(sql, (self.reservationID))
  1564.  
  1565.         for record in cursor:
  1566.             self.trainNum.append(record[0])
  1567.             self.departureDate.append(record[1])
  1568.             self.departFrom.append(record[2])
  1569.             self.arriveTo.append(record[3])
  1570.             self.classStatus.append(record[4])
  1571.             self.numbOfBags.append(record[5])
  1572.             self.passengerName.append(record[6])
  1573.  
  1574.        
  1575.         self.tracker1 = 2
  1576.         self.tracker2 = 2
  1577.         self.tracker3 = 2
  1578.         self.tracker3 = 2
  1579.         self.tracker4 = 2
  1580.         self.tracker5 = 2
  1581.         self.tracker6 = 2
  1582.         self.tracker7 = 2
  1583.  
  1584.         for i in self.trainNum:
  1585.             self.tracker1 = self.tracker1+1
  1586.  
  1587.             li = Label(self.updateRes1W, text=i, width=20)
  1588.             li.grid(row=self.tracker1, column=0)        
  1589.        
  1590.         for i in self.departureDate:
  1591.             self.tracker2 = self.tracker2+1
  1592.  
  1593.             li = Label(self.updateRes1W, text=i, width=20)
  1594.             li.grid(row=self.tracker2, column=1)
  1595.            
  1596.         for i in self.departFrom:
  1597.             self.tracker3 = self.tracker3+1
  1598.  
  1599.             li = Label(self.updateRes1W, text=i, width=20)
  1600.             li.grid(row=self.tracker3, column=2)
  1601.  
  1602.         for i in self.arriveTo:
  1603.             self.tracker4 = self.tracker4+1
  1604.  
  1605.             li = Label(self.updateRes1W, text=i, width=20)
  1606.             li.grid(row=self.tracker4, column=3)
  1607.  
  1608.         for i in self.classStatus:
  1609.             self.tracker5 = self.tracker5+1
  1610.  
  1611.             li = Label(self.updateRes1W, text=i, width=20)
  1612.             li.grid(row=self.tracker5, column=4)
  1613.  
  1614.             if self.classStatus == 1:
  1615.                 cursor = db.cursor()
  1616.                 sql = "SELECT 1st_Class_Price FROM TRAINROUTE WHERE resvID=%s"
  1617.                 found1 = cursor.execute(sql, (self.reservationID))
  1618.                 li = Label(self.updateRes1W, text=i, width=20)
  1619.                 li.grid(row=self.tracker5, column=5)
  1620.             elif self.classStatus == 0:
  1621.                 cursor = db.cursor()
  1622.                 sql = "SELECT 2nd_Class_Price FROM TRAINROUTE WHERE resvID=%s"
  1623.                 found1 = cursor.execute(sql, (self.reservationID))
  1624.                 li = Label(self.updateRes1W, text=i, width=20)
  1625.                 li.grid(row=self.tracker5, column=5)
  1626.  
  1627.         for i in self.numbOfBags:
  1628.             self.tracker6 = self.tracker6+1
  1629.  
  1630.             li = Label(self.updateRes1W, text=i, width=20)
  1631.             li.grid(row=self.tracker6, column=6)
  1632.  
  1633.         for i in self.passengerName:
  1634.             self.tracker7 = self.tracker7+1
  1635.  
  1636.             li = Label(self.updateRes1W, text=i, width=20)
  1637.             li.grid(row=self.tracker7, column=7)
  1638.  
  1639.             b3 = Button(self.updateRes1W, text="Select")
  1640.             b3.grid(row=self.tracker7, column=8, pady=30)
  1641.             b3.configure(command= self.updateRes2)
  1642.  
  1643.         self.tracker1 = self.tracker1+1
  1644.  
  1645.         b1 = Button(self.updateRes1W, text="Back")
  1646.         b1.grid(row=self.tracker1, column=0, pady=30)
  1647.  
  1648.         b1.configure(command= self.updateRes)
  1649.  
  1650.     def updateRes2(self):
  1651.         self.updateRes1W.withdraw()
  1652.         self.updateRes2W = Toplevel()
  1653.  
  1654.         self.reservationID = self.v17.get()
  1655.         self.trainNum = []
  1656.         self.departureDate = []
  1657.         self.departFrom = []
  1658.         self.arriveTo = []
  1659.         self.classStatus = []
  1660.         self.numOfBags = []
  1661.         self.passengerName = []
  1662.  
  1663.  
  1664.         l1 = Label(self.updateRes2W, text="Update Train Reservation", fg="goldenrod", font=("Helventica","24"))
  1665.         l1.grid(row=1, column=0, columnspan=4, pady=30, sticky=E+W)
  1666.  
  1667.         l2 = Label(self.updateRes2W, text="Train Number", width=20)
  1668.         l2.grid(row=2, column=0, sticky=W)
  1669.  
  1670.         l3 = Label(self.updateRes2W, text="Time (Duration)", width=20)
  1671.         l3.grid(row=2, column=1, sticky=W)
  1672.  
  1673.         l4 = Label(self.updateRes2W, text="Departs From", width=20)
  1674.         l4.grid(row=2, column=2, sticky=W)
  1675.  
  1676.         l5 = Label(self.updateRes2W, text="Arrives At", width=20)
  1677.         l5.grid(row=2, column=3, sticky=W)
  1678.  
  1679.         l6 = Label(self.updateRes2W, text="Class", width=20)
  1680.         l6.grid(row=2, column=4, sticky=W)
  1681.  
  1682.         l7 = Label(self.updateRes2W, text="Price", width=20)
  1683.         l7.grid(row=2, column=5, sticky=W)
  1684.  
  1685.         l8 = Label(self.updateRes2W, text="# of Bags", width=20)
  1686.         l8.grid(row=2, column=6, sticky=W)
  1687.  
  1688.         l9 = Label(self.updateRes2W, text="Passenger Name", width=20)
  1689.         l9.grid(row=2, column=7, sticky=W)
  1690.  
  1691.         db = self.connect()
  1692.  
  1693.         cursor = db.cursor()
  1694.         sql = "SELECT trainNum, departureDate, departFrom, arriveTo, class, baggageNum, passengerName FROM RESV_RESERVES_TRAINROUTE WHERE resvID=%s"
  1695.  
  1696.         found = cursor.execute(sql, (self.reservationID))
  1697.  
  1698.         for record in cursor:
  1699.             self.trainNum.append(record[0])
  1700.             self.departureDate.append(record[1])
  1701.             self.departFrom.append(record[2])
  1702.             self.arriveTo.append(record[3])
  1703.             self.classStatus.append(record[4])
  1704.             self.numbOfBags.append(record[5])
  1705.             self.passengerName.append(record[6])
  1706.  
  1707.        
  1708.         self.tracker1 = 2
  1709.         self.tracker2 = 2
  1710.         self.tracker3 = 2
  1711.         self.tracker3 = 2
  1712.         self.tracker4 = 2
  1713.         self.tracker5 = 2
  1714.         self.tracker6 = 2
  1715.         self.tracker7 = 2
  1716.  
  1717.         for i in self.trainNum:
  1718.             self.tracker1 = self.tracker1+1
  1719.  
  1720.             li = Label(self.updateRes2W, text=i, width=20)
  1721.             li.grid(row=self.tracker1, column=0)        
  1722.        
  1723.         for i in self.departureDate:
  1724.             self.tracker2 = self.tracker2+1
  1725.  
  1726.             li = Label(self.updateRes2W, text=i, width=20)
  1727.             li.grid(row=self.tracker2, column=1)
  1728.            
  1729.         for i in self.departFrom:
  1730.             self.tracker3 = self.tracker3+1
  1731.  
  1732.             li = Label(self.updateRes2W, text=i, width=20)
  1733.             li.grid(row=self.tracker3, column=2)
  1734.  
  1735.         for i in self.arriveTo:
  1736.             self.tracker4 = self.tracker4+1
  1737.  
  1738.             li = Label(self.updateRes2W, text=i, width=20)
  1739.             li.grid(row=self.tracker4, column=3)
  1740.  
  1741.         for i in self.classStatus:
  1742.             self.tracker5 = self.tracker5+1
  1743.  
  1744.             li = Label(self.updateRes2W, text=i, width=20)
  1745.             li.grid(row=self.tracker5, column=4)
  1746.  
  1747.             if self.classStatus == 1:
  1748.                 cursor = db.cursor()
  1749.                 sql = "SELECT 1st_Class_Price FROM TRAINROUTE WHERE resvID=%s"
  1750.                 found1 = cursor.execute(sql, (self.reservationID))
  1751.                 li = Label(self.updateRes1W, text=i, width=20)
  1752.                 li.grid(row=self.tracker5, column=5)
  1753.             elif self.classStatus == 0:
  1754.                 cursor = db.cursor()
  1755.                 sql = "SELECT 2nd_Class_Price FROM TRAINROUTE WHERE resvID=%s"
  1756.                 found1 = cursor.execute(sql, (self.reservationID))
  1757.                 li = Label(self.updateRes1W, text=i, width=20)
  1758.                 li.grid(row=self.tracker5, column=5)
  1759.  
  1760.         for i in self.numbOfBags:
  1761.             self.tracker6 = self.tracker6+1
  1762.  
  1763.             li = Label(self.updateRes2W, text=i, width=20)
  1764.             li.grid(row=self.tracker6, column=6)
  1765.  
  1766.         for i in self.passengerName:
  1767.             self.tracker7 = self.tracker7+1
  1768.  
  1769.             li = Label(self.updateRes2W, text=i, width=20)
  1770.             li.grid(row=self.tracker7, column=7)
  1771.  
  1772.     def cancelRes(self):
  1773.         self.functionW.withdraw()
  1774.         self.cancelResW = Toplevel()
  1775.         self.cancelResW.title("Cancel Train Reservation")
  1776.  
  1777.         l1 = Label(self.cancelResW, text="Cancel Reservation", fg="goldenrod", font=("Helventica","24"))
  1778.         l1.grid(row=1, column=0, columnspan=3, pady=30, sticky=E+W)
  1779.  
  1780.         l2 = Label(self.cancelResW, text="Reservation ID")
  1781.         l2.grid(row=2, column=0, padx=50)
  1782.  
  1783.         self.v18 = StringVar()
  1784.         self.e18 = Entry(self.cancelResW, textvariable = self.v18, state="normal")
  1785.         self.e18.grid(row=2, column=2)
  1786.  
  1787.         b1 = Button(self.cancelResW, text="Back", relief="raised")
  1788.         b1.grid(row=5, column=0, padx=50, pady=50)
  1789.  
  1790.         b2 = Button(self.cancelResW, text="Search", relief="raised")
  1791.         b2.grid(row=6, column=0, padx=50, pady=50)
  1792.    
  1793.         pic = PhotoImage(file='buzzpic.gif')
  1794.         pic1 = Label(self.cancelResW, image=pic)
  1795.         pic1.image = pic
  1796.         pic1.grid(row=4, column=2, rowspan=2, sticky=E)
  1797.  
  1798.         b1.configure(command=self.login)
  1799.         b2.configure(command=self.cancelRes1)
  1800.  
  1801.     def cancelRes1(self):
  1802.         self.cancelResW.withdraw()
  1803.         self.cancelRes1W = Toplevel()
  1804.  
  1805.         self.reservationID = self.v18.get()
  1806.         self.trainNum = []
  1807.         self.departureDate = []
  1808.         self.departFrom = []
  1809.         self.arriveTo = []
  1810.         self.classStatus = []
  1811.         self.numbOfBags = []
  1812.         self.passengerName = []
  1813.  
  1814.  
  1815.  
  1816.         l1 = Label(self.cancelRes1W, text="Cancel Train Reservation", fg="goldenrod", font=("Helventica","24"))
  1817.         l1.grid(row=1, column=0, columnspan=4, pady=30, sticky=E+W)
  1818.  
  1819.         l2 = Label(self.cancelRes1W, text="Train Number", width=20)
  1820.         l2.grid(row=2, column=0, sticky=W)
  1821.  
  1822.         l3 = Label(self.cancelRes1W, text="Time (Duration)", width=20)
  1823.         l3.grid(row=2, column=1, sticky=W)
  1824.  
  1825.         l4 = Label(self.cancelRes1W, text="Departs From", width=20)
  1826.         l4.grid(row=2, column=2, sticky=W)
  1827.  
  1828.         l5 = Label(self.cancelRes1W, text="Arrives At", width=20)
  1829.         l5.grid(row=2, column=3, sticky=W)
  1830.  
  1831.         l6 = Label(self.cancelRes1W, text="Class", width=20)
  1832.         l6.grid(row=2, column=4, sticky=W)
  1833.  
  1834.         l7 = Label(self.cancelRes1W, text="Price", width=20)
  1835.         l7.grid(row=2, column=5, sticky=W)
  1836.  
  1837.         l8 = Label(self.cancelRes1W, text="# of Bags", width=20)
  1838.         l8.grid(row=2, column=6, sticky=W)
  1839.  
  1840.         l9 = Label(self.cancelRes1W, text="Passenger Name", width=20)
  1841.         l9.grid(row=2, column=7, sticky=W)
  1842.  
  1843.         db = self.connect()
  1844.  
  1845.         cursor = db.cursor()
  1846.         sql = "SELECT trainNum, departureDate, departFrom, arriveTo, class, baggageNum, passengerName FROM RESV_RESERVES_TRAINROUTE WHERE resvID=%s"
  1847.  
  1848.         found = cursor.execute(sql, (self.reservationID))
  1849.  
  1850.         for record in cursor:
  1851.             self.trainNum.append(record[0])
  1852.             self.departureDate.append(record[1])
  1853.             self.departFrom.append(record[2])
  1854.             self.arriveTo.append(record[3])
  1855.             self.classStatus.append(record[4])
  1856.             self.numbOfBags.append(record[5])
  1857.             self.passengerName.append(record[6])
  1858.  
  1859.        
  1860.         self.tracker1 = 2
  1861.         self.tracker2 = 2
  1862.         self.tracker3 = 2
  1863.         self.tracker3 = 2
  1864.         self.tracker4 = 2
  1865.         self.tracker5 = 2
  1866.         self.tracker6 = 2
  1867.         self.tracker7 = 2
  1868.  
  1869.         for i in self.trainNum:
  1870.             self.tracker1 = self.tracker1+1
  1871.  
  1872.             li = Label(self.cancelRes1W, text=i, width=20)
  1873.             li.grid(row=self.tracker1, column=0)        
  1874.            
  1875.  
  1876.         for i in self.departureDate:
  1877.             self.tracker2 = self.tracker2+1
  1878.  
  1879.             li = Label(self.cancelRes1W, text=i, width=20)
  1880.             li.grid(row=self.tracker2, column=1)
  1881.            
  1882.         for i in self.departFrom:
  1883.             self.tracker3 = self.tracker3+1
  1884.  
  1885.             li = Label(self.cancelRes1W, text=i, width=20)
  1886.             li.grid(row=self.tracker3, column=2)
  1887.  
  1888.         for i in self.arriveTo:
  1889.             self.tracker4 = self.tracker4+1
  1890.  
  1891.             li = Label(self.cancelRes1W, text=i, width=20)
  1892.             li.grid(row=self.tracker4, column=3)
  1893.  
  1894.         for i in self.classStatus:
  1895.             self.tracker5 = self.tracker5+1
  1896.  
  1897.             li = Label(self.cancelRes1W, text=i, width=20)
  1898.             li.grid(row=self.tracker5, column=4)
  1899.  
  1900.         for i in self.numbOfBags:
  1901.             self.tracker6 = self.tracker6+1
  1902.  
  1903.             li = Label(self.cancelRes1W, text=i, width=20)
  1904.             li.grid(row=self.tracker6, column=6)
  1905.  
  1906.         for i in self.passengerName:
  1907.             self.tracker7 = self.tracker7+1
  1908.  
  1909.             li = Label(self.cancelRes1W, text=i, width=20)
  1910.             li.grid(row=self.tracker7, column=7)
  1911.                        
  1912.  
  1913.         self.tracker1 = self.tracker1+1
  1914.  
  1915.         b1 = Button(self.cancelRes1W, text="Back")
  1916.         b1.grid(row=self.tracker1, column=0, pady=30)
  1917.         b2 = Button(self.cancelResW, text="Next")
  1918.         b2.grid(row=self.tracker1, column=1, pady=30)
  1919.  
  1920.         b1.configure(command= self.cancelRes)
  1921.         b2.configure(command= self.canelRes2)
  1922.     def get_reviews(trainNo):
  1923.         sql = "SELECT * FROM Review WHERE TrainNumber = %s ORDER by Rating"
  1924.         cursor = db.cursor(pymysql.cursors.DictCursor)
  1925.         cursor.execute(sql,(trainNo))
  1926.         res=cursor.fetchall()
  1927.                        
  1928.         if len(res) == 0:
  1929.             return(jsonify(msg="Requested train does not exist or there's no review yet."))
  1930.         else:
  1931.             reviews.setReviews(res)
  1932.             res =  Response(json.dumps(res), mimetype='application/json')
  1933.             return(res)
  1934.     def submit_review():
  1935.         data = urllib.request.get_json()
  1936.         trainNo = data['trainNo']
  1937.         rating = data['rating']
  1938.         comment = data['comment']
  1939.         userN = user.getUserName()
  1940.         reviewNo = idGenerator()
  1941.         sql = "SELECT * FROM TRAIN_ROUTE WHERE trainNum = %s"
  1942.         cursor = db.cursor()
  1943.         cursor.execute(sql,(trainNo))
  1944.         res = cursor.fetchall()
  1945.  
  1946.         if len(res) == 0:
  1947.           return(jsonify(msg="Train does not exist."))
  1948.         else:
  1949.             sql = "INSERT INTO REVIEW (reviewID, trainNum, rating, username, comment) VALUES (%s, %s, %s, %s, %s)"
  1950.             cursor.execute(sql,(reviewNo, trainNo, rating, userN, comment))
  1951.             return(jsonify(msg="Review submitted successfully!"))
  1952.  
  1953.  
  1954.  
  1955.     def getreviews(self):
  1956.         self.functionW.withdraw()
  1957.         self.getreviewsW = Toplevel()
  1958.         self.getreviewsW.title("View Review")
  1959.        
  1960.         l1 = Label(self.getreviewsW,text="View Review", fg="goldenrod",font=("Helventica","24"))
  1961.         l1.grid(row=1, column=0, columnspan=3, pady=30, sticky=E+W)
  1962.        
  1963.         l2=Label(self.getreviewsW,text="Train Number")
  1964.         l2.grid(row=2, column=0, padx=50)
  1965.        
  1966.         self.v19=StringVar()
  1967.         self.e19 = Entry(self.getreviewsW,textvariable = self.v19,state="normal")
  1968.         self.e19.grid(row=2,column=1)
  1969.        
  1970.         b1 = Button(self.getreviewsW, text="Back", relief="raised")
  1971.         b1.grid(row=5, column=0, pady=10)
  1972.  
  1973.         b2 = Button(self.getreviewsW, text="Next", relief="raised")
  1974.         b2.grid(row=6, column=0, pady=10)
  1975.  
  1976.         b1.configure(command=self.login)
  1977.         b2.configure(command=self.getreviews1)
  1978.  
  1979.     def getreviews1(self):
  1980.         self.getreviewsW.withdraw()
  1981.         self.getreviews1W=Toplevel()
  1982.        
  1983.         self.trainNum = self.v19.get()
  1984.         self.rating = []
  1985.         self.comment = []
  1986.        
  1987.         l1 = Label(self.getreviews1W,text="View Review", fg="goldenrod",font=("Helventica","24"))
  1988.         l1.grid(row=1, column=0, columnspan=4, pady=30, sticky=E+W)
  1989.        
  1990.         l2 = Label(self.getreviews1W, text="Rating", width=20)
  1991.         l2.grid(row=2, column=0, sticky=W)
  1992.  
  1993.         l3 = Label(self.getreviews1W, text="Comment", width=20)
  1994.         l3.grid(row=2, column=1, sticky=W)
  1995.        
  1996.         db = self.connect()
  1997.         cursor =db.cursor()
  1998.         sql = "SELECT rating, comment FROM REVIEW WHERE trainNum = %s"
  1999.         found = cursor.execute(sql,trainNum)
  2000.  
  2001.         for record in cursor:
  2002.                 self.rating.append(record[0])
  2003.                 self.comment.append(record[1])
  2004.        
  2005.         if record[0] == NULL:
  2006.            
  2007.             messagebox.showerror("There is no review for this train")
  2008.             self.getreviews()
  2009.        
  2010.         else:
  2011.             for i in self.rating:
  2012.                 self.tracker1 = self.tracker1+1
  2013.  
  2014.                 li = Label(self.getreviews1W, text=i, width=20)
  2015.                 li.grid(row=self.tracker1, column=0)
  2016.                
  2017.             for i in self.comment:
  2018.                 self.tracker2 = self.tracker2+1
  2019.  
  2020.                 li = Label(self.getreviews1W, text=i, width=20)
  2021.                 li.grid(row=self.tracker2, column=1)
  2022.                
  2023.             self.tracker1 = self.tracker1+1
  2024.            
  2025.             b1 = Button(self.getreviews1W, text="Back to Choose Functionality")
  2026.             b1.grid(row=self.tracker1, column=0, pady=30)
  2027.            
  2028.             b1.configure(command = self.submitreviews)
  2029.            
  2030.            
  2031.            
  2032.     def submitreviews(self):
  2033.         self.functionW.withdraw()
  2034.         self.submitreviewsW = Toplevel()
  2035.         self.getreviewsW.title("Give Review")
  2036.        
  2037.        
  2038.         l1 = Label(self.submitreviewsW,text="Give Review", fg="goldenrod",font=("Helventica","24"))
  2039.         l1.grid(row=1, column=0, columnspan=3, pady=30, sticky=E+W)
  2040.        
  2041.         l2=Label(self.submitreviewsW,text="Train Number")
  2042.         l2.grid(row=2,  column=0, padx=50)
  2043.        
  2044.         l3 = Label(self.submitreviewsW, text="Rating", width=20)
  2045.         l3.grid(row=3,  column=0, padx=50)
  2046.        
  2047.         l4 = Label(self.submitreviewsW, text="Comment", width=20)
  2048.         l4.grid(row=4,  column=0, padx=50)
  2049.        
  2050.        
  2051.         ##sql = "SELECT * FROM TRAIN_ROUTE WHERE trainNum=%s"
  2052.         ##cursor = db.cursor()
  2053.         ##cursor.excute(sql,(trainNum))
  2054.          
  2055.         if self.v19.get() == "None":
  2056.            
  2057.             messagebox.showerror("Leave the review!")
  2058.             self.submitreview()
  2059.        
  2060.         else:
  2061.             db=self.connect()
  2062.             cursor = db.cursor()
  2063.             sql = "INSERT INTO `Review` (`Review_ID`, `Comment`, `Rating`, `Username`, `Train_Number`) VALUES (%s, %s, %s, %s, %s)"
  2064.             cursor.execute(sql,(self.v19.get(),self.rating,self.comment))
  2065.             cursor.close()
  2066.                    
  2067.             b1 = Button(self.submitreviewsW, text="Submit")
  2068.             b1.grid(row=self.tracker1, column=0, pady=30)
  2069.            
  2070.             db.commit()
  2071.             db.close()
  2072.        
  2073.  
  2074.  
  2075.    
  2076.  
  2077.  
  2078. rootWin = Tk()
  2079. app = Project(rootWin)
  2080. rootWin.mainloop()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top