当前位置: 首页>>代码示例>>Python>>正文


Python DBManager.getCuentas方法代码示例

本文整理汇总了Python中DBManager.DBManager.getCuentas方法的典型用法代码示例。如果您正苦于以下问题:Python DBManager.getCuentas方法的具体用法?Python DBManager.getCuentas怎么用?Python DBManager.getCuentas使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBManager.DBManager的用法示例。


在下文中一共展示了DBManager.getCuentas方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Reporter

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import getCuentas [as 别名]
class Reporter( object ):

   def __init__( self, reportname, data, tipo ):
      self.doc      = SimpleDocTemplate(reportname, pagesize=A4)
      self.data     = data
      self.elements = list()
      self.logo     = 'logo.png'
      self.DBM      = DBManager()
      self.tipo     = tipo

   def __addHead( self ):

      if  self.tipo == "stock":
         styles = getSampleStyleSheet()
         ptext  = '<font size=14>Reporte estado de Stock</font>'
         styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY))
         self.elements.append( Paragraph(ptext, styles["Normal"]) )
         self.elements.append(Spacer(1, 12))
      elif self.tipo == "ganancia":
         styles = getSampleStyleSheet()
         ptext  = '<font size=14>Reporte de ganancias de Tifosi (%s, %s)</font>' % ( self.data[0], self.data[1] )
         styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY))
         self.elements.append( Paragraph(ptext, styles["Normal"]) )
         self.elements.append(Spacer(1, 12))
  
   def __addTable( self ):
      tt    = list()

      if self.tipo == "ganancia":
         data  = self.DBM.getCuentas(self.data[0], self.data[1])
         total = 0
         tt.append( ['Fecha', 'Descripción', 'Cantidad', 'Precio'] )

         for producto in data:
            tt.append( [producto[0], producto[1], producto[2], "$ %.2f" % float( producto[4] ) ] )
            total += float( producto[4] )

         tt.append( ["TOTAL" , "", "", "$ %.2f" % total] )
      elif self.tipo == "stock":
         total = 0
         tt.append( ['Código', 'Descripción', 'Marca', 'Precio', 'Punto Pedido', 'Stock'] )

         for producto in self.data:
            if producto[1] != '1000':
               tt.append( [ producto[1], producto[2], producto[3], "$ %.2f" % float( producto[4] ), producto[5], producto[6] ] )
               total += float( producto[4] * producto[6] )

      tabla = Table(tt)

      if self.tipo == "ganancia":
          tabla.setStyle( TableStyle([
                                     ('ALIGN', (1,1), (-2, -2), 'RIGHT'),
                                     ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
                                     ('BOX', (0,0), (-1,-1), 0.55, colors.black),
                                     ('TEXTCOLOR',(0,-1),(-1,-1),colors.yellow),
                                     ('BACKGROUND',(0,-1),(-1,-1),colors.red),
                                     ('BACKGROUND',(0,0),(-1,0),colors.gray)
                                    ]))
      elif self.tipo == "stock":
          tabla.setStyle( TableStyle([
                                     ('ALIGN', (1,1), (-1, -1), 'RIGHT'),
                                     ('INNERGRID', (0,0), (-1,-1), 0.25, colors.black),
                                     ('BOX', (0,0), (-1,-1), 0.55, colors.black),
                                     ('BACKGROUND',(0,0),(-1,0),colors.gray)
                                    ]))

      self.elements.append( tabla )

      if self.tipo == "ganancia":
         styles = getSampleStyleSheet()
         ptext  = '<font size=10>Total de ventas: %s </font>' % len( data )
         self.elements.append(Spacer(1, 12))
         styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY))
         self.elements.append( Paragraph(ptext, styles["Normal"]) )
      elif self.tipo == "stock":
         styles = getSampleStyleSheet()
         ptext  = '<font size=10>Productos en Stock: %s </font>' % len( self.data )
         self.elements.append(Spacer(1, 12))
         styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY))
         self.elements.append( Paragraph(ptext, styles["Normal"]) )
      
         styles = getSampleStyleSheet()
         ptext  = '<font size=10>Dinero en Stock: $ %.2f </font>' % total
         styles.add(ParagraphStyle(name='Justify', alignment=TA_JUSTIFY))
         self.elements.append( Paragraph(ptext, styles["Normal"]) )

   def doReport( self ):
      self.__addHead()
      self.__addTable()
      self.doc.build( self.elements )
开发者ID:gaccardo,项目名称:canchas,代码行数:92,代码来源:Reporter.py

示例2: CanchasTabFinanzas

