def edit(self, id): self.editcan.delete(ALL) if id == 0: return if not password.askpass("admin"): return () f = Frame(self.editcan) con = cdb.Db().connection() cur = con.cursor() sql="select products.name,stock.id,stock.ini_count, stock.cur_count,stock.batch,stock.mrp, stock.expiry "\ "from products join stock on products.id=stock.product where stock.id=%s;" cur.execute(sql, (id)) row = cur.fetchone() Label(f, text="product").grid(row=0, column=0, sticky=E, padx=10, pady=5) Label(f, text=row[0]).grid(row=0, column=1, sticky=W, padx=10, pady=5) Label(f, text="batch").grid(row=1, column=0, sticky=E, padx=10, pady=5) Label(f, text=row[4]).grid(row=1, column=1, sticky=W, padx=10, pady=5) Label(f, text="stock").grid(row=2, column=0, sticky=E, padx=10, pady=5) f.count = IntVar() f.count.set(row[3]) Entry(f, textvariable=f.count, width=5).grid(row=2, column=1, sticky=W, padx=10, pady=5) Label(f, text="price").grid(row=3, column=0, sticky=E, padx=10, pady=5) f.price = DoubleVar() f.price.set(row[5]) Entry(f, textvariable=f.price, width=5).grid(row=3, column=1, sticky=W, padx=10, pady=5) Label(f, text="expiry").grid(row=6, column=0, sticky=E, padx=10, pady=5) calpicker = cal.Calbutton(f, inidate=row[6]) calpicker.grid(row=6, column=1, sticky=W) Button(f, text="save", command=lambda: self.savestock(row[1], f.count.get( ), f.price.get(), calpicker.get())).grid(row=7, column=1, sticky=W, padx=10, pady=5) self.editcan.create_window(1, 1, window=f, anchor=NW)
def showOptions(self, selection): f = self.f2 if f.fr: f.fr.pack_forget() if selection == "dayrep": f.fr = fr = Frame(f, bd=1) fr.pack(padx=5, pady=5) Label(fr, text="select date").pack(pady=20) dt = cp.Calbutton(fr) dt.pack() Button(fr, text="Load", command=lambda d=dt: self.showdayrep(dt)).pack(pady=10)
def __init__(self, parent=None, master=None): if not parent: parent = Toplevel() Frame.__init__(self, parent) self.pack() f1 = Frame(self) f2 = Frame(self, bd=1, relief=SUNKEN) sb = Scrollbar(f2) sb.pack(side=RIGHT, fill=Y) self.canvas = Canvas(f2, height=400, width=300, yscrollcommand=sb.set, relief=SUNKEN) self.canvas.pack(fill=BOTH, expand=1) sb.config(command=self.canvas.yview) cur = cdb.Db().connection().cursor() sql = "select * from stockist order by name;" cur.execute(sql) rows = cur.fetchall() stockists = [] for row in rows: stockists.append([row[1], row[0]]) self.stockists = comp.myComp2(f1, listitems=stockists, listheight=4) self.stockists.pack(side=LEFT) self.f3 = Frame(self, bd=1, relief=RIDGE, padx=20, pady=30) ff = self.f3 Label(ff, text="Add New Creditnote", font="Times 12 bold").grid(row=0, column=0, columnspan=2) Label(ff, text="Bill number").grid(row=1, column=0) Label(ff, text="date").grid(row=2, column=0) Label(ff, text="amount").grid(row=3, column=0) Button(ff, text="Add", command=self.addcredit).grid(row=4, column=1) self.crnumber = IntVar() self.crnumber.set(0) comp.NumEntry(ff, textvariable=self.crnumber, width=10).grid(row=1, column=1, padx=10, pady=10) self.crdate = calpicker.Calbutton(ff) self.crdate.grid(row=2, column=1, padx=10, pady=20) self.cramount = DoubleVar() self.cramount.set(0) comp.NumEntry(ff, textvariable=self.cramount, width=10).grid(row=3, column=1, padx=10, pady=20) f2.pack(side=RIGHT, fill=X, expand=1) f1.pack(side=TOP, padx=10, pady=10) self.f3.pack(fill=BOTH, expand=1, side=RIGHT) self.stockists.bind("<<listChanged>>", self.showcredits)
def __init__(self, master=None, parent=None, *args, **kwargs): if not parent: parent = Toplevel(master) Frame.__init__(self, parent, *args, **kwargs) self.parent = parent self.master = master self.items = [] parent.title("Purchase") db = cdb.Db().connection() cursor = db.cursor() cursor.execute("select * from stockist") result = cursor.fetchall() stockists = [] for row in result: stockists.append(row[1]) drugs = [] cursor.execute("select * from drug") result = cursor.fetchall() for row in result: drugs.append(row[1]) ftop = Frame(self, bd=1, relief=RAISED, background="cyan") ftop.pack(side=TOP, fill=X, expand=1) myfont = ("Times", 10, "bold") #frame1 - to select bill details f1 = Frame(ftop, bd=1, relief=GROOVE) Label(f1, text="Stockist", font=myfont).grid(row=0, column=0, sticky=E, padx=4, pady=2) self.stockists = comp.myComp(f1, listitems=stockists, listheight=2, width=14) self.stockists.grid(row=0, column=1, sticky=E + W + N + S, padx=4, pady=2) Label(f1, text="Bill Number", font=myfont).grid(row=1, column=0, sticky=E, padx=4, pady=2) self.billno = Entry(f1, width=14) self.billno.grid(row=1, column=1, sticky=E + W + N + S, padx=4, pady=2) Label(f1, text="Date", font=myfont).grid(row=2, column=0, sticky=E, padx=4, pady=2) self.date = calpicker.Calbutton(f1, width=14) self.date.grid(row=2, column=1, sticky=E + W + N + S, padx=4, pady=2) Label(f1, text='CGST', font=myfont).grid(row=3, column=0, sticky=E, padx=4, pady=2) self.cgst = comp.NumEntry(f1, width=14) self.cgst.grid(row=3, column=1, sticky=E + W + N + S, padx=4, pady=4) Label(f1, text='SGST', font=myfont).grid(row=4, column=0, sticky=E, padx=4, pady=2) self.sgst = comp.NumEntry(f1, width=14) self.sgst.grid(row=4, column=1, sticky=E + W + N + S, padx=4, pady=4) Label(f1, text="Total", font=myfont).grid(row=5, column=0, sticky=E, padx=4, pady=2) self.total = comp.NumEntry(f1, width=14) self.total.grid(row=5, column=1, sticky=E + W + N + S, padx=4, pady=4) f1.pack(side=TOP) #frame2 - to add stocks f2 = Frame(ftop) Label(f2, text="Drug", font=myfont).pack(side=LEFT) self.drug = comp.myComp(f2, listitems=drugs, listheight=3, width=14) self.drug.pack(side=LEFT) Label(f2, text="Batch", font=myfont).pack(side=LEFT) self.batch = Entry(f2, width=10) self.batch.pack(side=LEFT) Label(f2, text="Count", font=myfont).pack(side=LEFT) self.count = comp.NumEntry(f2, width=5) self.count.pack(side=LEFT) Label(f2, text="Rate", font=myfont).pack(side=LEFT) self.rate = comp.NumEntry(f2, width=10) self.rate.pack(side=LEFT) Label(f2, text="MRP", font=myfont).pack(side=LEFT) self.mrp = comp.NumEntry(f2, width=10) self.mrp.pack(side=LEFT) Label(f2, text="Discount", font=myfont).pack(side=LEFT) self.disc = DoubleVar() comp.NumEntry(f2, width=10, textvariable=self.disc).pack(side=LEFT) self.disc.set(0) Label(f2, text="CGST", font=myfont).pack(side=LEFT) self.cgstp = DoubleVar() comp.NumEntry(f2, textvariable=self.cgstp, width=3).pack(side=LEFT) self.cgstp.set(0) Label(f2, text="SGST", font=myfont).pack(side=LEFT) self.sgstp = DoubleVar() comp.NumEntry(f2, textvariable=self.sgstp, width=3).pack(side=LEFT) self.sgstp.set(0) Label(f2, text="Expiry", font=myfont).pack(side=LEFT) self.expiry = calpicker.Calbutton(f2, width=14) self.expiry.pack(side=LEFT) self.add = Button(f2, text="Add", command=self.addstock, font=myfont) self.add.bind("<Return>", self.addstock) self.add.pack(side=LEFT) f2.pack(side=TOP) #frame3 - bill list f = Frame(self, width=850, height=300) f.pack(side=LEFT, fill=X, expand=1) sb = Scrollbar(f) sb.pack(side=RIGHT, fill=Y) f3 = self.f3 = Canvas(f, bd=1, relief=SUNKEN, yscrollcommand=sb.set, width=800, height=300) f3.pack(fill=BOTH, expand=1) sb.config(command=f3.yview) self.gstbill = IntVar() Checkbutton(self, text="GST Bill", variable=self.gstbill, onvalue=1, offvalue=0).pack(pady=50) self.gstbill.set(1) submitButton = Button(self, text="Submit\nBill", font=("Times", 14, "bold"), padx=10, pady=10, command=self.addbill) submitButton.bind("<Return>", self.addbill) submitButton.pack() self.pack() self.stockists.focus()
def showOptions(self, selection): f = self.f2 if f.fr: f.fr.pack_forget() if selection == "sale": fr = self.packdruggroup(f) ft = Frame(fr, bd=1, relief=RIDGE) ft.pack(pady=5, fill=X) date = BooleanVar() Checkbutton(ft, text="Aggregate by date", variable=date).pack() Label(ft, text="from").pack(side=LEFT) d = dt.date.today() dd = dt.date(day=1, month=d.month, year=d.year) cb1 = cp.Calbutton(ft, inidate=dd) cb1.pack(side=LEFT) Label(ft, text="to").pack(side=LEFT) cb2 = cp.Calbutton(ft) cb2.pack(side=LEFT) ft = Frame(fr, bd=1, relief=RIDGE) ft.pack(pady=5, fill=X) doc = BooleanVar() Checkbutton(ft, text="Aggregate by doc", variable=doc).pack() dr = comp.myComp2(ft, listitems=[], listheight=3) dr.pack() self.loaddocs(dr) ft = Frame(fr, bd=1, relief=RIDGE) ft.pack(pady=5, fill=X) countoramount = IntVar() Radiobutton(ft, text="count", value=1, variable=countoramount).pack(padx=10, pady=5, side=LEFT) Radiobutton(ft, text="amount", value=2, variable=countoramount).pack(padx=10, pady=5, side=LEFT) countoramount.set(2) Button(fr, text="Load", command=lambda g=fr.g, d=fr.d, date=date, doc=doc, dr=dr, d1 =cb1, d2=cb2, cnt=countoramount: self.showsale( g, d, date, doc, dr, d1, d2, cnt)).pack(padx=20) elif selection == "sale2": fr = self.packdruggroup(f) ft = Frame(fr, bd=1, relief=RIDGE) ft.pack(pady=5, fill=X) Label(ft, text="from").pack(side=LEFT) d = dt.date.today() dd = dt.date(day=1, month=d.month, year=d.year) cb1 = cp.Calbutton(ft, inidate=dd) cb1.pack(side=LEFT) Label(ft, text="to").pack(side=LEFT) cb2 = cp.Calbutton(ft) cb2.pack(side=LEFT) Button(fr, text="Load", command=lambda g=fr.g, d=fr.d, d1=cb1, d2=cb2: self. showsale2(g, d, d1, d2)).pack(padx=20) elif selection == "stock": fr = self.packdruggroup(f) fr.opt = opt = IntVar() Radiobutton(fr, text="Low Stock", variable=opt, value=0).pack(pady=10) Radiobutton(fr, text="Slow moving", variable=opt, value=1).pack(pady=10) Radiobutton(fr, text="Expired(ing)", variable=opt, value=2).pack(pady=10) Radiobutton(fr, text="None", variable=opt, value=3).pack(pady=10) opt.set(3) Button(fr, text="Load", command=lambda g=fr.g, d=fr.d, opt=fr.opt: self.showstock( g, d, opt)).pack(padx=20, pady=5) elif selection == "purchase": fr = self.packdruggroup(f) ft = Frame(fr) ft.pack(pady=10, padx=10) Label(ft, text="stockist").pack(side=LEFT, pady=20, padx=10) st = comp.myComp2(ft, listitems=[]) st.pack() self.loadstockists(st) ft = Frame(fr) ft.pack(pady=10, padx=10) Label(ft, text="time period").pack(side=LEFT, pady=20, padx=10) ft.timeperiod = IntVar() Radiobutton(ft, variable=ft.timeperiod, text="one week", value=1).pack(side=TOP, pady=2, padx=10) Radiobutton(ft, variable=ft.timeperiod, text="one month", value=2).pack(side=TOP, pady=2, padx=10) Radiobutton(ft, variable=ft.timeperiod, text="six months", value=3).pack(side=TOP, pady=2, padx=10) Radiobutton(ft, variable=ft.timeperiod, text="one year", value=4).pack(side=TOP, pady=2, padx=10) Radiobutton(ft, variable=ft.timeperiod, text="all time", value=5).pack(side=TOP, pady=2, padx=10) ft.timeperiod.set(3) Button(fr, text="Load", command=lambda g=fr.g, d=fr.d, st=st, t=ft: self. showpurchase(g, d, st, t)).pack(pady=5, padx=20) elif selection == "bills": f.fr = fr = Frame(f, bd=1) fr.pack(side=TOP, padx=5, pady=5) ft = Frame(fr) ft.pack(pady=20, fill=X) Label(ft, text="From").pack(side=LEFT) d = dt.date.today() dd = dt.date(day=1, month=d.month, year=d.year) d1 = cp.Calbutton(ft, inidate=dd) d1.pack(side=RIGHT) ft = Frame(fr) ft.pack(pady=20, fill=X) Label(ft, text="To").pack(side=LEFT) d2 = cp.Calbutton(ft) d2.pack(side=RIGHT) optdate = BooleanVar() Checkbutton(fr, text="aggregate by date", variable=optdate).pack(pady=20) Button(fr, text="Load", command=lambda d1=d1, d2=d2, op1=optdate: self.showbills( d1, d2, op1)).pack(pady=5) elif selection == "gst": f.fr = fr = Frame(f, bd=1) fr.pack(side=TOP, padx=5, pady=5) ft = Frame(fr, bd=1, relief=RIDGE) ft.pack(pady=5, fill=X) date = BooleanVar() d = dt.date.today() dd = dt.date(day=1, month=d.month, year=d.year) Label(ft, text="from").pack(side=LEFT) cb1 = cp.Calbutton(ft, inidate=dd) cb1.pack(side=LEFT) Label(ft, text="to").pack(side=LEFT) cb2 = cp.Calbutton(ft) cb2.pack(side=LEFT) ft = Frame(fr) Label(ft, text="GST percentage:").pack() ft.pack(pady=5, fill=X) gst = comp.myComp2(ft, listitems=[], listheight=3) gst.pack() self.load_gstpercentage(gst) Button(fr, text="Load", command=lambda d1=cb1, d2=cb2, gst=gst: self.showgst( d1, d2, gst)).pack(padx=20)