Skip to content

Commit

Permalink
Final
Browse files Browse the repository at this point in the history
  • Loading branch information
miladbarooni committed Jan 24, 2020
1 parent e7a8203 commit d9af841
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 9 deletions.
46 changes: 46 additions & 0 deletions AdminGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def dashboardPage(self):

Button(self.dashboard_screen,text="Show all Foods", height="2", width="30", command=self.showFoods).pack()
Label(text="").pack()
Button(self.dashboard_screen,text="Edit Current Foods", height="2", width="30", command=self.editFood).pack()
Button(self.dashboard_screen,text="Add food", height="2", width="30", command=self.addFood).pack()
Button(self.dashboard_screen,text="Preparing orders", height="2", width="30", command=self.preparingOrders).pack()
Button(self.dashboard_screen,text="All Compelete orders", height="2", width="30", command=self.allOrders).pack()
Expand All @@ -186,6 +187,51 @@ def dashboardPage(self):
closeButton = Button(self.dashboard_screen, text="Exit", command=self.dashboard_screen.destroy, width="200", height="2")
closeButton.pack()

def editFood(self):
def updateFood(food_id, price_entry, about_entry,city_combo, discount_entry, name_entry):
if (city_combo.get() == ""):
cat_id = ""
else:
cat_id = int(city_combo.get()[0])
mydb.updateFood(food_id, price_entry.get(), about_entry.get(), name_entry.get(), discount_entry.get(),cat_id,"")
foods = mydb.showFoodsOfShop(self.shop_id)
print (foods)
self.edit_food_screen = Tk()
self.edit_food_screen.title("Edit Food")
for i in range(len(foods)):
Label(self.edit_food_screen, text="Food#"+str(i+1)).pack()
# show price
Label(self.edit_food_screen, text="Food Price:").pack()
price_entry = Entry(self.edit_food_screen)
price_entry.pack()
# Show about
Label(self.edit_food_screen, text="Food About:").pack()
about_entry = Entry(self.edit_food_screen)
about_entry.pack()
# Show categori
Label(self.edit_food_screen, text="Choose a Categori").pack()
city_combo = Combobox(self.edit_food_screen)
cities = mydb.showAllCategory()
cities_list = []
print(cities)
for city in cities:
cities_list.append(str(city[0]) + " " +city[1])

city_combo['values']= cities_list
city_combo.pack()
# Show discount
Label(self.edit_food_screen, text="Food Discount:").pack()
discount_entry = Entry(self.edit_food_screen)
discount_entry.pack()
# Show food Name
Label(self.edit_food_screen, text="Food Name:").pack()
name_entry = Entry(self.edit_food_screen)
name_entry.pack()

# Change button
Button(self.edit_food_screen,text="Change my information", height="2", width="30", command=
partial(updateFood, foods[i][0], price_entry, about_entry,city_combo, discount_entry, name_entry)).pack()
# print (email_address_entry.get())

def registerUser(self ,phone_number_entry, password_entry, repeat_password_entry, firstname_entry, lastname_entry, email_entry):
#insert into database
Expand Down
17 changes: 8 additions & 9 deletions Main.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def deleteAddress(self, address_id):


def editAddresses(self):
def updateAddress(i, x_entry, y_entry,city_combo, street_etnry, alley_entry, plaque_entry, address_text_entry):
def updateAddress(i, x_entry, y_entry,city_combo, street_entry, alley_entry, plaque_entry, address_text_entry):

x = x_entry.get()
if (x_entry.get() == ""):
Expand All @@ -437,13 +437,13 @@ def updateAddress(i, x_entry, y_entry,city_combo, street_etnry, alley_entry, pla
city_id = None
else :
city_id = int(city_combo.get()[0])
print (city_id)

street = street_entry.get()
if (street_entry.get()==""):
street = None

alley = alley_entry.get()
if (street_entry.get()==""):
if (alley_entry.get()==""):
alley = None

plaque = plaque_entry.get()
Expand All @@ -453,17 +453,14 @@ def updateAddress(i, x_entry, y_entry,city_combo, street_etnry, alley_entry, pla
address_text = address_text_entry.get()
if (address_text_entry==""):
address_text = None


mydb.updateAddress(i, x, y, city_id, street, alley, plaque, address_text)
addresses = mydb.showUserAddress(self.user_id)
print (addresses)
print (addresses[0][0])
self.edit_address_screen = Tk()
self.edit_address_screen.title("Edit Address")
for i in range(len(addresses)):
print (i)
print (type(i))
# print (i)
# print (type(i))
Label(self.edit_address_screen, text="Address#"+str(i+1)).pack()
# show x
Label(self.edit_address_screen, text="Address x:").pack()
Expand All @@ -474,6 +471,7 @@ def updateAddress(i, x_entry, y_entry,city_combo, street_etnry, alley_entry, pla
y_entry = Entry(self.edit_address_screen)
y_entry.pack()
# Show city
Label(self.edit_address_screen, text="Choose your city, if not please select None").pack()
city_combo = Combobox(self.edit_address_screen)
cities = mydb.showAllCity()
cities_list = []
Expand All @@ -484,6 +482,7 @@ def updateAddress(i, x_entry, y_entry,city_combo, street_etnry, alley_entry, pla

city_combo['values']= cities_list
city_combo.pack()
city_combo.current(0)
# Show Street
Label(self.edit_address_screen, text="Address Street:").pack()
street_entry = Entry(self.edit_address_screen)
Expand All @@ -498,7 +497,7 @@ def updateAddress(i, x_entry, y_entry,city_combo, street_etnry, alley_entry, pla
plaque_entry.pack()
# Show Address text
Label(self.edit_address_screen, text="Address Text:").pack()
address_text_entry = Entry(self.profile)
address_text_entry = Entry(self.edit_address_screen)
address_text_entry.pack()
# Change button
Button(self.edit_address_screen,text="Change my information", height="2", width="30", command=
Expand Down
Binary file modified __pycache__/snapFood.cpython-37.pyc
Binary file not shown.

0 comments on commit d9af841

Please sign in to comment.