Skip to content

Commit

Permalink
showUserAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
miladbarooni committed Jan 23, 2020
2 parents e8ee6bf + 9baebd2 commit 8d9f4b3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
39 changes: 32 additions & 7 deletions Main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from tkinter import Tk, Label, Button, Toplevel, StringVar, Entry, messagebox, Frame, END, Scrollbar, Y, RIGHT
from tkinter import Checkbutton, IntVar, BooleanVar, TkT
from tkinter import Checkbutton, IntVar, BooleanVar

from functools import partial
import tkinter as tk
Expand Down Expand Up @@ -169,13 +169,13 @@ def dashboardPage(self):
def profilePage(self):
def showAddress():
self.current_address_screen = Tk()
addresses = mydb.showAddress(self.user_id)
addresses = mydb.showUserAddress(self.user_id)
print (addresses)
for i in range(len(addresses)):
Label(self.current_address_screen, text="Address #"+str(i+1)+":").pack()
address_str = ""
for j in range(1,5):
address_str+= addresses[i][j] + " "
for j in range(1,6):
address_str+= addresses[i][j] + ", "
Label(self.current_address_screen, text=address_str).pack()
# self.dashboard.destroy()
self.profile = Tk()
Expand Down Expand Up @@ -289,20 +289,45 @@ def updateUserInformation(self, user_id,firstname_entry, lastname_entry, phone_n


def restaurantsPage(self):
style = Style()
style.configure("mystyle.Treeview", highlightthickness=0, bd=0, font=('Calibri', 11)) # Modify the font of the body
style.configure("mystyle.Treeview.Heading", font=('Calibri', 13,'bold')) # Modify the font of the headings
style.layout("mystyle.Treeview", [('mystyle.Treeview.treearea', {'sticky': 'nswe'})]) # Remove the borders

def showRestaurants():
def make_address_str(address_id):
address_info = mydb.show

address_id = -1
for variable in all_variables:
if (variable.get()):
index = all_variables.index(variable)
address_id = all_address[index][0]
resturants = mydb.searchShopByLocation(int(address_id), 10)
resturants = mydb.searchShopByLocation(int(address_id), 100)
print (resturants)
self.searched_resturant_screen = Tk()
self.searched_resturant_screen.title("Results")

tree=Treeview(self.searched_resturant_screen,style="mystyle.Treeview")
tree["columns"]=("one","two","three")
#set tree columns
tree.column("#0", width=270, minwidth=270, stretch=tk.NO)
tree.column("one", width=150, minwidth=150, stretch=tk.NO)
tree.column("two", width=400, minwidth=200)
tree.column("three", width=80, minwidth=50, stretch=tk.YES)
#set tree's heading
tree.heading("#0",text="Name",anchor=tk.W)
tree.heading("one", text="About",anchor=tk.W)
tree.heading("two", text="min bill value",anchor=tk.W)
tree.heading("three", text="address",anchor=tk.W)
for i in range(len(resturants)):
address_in_treeview = tree.insert("", i+1, "", text=resturants[i][1], values=(resturants[i][2], resturants[i][3], make_address_str(resturants[i][4])))
tree.pack()


self.address_selection_screen = Tk()
self.address_selection_screen.title("Your addresses")
self.address_selection_screen.geometry("700x500")
all_address = mydb.showAddress(self.user_id)
all_address = mydb.showUserAddress(self.user_id)
print (all_address)
all_variables = []

Expand Down
Binary file modified __pycache__/snapFood.cpython-37.pyc
Binary file not shown.
11 changes: 7 additions & 4 deletions snapFood.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ def addAddress(self, x, y, user_id, city_id, street = "", alley = "", plaque = "
def searchShopByLocation(self, address_id, radius):
self._mycursor.execute("SELECT * FROM LOCATION WHERE ADDRESSaddressid = \'{}\';".format(address_id))
data = self._mycursor.fetchall()
x = data[0][1]
y = data[0][2]
x = int(data[0][1])
y = int(data[0][2])
self._mycursor.execute("SELECT * FROM LOCATION;")
data = self._mycursor.fetchall()
sql = "SELECT * FROM SHOP WHERE ADDRESSaddressid IN ("
Expand Down Expand Up @@ -122,11 +122,11 @@ def showCategoryOfShop(self, shop_id): #NOT CHECKED

def addShopAndAdmin(self, user_name, password, city_id, x, y, shop_name = "", shop_about = "", shop_bill_value = "",
street = "", alley = "", plaque = "", address = ""): #NOT CHECKED
address_id = self.addAddress(x, y, NULL, city_id, street=street, alley=allay, plaque=plaque, address_text=address)
address_id = self.addAddress(x, y, "", city_id, street=street, alley=alley, plaque=plaque, address_text=address)
self._mycursor.execute("INSERT INTO SHOP(name, `about-text`, `minimum-bill-value`, ADDRESSaddressid) VALUES (\'{}\', \'{}\', \'{}\', \'{}\');"
.format(shop_name, shop_about, shop_bill_value, address_id))
shop_id = self._mycursor.lastrowid
self._mycursor.execute("INSERT INTO ADMIN(username, password, SHOPshopid) VALUES (?, ?, ?);"
self._mycursor.execute("INSERT INTO ADMIN(username, password, SHOPshopid) VALUES (\'{}\', \'{}\', \'{}\');"
.format(user_name, password, shop_id))
self._mydb.commit()
return self._mycursor.lastrowid
Expand Down Expand Up @@ -245,5 +245,8 @@ def searchShop(self, city_id = None, name = None, min_bill_val = -1): #NOT CHEC
self._mycursor.execute(sql)
return self._mycursor.fetchall()

def searchCategory(self, name = None):
return

def close(self):
self._mydb.close()

0 comments on commit 8d9f4b3

Please sign in to comment.