def __init__(self, parent, direction): self.parent=parent if direction == "out": self.name = "Payout cash" else: self.name = "Pitch in cash" self.conn=db.connect() wxDialog.__init__(self, parent,-1,self.name) # self.SetBackgroundColour("FIREBRICK") self.static1=wxStaticText(self, -1, self.name, pos=wxPoint(15,15)) self.amount=wxTextCtrl(id=-1,name="amount", parent=self, pos=wxPoint(15,40), size=wxSize(200,25), style=0) self.amount.SetValue("%.2f" % 0) self.amount.SetSelection(-1,-1) self.static2=wxStaticText(self, -1, "For what?",pos=wxPoint(15,70)) self.description=wxTextCtrl(id=-1,name="description", parent=self, pos=wxPoint(15,95), size=wxSize(200,25), style=0) self.b1 = wxButton(self, -1, self.name, (15, 130)) EVT_BUTTON(self, self.b1.GetId(), self.doIt) self.b1.SetDefault() self.b2 = wxButton(self, -1, "Cancel", (140, 130)) EVT_BUTTON(self, self.b2.GetId(), self.Cancel)
def storefront(self): searchform = widgets.TableForm(fields=SearchFields(), submit_text="Search!") conn = db.connect() cursor = conn.cursor() cursor.execute(""" select booktitle,count(book.id) as blah,title_id from book,title where book.title_id=title.id and book.status='SOLD' and title.kind_id=1 group by title_id order by blah desc limit 30 """) results = cursor.fetchall() cursor.close() best_sellers = [ Title.get(x[2]) for x in results if Title.get(x[2]).copies_in_status("STOCK") > 0 ] new_titles = Title.select(""" book.title_id=title.id AND book.status ='STOCK' """, orderBy="-title.id", clauseTables=['book'], distinct=True) return dict(authorswidget=AuthorsWidget(), titlelistwidget=TitleListWidget(), searchform=searchform, new_titles=new_titles[:10], best_sellers=best_sellers)
def run_sql_select( query_string): conn=db.connect() # query_string=''' # SELECT * FROM (SELECT b1.title_id FROM book b1 GROUP BY b1.title_id HAVING COUNT(CASE WHEN b1.status='STOCK' THEN 1 END) = 0) AS subq1 JOIN title t1 ON t1.id =subq1.title_id JOIN book b2 ON b2.title_id=t1.id # ''' query=db.connect().cursor() query.execute(query_string ) #get names of columns headers=[ h[0] for h in query.description ] results=[] for i in xrange(1, query.rowcount): record=query.fetchone() results.append(dict(zip(headers, record))) return results
def __init__(self,listctrl,parent,name,list_position, searchNotAsDialog = False): self.parent=parent self.searchNotAsDialog = searchNotAsDialog self.listctrl=listctrl self.items=[] self.width = 30 self.selected = -1 self.taxed=False self.totaled=False self.finalized=False self.conn=db.connect() self.name=name self.list_position=list_position
def populate(self): self.conn=db.connect() cursor=self.conn.cursor() cursor.execute("SELECT * from notes order by whenEntered desc limit 100") rows=cursor.fetchall() for r in rows: when="%s" % (r[2]) msg=r[0].replace("\n","\r\n") self.Append(msg) self.Append("-- %s, %s" % (r[1],when[5:len(when)-3])) self.Append("----------------------------")
def populate(self): self.conn = db.connect() cursor = self.conn.cursor() cursor.execute( "SELECT * from notes order by whenEntered desc limit 100") rows = cursor.fetchall() for r in rows: when = "%s" % (r[2]) msg = r[0].replace("\n", "\r\n") self.Append(msg) self.Append("-- %s, %s" % (r[1], when[5:len(when) - 3])) self.Append("----------------------------")
def __init__(self, parent): self.parent=parent self.name = "Deposit cash" self.conn=db.connect() wxDialog.__init__(self, parent,-1,self.name) self.static1=wxStaticText(self, -1, self.name, pos=wxPoint(15,15)) self.amount=wxTextCtrl(id=-1,name="amount", parent=self, pos=wxPoint(15,40), size=wxSize(200,25), style=0) self.amount.SetValue("%.2f" % 0) self.amount.SetSelection(-1,-1) self.b1 = wxButton(self, -1, self.name, (15, 70)) EVT_BUTTON(self, self.b1.GetId(), self.doIt) self.b1.SetDefault() self.b2 = wxButton(self, -1, "Cancel", (140, 70)) EVT_BUTTON(self, self.b2.GetId(), self.Cancel)
def storefront(self): searchform = widgets.TableForm(fields=SearchFields(), submit_text="Search!") conn=db.connect() cursor=conn.cursor() cursor.execute(""" select booktitle,count(book.id) as blah,title_id from book,title where book.title_id=title.id and book.status='SOLD' and title.kind_id=1 group by title_id order by blah desc limit 30 """) results= cursor.fetchall() cursor.close() best_sellers = [Title.get(x[2]) for x in results if Title.get(x[2]).copies_in_status("STOCK")>0] new_titles=Title.select(""" book.title_id=title.id AND book.status ='STOCK' """ ,orderBy="-title.id",clauseTables=['book'],distinct=True) return dict(authorswidget=AuthorsWidget(),titlelistwidget=TitleListWidget(),searchform=searchform,new_titles=new_titles[:10],best_sellers=best_sellers)
def Add(self,event): retval = true; first_name = self.first_name.GetValue() last_name = self.last_name.GetValue() phone = self.phone.GetValue() e_mail = self.e_mail.GetValue() paid=self.paid.GetSelection() if paid == 0: paid = true else: paid = false if first_name != "" and last_name != "" and phone != "" and len(phone) >= 7 and e_mail != "": try: id = self.main_window.membersList.addToMembers( first_name=first_name, last_name=last_name, phone=phone, e_mail=e_mail, paid=paid) except: self.statusBar.SetStatusText("didn't add stuff, system crashed instead") retval = false raise if paid == true: cfg = configuration() conn = db.connect() cursor = conn.cursor() cursor.execute (""" INSERT INTO transactionLog SET action = "MEMBER ADD", amount = %s, cashier = %s, date = NOW(), info = %s, paid_how= "CASH" """, (cfg.get("membershipfees"),self.parent.parent.cashbox.cashier, (first_name + u" " + last_name).encode("ascii", "backslashreplace"))) self.parent.parent.cashbox.addAmount(cfg.get("membershipfees")) cursor.close() else: dlg = wxMessageDialog(self, "Fill all fields !!!") dlg.ShowModal() retval = false return retval
def __init__(self, listctrl, parent, name, list_position, searchNotAsDialog=False): self.parent = parent self.searchNotAsDialog = searchNotAsDialog self.listctrl = listctrl self.items = [] self.width = 30 self.selected = -1 self.taxed = False self.totaled = False self.finalized = False self.conn = db.connect() self.name = name self.list_position = list_position
def __init__(self): self.reportlist=[getattr(__import__('reports.'+x,globals(),{},[1]),x) for x in cfg.get("reports")] self._indextemplate = IndexTemplate() self._carttemplate = CartTemplate() self._checkouttemplate = CheckoutTemplate() self._searchtemplate = SearchTemplate() self._bookedittemplate = BookEditTemplate() self._authoredittemplate = AuthorEditTemplate() self._categoryedittemplate = CategoryEditTemplate() self._kindedittemplate = KindEditTemplate() self._kindlisttemplate = KindListTemplate() self._titleedittemplate = TitleEditTemplate() self._titlelisttemplate = TitleListTemplate() self._reportlisttemplate = ReportListTemplate() self._reporttemplate = ReportTemplate() self._transactionstemplate = TransactionsTemplate() self.conn=db.connect()
def __init__(self): self.reportlist = [ getattr(__import__('reports.' + x, globals(), {}, [1]), x) for x in cfg.get("reports") ] self._indextemplate = IndexTemplate() self._carttemplate = CartTemplate() self._checkouttemplate = CheckoutTemplate() self._searchtemplate = SearchTemplate() self._bookedittemplate = BookEditTemplate() self._authoredittemplate = AuthorEditTemplate() self._categoryedittemplate = CategoryEditTemplate() self._kindedittemplate = KindEditTemplate() self._kindlisttemplate = KindListTemplate() self._titleedittemplate = TitleEditTemplate() self._titlelisttemplate = TitleListTemplate() self._reportlisttemplate = ReportListTemplate() self._reporttemplate = ReportTemplate() self._transactionstemplate = TransactionsTemplate() self.conn = db.connect()
def __init__(self, parent): self.parent=parent self.conn=db.connect() wxDialog.__init__(self, parent,-1,"Cash Out") # self.SetBackgroundColour("FIREBRICK") self.SetSize((250, 250)) self.static1=wxStaticText(self, -1, "Cash out",pos=wxPoint(15,15)) self.cash_out=wxTextCtrl(id=-1,name="cash_out", parent=self, pos=wxPoint(15,40), size=wxSize(200,25), style=0) self.cash_out.SetValue("%.2f" % 0) self.cash_out.SetSelection(-1,-1) self.static2=wxStaticText(self, -1, "For what?",pos=wxPoint(15,70)) self.description=wxTextCtrl(id=-1,name="description", parent=self, pos=wxPoint(15,95), size=wxSize(200,25), style=0) self.b1 = wxButton(self, -1, "Cash out", (15, 130)) EVT_BUTTON(self, self.b1.GetId(), self.CashOut) self.b1.SetDefault() self.b2 = wxButton(self, -1, "Cancel", (140, 130)) EVT_BUTTON(self, self.b2.GetId(), self.Cancel)
def __init__(self,args): self.conn=db.connect() self.args=args
def __init__(self, args): self.conn = db.connect() self.args = args