def Percent(self, event): cost = Filter(self.entry4.get()) if len(cost) == 0: return showinfo(title="Error", message='Product Cost Must Be Specified Before Product % ', parent=self.master) else: try: cost = float(cost) except(AttributeError, ValueError): return showinfo(title="Error", message='Numbers Must be Written in Cost Entry', parent=self.master) percent = Filter(self.entry7.get()) if len(percent) == 0: percent = 0 else: try: percent = float(percent) except(AttributeError, ValueError): return showinfo(title="Error", message='Numbers Must be Written in Profit % Entry', parent=self.master) s = cost / 100.0 s = s * percent price = float(cost) + s price = round(price, 2) self.entry2.delete(0, END) self.entry2.insert(0, price) return 1
def addcost(self, edit=False): try: PID = self.tup[0] except(IndexError): return showinfo(title="ERROR", message='Product Not Yet Saved', parent=self.master) try: newcost = float(Filter(self.ncost.get())) newprice = float(Filter(self.nprice.get())) except: return showinfo(title="ERROR", message='costs and price must be numbers', parent=self.master) costid = self.db.sqldb.getcostID(PID, newcost, newprice) if costid != None: return showinfo("Message", "Cost and Price Already Listed", parent=self.master) if edit == False: self.db.sqldb.addnewcost(PID, newcost, newprice) else: i = self.mlb11.Select_index if i == None: return showinfo("Message", "Select a Cost Or Price To Edit", parent=self.master) r = self.mlb11.get(i) pcostid = r[0] self.db.editcosts(pcostid, PID, newcost, newprice) self.Add2Mlb15() self.ncost.delete(0, END) self.nprice.delete(0, END)
def Im_CValidate(self, writer): for row in writer: try: name = Filter(row[self.d["Customer Name"]]).title() except (KeyError): return showinfo('Import Error', 'Cannot Import Current Csv File Try Again') try: phone = Filter(row[self.d["Customer Phone"]]).title() except (KeyError): return showinfo('Import Error', 'Cannot Import Current Csv File Try Again') try: address = Filter(row[self.d["Customer Address"]]).title() except (KeyError): address = "" try: email = Filter(row[self.d["Customer Email"]]).title() except (KeyError): email = "" if len(phone) == 10: phnid = self.db.sqldb.getphoneID(phone) print(phnid, phone, name, address, email), len(phone) if phnid != None: self.db.editcustomer(phnid, phone, name, address, email) else: self.db.addcustomer(name, address, phone, email) self.returns = True return 1
def adddis(event): amt = Filter(entry4.get()) paid = Filter(entry5.get()) try: amt = float(amt) paid = float(paid) except (ValueError): return None dis = amt - paid entry6.delete(0, END) entry6.insert(0, str(dis)) return None
def Im_CAssign(self): if len(self.el[1].get()) == 0: return showinfo("Warning", "Customer Name cannot be empty", parent=self.root2) d = {} d["Customer Name"] = Filter(self.el[0].get()) d["Customer Phone"] = Filter(self.el[1].get()) d["Customer Address"] = Filter(self.el[2].get()) d["Customer Email"] = Filter(self.el[3].get()) self.d = d self.iscdonme = True return self.root2.destroy()
def gotit(self, se, event=None): date = se.get_date() self.hour = int(Filter(self._h.get())) self.min = int(Filter(self._m.get())) self.sec = int(Filter(self._s.get())) if date != None: self.year = date[0] self.month = date[1] self.day = date[2] self.update() self.rootc1.destroy() self.btn['state'] = NORMAL self.rootc1.unbind_all('<Button-1>')
def Im_Assign(self): if len(self.entry.get()) == 0: return showinfo("Warning", "Name cannot be empty", parent=self.root2) if len(self.entry1.get()) == 0: return showinfo("Warning", "Category cannot be empty", parent=self.root2) d = {} d["Name"] = Filter(self.entry.get()) d['Category'] = Filter(self.entry1.get()) d['Description'] = Filter(self.entry2.get()) self.d = d self.isdonme = True return self.root2.destroy()
def Savephone(self, edit, tup): phone = Filter(self.e.get()) if self.db.sqldb.getphoneID(phone) is not None: return showinfo('Error', 'Phone Number Is Already Added.', parent=self.t) # phnid = self.db.sqldb.getphoneID(phone) # ctmid = self.ctmid # if phnid is not None and edit == False: # return showinfo('Type Error', 'Phone Number Is Already Listed', parent=self.t) # if not phone.isdigit(): # return showinfo('Type Error', 'Not a Valid Phone Number', parent=self.t) # if edit: # pphn = self.db.sqldb.getphoneID(tup[0]) # if pphn is not None: # self.db.editphone(pphn, phone, ctmid) # else: # return showinfo('Type Error', 'Phone Number Already Listed', parent=self.t) # else: # if ctmid is None: # return showinfo('Error', 'Add Phone Number After Adding Customer.', parent=self.t) # self.db.addphone(phone, ctmid) if edit: index = self.mlb2221.Select_index if index is None or index > self.mlb2221.size(): return showinfo('Select Error', 'Noting Is Selected', parent=self.master) piid = self.mlb2221.trueparent(self.mlb2221.Select_iid) index = self.mlb2221.index(piid) self.mlb2221.setvalue(index, 0, phone) else: self.mlb2221.insert(END, phone) self.t.destroy() return None
def Acat(self, edit, tup): Cname = Filter(self.e.get()).title() catid = self.db.sqldb.getcategory_id(Cname) if catid != None: return showinfo('Type Error', 'Category Name Is Already Listed', parent=self.t) if len(Cname.split()) == 0: return showinfo('Type Error', 'Category Name Must Be Specified', parent=self.t) if edit == True: self.db.editcategoryname(tup[0], Cname) else: self.db.addcategory(Cname) self.t.destroy() self.Refresh() return showinfo('Successful', 'Changes Saved', parent=self.master)
def Ainv(self, edit, tup): d = {} inv_no = Filter(self.li[0].get()) if str(inv_no).isdigit() == False: return showinfo('Input Error', 'Invoice Number Should Be Numbers', parent=self.t) sd = str(inv_no) in invn.keys() if sd == True: return showinfo('Input Error', 'Invoice Number Already Exists', parent=self.t) inv_date = Filter(self.li[1].get()) if len(inv_date.split()) == 0: return showinfo('Input Error', 'Invoioce Date Should Be specified', parent=self.t) Cname = Filter(self.li[2].get()).title() if len(Cname.split()) == 0: return showinfo('Input Error', 'Customer Name Should Be specified', parent=self.t) Cadd = Filter(self.li[3].get(0.0, END)).title() Cphn = Filter(self.li[4].get()).title() if edit == True: s = self.invn.pop(tup[1]) r = self.nam[s.keys()[0]]['Invoice Nos'].split(",") delindex = r.index(str(tup[1])) del r[delindex] self.nam[s.keys()[0]]['Invoice Nos'] = ",".join(r) d['Name'] = Cname d['Address'] = Cadd d['Phone No'] = Cphn gh = Cname in self.nam.keys() if gh == True: d['ID No'] = self.nam[Cname]['ID No'] d['Invoice Nos'] = str( inv_no) + "," + self.nam[Cname]['Invoice Nos'] else: d['ID No'] = len(self.nam.keys()) + 1 d['Invoice Nos'] = str(inv_no) d['Invoice Date'] = str(inv_date) d['Due'] = 0 d['Email'] = "" self.nam[Cname] = d self.invn[str(inv_no)] = {} self.invn[str(inv_no)][Cname] = d self.t.destroy() return self.Refresh()
def invoicesave(self): try: no = float(Filter(self.invno.get())) phn = Filter(self.cusphn.get()) date = Filter(self.invdate.get()) except: return showinfo(title="ERROR", message='Invoice Number must be numbers', parent=self.master) ctmid = self.db.sqldb.getcustomerID(phn) if ctmid == None: return showinfo(title="ERROR", message='Customer Not Found', parent=self.master) self.db.editinvoice(self.invid, ctmid, no, date) self.invgui.destroy() self.mlb21load() return showinfo(title="Successful", message='Changes Saved', parent=self.master)
def pDssdd(): index = lb.Select_index if index == None or index > lb.size(): return 0 tmtup = lb.get(index) amount = float(Filter(entry4.get())) amount -= float(tmtup[2]) * float(tmtup[1]) entry4.delete(0, END) entry4.insert(END, str(round(amount, 2))) lb.delete(index) return 1
def autofill(event): st = Filter(entry1.get()) l = self.db.sqldb.execute( """SELECT customer_address,phone_no FROM customers JOIN contacts USING (customer_id) WHERE customer_name = "%s" """ % (st)).fetchone() if l == None: return None add = l[0] phn = l[1] entry2.delete(0.0, END) entry2.insert(0.0, add) entry3.delete(0, END) entry3.insert(0, phn)
def pAssdd(): name = Filter(entry7.get()).title() amount = Filter(entry4.get()) qty = Filter(entry8.get()) PID = self.db.sqldb.getproductID(name) if PID == None: return showinfo("Error", "No Product Name %s is in Product List" % (name), parent=self.app) try: amount = float(amount) qty = float(qty) except (ValueError): return showinfo("Error", "Amount,Qty Should be in Numbers", parent=self.app) price = self.db.sqldb.getcell("costs", "product_id", "price", PID) if price == None: return showinfo("Error", "No Purchse has been made on %s " % (name), parent=self.app) costid = self.db.getanycostid(PID, price) boo = False for i in xrange(lb.size()): r = lb.get(i) if costid == r[3]: newqty = float(r[1]) + float(qty) lb.setvalue(i, "Qty", newqty) boo = True amount += float(price) * qty if boo == False: lb.insert(END, (name, qty, price, costid)) entry7.delete(0, END) entry4.delete(0, END) entry4.insert(END, str(round(amount, 2))) return 1
def Save(self, modify, tup): """ tup[0] = id no tup[1] = customer name tup[2] = phn no tup[3] = address tup[4] = email """ name = Filter(self.entry5.get()).title() add = Filter(self.text.get(0.0, END)).title() email = Filter(self.entry3.get()).title() if len(name.split()) == 0: return showinfo(title="Error", message='Customer Name Must Be Specified', parent=self.master) ctmid = None if not modify: ctmid = self.db.addcustomer(name, address=add, email=email) else: ctmid = self.tup[0] ask = askokcancel( "Key Error", "Are You Sure You Want To Change The Customer Name From %s To %s ?" % (tup[1], name), parent=self.master) if not ask: return 1 self.db.editcustomer(ctmid, name, add, email) if ctmid is not None: for i in xrange(self.mlb2221.size()): tup = self.mlb2221.get(i) phnid = self.db.sqldb.getphoneID(tup[0]) if phnid is None: self.db.addphone(tup[0], ctmid) self.master.destroy() return showinfo("ADDED", 'Saved Successfully')
def Im_Validate(self, writer): for row in writer: try: name = Filter(row[self.d["Name"]]).title() except (KeyError, IndexError): return showinfo('Import Error', 'Cannot Import Current Csv File Try Again') try: category = Filter(row[self.d['Category']]).title() except (KeyError): return showinfo('Import Error', 'Cannot Import Current Csv File Try Again') try: description = Filter(row[self.d['Description']]).title() except (KeyError): description = "" PID = self.db.sqldb.getproductID(name) if PID != None: self.db.editproduct(PID, name, category, description) else: self.db.addproduct(name, category, description) self.returns = True return 0
def purchasesave(self): PID = self.tup[0] try: cost = float(Filter(self.purcost.get())) price = float(Filter(self.purprice.get())) qty = float(Filter(self.purqty.get())) date = Filter(self.purdate.get()) date = " ".join(date.split()) except: return showinfo(title="ERROR", message='costs and price must be numbers', parent=self.master) costid = self.db.sqldb.getcostID(PID, cost, price) if costid == None: costid = self.db.sqldb.addnewcost(PID, cost, price) self.db.editpurchase(self.purid, costid, qty, date) self.purgui.destroy() self.Add2Mlb21() return showinfo(title="Successful", message='Changes Saved', parent=self.master)
def Save(self, modify, tup): """Objects of Tup tup[0] -> ID No tup[1] -> Product name tup[2] -> category tup[3] -> description tup[4] -> quantity """ name = Filter(self.entry5.get()).title() category = Filter(self.entry.get()).title() description = Filter(self.text.get(0.0, END)).title() if len(name.split()) == 0: return showinfo(title="Error", message='Product Name Must Be Specified', parent=self.master) if len(category.split()) == 0: return showinfo(title="Error", message='Product Category Must Be Specified', parent=self.master) vre = self.db.sqldb.getproductID(name) if modify == False: if vre != None: return showinfo(title="Error", message='Product Name is Already Listed Change Name To Save As Copy', parent=self.master) PID = self.db.addproduct(name, category, description) elif modify == True: PID = tup[0] previousname = tup[1] previouscategory = tup[2] pdescription = tup[3] if previousname != name: if vre != None: return showinfo(title="Error", message='Product Name is Already Listed', parent=self.master) s = askokcancel("Name Mismatch", "Are You Sure You Want to Change\n\n%s to %s\n\n%s to %s\n\n%s to %s" % ( previousname, name, previouscategory, category, pdescription, description), parent=self.master) if s == False: return False self.db.editproduct(PID, name, category, description) self.master.destroy() return showinfo("ADDED", 'Saved Successfully')
def salesave(self): PID = self.tup[0] try: cost = float(Filter(self.selcost.get())) price = float(Filter(self.selprice.get())) sold = float(Filter(self.selsold.get())) qty = float(Filter(self.selqty.get())) invno = float(Filter(self.selinvno.get())) date = Filter(self.seldate.get()) except: return showinfo(title="ERROR", message='Costs,Price,Selling,Price,Invoice No And Qty must be numbers', parent=self.master) costid = self.db.sqldb.getcostID(PID, cost, price) if costid == None: costid = self.db.sqldb.addnewcost(PID, cost, price) invid = self.db.sqldb.getinvoiceID(invno) if invid == None: return showinfo(title="ERROR", message='Invoice In That Number Dsn\'t Exsist', parent=self.master) print (self.selid, sold, qty, costid) self.db.editsells(self.selid, sold, qty, costid) self.salegui.destroy() self.Add2Mlb22() return showinfo(title="Successful", message='Changes Saved', parent=self.master)
def setdes(self, des): self.__description = Filter(str(des)).title()
def setcategory(self, category): self.__category = Filter(str(category)).title()
def setname(self, name): self.__name = Filter(str(name)).title()
def Ainv(self, edit, tup): """tup = [invoice number,invoice date,customer name] """ inv_no = Filter(self.entry0.get()) if edit == True: invid = tup[0] else: invid = self.db.sqldb.getinvoiceID(inv_no) if invid != None and edit == False: return showinfo('Input Error', 'Invoice Number Already Exists', parent=self.t) inv_date = self.cb0.get() if self.lb.size() == 0: return showinfo('Input Error', 'At Least One Product must be Added', parent=self.t) Cname = Filter(self.entry1.get()).title() if len(Cname) == 0: return showinfo('Input Error', 'Customer Name Should Be specified', parent=self.t) Cadd = Filter(self.entry2.get(0.0, END)).title() Cphn = Filter(self.entry3.get()).title() try: amount = float(Filter(self.entry4.get())) paid = float(Filter(self.entry5.get())) discount = float(Filter(self.entry6.get())) except (ValueError): return showinfo('Input Error', 'Amount, Paid and Discount Have To Be numbers', parent=self.t) ctmid = self.db.sqldb.getcustomerID(Cphn) if ctmid == None: ans = askokcancel( "New Customer", "The Customer %s is not in customer list!\nAdd It?", parent=self.t) if ans == False: return 0 ctmid = self.db.addcustomer(Cname, Cadd, Cphn, "") else: dbcmname = self.db.sqldb.getcell("customers", "customer_id", "customer_name", ctmid) if dbcmname != Cname: showinfo('Input Error', 'Phone Number Already Registered in Another Name', parent=self.t) if edit == True: self.db.editinvoice_withpaid(invid, ctmid, paid, inv_no, inv_date) else: invid = self.db.addinvoice(ctmid, inv_no, paid, inv_date) selids = self.db.getallsellID(invid) for i in selids: self.db.deletesells(i) tnoofproduct = 0 for i in xrange(self.lb.size()): r = self.lb.get(i) tnoofproduct += float(tup[1]) discountperproduct = discount / tnoofproduct for i in xrange(self.lb.size()): tup = self.lb.get(i) product_price = float(tup[2]) product_qty = float(tup[1]) costid = tup[3] selID = self.db.sqldb.getsellID(invid, costid) sold_price = product_price - discountperproduct self.db.addsells(costid, sold_price, invid, product_qty) self.lb.delete(0, END) self.app.destroy() return self.Refresh()
def productsearch(): inp = Filter(entry7.get()) l = self.db.searchproduct(inp.title()) entry7["value"] = l return 1
def De_Save(self): detail = { 'comp_name': Filter(self.company_name.get()), 'comp_add': Filter(str(self.company_address.get(0.0, END))), 'comp_phn': Filter(self.company_phone.get()), 'comp_email': Filter(str(self.company_email.get())), 'comp_site': Filter(str(self.company_website.get())), 'detail_top': Filter(str(self.detail_top.get(0.0, END))), 'curry': Filter(str(self.currency.get())), 'extra': Filter(str(self.ei_buttom.get(0.0, END))), 'sgst': Filter(self.sgst_inp.get()), 'cgst': Filter(self.cgst_inp.get()), 'pic_add': "logo.png" } if Filter(str(self.invoice_num_s.get()).split()) == "": detail['inv_start'] = "0" else: detail['inv_start'] = Filter(str(self.invoice_num_s.get())) self.db.sqldb.save_company_details(detail) return showinfo("Info", "Company Detail Saved Successfully", parent=self.root)
def update_name(self, event): name = Filter(self.entry5.get()).title() if len(name) == 0: name = "Product Name" self.name.configure(text=name)