示例#1
0
def getprod1(callval1, codnum1, prodnom1):

    #loginwindow.show()

    connectionStock1 = MySQLdb.connect(host='xxxxxxxxxxxx',
                                     port=3336,
                                     database='xxxxStock',
                                     user='******',
                                     password='******')

    QueryprodC1 = """SELECT 
                                    codigo,
                                    nombre,
                                    PrecioDetal
                                    
                                FROM stockRioCuarto WHERE codigo='"""+str(codnum1)+"""';"""
    QueryprodN1 = """SELECT 
                                        codigo,
                                        nombre,
                                        PrecioDetal

                                    FROM stockRioCuarto WHERE 
                                    locate('""" + str(prodnom1) + """', nombre);"""
    cursorQp1 = connectionStock1.cursor()
    if callval1 == int(1):
        Queryprodf1=QueryprodC1
    if callval1 == int(2):
        Queryprodf1=QueryprodN1
    cursorQp1.execute(Queryprodf1)
    # print(result)
    connectionStock1.commit()
    recordst1 = cursorQp1.fetchall()
    recordst2 = recordst1[int(int(len(recordst1))-int(1))]
    cursorQp1.close()

    print(recordst1)

    for i in range(int(len(recordst1))):
        stockwfile = QFile("prodstockwidget.ui")
        stockwfile.open(QFile.ReadOnly)
        stockloader = QUiLoader()
        stockwwindow = stockloader.load(stockwfile)
        tam1=QSize()
        tam1.setHeight(44)
        tam1.setWidth(963)
        itemN1 = QtWidgets.QListWidgetItem()
        itemN1.setSizeHint(tam1)
        Codpros1 = stockwwindow.findChild(QLabel, 'codn1')
        Nombpros1 = stockwwindow.findChild(QLabel, 'nomp1')
        pricest1 = stockwwindow.findChild(QLabel, 'preciow1')
        Codpros1.setText(str(recordst1[int(i)][0]))
        Nombpros1.setText(str(recordst1[int(i)][1]))
        pricest1.setText(str(recordst1[int(i)][2]))
        Busqlis1.addItem(itemN1)
        Busqlis1.setItemWidget(itemN1, stockwwindow)
 def calculateSize(self, sizeType):
     totalSize = QSize()
     for wrapper in self.list:
         position = wrapper.position
         itemSize = QSize()
         if sizeType == BorderLayout.MinimumSize:
             itemSize = wrapper.item.minimumSize()
         else:  # sizeType == BorderLayout.SizeHint
             itemSize = wrapper.item.sizeHint()
         if position in (BorderLayout.North, BorderLayout.South,
                         BorderLayout.Center):
             totalSize.setHeight(totalSize.height() + itemSize.height())
         if position in (BorderLayout.West, BorderLayout.East,
                         BorderLayout.Center):
             totalSize.setWidth(totalSize.width() + itemSize.width())
     return totalSize
示例#3
0
def adtocart1(codnum2):
    connectionStock4 = MySQLdb.connect(host='xxxxxxxxxxxx',
                                       port=3336,
                                       database='xxxxStock',
                                       user='******',
                                       password='******')

    QueryprodC4 = """SELECT 
                                        codigo,
                                        nombre,
                                        PrecioDetal

                                    FROM stockRioCuarto WHERE codigo=""" + str(codnum2) + """;"""
    cursorQp4 = connectionStock4.cursor()
    cursorQp4.execute(QueryprodC4)
    # print(result)
    connectionStock4.commit()
    recordst4 = cursorQp4.fetchall()
    recordst5 = recordst4[int(int(len(recordst4)) - int(1))]
    cursorQp4.close()
    print(recordst5)
    for i in range(1):
        cartwfile = QFile("proddesglowidget.ui")
        cartwfile.open(QFile.ReadOnly)
        cartloader = QUiLoader()
        cartwwindow = cartloader.load(cartwfile)
        tam3 = QSize()
        tam3.setHeight(44)
        tam3.setWidth(963)
        itemN3 = QtWidgets.QListWidgetItem()
        itemN3.setSizeHint(tam3)
        Codpros3 = cartwwindow.findChild(QLabel, 'codn2')
        Nombpros3 = cartwwindow.findChild(QLabel, 'nomp2')
        pricest3 = cartwwindow.findChild(QLabel, 'preciow2')
        cantvprod3= cartwwindow.findChild(QSpinBox, 'cantidadp2')
        Codpros3.setText(str(recordst5[0]))
        Nombpros3.setText(str(recordst5[1]))
        pricest3.setText(str(recordst5[2]))
        Desgloselis1.addItem(itemN3)
        print('sfsaf')
        Desgloselis1.setItemWidget(itemN3, cartwwindow)