コード例 #1
0
 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()
コード例 #2
0
    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')
コード例 #3
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)
コード例 #4
0
 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)
コード例 #5
0
    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')