# 需要导入模块: from DBManager import DBManager [as 别名]
# 或者: from DBManager.DBManager import getCuentas [as 别名]
class CanchasTabFinanzas(wx.Panel):

   def __init__(self, parent):

       wx.Panel.__init__(self, parent=parent, id=wx.ID_ANY)

       self.DBM   = DBManager()
       self.vbox  = wx.BoxSizer( wx.VERTICAL )
       hbox1      = wx.BoxSizer( wx.HORIZONTAL )
       image1     = wx.Image('calendar.png', wx.BITMAP_TYPE_ANY).ConvertToBitmap()
       btn_cal    = wx.BitmapButton(self, id=-1, bitmap=image1, size=(40,30))
       image2     = wx.Image('print.png', wx.BITMAP_TYPE_ANY).ConvertToBitmap()
       btn_prt    = wx.BitmapButton(self, id=-1, bitmap=image2, size=(40,30))
       image3     = wx.Image('money.png', wx.BITMAP_TYPE_ANY).ConvertToBitmap()
       btn_inicio = wx.BitmapButton(self, id=-1, bitmap=image3, size=(40,30))
       image4     = wx.Image('cashRegister.png', wx.BITMAP_TYPE_ANY).ConvertToBitmap()
       btn_gasto  = wx.BitmapButton(self, id=-1, bitmap=image4, size=(40,30))
       #image3       = wx.Image('venta.png', wx.BITMAP_TYPE_ANY).ConvertToBitmap()
       #btn_vta      = wx.BitmapButton(self, id=-1, bitmap=image3, size=(40,30))
       self.desde   = None
       self.hasta   = None

       self.Bind(wx.EVT_BUTTON, self.OnCalendar, btn_cal)
       #self.Bind(wx.EVT_BUTTON, self.OnVenta, btn_vta)
       self.Bind(wx.EVT_BUTTON, self.OnPrint, btn_prt)
       self.Bind(wx.EVT_BUTTON, self.OnInicio, btn_inicio)
       self.Bind(wx.EVT_BUTTON, self.OnGasto, btn_gasto)

       hbox1.Add(btn_cal)
       hbox1.Add(btn_prt)
       hbox1.Add(btn_inicio)
       hbox1.Add(btn_gasto)
       #hbox1.Add(btn_vta)
       self.vbox.Add(hbox1)

       self.hbox2     = wx.BoxSizer( wx.HORIZONTAL )
       self.list_ctrl = wx.ListCtrl(self, style=wx.LC_REPORT)

       self.hbox2.Add(self.list_ctrl, 2, flag=wx.EXPAND)
       self.vbox.Add(self.hbox2, 2, wx.EXPAND)
       self.TOTAL     = 0

       self.SetSizer(self.vbox)
       self.__generateContent()
       Publisher().subscribe(self.OnExternalCalSelected, ("dates"))
       Publisher().subscribe(self.OnTabSelected , ("tab_cuentas_update"))

   def __generateContent( self, desde=None, hasta=None): 
       cuentas = self.DBM.getCuentas(desde, hasta)
       egresos = self.DBM.getEgresos(desde, hasta)

       index = 0

       self.list_ctrl.InsertColumn(0, "Hora")
       self.list_ctrl.InsertColumn(1, "Producto")
       self.list_ctrl.InsertColumn(2, "Cantidad")
       self.list_ctrl.InsertColumn(3, "Precio")
       self.list_ctrl.InsertColumn(4, "Total")

       for cuenta in cuentas+egresos:
          self.list_ctrl.InsertStringItem(index, cuenta[0])
          self.list_ctrl.SetStringItem(index, 1, cuenta[1])
          if cuenta[1] == "Inicio de caja":
              self.list_ctrl.SetStringItem(index, 2, '-')
              self.list_ctrl.SetStringItem(index, 3, '-')
          else:
              self.list_ctrl.SetStringItem(index, 3, "$ %s" % str(cuenta[3]))
              self.list_ctrl.SetStringItem(index, 2, str(cuenta[2]))

          self.list_ctrl.SetStringItem(index, 4, "$ %s" % str(cuenta[4]))

          self.TOTAL += cuenta[4]

          if index % 2:
             self.list_ctrl.SetItemBackgroundColour(index, "white")
          else:
             self.list_ctrl.SetItemBackgroundColour(index, "gray")
          index += 1

       self.list_ctrl.InsertStringItem(index, 'TOTAL')
       self.list_ctrl.SetStringItem(index, 1, '')
       self.list_ctrl.SetStringItem(index, 2, '')
       self.list_ctrl.SetStringItem(index, 3, '')
       self.list_ctrl.SetStringItem(index, 4, '$ %s' % str(self.TOTAL))
       self.list_ctrl.SetItemBackgroundColour(index, "red")
       self.list_ctrl.SetItemTextColour(index, "yellow")

   def OnExternalCalSelected( self, evt ):
       desde      = evt.data[0].__str__().split(' ')[0]
       hasta      = evt.data[1].__str__().split(' ')[0]
       self.desde = desde
       self.hasta = hasta
       self.TOTAL = 0
       self.list_ctrl.ClearAll()
       self.__generateContent( desde, hasta )

   def OnGasto( self, evt ):
       Gasto(self, -1, "Egreso de caja")
       self.list_ctrl.ClearAll()
       self.__generateContent()
#.........这里部分代码省略.........
开发者ID:gaccardo,项目名称:canchas,代码行数:103,代码来源:CanchasTabFinanzas.py


注:本文中的DBManager.DBManager.getCuentas方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。