def removeSale(ea,buton): table=ea[0].get() subtable=ea[1].get() quantityValue=ea[2].get() price=Fetch.getPrice(str(table), str(subtable),cursor,"salesprice") categoryList.append(table) nameList.append(subtable) cursor.execute("USE archa") quantity=Fetch.getQuantity(str(table),str(subtable),cursor) qtyList.append(quantityValue) cursor.execute("USE archa") attDict=dict() conditionDict=dict() attDict={'qty':str(quantity[0]+int(quantityValue))} conditionDict={'Name':str(subtable)} DbUtils.updateDB(str(table),attDict,conditionDict,cursor) priceFinal=int(price*int(quantityValue)) w.config(text=str(int(w.cget("text"))-priceFinal)) #update the price in the totalsale as subtract whatever is removed qtyArray=[] for i in range(int(quantity[0]+int(quantityValue))): #update the qty availalbein the quantity box again as available qty+whatever was removed qtyArray.append(i+1) i+=1 qtyTable['values']=qtyArray #updateSaleOut(table,subtable,quantity,price) for i in range(len(ea)): ea[i].destroy() buton.destroy()
def updateQuantity(event): qtyArray=[] cursor.execute("USE archa") quantity=Fetch.getQuantity(str(table.get()),str(subTable.get()),cursor) j=0 for i in range(int(quantity[0])): qtyArray.append(i+1) i+=1 qtyTable['values']=qtyArray #update the qty availalbe in the quantity box again as available qty-whatever was added to sale
def isAvailable(): qtyArray=[] #this function checks if selected item is available and populates the qty box with available qty cursor.execute("USE archa") quantity=Fetch.getQuantity(str(table.get()),str(subTable.get()),cursor) if(quantity[0]==0): return False else: cursor.execute("USE archa") attDict=dict() conditionDict=dict() attDict={'qty':str(int(quantity[0])-int(qtyTable.get()))} conditionDict={'Name':str(subTable.get())} DbUtils.updateDB(str(table.get()),attDict,conditionDict,cursor) for i in range(int(quantity[0]-int(qtyTable.get()))): qtyArray.append(i+1) i+=1 qtyTable['values']=qtyArray # populates the qty box with available qty saleOut(Fetch.getPrice(str(table.get()),str(subTable.get()),cursor,"salesprice")) return True
def getcurrentQty(): quantity = Fetch.getQuantity(str(categoty.get()), str(nameBox.get()), cursor) return quantity[0]