class Booking: def __init__(self): self.booking() self.database = MyDb() def booking(self): try: self.window7 = Tk() self.window7.title('ticket booking') self.window7.geometry('1400x800') self.window7.configure(bg='darkorange1') self.lblc1big = Label(self.window7, bg='darkorange2', width=32, height=15, font=('Ariel', 15, 'bold')) self.lblc1big.place(x=5, y=190) self.lblc1search = Label(self.window7, bg='darkorange2', width=32, height=3, font=('Ariel', 15, 'bold')) self.lblc1search.place(x=5, y=80) self.lblc1ticket = Label(self.window7, bg='darkorange2', width=80, height=2, font=('Ariel', 15, 'bold')) self.lblc1ticket.place(x=450, y=500) self.lbl9 = Label(self.window7, text='SEARCHING BUS', fg='black', bg='darkorange1', font=('Century', 25, 'bold')) self.lbl9.place(x=500, y=1) self.lbl = Label(self.window7, text="SEARCH BUS BY:", fg='black', bg='darkorange2', font=('Cambria', 16, 'bold')) self.lbl.place(x=30, y=85) self.cat5 = ttk.Combobox(self.window7) self.cat5.set('--choose --') self.cat5['values'] = ('Bus Company', 'Route', ' Departure Time' ) # self.combo() self.cat5.place(x=240, y=85) self.select2_but = Button(self.window7, text="SELECT", command=self.sort, bg='darkorange3', font=('Century', '10', 'bold')) self.select2_but.place(x=420, y=85) self.lbl = Label(self.window7, text='keyword', fg='black', bg='darkorange2', font=('Cambria', 16, 'bold')) self.lbl.place(x=30, y=115) self.placen_ent = Entry(self.window7, bg='silver') self.placen_ent.place(x=240, y=115) self.search1_but = Button(self.window7, text="BUS SEARCH", bg='darkorange3', font=('Century', '10', 'bold')) self.search1_but.place(x=420, y=115) self.lbl = Label(self.window7, text='Bus Number', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=200) self.ent_bnum = Entry(self.window7, bg='silver') self.ent_bnum.place(x=240, y=200) self.lbl = Label(self.window7, text='Bus Company', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=250) self.bcom_ent = Entry(self.window7, bg='silver') self.bcom_ent.place(x=240, y=250) self.lbl = Label(self.window7, text='Driver Name', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=300) self.dnam_ent = Entry(self.window7, bg='silver') self.dnam_ent.place(x=240, y=300) self.lbl = Label(self.window7, text='Driver Contact', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=350) self.dcom_ent = Entry(self.window7, bg='silver') self.dcom_ent.place(x=240, y=350) self.lbl = Label(self.window7, text='Total Seat', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=400) self.tseat_ent = Entry(self.window7, bg='silver') self.tseat_ent.place(x=240, y=400) self.lbl = Label(self.window7, text='Route', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=450) self.rou_ent = Entry(self.window7, bg='silver') self.rou_ent.place(x=240, y=450) self.lbl = Label(self.window7, text=' Departure Time', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=20, y=500) self.dtim_ent = Entry(self.window7, bg='silver') self.dtim_ent.place(x=240, y=500) self.add_tree = ttk.Treeview(self.window7, height=15, column=('n', 'w', 'p', 'm', 'c', 'g', 'h')) self.add_tree.place(x=550, y=80) self.add_tree['show'] = 'headings' self.add_tree.column('n', width=100) self.add_tree.column('w', width=100) self.add_tree.column('p', width=100) self.add_tree.column('m', width=100) self.add_tree.column('c', width=100) self.add_tree.column('g', width=100) self.add_tree.column('h', width=100) self.add_tree.heading('n', text='Bus number') self.add_tree.heading('w', text='Bus Company') self.add_tree.heading('p', text='Driver Name') self.add_tree.heading('m', text='Driver Contact') self.add_tree.heading('c', text='Total Seat') self.add_tree.heading('g', text='Route') self.add_tree.heading('h', text='Departure Time') except Exception as e: print(e) def sort(self): try: search_bus_by = self.cat5.get() if search_bus_by == 'Bus Company': self.search1_but = Button(self.window7, text="BUS SEARCH", command=self.search_by_company, bg='darkorange3', font=('Century', '10', 'bold')) self.search1_but.place(x=420, y=115) elif search_bus_by == 'Route': self.search1_but = Button(self.window7, text="BUS SEARCH", command=self.search_by_route, bg='darkorange3', font=('Century', '10', 'bold')) self.search1_but.place(x=420, y=115) else: self.search1_but = Button(self.window7, text="BUS SEARCH", command=self.search_by_time, bg='darkorange3', font=('Century', '10', 'bold')) self.search1_but.place(x=420, y=115) except Exception as e: print(e) def by_company(self, keyword): try: self.database = MyDb() qry = "SELECT * FROM bus_register WHERE bus_company LIKE '" + keyword + "%'" result = self.database.get_data(qry) return result except Exception as e: print(e) def search_by_company(self): try: sea1 = self.placen_ent.get() all_result = self.by_company(sea1) self.add_tree.delete(*self.add_tree.get_children()) for i in all_result: self.add_tree.insert('', 'end', text=i[0], value=(i[1], i[2], i[3], i[4], i[5], i[6], i[7])) self.add_tree.bind("<Double-1>", self.select_item) self.generatebill_but = Button(self.window7, text="GENERATE TICKET", command=self.bill, bg='darkorange3', font=('Century', '10', 'bold')) self.generatebill_but.place(x=480, y=510) except Exception as e: print(e) def by_route(self, keyword): try: self.database = MyDb() qry = "SELECT * FROM bus_register WHERE route LIKE '" + keyword + "%'" result = self.database.get_data(qry) return result except Exception as e: print(e) def search_by_route(self): try: sea1 = self.placen_ent.get() all_result = self.by_route(sea1) self.add_tree.delete(*self.add_tree.get_children()) for i in all_result: self.add_tree.insert('', 'end', text=i[0], value=(i[1], i[2], i[3], i[4], i[5], i[6], i[7])) self.add_tree.bind("<Double-1>", self.select_item) self.generatebill_but = Button(self.window7, text="GENERATE TICKET", command=self.bill, bg='darkorange3', font=('Century', '10', 'bold')) self.generatebill_but.place(x=480, y=510) except Exception as e: print(e) def by_time(self, keyword): try: self.database = MyDb() qry = "SELECT * FROM bus_register WHERE dep_time LIKE '" + keyword + "%'" result = self.database.get_data(qry) return result except Exception as e: print(e) def search_by_time(self): try: sea1 = self.placen_ent.get() all_result = self.by_time(sea1) self.add_tree.delete(*self.add_tree.get_children()) for i in all_result: self.add_tree.insert('', 'end', text=i[0], value=(i[1], i[2], i[3], i[4], i[5], i[6], i[7])) self.add_tree.bind("<Double-1>", self.select_item) self.generatebill_but = Button(self.window7, text="GENERATE TICKET", command=self.bill, bg='darkorange3', font=('Century', '10', 'bold')) self.generatebill_but.place(x=480, y=510) except Exception as e: print(e) def select_item(self, event): try: sel_row = self.add_tree.selection()[0] sel_item = self.add_tree.item(sel_row) self.update_index = self.add_tree.item(sel_row, 'text') selected_data = self.add_tree.item(sel_row, 'values') self.ent_bnum.delete(0, 'end') self.ent_bnum.insert(0, selected_data[0]) self.bcom_ent.delete(0, 'end') self.bcom_ent.insert(0, selected_data[1]) self.dnam_ent.delete(0, 'end') self.dnam_ent.insert(0, selected_data[2]) self.dcom_ent.delete(0, 'end') self.dcom_ent.insert(0, selected_data[4]) self.tseat_ent.delete(0, 'end') self.tseat_ent.insert(0, selected_data[3]) self.rou_ent.delete(0, 'end') self.rou_ent.insert(0, selected_data[5]) self.dtim_ent.delete(0, 'end') self.dtim_ent.insert(0, selected_data[6]) except Exception as e: print(e) def bill(self): try: self.window6 = Tk() self.window6.title('generate ticket') self.window6.geometry('700x400') self.window6.configure(bg='wheat1') self.lbl9 = Label(self.window6, text='Kathmandu Delux Volvo A/c Bus Service', fg='black', bg='wheat2', font=('Century', 25, 'bold')) self.lbl9.place(x=15, y=00) # self.lblc1delux = Label(self.window6, bg='wheat2', width=70, height=2, font=('Ariel', 15, 'bold')) # self.lblc1delux.place(x=0, y=00) self.lblc1booking = Label(self.window6, bg='wheat3', width=100, height=2, font=('Ariel', 10, 'bold')) self.lblc1booking.place(x=00, y=60) self.lbl9 = Label(self.window6, text='Ticket Booking', fg='black', bg='wheat3', font=('Constantia', 15, 'bold')) self.lbl9.place(x=240, y=60) self.lbl10 = Label(self.window6, text='free wifi ', fg='pink', bg='navy', font=('Constantia', 15, 'bold')) self.lbl10.place(x=50, y=100) self.lbl = Label(self.window6, text="Bus company", fg='silver', bg='navy', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=180) self.bcomm_ent = Entry(self.window6, bg='silver') self.bcomm_ent.place(x=155, y=180) self.lbl = Label(self.window6, text="Bus Number", fg='silver', bg='navy', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=200) self.ent_dop = Entry(self.window6, bg='silver') self.ent_dop.place( x=155, y=200, ) self.lbl = Label(self.window6, text="Date ", fg='silver', bg='navy', font=('Cambria', 12, 'bold')) self.lbl.place(x=280, y=150) self.ent_d = Entry(self.window6, bg='silver') self.ent_d.place(x=330, y=150) today = date.today() self.ent_d.insert(0, today) self.lbl = Label(self.window6, text='Dep_Time', fg='silver', bg='navy', font=('Cambria', 12, 'bold')) self.lbl.place(x=480, y=150) self.ti_ent = Entry(self.window6, bg='silver') self.ti_ent.place(x=570, y=150) self.lbl = Label(self.window6, text='Name', fg='silver', bg='navy', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=220) self.na_ent = Entry(self.window6, bg='silver') self.na_ent.place(x=155, y=220) self.lbl = Label(self.window6, text='No.of passenger', fg='silver', bg='navy', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=240) self.no_ent = Entry(self.window6, bg='silver') self.no_ent.place(x=155, y=240) self.lbl = Label(self.window6, text='From.', fg='silver', bg='navy', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=260) self.from_ent = Entry(self.window6, bg='silver') self.from_ent.place(x=155, y=260) self.lbl = Label(self.window6, text='To', fg='silver', bg='navy', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=280) self.to_ent = Entry(self.window6, bg='silver') self.to_ent.place(x=155, y=280) self.lbl = Label(self.window6, text='Fare rs.', fg='silver', bg='navy', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=300) self.rr_ent = Entry(self.window6, bg='silver') self.rr_ent.place(x=155, y=300) self.generatebill_but = Button(self.window6, text="Store", command=self.store, bg='grey', font=('Century', '10', 'bold')) self.generatebill_but.place(x=500, y=350) busnumber = self.ent_bnum.get() buscompany = self.bcom_ent.get() deptime = self.dtim_ent.get() self.bcomm_ent.insert(0, buscompany) self.ent_dop.insert(0, busnumber) self.ti_ent.insert(0, deptime) self.window6.mainloop() except Exception as e: print(e) def store(self, Bus_company, Bus_Number, Name, no_of_passenger, Date, Dep_Time, From_, To_, Fare_rs): try: # self.database = MyDb() # Bus_company=self.bcom_ent.get() # Bus_Number =self.ent_dop.get() # Date = self.ent_d.get() # Dep_Time = self.ti_ent.get() # Name = self.na_ent.get() # no_of_passenger =self.no_ent.get() # From_ = self.from_ent.get() # To_ = self.to_ent.get() # Fare_rs = self.rr_ent.get() if Bus_company == '' or Bus_Number == '' or Date == '' or Dep_Time == '' or Name == '' or no_of_passenger == '' or From_ == '' or To_ == '' or Fare_rs == '': # messagebox.showerror('Error', ' Enter each boxes carefully!') return False else: qry = '''insert into ticket_booking (Bus_company,Bus_Number,Name, no_of_passenger,Date,Dep_Time,From_,To_,Fare_rs) values(%s,%s,%s,%s,%s,%s,%s,%s,%s)''' values = (Bus_company, Bus_Number, Name, no_of_passenger, Date, Dep_Time, From_, To_, Fare_rs) self.database.iud(qry, values) # messagebox.showinfo('Done', ' stored successfully!') return True except Exception as e: print(e) return False
class Register: def __init__(self): self.reg() # self.mainsc() self.choose = Choose() self.database = MyDb() def reg(self): try: self.window = Tk() self.window.title('register for login') self.window.geometry('1000x500') self.window.configure(bg='darkorange1') # img_register = PhotoImage.open("bibhuti & santosh (12).JPG") # resized = img_register.resize((500, 500), Image.ANTIALIAS) # new_pic = PhotoImage(resized) # register_label = Label(self.window, image=new_pic) # register_label.place(x=1, y=1) self.lblc1 = Label(self.window, bg='darkorange2', width=20, height=5, font=('Ariel', 15, 'bold')) self.lblc1.place(x=745, y=90) self.lblc2 = Label(self.window, bg='darkorange2', width=23, height=14, font=('Ariel', 15, 'bold')) self.lblc2.place(x=5, y=60) self.lbl9 = Label(self.window, text=' Kathmandu Delux Volvo A/c Bus Service ', fg='black', bg='darkorange1', font=('Century', 25, 'bold')) self.lbl9.place(x=200, y=10) self.lbl = Label(self.window, text='Enter first name', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=27, y=70) self.ent_name = Entry(self.window, bg='silver') self.ent_name.place(x=155, y=75) self.lbl = Label(self.window, text='Enter last name', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=120) self.ent_ls = Entry(self.window, bg='silver') self.ent_ls.place(x=155, y=125) self.lbl = Label(self.window, text='username', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=170) self.ent_un = Entry(self.window, bg='silver') self.ent_un.place(x=155, y=175) self.lbl = Label(self.window, text='password', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=320) self.ent_ps = Entry(self.window, bg='silver') self.ent_ps.place(x=155, y=325) self.lbl = Label(self.window, text='phone number', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=220) self.ent_pn = Entry(self.window, bg='silver') self.ent_pn.place(x=155, y=225) self.lbl = Label(self.window, text='address', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=270) self.ent_ad = Entry(self.window, bg='silver') self.ent_ad.place(x=155, y=275) self.registernow_but = Button(self.window, text="REGISTER NOW", command=self.getting, bg='darkorange3', font=('Century', "9", 'bold')) self.registernow_but.place(x=155, y=360) self.username = Label(self.window, text=' username', fg='black', bg='darkorange2', font=('Cambria', 13, 'bold')) self.username.place(x=750, y=97) self.un_ent = Entry(self.window, bg='silver') self.un_ent.place(x=850, y=100) self.password = Label(self.window, text=' password', fg='black', bg='darkorange2', font=('Cambria', 13, 'bold')) self.password.place(x=750, y=130) self.ps_ent = Entry(self.window, show='*', bg='silver') self.ps_ent.place(x=850, y=130) self.loginhere_but = Button( self.window, text="LOGIN HERE", command=self.login_backend, bg='darkorange3', font=('Century', 7, 'bold'), ) self.loginhere_but.place(x=880, y=170) self.window.mainloop() except Exception as e: print(e) def getting(self): try: self.database = MyDb() first_name = self.ent_name.get() last_name = self.ent_ls.get() username = self.ent_un.get() password = self.ent_ps.get() phone = self.ent_pn.get() address = self.ent_ad.get() if first_name == '' or last_name == '' or username == '' or password == '' or phone == '' or address == '': messagebox.showerror('Error', ' Enter each boxes carefully!') # return False else: qry = '''insert into registration (username,password,firstname,lastname,address,phone) values(%s,%s,%s,%s,%s,%s)''' values = (username, password, first_name, last_name, address, phone) self.database.iud(qry, values) messagebox.showinfo('Done', ' Registered successfully!') # return True except Exception as e: print(e) # return False # def login(self): # try: # self.window1 = Tk() # self.window1.title(' login') # self.window1.geometry('700x400') # self.window1.configure(bg='navy') # # self.lbl = Label(self.window1, text='Kathmandu Delux Volvo A/c Bus Service ', fg='red', bg='white',font=('Bradley Hand ITC', 18, 'bold')) # self.lbl.place(x=120, y=10) # # # self.username = Label(self.window1, text=' username', fg='silver', bg='navy', font=('Cambria', 13, 'bold')) # self.username.place(x=230, y=97) # # self.un_ent = Entry(self.window1, bg='silver') # self.un_ent.place(x=330, y=100) # # self.password = Label(self.window1, text=' password', fg='silver', bg='navy', font=('Cambria', 13, 'bold')) # self.password.place(x=230, y=130) # # self.ps_ent = Entry(self.window1, show='*', bg='silver') # self.ps_ent.place(x=330, y=130) # # self.loginhere_but = Button(self.window1, text="LOGIN HERE", command=self.login_backend, bg='grey', font=('Century', 7, 'bold'),) # self.loginhere_but.place(x=370, y=170) # self.window1.mainloop() # except Exception as e: # print(e) def login_backend(self): try: self.database = MyDb() self.choose = Choose() userna = self.un_ent.get() passw = self.ps_ent.get() if userna == '' or passw == '': messagebox.showerror("error", "enter username or password first!") else: qry = '''select * from registration where username=%s and password=%s''' values = (userna, passw) user = self.database.get_data_p(qry, values) if len(user) == 1: messagebox.showinfo("Bomm", "Login successfull") self.choose.window3() # return True else: messagebox.showerror("Error", "Wrong password or username") # return False except Exception as e: print(e)
class Addbus: def __init__(self): self.update_index = '' self.database = MyDb() def busadd(self): try: self.window5 = Tk() self.window5.title('Add bus') self.window5.geometry('1200x500') self.window5.configure(bg='darkorange1') self.lblbox1 = Label(self.window5, bg='darkorange2', width=24, height=14, font=('Ariel', 15, 'bold')) self.lblbox1.place(x=15, y=95) self.lbl9 = Label(self.window5, text=' REGISTRATION OF BUS', fg='black', bg='darkorange1', font=('Century', 25, 'bold')) self.lbl9.place(x=380, y=10) self.lbl = Label(self.window5, text='Bus Number', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=100) self.ent_bn = Entry(self.window5, bg='silver') self.ent_bn.place(x=180, y=105) self.lbl = Label(self.window5, text='Bus Company', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=150) self.bc_ent = Entry(self.window5, bg='silver') self.bc_ent.place(x=180, y=155) self.lbl = Label(self.window5, text='Driver Name', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=200) self.dn_ent = Entry(self.window5, bg='silver') self.dn_ent.place(x=180, y=205) self.lbl = Label(self.window5, text='Driver Contact', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=250) self.dc_ent = Entry(self.window5, bg='silver') self.dc_ent.place(x=180, y=255) self.lbl = Label(self.window5, text='Total Seat', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=300) self.ts_ent = Entry(self.window5, bg='silver') self.ts_ent.place(x=180, y=305) self.lbl = Label(self.window5, text='Route', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl.place(x=30, y=350) self.r_ent = Entry(self.window5, bg='silver') self.r_ent.place(x=180, y=350) self.lbl1 = Label(self.window5, text=' Departure Time', fg='black', bg='darkorange2', font=('Cambria', 12, 'bold')) self.lbl1.place(x=25, y=400) self.dt_ent = Entry(self.window5, bg='silver') self.dt_ent.place(x=180, y=400) self.add_tree = ttk.Treeview(self.window5, column=( 'n', 'w', 'p', 'm', 'c', 'g', 'h', )) self.add_tree.place(x=450, y=95) self.add_tree['show'] = 'headings' self.add_tree.column('n', width=100) self.add_tree.column('w', width=100) self.add_tree.column('p', width=100) self.add_tree.column('m', width=100) self.add_tree.column('c', width=100) self.add_tree.column('g', width=100) self.add_tree.column('h', width=100) self.add_tree.heading('n', text='Bus number') self.add_tree.heading('w', text='Bus Company') self.add_tree.heading('p', text='Driver Name') self.add_tree.heading('m', text='Driver Contact') self.add_tree.heading('c', text='Total Seat') self.add_tree.heading('g', text='Route') self.add_tree.heading('h', text='Departure Time') self.treeview_method() self.addedbus_but = Button(self.window5, text="ADD", command=self.add_bus, bg='darkorange3', font=('Century', '10', 'bold')) self.addedbus_but.place(x=450, y=350) self.update1_but = Button(self.window5, text="UPDATE", command=self.update_busdetail, bg='darkorange3', font=('Century', '10', 'bold')) self.update1_but.place(x=500, y=350) self.delete1_but = Button(self.window5, text="DELETE", command=self.delete_000, bg='darkorange3', font=('Century', '10', 'bold')) self.delete1_but.place(x=581, y=350) self.window5.mainloop() except Exception as e: print(e) def add_bus(self, bus_number, bus_company, driver_name, driver_contact, total_seat, route, dep_time): try: self.database = MyDb() # bus_number = self.ent_bn.get() # bus_company = self.bc_ent.get() # driver_name = self.dn_ent.get() # driver_contact = self.dc_ent.get() # total_seat = self.ts_ent.get() # route = self.r_ent.get() # dep_time = self.dt_ent.get() if bus_number == '' or bus_company == '' or driver_name == '' or driver_contact == '' or total_seat == '' or route == '' or dep_time == '': # messagebox.showerror('Error', ' Enter each boxes carefully!') return False else: qry = '''insert into bus_register (bus_number, bus_company, driver_name, driver_contact, total_seat, route,dep_time) values(%s,%s,%s,%s,%s,%s,%s)''' values = (bus_number, bus_company, driver_name, driver_contact, total_seat, route, dep_time) self.database.iud(qry, values) # messagebox.showinfo('Done', 'Added bus successfully!') self.treeview_method() return True except Exception as e: print(e) return False def data_treeview(self): try: self.database = MyDb() qry = '''select * from bus_register ''' bus = self.database.get_data(qry) return bus except Exception as e: print(e) def treeview_method(self): try: buses = self.data_treeview() self.add_tree.delete(*self.add_tree.get_children()) for i in buses: self.add_tree.insert('', 'end', text=i[0], value=(i[1], i[2], i[3], i[4], i[5], i[6], i[7])) self.add_tree.bind("<Double-1>", self.select_item) #seleted event pass except Exception as e: print(e) def update_bus(self, index, bus_number, bus_company, driver_name, driver_contact, total_seat, route, dep_time): try: qry = "UPDATE bus_register SET bus_number = %s, bus_company = %s, driver_name = %s, driver_contact=%s, total_seat=%s, route =%s, dep_time =%s WHERE id = %s" values = (bus_number, bus_company, driver_name, driver_contact, total_seat, route, dep_time, index) self.database.iud(qry, values) return True except Exception as e: print(e) return False def update_busdetail(self): try: bus_number = self.ent_bn.get() bus_company = self.bc_ent.get() driver_name = self.dn_ent.get() driver_contact = self.dc_ent.get() total_seat = self.ts_ent.get() route = self.r_ent.get() dep_time = self.dt_ent.get() if self.update_index == "": messagebox.showerror("Error", "Select Item first") elif not bus_number == '' or bus_company == '' or driver_name == '' or driver_contact == '' or total_seat == '' or route == '' or dep_time == '': return True if self.update_bus(int(self.update_index), bus_number, bus_company, driver_name, driver_contact, total_seat, route, dep_time): messagebox.showinfo("Item", "Item Updated") self.treeview_method() else: messagebox.showerror("Error", "Item can not be Updated") except Exception as e: print(e) def select_item(self, event): try: sel_row = self.add_tree.selection()[0] sel_item = self.add_tree.item(sel_row) self.update_index = self.add_tree.item(sel_row, 'text') selected_data = self.add_tree.item(sel_row, 'values') self.ent_bn.delete(0, 'end') self.ent_bn.insert(0, selected_data[0]) self.bc_ent.delete(0, 'end') self.bc_ent.insert(0, selected_data[1]) self.dn_ent.delete(0, 'end') self.dn_ent.insert(0, selected_data[2]) self.dc_ent.delete(0, 'end') self.dc_ent.insert(0, selected_data[4]) self.ts_ent.delete(0, 'end') self.ts_ent.insert(0, selected_data[3]) self.r_ent.delete(0, 'end') self.r_ent.insert(0, selected_data[5]) self.dt_ent.delete(0, 'end') self.dt_ent.insert(0, selected_data[6]) except Exception as e: print(e) def delete_bus(self, id): try: qry = "DELETE FROM bus_register WHERE id = %s" values = (id) self.database.iud(qry, values) return True except Exception as e: print(e) return False def delete_000(self): try: bus_number = self.ent_bn.get() bus_company = self.bc_ent.get() driver_name = self.dn_ent.get() driver_contact = self.dc_ent.get() total_seat = self.ts_ent.get() route = self.r_ent.get() dep_time = self.dt_ent.get() if self.update_index == "": messagebox.showerror("Error", "Select Item first") elif not bus_number == '' or bus_company == '' or driver_name == '' or driver_contact == '' or total_seat == '' or route == '' or dep_time == '': self.delete_bus(self.del_1(bus_company, bus_company)) messagebox.showinfo("Success", "Delete success") self.treeview_method() except Exception as e: print(e) def del_1(self, name, publisher): try: bus_number = self.ent_bn.get() bus_company = self.bc_ent.get() qry = '''select id from bus_register where bus_number= %s and bus_company=%s''' values = (bus_number, bus_company) result = self.database.get_data_p(qry, values) mukhiya = (result[0]) return mukhiya except Exception as e: print(e)