Example #1
0
 def putPrice(
     event
 ):  #this function populated price if trying to add existing stock
     price = Fetch.getPrice(str(categoty.get()), str(nameBox.get()),
                            cursor, "salesprice")
     priceText.delete(1.0, "end")
     priceText.insert(1.0, str(price))
     price = Fetch.getPrice(str(categoty.get()), str(nameBox.get()),
                            cursor, "costprice")
     costprice.delete(1.0, "end")
     costprice.insert(1.0, str(price))
Example #2
0
 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()
Example #3
0
 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
Example #4
0
 def addSale():
                                         #this function is the main function that adds sale to the totalsale, updates price, updates qty
         if(isAvailable()):
                 
                 price=Fetch.getPrice(str(table.get()), str(subTable.get()),cursor,"salesprice")
                 individualprice=int(price)
                 prevprice=int(w.cget("text"))
                 items=int(totalItems .cget("text"))
                 items+=1
                 totalItems.config(text=str(items))                                       
                 totalprice=prevprice+(int(qtyTable.get())*individualprice)
                 w.config(text=str(totalprice))
                 List=[]
                 for i in range(3):
                         
                         ea = ttk.Entry(saleFrame, width=10)                                 
                         ea.grid(row=items+7,column=i)                                              
                         ea.insert(END, str(table.get()))if i==0 else ea.insert(END, str(subTable.get())) if i==1 else ea.insert(END, str(qtyTable.get()))
                         List.append(ea)
                         
                 makeSaleButton = Button(saleFrame, text = "remove", width=10,command=lambda:removeSale(List,makeSaleButton))
                 makeSaleButton.grid(row = items+7,  column= i+1)
         else:
                 messagebox.showerror("out of stock","Sorry, the item"+str(subTable.get())+"is out of stock")