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 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
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 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
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 addContactReq(first_name, last_name, email, massage): query_result = dbManager.commit( "insert into contact_massages(first_name, last_name, email, massage) VALUES ('%s', '%s', '%s', '%s')" % (first_name, last_name, email, massage)) return query_result
def insertNewUser(first_name, last_name, user_name, email, password): dbManager.commit("INSERT INTO users(first_name, last_name, user_name, email, password) " "VALUES ('%s', '%s', '%s', '%s', '%s')" % (first_name, last_name, user_name, email, password)) return True
def updateUser(first_name, last_name, user_name, password, email): query_result = dbManager.commit( 'update users set first_Name=%s, last_Name=%s, user_name=%s, password=%s where email=%s', (first_name, last_name, user_name, password, email)) return query_result
def deleteCart(user_name): return dbManager.commit("DELETE FROM cart WHERE user_name='%s'" % (user_name))
def updateProductQuantity(p_name, user_name, quantity): dbManager.commit( "UPDATE cart SET quantity='%s' WHERE p_name='%s' AND user_name='%s'" % (quantity, p_name, user_name)) return True
def removeProductsFromCart(p_name, user_name): return dbManager.commit( "DELETE FROM cart WHERE p_name='%s' AND user_name='%s'" % (p_name, user_name))