def insertProductsToOrders(p_name, quantity):
     query1 = dbManager.fetch("SELECT * FROM orders")
     order_id = len(query1) + 1
     dbManager.commit(
         "INSERT INTO products_in_order (p_name,order_id, quantity) VALUES ('%s', '%s', '%s')"
         % (p_name, order_id, quantity))
     return True
Beispiel #2
0
 def addAppointment(full_name, phone, email, description, date):
     query2 = dbManager.fetch("SELECT * FROM appointments")
     app_id = len(query2) + 1
     query_result = dbManager.commit(
         "insert into appointments(app_id,full_name, phone, email, description) VALUES ('%s', '%s', '%s', '%s', '%s')"
         % (app_id, full_name, phone, email, description))
     return query_result
 def insertCart(p_name, user_name, quantity):
     price = dbManager.fetch(
         "SELECT price FROM products WHERE p_name='%s'" % p_name)[0][0]
     dbManager.commit(
         "INSERT INTO cart (p_name, user_name, quantity, price) VALUES ('%s', '%s', '%s', '%s')"
         % (p_name, user_name, quantity, int(price)))
     return True
 def checkProductInCart(p_name, user_name):
     query_result = dbManager.fetch(
         "SELECT p_name FROM cart WHERE p_name='%s' AND user_name='%s'" %
         (p_name, user_name))
     if len(query_result) > 0:
         return True
     return False
 def moveFromCartToOrder(user_name, order_id):
     cart = dbManager.fetch("SELECT * FROM cart WHERE user_name='%s'" %
                            user_name)
     for c in cart:
         dbManager.commit(
             "INSERT INTO products_in_order (p_name,order_id, quantity, price) VALUES ('%s', '%s', '%s', '%s')"
             % (c.p_name, order_id, c.quantity, c.price))
     return True
 def checkCartExists(email):
     order = dbManager.fetch(
         "SELECT order_id FROM orders WHERE email='%s' AND finished=0" %
         email)
     if len(order) == 0:  # there is no open order (current cart)
         return False
     print(order[0].order_id)
     return order[0].order_id  # there is an open order for the user
 def createNewCart(user_name, datetime):
     user_email = UserManager.getUserEmail(user_name)
     dbManager.commit(
         "INSERT INTO orders (email, date) VALUES ('%s', '%s')" %
         (user_email, datetime.now()))
     order_id = dbManager.fetch(
         "SELECT order_id FROM orders WHERE email='%s' AND finished=0" %
         user_email)
     return order_id
 def createNewOrder(user_name, first_name, last_name, email, cc, cvv):
     amount = ShopManager.calculateAmount(user_name)
     query1 = dbManager.fetch("SELECT * FROM orders")
     order_id = 1
     if len(query1) > 0:
         order_id = len(query1) + 1
     dbManager.commit(
         "INSERT INTO orders (order_id, first_name, last_name, email, cc, cvv , amount) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s')"
         % (order_id, first_name, last_name, email, cc, cvv, amount))
     return order_id
Beispiel #9
0
 def getApps(email):
     return dbManager.fetch("SELECT * FROM appointments WHERE email='%s'" %
                            email)
 def getOrdersproducts(email):
     return dbManager.fetch("SELECT * FROM orders WHERE email='%s'" % email)
 def getUserbyEmail(email):
     return dbManager.fetch("SELECT * FROM users WHERE email='%s'" % email)
 def getUser(user_name):
     return dbManager.fetch("SELECT * FROM users WHERE user_name='%s'" % user_name)
 def getUserLastName(user_name):
     return dbManager.fetch("SELECT last_name FROM users WHERE user_name='%s'" % user_name)[0][0]
 def getUserName(email):
     return dbManager.fetch("SELECT user_name FROM users WHERE email='%s'" % email)[0][0]
 def getUserEmail(user_name):
     return dbManager.fetch("SELECT email FROM users WHERE user_name='%s'" % user_name)[0][0]
 def checkIfUserExists(email):
     query_result = dbManager.fetch("SELECT * FROM users where email='%s'" % email)
     if len(query_result) == 0:
         return False
     return True
 def calculateAmount(user_name):
     return dbManager.fetch(
         "SELECT SUM(price*quantity) as orderTotal FROM cart WHERE user_name='%s'"
         % user_name)[0][0]
 def getCart(user_name):
     return dbManager.fetch("SELECT * FROM cart WHERE user_name='%s'" %
                            user_name)
 def getProducts(p_name: str):
     query_result = dbManager.fetch(
         'SELECT * FROM products WHERE p_name=%s', p_name)
     return query_result