def __init__(self, id=None, nombreUsuario=None, contrasena=None): self.id = id self.nombreUsuario = nombreUsuario self.contrasena = contrasena self.bd = BaseDatos() self.conectarBD() if (id is not None): self.activo = 1 self.generaUsuarioConId() else: self.activo = 0
def __init__(self, id=None, nombreUsuario=None, numero_documento=None): self.id = id self.nombreUsuario = nombreUsuario self.numero_documento = numero_documento self.bd = BaseDatos() self.conectarBD() if (id is not None): self.activo = 1 self.generaProveedorConId() else: self.activo = 0
def __init__(self,id=None,id_cliente=None,id_usuario=None,fecha=None): self.id=id self.id_cliente=id_cliente self.id_usuario=id_usuario self.fecha=fecha self.total=0 self.iva_total=0 self.iva_total_desc=0 self.items_venta=[] self.medioPago=None self.descuento=None self.bd=BaseDatos() self.conectarBD()
class Compra: def __init__(self,id=None,id_cliente=None,id_usuario=None,fecha=None): self.id=id self.id_cliente=id_cliente self.id_usuario=id_usuario self.fecha=fecha self.total=0 self.iva_total=0 self.iva_total_desc=0 self.items_venta=[] self.medioPago=None self.descuento=None self.bd=BaseDatos() self.conectarBD() def conectarBD(self): self.conn = sqlite3.connect("basedatos.db") self.cursor = self.conn.cursor() def clearAll(self): self.id_cliente=None self.total=0 self.iva_total=0 self.iva_total_desc=0 self.items_venta=[] self.medioPago=None self.descuento=None def buscarItemVenta(self): print("cargarDatos") self.arregloBotones=[] tabla="items_compra" camposSelect=["id","nombre","contrasena"] self.tableWidget.setRowCount(0) rows=self.bd.cargarDatosValorCampo(tabla,camposSelect) def guardarVenta(self): tabla="compras" print("id Proveedor: "+str(self.id_cliente)) print("id_usuario: "+str(self.id_usuario)) campos=["id_proveedor","id_usuario","fecha","total","iva_total","medio_pago_id"] valorCampos=[self.id_cliente,self.id_usuario,self.fecha,self.total,self.iva_total_desc,self.medioPago] self.id=self.bd.crearValorCampo(tabla,campos,valorCampos) self.guardarItemsVenta() def guardarItemsVenta(self): tabla="items_compra" campos=["id_compra","precio","cantidad","iva","id_producto","total"] for item in self.items_venta: valorCampos=[self.id,item.precio,item.cantidad,item.iva,item.id,item.totalSinIva] id_item=self.bd.crearValorCampo(tabla,campos,valorCampos) item.actualizarInventarioVenta2()
def setupUi(self, historicoVentas, usuarioActual): self.bd = BaseDatos() historicoVentas.setObjectName("historicoVentas") historicoVentas.resize(894, 659) historicoVentas.setMinimumSize(QtCore.QSize(894, 659)) historicoVentas.setMaximumSize(QtCore.QSize(894, 659)) self.tableWidget = QtWidgets.QTableWidget(historicoVentas) self.tableWidget.setGeometry(QtCore.QRect(40, 50, 821, 491)) self.tableWidget.setObjectName("tableWidget") self.tableWidget.setColumnCount(8) self.tableWidget.setRowCount(0) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(0, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(1, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(2, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(3, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(4, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(5, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(6, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(7, item) self.cargarDatosVentas() self.retranslateUi(historicoVentas) QtCore.QMetaObject.connectSlotsByName(historicoVentas)
def setupUi(self, historicoItemVentas, idVenta): self.bd = BaseDatos() historicoItemVentas.setObjectName("historicoItemVentas") historicoItemVentas.resize(659 * 0.7, 659 * 0.7) historicoItemVentas.setMinimumSize(QtCore.QSize(659 * 0.7, 659 * 0.7)) historicoItemVentas.setMaximumSize(QtCore.QSize(659 * 0.7, 659 * 0.7)) self.listWidget = QtWidgets.QListWidget(historicoItemVentas) self.listWidget.setGeometry(QtCore.QRect(40, 30, 591 * 0.7, 591 * 0.7)) self.listWidget.setObjectName("listWidget") self.cargarTodo(idVenta) self.retranslateUi(historicoItemVentas) QtCore.QMetaObject.connectSlotsByName(historicoItemVentas)
def __init__(self, id=None, codigo=None, descripcion=None, precio=None, id_categoria=None, iva=None, cantidad=None, inventario=None): self.id = id self.codigo = codigo self.descripcion = descripcion self.precio = precio self.id_categoria = id_categoria self.categoria = None self.iva = iva self.cantidad = None self.inventario = inventario self.totalConIva = None self.totalSinIva = None self.bd = BaseDatos() self.conectarBD()
def setupUi(self, ventasObject, usuarioActual): self.categorias = [] self.categoriasId = [] self.descuentos_desc = [] self.descuentos_valor = [] self.medioPagos = [] self.medioPagos_cod = [] self.cantidadItems = 0 self.bd = BaseDatos() self.clienteActual = Proveedor() self.ventaActual = Compra(id_usuario=usuarioActual.id) now = datetime.now() self.ventaActual.fecha = str(now.year) + "/" + str( now.month) + "/" + str(now.day) print(self.ventaActual.fecha) ventasObject.setObjectName("ventasObject") ventasObject.resize(800, 600) ventasObject.setMinimumSize(QtCore.QSize(800, 600)) ventasObject.setMaximumSize(QtCore.QSize(800, 600)) ventasObject.setAcceptDrops(True) self.pushButton_vincularCliente = QtWidgets.QPushButton(ventasObject) self.pushButton_vincularCliente.setGeometry( QtCore.QRect(650, 90, 121, 31)) self.pushButton_vincularCliente.setObjectName( "pushButton_vincularCliente") self.label_ClienteActivo = QtWidgets.QLabel(ventasObject) self.label_ClienteActivo.setGeometry(QtCore.QRect(660, 0, 91, 31)) self.label_ClienteActivo.setObjectName("label_ClienteActivo") self.label_usuarioActivo = QtWidgets.QLabel(ventasObject) self.label_usuarioActivo.setGeometry(QtCore.QRect(10, 10, 181, 21)) self.label_usuarioActivo.setObjectName("label_ClienteActivo") self.label_usuarioActivo.setText("Usuario: " + str(usuarioActual.nombreUsuario)) self.label_id_clienteActivo = QtWidgets.QLabel(ventasObject) self.label_id_clienteActivo.setGeometry(QtCore.QRect(610, 30, 21, 21)) self.label_id_clienteActivo.setObjectName("label_id_clienteActivo") self.label_nombre_clienteActivo = QtWidgets.QLabel(ventasObject) self.label_nombre_clienteActivo.setGeometry( QtCore.QRect(580, 70, 57, 14)) self.label_nombre_clienteActivo.setObjectName( "label_nombre_clienteActivo") self.lineEdit_clienteActivo = QtWidgets.QLineEdit(ventasObject) self.lineEdit_clienteActivo.setGeometry(QtCore.QRect(640, 30, 151, 26)) self.lineEdit_clienteActivo.setObjectName("lineEdit_clienteActivo") self.label_errorClienteActivo = QtWidgets.QLabel(ventasObject) self.label_errorClienteActivo.setGeometry( QtCore.QRect(580, 130, 201, 16)) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(170, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(170, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(101, 112, 117)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) self.label_errorClienteActivo.setPalette(palette) self.label_errorClienteActivo.setObjectName("label_errorClienteActivo") self.label_mostrar_nombreClienteActivo = QtWidgets.QLabel(ventasObject) self.label_mostrar_nombreClienteActivo.setGeometry( QtCore.QRect(640, 70, 151, 16)) self.label_mostrar_nombreClienteActivo.setText("") self.label_mostrar_nombreClienteActivo.setObjectName( "label_mostrar_nombreClienteActivo") self.label_buscadorItems = QtWidgets.QLabel(ventasObject) self.label_buscadorItems.setGeometry(QtCore.QRect(220, 10, 131, 16)) self.label_buscadorItems.setObjectName("label_buscadorItems") self.listWidget_buscarItems = QtWidgets.QListWidget(ventasObject) self.listWidget_buscarItems.setGeometry(QtCore.QRect(70, 90, 451, 91)) self.listWidget_buscarItems.setObjectName("listWidget_buscarItems") item = QtWidgets.QListWidgetItem() # self.listWidget_buscarItems.addItem(item) self.tableWidget_itemVentas = QtWidgets.QTableWidget(ventasObject) self.tableWidget_itemVentas.setGeometry(QtCore.QRect( 50, 350, 711, 171)) self.tableWidget_itemVentas.setObjectName("tableWidget_itemVentas") self.tableWidget_itemVentas.setColumnCount(9) self.tableWidget_itemVentas.setRowCount(0) item = QtWidgets.QTableWidgetItem() self.tableWidget_itemVentas.setHorizontalHeaderItem(0, item) item = QtWidgets.QTableWidgetItem() self.tableWidget_itemVentas.setHorizontalHeaderItem(1, item) item = QtWidgets.QTableWidgetItem() self.tableWidget_itemVentas.setHorizontalHeaderItem(2, item) item = QtWidgets.QTableWidgetItem() self.tableWidget_itemVentas.setHorizontalHeaderItem(3, item) item = QtWidgets.QTableWidgetItem() self.tableWidget_itemVentas.setHorizontalHeaderItem(4, item) item = QtWidgets.QTableWidgetItem() self.tableWidget_itemVentas.setHorizontalHeaderItem(5, item) item = QtWidgets.QTableWidgetItem() self.tableWidget_itemVentas.setHorizontalHeaderItem(6, item) item = QtWidgets.QTableWidgetItem() self.tableWidget_itemVentas.setHorizontalHeaderItem(7, item) item = QtWidgets.QTableWidgetItem() self.tableWidget_itemVentas.setHorizontalHeaderItem(8, item) self.pushButton_confirmarVenta = QtWidgets.QPushButton(ventasObject) self.pushButton_confirmarVenta.setGeometry( QtCore.QRect(650, 550, 121, 31)) self.pushButton_confirmarVenta.setObjectName( "pushButton_confirmarVenta") self.pushButton_cancelarVenta = QtWidgets.QPushButton(ventasObject) self.pushButton_cancelarVenta.setGeometry( QtCore.QRect(510, 550, 121, 31)) self.pushButton_cancelarVenta.setObjectName("pushButton_cancelarVenta") self.label_infoProducto = QtWidgets.QLabel(ventasObject) self.label_infoProducto.setGeometry(QtCore.QRect(50, 190, 211, 16)) self.label_infoProducto.setObjectName("label_infoProducto") self.pushButton_agregarItemVenta = QtWidgets.QPushButton(ventasObject) self.pushButton_agregarItemVenta.setGeometry( QtCore.QRect(580, 280, 191, 51)) self.pushButton_agregarItemVenta.setObjectName( "pushButton_agregarItemVenta") self.label_codigo_item = QtWidgets.QLabel(ventasObject) self.label_codigo_item.setGeometry(QtCore.QRect(50, 220, 51, 21)) self.label_codigo_item.setObjectName("label_codigo_item") self.lineEdit_codigo_Item = QtWidgets.QLineEdit(ventasObject) self.lineEdit_codigo_Item.setGeometry(QtCore.QRect(40, 240, 81, 26)) self.lineEdit_codigo_Item.setObjectName("lineEdit_codigo_Item") self.label_descripcion = QtWidgets.QLabel(ventasObject) self.label_descripcion.setGeometry(QtCore.QRect(60, 280, 91, 16)) self.label_descripcion.setObjectName("label_descripcion") self.label_codigo_buscar = QtWidgets.QLabel(ventasObject) self.label_codigo_buscar.setGeometry(QtCore.QRect(80, 40, 81, 16)) self.label_codigo_buscar.setObjectName("label_codigo_buscar") self.label_descripcion_buscar = QtWidgets.QLabel(ventasObject) self.label_descripcion_buscar.setGeometry(QtCore.QRect( 200, 40, 57, 14)) self.label_descripcion_buscar.setObjectName("label_descripcion_buscar") self.spinBox_cantidadItem = QtWidgets.QSpinBox(ventasObject) self.spinBox_cantidadItem.setGeometry(QtCore.QRect(490, 300, 41, 24)) self.spinBox_cantidadItem.setProperty("value", 1) self.spinBox_cantidadItem.setObjectName("spinBox_cantidadItem") self.spinBox_cantidadItem.setMinimum(1) self.comboBox_categoria_buscar = QtWidgets.QComboBox(ventasObject) self.comboBox_categoria_buscar.setGeometry( QtCore.QRect(300, 60, 141, 22)) self.comboBox_categoria_buscar.setObjectName( "comboBox_categoria_buscar") # self.comboBox_categoria_buscar.addItem("") # self.comboBox_categoria_buscar.addItem("") self.label_categoria_buscar = QtWidgets.QLabel(ventasObject) self.label_categoria_buscar.setGeometry(QtCore.QRect(320, 40, 57, 14)) self.label_categoria_buscar.setObjectName("label_categoria_buscar") self.label_inventarioDisp = QtWidgets.QLabel(ventasObject) self.label_inventarioDisp.setGeometry(QtCore.QRect(160, 280, 91, 16)) self.label_inventarioDisp.setObjectName("label_inventarioDisp") self.label_categoria_item = QtWidgets.QLabel(ventasObject) self.label_categoria_item.setGeometry(QtCore.QRect(260, 280, 91, 16)) self.label_categoria_item.setObjectName("label_categoria_item") self.comboBox_itemDescuento = QtWidgets.QComboBox(ventasObject) self.comboBox_itemDescuento.setGeometry(QtCore.QRect( 570, 240, 141, 22)) self.comboBox_itemDescuento.setObjectName("comboBox_itemDescuento") # self.comboBox_itemDescuento.addItem("") # self.comboBox_itemDescuento.addItem("") self.label_cantidadItem = QtWidgets.QLabel(ventasObject) self.label_cantidadItem.setGeometry(QtCore.QRect(480, 280, 91, 16)) self.label_cantidadItem.setObjectName("label_cantidadItem") self.label_descuento = QtWidgets.QLabel(ventasObject) self.label_descuento.setGeometry(QtCore.QRect(600, 220, 91, 16)) self.label_descuento.setObjectName("label_descuento") self.lineEdit_mostrarDescripcionItem = QtWidgets.QLineEdit( ventasObject) self.lineEdit_mostrarDescripcionItem.setGeometry( QtCore.QRect(40, 300, 113, 26)) self.lineEdit_mostrarDescripcionItem.setText("") self.lineEdit_mostrarDescripcionItem.setReadOnly(True) self.lineEdit_mostrarDescripcionItem.setClearButtonEnabled(False) self.lineEdit_mostrarDescripcionItem.setObjectName( "lineEdit_mostrarDescripcionItem") self.lineEdit_mostrarInventarioDisp = QtWidgets.QLineEdit(ventasObject) self.lineEdit_mostrarInventarioDisp.setGeometry( QtCore.QRect(180, 300, 31, 26)) self.lineEdit_mostrarInventarioDisp.setText("") self.lineEdit_mostrarInventarioDisp.setReadOnly(True) self.lineEdit_mostrarInventarioDisp.setClearButtonEnabled(False) self.lineEdit_mostrarInventarioDisp.setObjectName( "lineEdit_mostrarInventarioDisp") self.lineEdit_mostrarCategoria = QtWidgets.QLineEdit(ventasObject) self.lineEdit_mostrarCategoria.setGeometry( QtCore.QRect(240, 300, 113, 26)) self.lineEdit_mostrarCategoria.setText("") self.lineEdit_mostrarCategoria.setReadOnly(True) self.lineEdit_mostrarCategoria.setClearButtonEnabled(False) self.lineEdit_mostrarCategoria.setObjectName( "lineEdit_mostrarCategoria") self.label_precio = QtWidgets.QLabel(ventasObject) self.label_precio.setGeometry(QtCore.QRect(170, 220, 91, 16)) self.label_precio.setObjectName("label_precio") self.lineEdit_mostrarPrecioUnitario = QtWidgets.QLineEdit(ventasObject) self.lineEdit_mostrarPrecioUnitario.setGeometry( QtCore.QRect(160, 240, 113, 26)) self.lineEdit_mostrarPrecioUnitario.setText("") self.lineEdit_mostrarPrecioUnitario.setReadOnly(True) self.lineEdit_mostrarPrecioUnitario.setClearButtonEnabled(False) self.lineEdit_mostrarPrecioUnitario.setObjectName( "lineEdit_mostrarPrecioUnitario") self.label_infoProducto_2 = QtWidgets.QLabel(ventasObject) self.label_infoProducto_2.setGeometry(QtCore.QRect(360, 190, 341, 21)) self.label_infoProducto_2.setObjectName("label_infoProducto_2") self.label_medioPago = QtWidgets.QLabel(ventasObject) self.label_medioPago.setGeometry(QtCore.QRect(400, 220, 91, 16)) self.label_medioPago.setObjectName("label_medioPago") self.comboBox_item_medioPago = QtWidgets.QComboBox(ventasObject) self.comboBox_item_medioPago.setGeometry( QtCore.QRect(380, 240, 141, 22)) self.comboBox_item_medioPago.setObjectName("comboBox_item_medioPago") # self.comboBox_item_medioPago.addItem("") # self.comboBox_item_medioPago.addItem("") self.lineEdit_codigo_buscar = QtWidgets.QLineEdit(ventasObject) self.lineEdit_codigo_buscar.setGeometry(QtCore.QRect(60, 60, 113, 26)) self.lineEdit_codigo_buscar.setObjectName("lineEdit_codigo_buscar") self.lineEdit_descripcion_buscar = QtWidgets.QLineEdit(ventasObject) self.lineEdit_descripcion_buscar.setGeometry( QtCore.QRect(180, 60, 113, 26)) self.lineEdit_descripcion_buscar.setObjectName( "lineEdit_descripcion_buscar") self.label_errorCodigo = QtWidgets.QLabel(ventasObject) self.label_errorCodigo.setGeometry(QtCore.QRect(30, 560, 201, 16)) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(170, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(170, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(101, 112, 117)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) self.label_errorCodigo.setPalette(palette) self.label_errorCodigo.setText("") self.label_errorCodigo.setObjectName("label_errorCodigo") self.label_total_desc = QtWidgets.QLabel(ventasObject) self.label_total_desc.setGeometry(QtCore.QRect(250, 550, 91, 20)) self.label_total_desc.setObjectName("label_total_desc") self.lineEdit_mostrarTotalConDesc = QtWidgets.QLineEdit(ventasObject) self.lineEdit_mostrarTotalConDesc.setGeometry( QtCore.QRect(340, 540, 151, 41)) font = QtGui.QFont() font.setPointSize(20) self.lineEdit_mostrarTotalConDesc.setFont(font) self.lineEdit_mostrarTotalConDesc.setAlignment(QtCore.Qt.AlignCenter) self.lineEdit_mostrarTotalConDesc.setReadOnly(True) self.lineEdit_mostrarTotalConDesc.setClearButtonEnabled(False) self.lineEdit_mostrarTotalConDesc.setObjectName( "lineEdit_mostrarTotalConDesc") self.label_IVA = QtWidgets.QLabel(ventasObject) self.label_IVA.setGeometry(QtCore.QRect(400, 280, 41, 16)) self.label_IVA.setObjectName("label_IVA") self.spinBox_IVA = QtWidgets.QSpinBox(ventasObject) self.spinBox_IVA.setGeometry(QtCore.QRect(400, 300, 41, 24)) self.spinBox_IVA.setProperty("value", 19) self.spinBox_IVA.setObjectName("spinBox_IVA") self.pushButton_buscar = QtWidgets.QPushButton(ventasObject) self.pushButton_buscar.setGeometry(QtCore.QRect(460, 30, 71, 51)) self.pushButton_buscar.setObjectName("pushButton_buscar") self.deshabilitarBotonesPrincipales() self.pushButton_cancelarVenta.clicked.connect(self.resetearVenta) self.pushButton_vincularCliente.clicked.connect(self.vincularCliente) self.pushButton_buscar.clicked.connect(self.buscarItem) self.lineEdit_codigo_Item.returnPressed.connect(self.buscarInfoCodigo) self.pushButton_agregarItemVenta.clicked.connect(self.agregarItem) self.pushButton_confirmarVenta.clicked.connect(self.confirmarVenta) self.getCategorias() self.getDescuentos() self.getmediosPago() self.retranslateUi(ventasObject) QtCore.QMetaObject.connectSlotsByName(ventasObject)
def setupUi(self, Form, usuarioActualConectado): self.bd = BaseDatos() print("setupUi") Form.setObjectName("Form") Form.resize(450, 534) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(Form.sizePolicy().hasHeightForWidth()) Form.setSizePolicy(sizePolicy) Form.setMinimumSize(QtCore.QSize(450, 0)) Form.setMaximumSize(QtCore.QSize(450, 16777215)) self.gridLayout = QtWidgets.QGridLayout(Form) self.gridLayout.setObjectName("gridLayout") self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.verticalLayout_2 = QtWidgets.QVBoxLayout() self.verticalLayout_2.setObjectName("verticalLayout_2") self.label = QtWidgets.QLabel(Form) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.label.sizePolicy().hasHeightForWidth()) self.label.setSizePolicy(sizePolicy) self.label.setObjectName("label") self.verticalLayout_2.addWidget(self.label) self.lineEdit = QtWidgets.QLineEdit(Form) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lineEdit.sizePolicy().hasHeightForWidth()) self.lineEdit.setSizePolicy(sizePolicy) self.lineEdit.setObjectName("lineEdit") self.verticalLayout_2.addWidget(self.lineEdit) self.horizontalLayout.addLayout(self.verticalLayout_2) self.verticalLayout_3 = QtWidgets.QVBoxLayout() self.verticalLayout_3.setObjectName("verticalLayout_3") self.label_2 = QtWidgets.QLabel(Form) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.label_2.sizePolicy().hasHeightForWidth()) self.label_2.setSizePolicy(sizePolicy) self.label_2.setObjectName("label_2") self.verticalLayout_3.addWidget(self.label_2) self.lineEdit_2 = QtWidgets.QLineEdit(Form) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lineEdit_2.sizePolicy().hasHeightForWidth()) self.lineEdit_2.setSizePolicy(sizePolicy) self.lineEdit_2.setObjectName("lineEdit_2") self.verticalLayout_3.addWidget(self.lineEdit_2) self.horizontalLayout.addLayout(self.verticalLayout_3) self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") spacerItem = QtWidgets.QSpacerItem(20, 16, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Maximum) self.verticalLayout.addItem(spacerItem) self.pushButton = QtWidgets.QPushButton(Form) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.pushButton.sizePolicy().hasHeightForWidth()) self.pushButton.setSizePolicy(sizePolicy) self.pushButton.setObjectName("pushButton") self.verticalLayout.addWidget(self.pushButton) self.horizontalLayout.addLayout(self.verticalLayout) self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1) self.tableWidget = QtWidgets.QTableWidget(Form) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.tableWidget.sizePolicy().hasHeightForWidth()) self.tableWidget.setSizePolicy(sizePolicy) self.tableWidget.setMinimumSize(QtCore.QSize(400, 0)) self.tableWidget.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.tableWidget.setStyleSheet("") self.tableWidget.setObjectName("tableWidget") self.tableWidget.setColumnCount(4) self.tableWidget.setRowCount(1) item = QtWidgets.QTableWidgetItem() self.tableWidget.setVerticalHeaderItem(0, item) item = QtWidgets.QTableWidgetItem() item.setTextAlignment(QtCore.Qt.AlignCenter) self.tableWidget.setHorizontalHeaderItem(0, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(1, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(2, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(3, item) item = QtWidgets.QTableWidgetItem() item.setTextAlignment(QtCore.Qt.AlignCenter) self.tableWidget.setItem(0, 1, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setItem(0, 2, item) self.gridLayout.addWidget(self.tableWidget, 1, 0, 1, 1, QtCore.Qt.AlignHCenter) self.tableWidget.blockSignals(True) self.cargarDatos() self.tableWidget.blockSignals(False) self.retranslateUi(Form) self.tableWidget.cellChanged['int', 'int'].connect(self.actualizarUsuario) self.pushButton.clicked.connect(self.crearUsuario) QtCore.QMetaObject.connectSlotsByName(Form)
class Proveedor: def __init__(self, id=None, nombreUsuario=None, numero_documento=None): self.id = id self.nombreUsuario = nombreUsuario self.numero_documento = numero_documento self.bd = BaseDatos() self.conectarBD() if (id is not None): self.activo = 1 self.generaProveedorConId() else: self.activo = 0 def getNombreUsuario(self): tabla = "proveedores" camposSelect = ["nombre"] camposWhere = ["numero_documento", "activo"] tipoCampoWhere = [-1, 1] datoNombre = self.bd.generarValorCampoConId(tabla, camposSelect, camposWhere, tipoCampoWhere, self.numero_documento) self.nombreUsuario = datoNombre[0] print("Dato nombre es: ") print(datoNombre[0]) def buscarProveedorDoc(self, numero_documento): # id=None tabla = "proveedores" campos = ["numero_documento", "activo"] tipoCampos = [-1, 1] valorCampos = [numero_documento] id = self.bd.buscarValorCampo(tabla, campos, tipoCampos, valorCampos) # sql = "SELECT id FROM usuarios where nombre=? and contrasena=? and activo=1" # self.cursor.execute(sql, [(nombre),(contrasena)]) # id=self.cursor.fetchone() if id is not None: self.id = id[0] self.numero_documento = numero_documento self.activo = 1 self.getNombreUsuario() return True else: return False def crearProveedor(self): tabla = "proveedores" campos = ["nombre", "numero_documento"] valorCampos = [self.nombreUsuario, self.numero_documento] self.id = self.bd.crearValorCampo(tabla, campos, valorCampos) def conectarBD(self): self.conn = sqlite3.connect("basedatos.db") self.cursor = self.conn.cursor() def generaProveedorConId(self): # sql = "SELECT nombre, contrasena FROM usuarios where id=? and activo=1" # self.cursor.execute(sql,[(self.id)]) tabla = "proveedores" camposSelect = ["nombre", "numero_documento"] camposWhere = ["id", "activo"] tipoCampoWhere = [-1, 1] datosUsuario = self.bd.generarValorCampoConId(tabla, camposSelect, camposWhere, tipoCampoWhere, self.id) # datosUsuario=self.cursor.fetchone() self.nombreUsuario = datosUsuario[0] self.numero_documento = datosUsuario[1] print("nombres usuario viejo: " + str(self.nombreUsuario)) print("numero_documento usuario viejo: " + str(self.numero_documento)) def borrarProveedor(self): tabla = "proveedores" self.bd.borrarValorCampo(tabla, self.id)
def setupUi(self, interfazProductosNew, usuarioActual): self.categorias = [] self.categoriasId = [] self.bd = BaseDatos() interfazProductosNew.setObjectName("interfazProductosNew") interfazProductosNew.resize(709, 604) interfazProductosNew.setMinimumSize(QtCore.QSize(709, 604)) interfazProductosNew.setMaximumSize(QtCore.QSize(709, 604)) self.lineEdit_Codigo = QtWidgets.QLineEdit(interfazProductosNew) self.lineEdit_Codigo.setGeometry(QtCore.QRect(100, 30, 118, 30)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lineEdit_Codigo.sizePolicy().hasHeightForWidth()) self.lineEdit_Codigo.setSizePolicy(sizePolicy) self.lineEdit_Codigo.setObjectName("lineEdit_Codigo") self.label_codigo = QtWidgets.QLabel(interfazProductosNew) self.label_codigo.setGeometry(QtCore.QRect(40, 40, 51, 16)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.label_codigo.sizePolicy().hasHeightForWidth()) self.label_codigo.setSizePolicy(sizePolicy) self.label_codigo.setObjectName("label_codigo") self.label_precio = QtWidgets.QLabel(interfazProductosNew) self.label_precio.setGeometry(QtCore.QRect(290, 30, 51, 21)) self.label_precio.setObjectName("label_precio") self.lineEdit_descripcion = QtWidgets.QLineEdit(interfazProductosNew) self.lineEdit_descripcion.setGeometry(QtCore.QRect(110, 90, 118, 30)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lineEdit_descripcion.sizePolicy().hasHeightForWidth()) self.lineEdit_descripcion.setSizePolicy(sizePolicy) self.lineEdit_descripcion.setObjectName("lineEdit_descripcion") self.btnAdd = QtWidgets.QPushButton(interfazProductosNew) self.btnAdd.setGeometry(QtCore.QRect(550, 60, 85, 30)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btnAdd.sizePolicy().hasHeightForWidth()) self.btnAdd.setSizePolicy(sizePolicy) self.btnAdd.setObjectName("btnAdd") self.laberl_descripcion = QtWidgets.QLabel(interfazProductosNew) self.laberl_descripcion.setGeometry(QtCore.QRect(30, 100, 81, 20)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.laberl_descripcion.sizePolicy().hasHeightForWidth()) self.laberl_descripcion.setSizePolicy(sizePolicy) self.laberl_descripcion.setObjectName("laberl_descripcion") self.label_4 = QtWidgets.QLabel(interfazProductosNew) self.label_4.setGeometry(QtCore.QRect(290, 150, 211, 16)) self.label_4.setObjectName("label_4") self.lineEdit_Precio = QtWidgets.QLineEdit(interfazProductosNew) self.lineEdit_Precio.setGeometry(QtCore.QRect(350, 30, 118, 30)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lineEdit_Precio.sizePolicy().hasHeightForWidth()) self.lineEdit_Precio.setSizePolicy(sizePolicy) self.lineEdit_Precio.setObjectName("lineEdit_Precio") self.tableWidget = QtWidgets.QTableWidget(interfazProductosNew) self.tableWidget.setGeometry(QtCore.QRect(60, 220, 601, 323)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.tableWidget.sizePolicy().hasHeightForWidth()) self.tableWidget.setSizePolicy(sizePolicy) self.tableWidget.setMinimumSize(QtCore.QSize(500, 0)) self.tableWidget.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.tableWidget.setStyleSheet("") self.tableWidget.setObjectName("tableWidget") self.tableWidget.setColumnCount(7) self.tableWidget.setRowCount(1) item = QtWidgets.QTableWidgetItem() self.tableWidget.setVerticalHeaderItem(0, item) item = QtWidgets.QTableWidgetItem() item.setTextAlignment(QtCore.Qt.AlignCenter) self.tableWidget.setHorizontalHeaderItem(0, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(1, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(2, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(3, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(4, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(5, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(6, item) item = QtWidgets.QTableWidgetItem() item.setTextAlignment(QtCore.Qt.AlignCenter) self.tableWidget.setItem(0, 1, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setItem(0, 2, item) self.laberl_invInit = QtWidgets.QLabel(interfazProductosNew) self.laberl_invInit.setGeometry(QtCore.QRect(30, 140, 81, 20)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.laberl_invInit.sizePolicy().hasHeightForWidth()) self.laberl_invInit.setSizePolicy(sizePolicy) self.laberl_invInit.setObjectName("laberl_invInit") self.laberl_idCategoria = QtWidgets.QLabel(interfazProductosNew) self.laberl_idCategoria.setGeometry(QtCore.QRect(290, 90, 81, 20)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.laberl_idCategoria.sizePolicy().hasHeightForWidth()) self.laberl_idCategoria.setSizePolicy(sizePolicy) self.laberl_idCategoria.setObjectName("laberl_idCategoria") self.comboBox_categoria = QtWidgets.QComboBox(interfazProductosNew) self.comboBox_categoria.setGeometry(QtCore.QRect(350, 90, 121, 22)) self.comboBox_categoria.setObjectName("comboBox_categoria") self.spinBox_invInit = QtWidgets.QSpinBox(interfazProductosNew) self.spinBox_invInit.setGeometry(QtCore.QRect(120, 140, 46, 24)) self.spinBox_invInit.setProperty("value", 1) self.spinBox_invInit.setObjectName("spinBox_invInit") self.spinBox_invInit.setMinimum(1) self.getCategorias() self.cargarDatosProductos() self.btnAdd.clicked.connect(self.crearProducto) self.retranslateUi(interfazProductosNew) QtCore.QMetaObject.connectSlotsByName(interfazProductosNew)
def setupUi(self, clientesForm, usuarioActual): self.bd = BaseDatos() clientesForm.setObjectName("clientesForm") clientesForm.resize(500, 526) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( clientesForm.sizePolicy().hasHeightForWidth()) clientesForm.setSizePolicy(sizePolicy) clientesForm.setMinimumSize(QtCore.QSize(500, 0)) clientesForm.setMaximumSize(QtCore.QSize(500, 16777215)) self.gridLayout = QtWidgets.QGridLayout(clientesForm) self.gridLayout.setObjectName("gridLayout") self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setObjectName("horizontalLayout") self.verticalLayout_2 = QtWidgets.QVBoxLayout() self.verticalLayout_2.setObjectName("verticalLayout_2") self.label = QtWidgets.QLabel(clientesForm) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.label.sizePolicy().hasHeightForWidth()) self.label.setSizePolicy(sizePolicy) self.label.setObjectName("label") self.verticalLayout_2.addWidget(self.label) self.lineEdit_Nombre = QtWidgets.QLineEdit(clientesForm) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lineEdit_Nombre.sizePolicy().hasHeightForWidth()) self.lineEdit_Nombre.setSizePolicy(sizePolicy) self.lineEdit_Nombre.setObjectName("lineEdit_Nombre") self.verticalLayout_2.addWidget(self.lineEdit_Nombre) self.label_3 = QtWidgets.QLabel(clientesForm) self.label_3.setObjectName("label_3") self.verticalLayout_2.addWidget(self.label_3) self.lineEdit_Documento = QtWidgets.QLineEdit(clientesForm) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lineEdit_Documento.sizePolicy().hasHeightForWidth()) self.lineEdit_Documento.setSizePolicy(sizePolicy) self.lineEdit_Documento.setObjectName("lineEdit_Documento") self.verticalLayout_2.addWidget(self.lineEdit_Documento) self.horizontalLayout.addLayout(self.verticalLayout_2) self.verticalLayout = QtWidgets.QVBoxLayout() self.verticalLayout.setObjectName("verticalLayout") self.btnAdd = QtWidgets.QPushButton(clientesForm) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btnAdd.sizePolicy().hasHeightForWidth()) self.btnAdd.setSizePolicy(sizePolicy) self.btnAdd.setObjectName("btnAdd") self.verticalLayout.addWidget(self.btnAdd) self.label_4 = QtWidgets.QLabel(clientesForm) self.label_4.setGeometry(QtCore.QRect(280, 80, 211, 16)) self.label_4.setObjectName("label_4") # self.verticalLayout.addWidget(self.label_4) self.horizontalLayout.addLayout(self.verticalLayout) self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1) self.tableWidget = QtWidgets.QTableWidget(clientesForm) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.tableWidget.sizePolicy().hasHeightForWidth()) self.tableWidget.setSizePolicy(sizePolicy) self.tableWidget.setMinimumSize(QtCore.QSize(400, 0)) self.tableWidget.setMaximumSize(QtCore.QSize(16777215, 16777215)) self.tableWidget.setStyleSheet("") self.tableWidget.setObjectName("tableWidget") self.tableWidget.setColumnCount(4) self.tableWidget.setRowCount(1) item = QtWidgets.QTableWidgetItem() self.tableWidget.setVerticalHeaderItem(0, item) item = QtWidgets.QTableWidgetItem() item.setTextAlignment(QtCore.Qt.AlignCenter) self.tableWidget.setHorizontalHeaderItem(0, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(1, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(2, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(3, item) item = QtWidgets.QTableWidgetItem() self.tableWidget.setItem(0, 1, item) item = QtWidgets.QTableWidgetItem() item.setTextAlignment(QtCore.Qt.AlignCenter) self.tableWidget.setItem(0, 2, item) self.gridLayout.addWidget(self.tableWidget, 1, 0, 1, 1, QtCore.Qt.AlignHCenter) self.tableWidget.blockSignals(True) self.cargarDatos() self.tableWidget.blockSignals(False) self.btnAdd.clicked.connect(self.crearCliente) self.retranslateUi(clientesForm) QtCore.QMetaObject.connectSlotsByName(clientesForm)
class Usuario: def __init__(self, id=None, nombreUsuario=None, contrasena=None): self.id = id self.nombreUsuario = nombreUsuario self.contrasena = contrasena self.bd = BaseDatos() self.conectarBD() if (id is not None): self.activo = 1 self.generaUsuarioConId() else: self.activo = 0 def conectarBD(self): self.conn = sqlite3.connect("basedatos.db") self.cursor = self.conn.cursor() # self.conn,self.cursor=self.bd.conectarBD() def generaUsuarioConId(self): # sql = "SELECT nombre, contrasena FROM usuarios where id=? and activo=1" # self.cursor.execute(sql,[(self.id)]) tabla = "usuarios" camposSelect = ["nombre", "contrasena"] camposWhere = ["id", "activo"] tipoCampoWhere = [-1, 1] datosUsuario = self.bd.generarValorCampoConId(tabla, camposSelect, camposWhere, tipoCampoWhere, self.id) # datosUsuario=self.cursor.fetchone() self.nombreUsuario = datosUsuario[0] self.contrasena = datosUsuario[1] print("nombres usuario viejo: " + str(self.nombreUsuario)) print("contrasena usuario viejo: " + str(self.contrasena)) # print(datosUsuario) # print("repite?") def buscarUsuario(self, nombre, contrasena): # print("---------------------------") # cwd = os.getcwd() # print(cwd) # print("---------------------------") # id=None tabla = "usuarios" campos = ["nombre", "contrasena", "activo"] tipoCampos = [-1, -1, 1] valorCampos = [nombre, contrasena] id = self.bd.buscarValorCampo(tabla, campos, tipoCampos, valorCampos) # sql = "SELECT id FROM usuarios where nombre=? and contrasena=? and activo=1" # self.cursor.execute(sql, [(nombre),(contrasena)]) # id=self.cursor.fetchone() if id is not None: self.id = id[0] self.nombreUsuario = nombre self.contrasena = contrasena self.activo = 1 return True else: return False def borrarUsuario(self): tabla = "usuarios" self.bd.borrarValorCampo(tabla, self.id) def crearUsuario(self): tabla = "usuarios" campos = ["nombre", "contrasena"] valorCampos = [self.nombreUsuario, self.contrasena] self.id = self.bd.crearValorCampo(tabla, campos, valorCampos) # sql = "INSERT INTO usuarios(nombre,contrasena) VALUES (?,?)" # self.cursor.execute(sql, # [ # (self.nombreUsuario), # (self.contrasena), # ] # ) # self.conn.commit() # self.id= self.cursor.lastrowid def actualizarUsuario(self, nombre, contrasena): tabla = "usuarios" campos = ["nombre", "contrasena"] valorCampos = [nombre, contrasena, self.id] self.bd.actualizarValorCampo(tabla, campos, valorCampos)
class Producto: def __init__(self, id=None, codigo=None, descripcion=None, precio=None, id_categoria=None, iva=None, cantidad=None, inventario=None): self.id = id self.codigo = codigo self.descripcion = descripcion self.precio = precio self.id_categoria = id_categoria self.categoria = None self.iva = iva self.cantidad = None self.inventario = inventario self.totalConIva = None self.totalSinIva = None self.bd = BaseDatos() self.conectarBD() def borrarProducto(self): tabla = "productos" self.bd.borrarValorCampo(tabla, self.id) def crearProducto(self): tabla = "productos" campos = [ "codigo", "descripcion", "precio", "inventario", "id_categoria" ] print( str(self.codigo) + str(self.descripcion) + str(self.precio) + str(self.inventario) + str(self.id_categoria)) valorCampos = [ self.codigo, self.descripcion, self.precio, self.inventario, self.id_categoria ] self.id = self.bd.crearValorCampo(tabla, campos, valorCampos) def cargarDatos(self): print("cargarDatos") self.arregloBotones = [] tabla = "usuarios" camposSelect = ["id", "nombre", "contrasena"] self.tableWidget.setRowCount(0) rows = self.bd.cargarDatosValorCampo(tabla, camposSelect) # conn = sqlite3.connect("basedatos.db") # cursor = conn.cursor() # cursor.execute('SELECT id, nombre, contrasena FROM usuarios WHERE activo = 1') # rows = cursor.fetchall() for count in range(len(rows)): self.arregloBotones.append(QtWidgets.QPushButton(self.tableWidget)) self.arregloBotones[count].setText('Borrar') for row in rows: inx = rows.index(row) self.tableWidget.insertRow(inx) a = QtWidgets.QTableWidgetItem(str(row[0])) a.setFlags(a.flags() & ~Qt.ItemIsEditable) self.tableWidget.setItem(inx, 0, a) self.tableWidget.setItem(inx, 1, QtWidgets.QTableWidgetItem(str(row[1]))) self.tableWidget.setItem(inx, 2, QtWidgets.QTableWidgetItem(str(row[2]))) self.tableWidget.setCellWidget(inx, 3, self.arregloBotones[int(inx)]) self.arregloBotones[inx].clicked.connect(self.borrarUsuario) def actualizarInventarioVenta(self): tabla = "productos" campos = ["inventario"] inventarioAct = self.inventario - self.cantidad print("inventarioAct: " + str(inventarioAct)) print("id producto: " + str(self.id)) valorCampos = [int(inventarioAct), self.id] self.bd.actualizarValorCampo(tabla, campos, valorCampos) def actualizarInventarioVenta2(self): tabla = "productos" campos = ["inventario"] inventarioAct = self.inventario + self.cantidad print("inventarioAct: " + str(inventarioAct)) print("id producto: " + str(self.id)) valorCampos = [int(inventarioAct), self.id] self.bd.actualizarValorCampo(tabla, campos, valorCampos) def calcularTotales(self): self.totalSinIva = self.precio * self.cantidad self.totalConIva = self.totalSinIva * (1 + self.iva) print(self.totalSinIva) print(self.totalConIva) def conectarBD(self): self.conn = sqlite3.connect("basedatos.db") self.cursor = self.conn.cursor() def findCategoria(self): tabla = "categorias" camposSelect = ["nombre"] camposWhere = ["id"] tipoCamposWhere = [-1] valorCamposWhere = [self.id_categoria] row = self.bd.buscarValorCamposGeneral(tabla, camposSelect, camposWhere, tipoCamposWhere, valorCamposWhere) self.categoria = row[0] def actualizarInfoProducto(self): tabla = "productos" camposSelect = [ "descripcion", "precio", "inventario", "id_categoria", "id" ] camposWhere = ["codigo"] tipoCamposWhere = [-1] valorCamposWhere = [self.codigo] print(valorCamposWhere) rows = self.bd.buscarValorCamposGeneral(tabla, camposSelect, camposWhere, tipoCamposWhere, valorCamposWhere) self.descripcion = rows[0] self.precio = rows[1] self.inventario = rows[2] self.id_categoria = rows[3] self.findCategoria() self.id = rows[4]