├── GUI.py ├── GUI.ui ├── README.md ├── base_datos.sql ├── conexionBD.py └── main.py /GUI.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # Form implementation generated from reading ui file 'GUI.ui' 3 | # Created by: PyQt5 UI code generator 5.9.2 4 | # WARNING! All changes made in this file will be lost! 5 | 6 | 7 | 8 | from PyQt5 import QtCore, QtGui, QtWidgets 9 | 10 | class Ui_Form(object): 11 | def setupUi(self, Form): 12 | Form.setObjectName("Form") 13 | Form.resize(681, 400) 14 | Form.setMinimumSize(QtCore.QSize(681, 400)) 15 | Form.setStyleSheet("background-color: rgb(0, 0, 255);") 16 | self.pantalla = QtWidgets.QTabWidget(Form) 17 | self.pantalla.setGeometry(QtCore.QRect(0, 0, 681, 400)) 18 | self.pantalla.setMinimumSize(QtCore.QSize(681, 400)) 19 | self.pantalla.setStyleSheet("background-color: rgb(255, 255, 255);\n" 20 | "color: rgb(0, 0, 0);") 21 | self.pantalla.setObjectName("pantalla") 22 | self.tab_5 = QtWidgets.QWidget() 23 | self.tab_5.setObjectName("tab_5") 24 | self.bt_refrescar = QtWidgets.QPushButton(self.tab_5) 25 | self.bt_refrescar.setGeometry(QtCore.QRect(550, 320, 75, 23)) 26 | self.bt_refrescar.setStyleSheet("background-color: rgb(85, 0, 255);\n" 27 | "color: rgb(255, 255, 255);\n" 28 | "font: 75 10pt \"MS Shell Dlg 2\";") 29 | self.bt_refrescar.setObjectName("bt_refrescar") 30 | self.tabla_productos = QtWidgets.QTableWidget(self.tab_5) 31 | self.tabla_productos.setGeometry(QtCore.QRect(30, 60, 511, 281)) 32 | self.tabla_productos.setRowCount(0) 33 | self.tabla_productos.setColumnCount(5) 34 | self.tabla_productos.setObjectName("tabla_productos") 35 | item = QtWidgets.QTableWidgetItem() 36 | item.setTextAlignment(QtCore.Qt.AlignCenter) 37 | font = QtGui.QFont() 38 | font.setBold(True) 39 | font.setWeight(75) 40 | item.setFont(font) 41 | item.setBackground(QtGui.QColor(255, 0, 191)) 42 | self.tabla_productos.setHorizontalHeaderItem(0, item) 43 | item = QtWidgets.QTableWidgetItem() 44 | item.setTextAlignment(QtCore.Qt.AlignCenter) 45 | font = QtGui.QFont() 46 | font.setBold(True) 47 | font.setWeight(75) 48 | item.setFont(font) 49 | item.setBackground(QtGui.QColor(85, 255, 127)) 50 | self.tabla_productos.setHorizontalHeaderItem(1, item) 51 | item = QtWidgets.QTableWidgetItem() 52 | item.setTextAlignment(QtCore.Qt.AlignCenter) 53 | font = QtGui.QFont() 54 | font.setBold(True) 55 | font.setWeight(75) 56 | item.setFont(font) 57 | item.setBackground(QtGui.QColor(255, 248, 53)) 58 | self.tabla_productos.setHorizontalHeaderItem(2, item) 59 | item = QtWidgets.QTableWidgetItem() 60 | item.setTextAlignment(QtCore.Qt.AlignCenter) 61 | font = QtGui.QFont() 62 | font.setBold(True) 63 | font.setWeight(75) 64 | item.setFont(font) 65 | item.setBackground(QtGui.QColor(0, 170, 127)) 66 | self.tabla_productos.setHorizontalHeaderItem(3, item) 67 | item = QtWidgets.QTableWidgetItem() 68 | item.setTextAlignment(QtCore.Qt.AlignCenter) 69 | font = QtGui.QFont() 70 | font.setBold(True) 71 | font.setWeight(75) 72 | item.setFont(font) 73 | item.setBackground(QtGui.QColor(255, 170, 0)) 74 | self.tabla_productos.setHorizontalHeaderItem(4, item) 75 | self.pantalla.addTab(self.tab_5, "") 76 | self.tab = QtWidgets.QWidget() 77 | self.tab.setObjectName("tab") 78 | self.bt_buscar = QtWidgets.QPushButton(self.tab) 79 | self.bt_buscar.setGeometry(QtCore.QRect(550, 330, 75, 23)) 80 | self.bt_buscar.setStyleSheet("background-color: rgb(85, 0, 255);\n" 81 | "color: rgb(255, 255, 255);\n" 82 | "font: 75 10pt \"MS Shell Dlg 2\";") 83 | self.bt_buscar.setObjectName("bt_buscar") 84 | self.codigoB = QtWidgets.QLineEdit(self.tab) 85 | self.codigoB.setGeometry(QtCore.QRect(72, 51, 101, 20)) 86 | self.codigoB.setText("") 87 | self.codigoB.setObjectName("codigoB") 88 | self.label = QtWidgets.QLabel(self.tab) 89 | self.label.setGeometry(QtCore.QRect(21, 51, 45, 16)) 90 | self.label.setObjectName("label") 91 | self.tabla_buscar = QtWidgets.QTableWidget(self.tab) 92 | self.tabla_buscar.setGeometry(QtCore.QRect(30, 90, 511, 261)) 93 | self.tabla_buscar.setRowCount(0) 94 | self.tabla_buscar.setColumnCount(5) 95 | self.tabla_buscar.setObjectName("tabla_buscar") 96 | item = QtWidgets.QTableWidgetItem() 97 | item.setTextAlignment(QtCore.Qt.AlignCenter) 98 | font = QtGui.QFont() 99 | font.setBold(True) 100 | font.setWeight(75) 101 | item.setFont(font) 102 | item.setBackground(QtGui.QColor(255, 0, 191)) 103 | self.tabla_buscar.setHorizontalHeaderItem(0, item) 104 | item = QtWidgets.QTableWidgetItem() 105 | item.setTextAlignment(QtCore.Qt.AlignCenter) 106 | font = QtGui.QFont() 107 | font.setBold(True) 108 | font.setWeight(75) 109 | item.setFont(font) 110 | item.setBackground(QtGui.QColor(85, 255, 127)) 111 | self.tabla_buscar.setHorizontalHeaderItem(1, item) 112 | item = QtWidgets.QTableWidgetItem() 113 | item.setTextAlignment(QtCore.Qt.AlignCenter) 114 | font = QtGui.QFont() 115 | font.setBold(True) 116 | font.setWeight(75) 117 | item.setFont(font) 118 | item.setBackground(QtGui.QColor(255, 248, 53)) 119 | self.tabla_buscar.setHorizontalHeaderItem(2, item) 120 | item = QtWidgets.QTableWidgetItem() 121 | item.setTextAlignment(QtCore.Qt.AlignCenter) 122 | font = QtGui.QFont() 123 | font.setBold(True) 124 | font.setWeight(75) 125 | item.setFont(font) 126 | item.setBackground(QtGui.QColor(0, 170, 127)) 127 | self.tabla_buscar.setHorizontalHeaderItem(3, item) 128 | item = QtWidgets.QTableWidgetItem() 129 | item.setTextAlignment(QtCore.Qt.AlignCenter) 130 | font = QtGui.QFont() 131 | font.setBold(True) 132 | font.setWeight(75) 133 | item.setFont(font) 134 | item.setBackground(QtGui.QColor(255, 170, 0)) 135 | self.tabla_buscar.setHorizontalHeaderItem(4, item) 136 | self.pantalla.addTab(self.tab, "") 137 | self.tab_2 = QtWidgets.QWidget() 138 | self.tab_2.setObjectName("tab_2") 139 | self.bt_agregar = QtWidgets.QPushButton(self.tab_2) 140 | self.bt_agregar.setGeometry(QtCore.QRect(420, 260, 75, 23)) 141 | self.bt_agregar.setStyleSheet("background-color: rgb(85, 0, 255);\n" 142 | "color: rgb(255, 255, 255);\n" 143 | "font: 75 10pt \"MS Shell Dlg 2\";") 144 | self.bt_agregar.setObjectName("bt_agregar") 145 | self.layoutWidget = QtWidgets.QWidget(self.tab_2) 146 | self.layoutWidget.setGeometry(QtCore.QRect(170, 70, 231, 211)) 147 | self.layoutWidget.setObjectName("layoutWidget") 148 | self.horizontalLayout = QtWidgets.QHBoxLayout(self.layoutWidget) 149 | self.horizontalLayout.setContentsMargins(0, 0, 0, 0) 150 | self.horizontalLayout.setObjectName("horizontalLayout") 151 | self.verticalLayout_2 = QtWidgets.QVBoxLayout() 152 | self.verticalLayout_2.setObjectName("verticalLayout_2") 153 | self.label_2 = QtWidgets.QLabel(self.layoutWidget) 154 | self.label_2.setObjectName("label_2") 155 | self.verticalLayout_2.addWidget(self.label_2) 156 | self.label_3 = QtWidgets.QLabel(self.layoutWidget) 157 | self.label_3.setObjectName("label_3") 158 | self.verticalLayout_2.addWidget(self.label_3) 159 | self.label_4 = QtWidgets.QLabel(self.layoutWidget) 160 | self.label_4.setObjectName("label_4") 161 | self.verticalLayout_2.addWidget(self.label_4) 162 | self.label_5 = QtWidgets.QLabel(self.layoutWidget) 163 | self.label_5.setObjectName("label_5") 164 | self.verticalLayout_2.addWidget(self.label_5) 165 | self.label_6 = QtWidgets.QLabel(self.layoutWidget) 166 | self.label_6.setObjectName("label_6") 167 | self.verticalLayout_2.addWidget(self.label_6) 168 | self.horizontalLayout.addLayout(self.verticalLayout_2) 169 | self.verticalLayout = QtWidgets.QVBoxLayout() 170 | self.verticalLayout.setObjectName("verticalLayout") 171 | self.codigoA = QtWidgets.QLineEdit(self.layoutWidget) 172 | self.codigoA.setObjectName("codigoA") 173 | self.verticalLayout.addWidget(self.codigoA) 174 | self.nombreA = QtWidgets.QLineEdit(self.layoutWidget) 175 | self.nombreA.setObjectName("nombreA") 176 | self.verticalLayout.addWidget(self.nombreA) 177 | self.modeloA = QtWidgets.QLineEdit(self.layoutWidget) 178 | self.modeloA.setObjectName("modeloA") 179 | self.verticalLayout.addWidget(self.modeloA) 180 | self.precioA = QtWidgets.QLineEdit(self.layoutWidget) 181 | self.precioA.setObjectName("precioA") 182 | self.verticalLayout.addWidget(self.precioA) 183 | self.cantidadA = QtWidgets.QLineEdit(self.layoutWidget) 184 | self.cantidadA.setObjectName("cantidadA") 185 | self.verticalLayout.addWidget(self.cantidadA) 186 | self.horizontalLayout.addLayout(self.verticalLayout) 187 | self.pantalla.addTab(self.tab_2, "") 188 | self.tab_3 = QtWidgets.QWidget() 189 | self.tab_3.setObjectName("tab_3") 190 | self.bt_actualizar = QtWidgets.QPushButton(self.tab_3) 191 | self.bt_actualizar.setGeometry(QtCore.QRect(530, 280, 91, 21)) 192 | self.bt_actualizar.setStyleSheet("background-color: rgb(85, 0, 255);\n" 193 | "color: rgb(255, 255, 255);\n" 194 | "font: 75 10pt \"MS Shell Dlg 2\";") 195 | self.bt_actualizar.setObjectName("bt_actualizar") 196 | self.layoutWidget1 = QtWidgets.QWidget(self.tab_3) 197 | self.layoutWidget1.setGeometry(QtCore.QRect(270, 80, 251, 221)) 198 | self.layoutWidget1.setObjectName("layoutWidget1") 199 | self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.layoutWidget1) 200 | self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) 201 | self.horizontalLayout_2.setObjectName("horizontalLayout_2") 202 | self.verticalLayout_4 = QtWidgets.QVBoxLayout() 203 | self.verticalLayout_4.setObjectName("verticalLayout_4") 204 | self.label_7 = QtWidgets.QLabel(self.layoutWidget1) 205 | self.label_7.setObjectName("label_7") 206 | self.verticalLayout_4.addWidget(self.label_7) 207 | self.label_8 = QtWidgets.QLabel(self.layoutWidget1) 208 | self.label_8.setObjectName("label_8") 209 | self.verticalLayout_4.addWidget(self.label_8) 210 | self.label_9 = QtWidgets.QLabel(self.layoutWidget1) 211 | self.label_9.setObjectName("label_9") 212 | self.verticalLayout_4.addWidget(self.label_9) 213 | self.label_10 = QtWidgets.QLabel(self.layoutWidget1) 214 | self.label_10.setObjectName("label_10") 215 | self.verticalLayout_4.addWidget(self.label_10) 216 | self.label_11 = QtWidgets.QLabel(self.layoutWidget1) 217 | self.label_11.setObjectName("label_11") 218 | self.verticalLayout_4.addWidget(self.label_11) 219 | self.horizontalLayout_2.addLayout(self.verticalLayout_4) 220 | self.verticalLayout_3 = QtWidgets.QVBoxLayout() 221 | self.verticalLayout_3.setObjectName("verticalLayout_3") 222 | self.codigo_actualizar = QtWidgets.QLineEdit(self.layoutWidget1) 223 | self.codigo_actualizar.setObjectName("codigo_actualizar") 224 | self.verticalLayout_3.addWidget(self.codigo_actualizar) 225 | self.nombre_actualizar = QtWidgets.QLineEdit(self.layoutWidget1) 226 | self.nombre_actualizar.setObjectName("nombre_actualizar") 227 | self.verticalLayout_3.addWidget(self.nombre_actualizar) 228 | self.modelo_actualizar = QtWidgets.QLineEdit(self.layoutWidget1) 229 | self.modelo_actualizar.setObjectName("modelo_actualizar") 230 | self.verticalLayout_3.addWidget(self.modelo_actualizar) 231 | self.precio_actualizar = QtWidgets.QLineEdit(self.layoutWidget1) 232 | self.precio_actualizar.setObjectName("precio_actualizar") 233 | self.verticalLayout_3.addWidget(self.precio_actualizar) 234 | self.cantidad_actualizar = QtWidgets.QLineEdit(self.layoutWidget1) 235 | self.cantidad_actualizar.setObjectName("cantidad_actualizar") 236 | self.verticalLayout_3.addWidget(self.cantidad_actualizar) 237 | self.horizontalLayout_2.addLayout(self.verticalLayout_3) 238 | self.id_producto = QtWidgets.QLineEdit(self.tab_3) 239 | self.id_producto.setGeometry(QtCore.QRect(30, 120, 180, 20)) 240 | self.id_producto.setObjectName("id_producto") 241 | self.label_13 = QtWidgets.QLabel(self.tab_3) 242 | self.label_13.setGeometry(QtCore.QRect(40, 80, 191, 39)) 243 | self.label_13.setObjectName("label_13") 244 | self.id_buscar = QtWidgets.QPushButton(self.tab_3) 245 | self.id_buscar.setGeometry(QtCore.QRect(70, 150, 75, 23)) 246 | self.id_buscar.setStyleSheet("background-color: rgb(255, 255, 255);") 247 | self.id_buscar.setObjectName("id_buscar") 248 | self.pantalla.addTab(self.tab_3, "") 249 | self.tab_4 = QtWidgets.QWidget() 250 | self.tab_4.setObjectName("tab_4") 251 | self.codigo_borrar = QtWidgets.QLineEdit(self.tab_4) 252 | self.codigo_borrar.setGeometry(QtCore.QRect(91, 50, 101, 20)) 253 | self.codigo_borrar.setText("") 254 | self.codigo_borrar.setObjectName("codigo_borrar") 255 | self.label_12 = QtWidgets.QLabel(self.tab_4) 256 | self.label_12.setGeometry(QtCore.QRect(40, 50, 45, 16)) 257 | self.label_12.setObjectName("label_12") 258 | self.borrar_ok = QtWidgets.QPushButton(self.tab_4) 259 | self.borrar_ok.setGeometry(QtCore.QRect(200, 50, 91, 23)) 260 | self.borrar_ok.setStyleSheet("background-color: rgb(255, 0, 127);") 261 | self.borrar_ok.setObjectName("borrar_ok") 262 | self.bt_borrar = QtWidgets.QPushButton(self.tab_4) 263 | self.bt_borrar.setGeometry(QtCore.QRect(560, 290, 75, 23)) 264 | self.bt_borrar.setStyleSheet("background-color: rgb(85, 0, 255);\n" 265 | "color: rgb(255, 255, 255);\n" 266 | "font: 75 10pt \"MS Shell Dlg 2\";") 267 | self.bt_borrar.setObjectName("bt_borrar") 268 | self.tabla_borrar = QtWidgets.QTableWidget(self.tab_4) 269 | self.tabla_borrar.setGeometry(QtCore.QRect(30, 80, 511, 231)) 270 | self.tabla_borrar.setRowCount(0) 271 | self.tabla_borrar.setColumnCount(5) 272 | self.tabla_borrar.setObjectName("tabla_borrar") 273 | item = QtWidgets.QTableWidgetItem() 274 | item.setTextAlignment(QtCore.Qt.AlignCenter) 275 | font = QtGui.QFont() 276 | font.setBold(True) 277 | font.setWeight(75) 278 | item.setFont(font) 279 | item.setBackground(QtGui.QColor(255, 0, 191)) 280 | self.tabla_borrar.setHorizontalHeaderItem(0, item) 281 | item = QtWidgets.QTableWidgetItem() 282 | item.setTextAlignment(QtCore.Qt.AlignCenter) 283 | font = QtGui.QFont() 284 | font.setBold(True) 285 | font.setWeight(75) 286 | item.setFont(font) 287 | item.setBackground(QtGui.QColor(85, 255, 127)) 288 | self.tabla_borrar.setHorizontalHeaderItem(1, item) 289 | item = QtWidgets.QTableWidgetItem() 290 | item.setTextAlignment(QtCore.Qt.AlignCenter) 291 | font = QtGui.QFont() 292 | font.setBold(True) 293 | font.setWeight(75) 294 | item.setFont(font) 295 | item.setBackground(QtGui.QColor(255, 248, 53)) 296 | self.tabla_borrar.setHorizontalHeaderItem(2, item) 297 | item = QtWidgets.QTableWidgetItem() 298 | item.setTextAlignment(QtCore.Qt.AlignCenter) 299 | font = QtGui.QFont() 300 | font.setBold(True) 301 | font.setWeight(75) 302 | item.setFont(font) 303 | item.setBackground(QtGui.QColor(0, 170, 127)) 304 | self.tabla_borrar.setHorizontalHeaderItem(3, item) 305 | item = QtWidgets.QTableWidgetItem() 306 | item.setTextAlignment(QtCore.Qt.AlignCenter) 307 | font = QtGui.QFont() 308 | font.setBold(True) 309 | font.setWeight(75) 310 | item.setFont(font) 311 | item.setBackground(QtGui.QColor(255, 170, 0)) 312 | self.tabla_borrar.setHorizontalHeaderItem(4, item) 313 | self.pantalla.addTab(self.tab_4, "") 314 | 315 | self.retranslateUi(Form) 316 | self.pantalla.setCurrentIndex(3) 317 | QtCore.QMetaObject.connectSlotsByName(Form) 318 | 319 | def retranslateUi(self, Form): 320 | _translate = QtCore.QCoreApplication.translate 321 | Form.setWindowTitle(_translate("Form", "REGISTRO DE PRODUCTOS")) 322 | self.bt_refrescar.setText(_translate("Form", "REFRESCAR")) 323 | item = self.tabla_productos.horizontalHeaderItem(0) 324 | item.setText(_translate("Form", "Codigo")) 325 | item = self.tabla_productos.horizontalHeaderItem(1) 326 | item.setText(_translate("Form", "Nombre")) 327 | item = self.tabla_productos.horizontalHeaderItem(2) 328 | item.setText(_translate("Form", "Modelo")) 329 | item = self.tabla_productos.horizontalHeaderItem(3) 330 | item.setText(_translate("Form", "Precio")) 331 | item = self.tabla_productos.horizontalHeaderItem(4) 332 | item.setText(_translate("Form", "Cantidad")) 333 | self.pantalla.setTabText(self.pantalla.indexOf(self.tab_5), _translate("Form", "PRODUCTOS")) 334 | self.bt_buscar.setText(_translate("Form", "BUSCAR")) 335 | self.label.setText(_translate("Form", "CODIGO:")) 336 | item = self.tabla_buscar.horizontalHeaderItem(0) 337 | item.setText(_translate("Form", "Codigo")) 338 | item = self.tabla_buscar.horizontalHeaderItem(1) 339 | item.setText(_translate("Form", "Nombre")) 340 | item = self.tabla_buscar.horizontalHeaderItem(2) 341 | item.setText(_translate("Form", "Modelo")) 342 | item = self.tabla_buscar.horizontalHeaderItem(3) 343 | item.setText(_translate("Form", "Precio")) 344 | item = self.tabla_buscar.horizontalHeaderItem(4) 345 | item.setText(_translate("Form", "Cantidad")) 346 | self.pantalla.setTabText(self.pantalla.indexOf(self.tab), _translate("Form", "BUSCAR PRODUCTO")) 347 | self.bt_agregar.setText(_translate("Form", "AGREGAR")) 348 | self.label_2.setText(_translate("Form", "CODIGO:")) 349 | self.label_3.setText(_translate("Form", "NOMBRE:")) 350 | self.label_4.setText(_translate("Form", "MODELO:")) 351 | self.label_5.setText(_translate("Form", "PRECIO: ")) 352 | self.label_6.setText(_translate("Form", "CANTIDAD: ")) 353 | self.pantalla.setTabText(self.pantalla.indexOf(self.tab_2), _translate("Form", "AGREGAR NUEVOS PRODUCTOS")) 354 | self.bt_actualizar.setText(_translate("Form", "ACTUALIZAR")) 355 | self.label_7.setText(_translate("Form", "CODIGO:")) 356 | self.label_8.setText(_translate("Form", "NOMBRE:")) 357 | self.label_9.setText(_translate("Form", "MODELO:")) 358 | self.label_10.setText(_translate("Form", "PRECIO: ")) 359 | self.label_11.setText(_translate("Form", "CANTIDAD: ")) 360 | self.label_13.setText(_translate("Form", "INGRESE EL ID DEL PRODUCTO")) 361 | self.id_buscar.setText(_translate("Form", "BUSCAR")) 362 | self.pantalla.setTabText(self.pantalla.indexOf(self.tab_3), _translate("Form", "ACTUALIZAR PRODUCTOS")) 363 | self.label_12.setText(_translate("Form", "CODIGO:")) 364 | self.borrar_ok.setText(_translate("Form", "OK")) 365 | self.bt_borrar.setText(_translate("Form", "BORRAR")) 366 | item = self.tabla_borrar.horizontalHeaderItem(0) 367 | item.setText(_translate("Form", "Codigo")) 368 | item = self.tabla_borrar.horizontalHeaderItem(1) 369 | item.setText(_translate("Form", "Nombre")) 370 | item = self.tabla_borrar.horizontalHeaderItem(2) 371 | item.setText(_translate("Form", "Modelo")) 372 | item = self.tabla_borrar.horizontalHeaderItem(3) 373 | item.setText(_translate("Form", "Precio")) 374 | item = self.tabla_borrar.horizontalHeaderItem(4) 375 | item.setText(_translate("Form", "Cantidad")) 376 | self.pantalla.setTabText(self.pantalla.indexOf(self.tab_4), _translate("Form", "BORRAR PRODUCTOS")) 377 | 378 | 379 | if __name__ == "__main__": 380 | import sys 381 | app = QtWidgets.QApplication(sys.argv) 382 | Form = QtWidgets.QWidget() 383 | ui = Ui_Form() 384 | ui.setupUi(Form) 385 | Form.show() 386 | sys.exit(app.exec_()) 387 | 388 | -------------------------------------------------------------------------------- /GUI.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Form 4 | 5 | 6 | 7 | 0 8 | 0 9 | 681 10 | 400 11 | 12 | 13 | 14 | 15 | 681 16 | 400 17 | 18 | 19 | 20 | REGISTRO DE PRODUCTOS 21 | 22 | 23 | background-color: rgb(0, 0, 255); 24 | 25 | 26 | 27 | 28 | 0 29 | 0 30 | 681 31 | 400 32 | 33 | 34 | 35 | 36 | 681 37 | 400 38 | 39 | 40 | 41 | background-color: rgb(255, 255, 255); 42 | color: rgb(0, 0, 0); 43 | 44 | 45 | 3 46 | 47 | 48 | 49 | PRODUCTOS 50 | 51 | 52 | 53 | 54 | 550 55 | 320 56 | 75 57 | 23 58 | 59 | 60 | 61 | background-color: rgb(85, 0, 255); 62 | color: rgb(255, 255, 255); 63 | font: 75 10pt "MS Shell Dlg 2"; 64 | 65 | 66 | REFESCRAR 67 | 68 | 69 | 70 | 71 | 72 | 30 73 | 60 74 | 511 75 | 281 76 | 77 | 78 | 79 | 0 80 | 81 | 82 | 5 83 | 84 | 85 | 86 | Codigo 87 | 88 | 89 | 90 | 75 91 | true 92 | 93 | 94 | 95 | AlignCenter 96 | 97 | 98 | 99 | 255 100 | 0 101 | 191 102 | 103 | 104 | 105 | 106 | 107 | Nombre 108 | 109 | 110 | 111 | 75 112 | true 113 | 114 | 115 | 116 | AlignCenter 117 | 118 | 119 | 120 | 85 121 | 255 122 | 127 123 | 124 | 125 | 126 | 127 | 128 | Modelo 129 | 130 | 131 | 132 | 75 133 | true 134 | 135 | 136 | 137 | AlignCenter 138 | 139 | 140 | 141 | 255 142 | 248 143 | 53 144 | 145 | 146 | 147 | 148 | 149 | Precio 150 | 151 | 152 | 153 | 75 154 | true 155 | 156 | 157 | 158 | AlignCenter 159 | 160 | 161 | 162 | 0 163 | 170 164 | 127 165 | 166 | 167 | 168 | 169 | 170 | Cantidad 171 | 172 | 173 | 174 | 75 175 | true 176 | 177 | 178 | 179 | AlignCenter 180 | 181 | 182 | 183 | 255 184 | 170 185 | 0 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | BUSCAR PRODUCTO 194 | 195 | 196 | 197 | 198 | 550 199 | 330 200 | 75 201 | 23 202 | 203 | 204 | 205 | background-color: rgb(85, 0, 255); 206 | color: rgb(255, 255, 255); 207 | font: 75 10pt "MS Shell Dlg 2"; 208 | 209 | 210 | BUSCAR 211 | 212 | 213 | 214 | 215 | 216 | 72 217 | 51 218 | 101 219 | 20 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 21 230 | 51 231 | 45 232 | 16 233 | 234 | 235 | 236 | CODIGO: 237 | 238 | 239 | 240 | 241 | 242 | 30 243 | 90 244 | 511 245 | 261 246 | 247 | 248 | 249 | 0 250 | 251 | 252 | 5 253 | 254 | 255 | 256 | Codigo 257 | 258 | 259 | 260 | 75 261 | true 262 | 263 | 264 | 265 | AlignCenter 266 | 267 | 268 | 269 | 255 270 | 0 271 | 191 272 | 273 | 274 | 275 | 276 | 277 | Nombre 278 | 279 | 280 | 281 | 75 282 | true 283 | 284 | 285 | 286 | AlignCenter 287 | 288 | 289 | 290 | 85 291 | 255 292 | 127 293 | 294 | 295 | 296 | 297 | 298 | Modelo 299 | 300 | 301 | 302 | 75 303 | true 304 | 305 | 306 | 307 | AlignCenter 308 | 309 | 310 | 311 | 255 312 | 248 313 | 53 314 | 315 | 316 | 317 | 318 | 319 | Precio 320 | 321 | 322 | 323 | 75 324 | true 325 | 326 | 327 | 328 | AlignCenter 329 | 330 | 331 | 332 | 0 333 | 170 334 | 127 335 | 336 | 337 | 338 | 339 | 340 | Cantidad 341 | 342 | 343 | 344 | 75 345 | true 346 | 347 | 348 | 349 | AlignCenter 350 | 351 | 352 | 353 | 255 354 | 170 355 | 0 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | AGREGAR NUEVOS PRODUCTOS 364 | 365 | 366 | 367 | 368 | 420 369 | 260 370 | 75 371 | 23 372 | 373 | 374 | 375 | background-color: rgb(85, 0, 255); 376 | color: rgb(255, 255, 255); 377 | font: 75 10pt "MS Shell Dlg 2"; 378 | 379 | 380 | AGREGAR 381 | 382 | 383 | 384 | 385 | 386 | 170 387 | 70 388 | 231 389 | 211 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | CODIGO: 399 | 400 | 401 | 402 | 403 | 404 | 405 | NOMBRE: 406 | 407 | 408 | 409 | 410 | 411 | 412 | MODELO: 413 | 414 | 415 | 416 | 417 | 418 | 419 | PRECIO: 420 | 421 | 422 | 423 | 424 | 425 | 426 | CANTIDAD: 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | ACTUALIZAR PRODUCTOS 457 | 458 | 459 | 460 | 461 | 530 462 | 280 463 | 91 464 | 21 465 | 466 | 467 | 468 | background-color: rgb(85, 0, 255); 469 | color: rgb(255, 255, 255); 470 | font: 75 10pt "MS Shell Dlg 2"; 471 | 472 | 473 | ACTUALIZAR 474 | 475 | 476 | 477 | 478 | 479 | 270 480 | 80 481 | 251 482 | 221 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | CODIGO: 492 | 493 | 494 | 495 | 496 | 497 | 498 | NOMBRE: 499 | 500 | 501 | 502 | 503 | 504 | 505 | MODELO: 506 | 507 | 508 | 509 | 510 | 511 | 512 | PRECIO: 513 | 514 | 515 | 516 | 517 | 518 | 519 | CANTIDAD: 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 30 550 | 120 551 | 180 552 | 20 553 | 554 | 555 | 556 | 557 | 558 | 559 | 40 560 | 80 561 | 191 562 | 39 563 | 564 | 565 | 566 | INGRESE EL ID DEL PRODUCTO 567 | 568 | 569 | 570 | 571 | 572 | 70 573 | 150 574 | 75 575 | 23 576 | 577 | 578 | 579 | background-color: rgb(255, 255, 255); 580 | 581 | 582 | BUSCAR 583 | 584 | 585 | 586 | 587 | 588 | BORRAR PRODUCTOS 589 | 590 | 591 | 592 | 593 | 91 594 | 50 595 | 101 596 | 20 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 40 607 | 50 608 | 45 609 | 16 610 | 611 | 612 | 613 | CODIGO: 614 | 615 | 616 | 617 | 618 | 619 | 200 620 | 50 621 | 91 622 | 23 623 | 624 | 625 | 626 | background-color: rgb(255, 0, 127); 627 | 628 | 629 | OK 630 | 631 | 632 | 633 | 634 | 635 | 560 636 | 290 637 | 75 638 | 23 639 | 640 | 641 | 642 | background-color: rgb(85, 0, 255); 643 | color: rgb(255, 255, 255); 644 | font: 75 10pt "MS Shell Dlg 2"; 645 | 646 | 647 | BORRAR 648 | 649 | 650 | 651 | 652 | 653 | 30 654 | 80 655 | 511 656 | 231 657 | 658 | 659 | 660 | 0 661 | 662 | 663 | 5 664 | 665 | 666 | 667 | Codigo 668 | 669 | 670 | 671 | 75 672 | true 673 | 674 | 675 | 676 | AlignCenter 677 | 678 | 679 | 680 | 255 681 | 0 682 | 191 683 | 684 | 685 | 686 | 687 | 688 | Nombre 689 | 690 | 691 | 692 | 75 693 | true 694 | 695 | 696 | 697 | AlignCenter 698 | 699 | 700 | 701 | 85 702 | 255 703 | 127 704 | 705 | 706 | 707 | 708 | 709 | Modelo 710 | 711 | 712 | 713 | 75 714 | true 715 | 716 | 717 | 718 | AlignCenter 719 | 720 | 721 | 722 | 255 723 | 248 724 | 53 725 | 726 | 727 | 728 | 729 | 730 | Precio 731 | 732 | 733 | 734 | 75 735 | true 736 | 737 | 738 | 739 | AlignCenter 740 | 741 | 742 | 743 | 0 744 | 170 745 | 127 746 | 747 | 748 | 749 | 750 | 751 | Cantidad 752 | 753 | 754 | 755 | 75 756 | true 757 | 758 | 759 | 760 | AlignCenter 761 | 762 | 763 | 764 | 255 765 | 170 766 | 0 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Database with python pyqt5 GUI 3 | -------------------------------------------------------------------------------- /base_datos.sql: -------------------------------------------------------------------------------- 1 | 2 | -- Volcando datos para la tabla base_datos.productos: ~19 rows (aproximadamente) 3 | /*!40000 ALTER TABLE `productos` DISABLE KEYS */; 4 | INSERT INTO `productos` (`ID`, `CODIGO`, `NOMBRE`, `MODELO`, `PRECIO`, `CANTIDAD`) VALUES 5 | (39, 'RES001', 'RESISTENCIA', 'RV', '2.00', '222'), 6 | (40, 'TRAS-11', 'TRANSISTOR', 'PNP', '1.00', '554'), 7 | (44, '10101', 'CONDENSADOR', 'CERAMICO', '2.00', '100'), 8 | (168, 'DB121', 'DIODO', 'ZENER', '1.50', '231'), 9 | (169, 'IC002', 'IC', 'AND', '1.00', '200'), 10 | (170, 'IC003', 'IC', 'XOR', '1.00', '300'), 11 | (171, 'D0092', 'DIOD0', 'ZENER', '2.00', '232'), 12 | (172, 'RE21', 'RELE', '221R', '2.50', '423'), 13 | (173, '2560', 'ARDUINO', 'MEGA', '30.0', '37'), 14 | (174, '2021DS', 'ARDUINO', 'UNO R3', '15.50', '73'), 15 | (175, 'RES2021', 'RESISTENCIA', '4B', '0.10', '1000'), 16 | (176, 'LED122', 'LED', 'GREENR3', '0.50', '144'), 17 | (177, 'LDR43', 'LDR', 'LDRG', '2.00', '43'), 18 | (178, 'FUSI232', 'FUSIBLE', '23FDEW', '2.00', '331'), 19 | (179, 'MATRIZ32', 'MATRIZ', '32X8', '50.0', '56'), 20 | (180, 'SENSORRE', 'ULTRASONIC', 'RGR0544', '5.00', '231'), 21 | (181, '555N', 'TIMER', '555', '1.50', '621'), 22 | (182, 'ER43', 'PILAS', 'AAA', '2.00', '544'), 23 | (185, '1212', '12121', '12121', '22121', '12121'); 24 | /*!40000 ALTER TABLE `productos` ENABLE KEYS */; 25 | 26 | -------------------------------------------------------------------------------- /conexionBD.py: -------------------------------------------------------------------------------- 1 | import mysql.connector 2 | 3 | 4 | class Registro_datos(): 5 | def __init__(self): 6 | self.conexion = mysql.connector.connect( host='localhost', 7 | database ='base_datos', 8 | user = 'root', 9 | password ='admin') 10 | def inserta_producto(self,codigo, nombre, modelo, precio, cantidad): 11 | cur = self.conexion.cursor() 12 | sql='''INSERT INTO productos (CODIGO, NOMBRE, MODELO, PRECIO, CANTIDAD) 13 | VALUES('{}', '{}','{}', '{}','{}')'''.format(codigo, nombre, modelo, precio, cantidad) 14 | cur.execute(sql) 15 | self.conexion.commit() 16 | cur.close() 17 | def buscar_productos(self): 18 | cursor = self.conexion.cursor() 19 | sql = "SELECT * FROM productos " 20 | cursor.execute(sql) 21 | registro = cursor.fetchall() 22 | return registro 23 | 24 | def busca_producto(self, nombre_producto): 25 | cur = self.conexion.cursor() 26 | sql = "SELECT * FROM productos WHERE NOMBRE = {}".format(nombre_producto) 27 | cur.execute(sql) 28 | nombrex = cur.fetchall() 29 | cur.close() 30 | return nombrex 31 | 32 | def elimina_productos(self,nombre): 33 | cur = self.conexion.cursor() 34 | sql='''DELETE FROM productos WHERE NOMBRE = {}'''.format(nombre) 35 | cur.execute(sql) 36 | nom = cur.rowcount 37 | self.conexion.commit() 38 | cur.close() 39 | return nom 40 | def actualiza_productos(self, codigo, nombre, modelo, precio, cantidad): 41 | cur = self.conexion.cursor() 42 | sql ='''UPDATE productos SET CODIGO =' {}' , MODELO = '{}', PRECIO = '{}', CANTIDAD = '{}' 43 | WHERE NOMBRE = '{}' '''.format(codigo, modelo, precio, cantidad, nombre) 44 | cur.execute(sql) 45 | act = cur.rowcount 46 | self.conexion.commit() 47 | cur.close() 48 | return act 49 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | # @autor: Magno Efren 2 | # https://www.youtube.com/c/MagnoEfren 3 | import sys 4 | from GUI import * 5 | from conexionBD import* 6 | from PyQt5.QtWidgets import QTableWidgetItem 7 | 8 | class MiApp(QtWidgets.QMainWindow): 9 | def __init__(self): 10 | super().__init__() 11 | self.ui = Ui_Form() 12 | self.ui.setupUi(self) 13 | 14 | self.datosTotal = Registro_datos() 15 | self.ui.bt_refrescar.clicked.connect(self.m_productos) 16 | self.ui.bt_agregar.clicked.connect(self.insert_productos) 17 | self.ui.bt_buscar.clicked.connect(self.buscar_producto) 18 | self.ui.bt_borrar.clicked.connect(self.eliminar_producto) 19 | self.ui.bt_actualizar.clicked.connect(self.modificar_productos) 20 | 21 | self.ui.tabla_productos.setColumnWidth(0,98) 22 | self.ui.tabla_productos.setColumnWidth(1,100) 23 | self.ui.tabla_productos.setColumnWidth(2,98) 24 | self.ui.tabla_productos.setColumnWidth(3,98) 25 | self.ui.tabla_productos.setColumnWidth(4,98) 26 | self.ui.tabla_borrar.setColumnWidth(0,98) 27 | self.ui.tabla_borrar.setColumnWidth(1,100) 28 | self.ui.tabla_borrar.setColumnWidth(2,98) 29 | self.ui.tabla_borrar.setColumnWidth(3,98) 30 | self.ui.tabla_borrar.setColumnWidth(4,98) 31 | self.ui.tabla_buscar.setColumnWidth(0,98) 32 | self.ui.tabla_buscar.setColumnWidth(1,100) 33 | self.ui.tabla_buscar.setColumnWidth(2,98) 34 | self.ui.tabla_buscar.setColumnWidth(3,98) 35 | self.ui.tabla_buscar.setColumnWidth(4,98) 36 | 37 | def m_productos(self): 38 | datos = self.datosTotal.buscar_productos() 39 | i = len(datos) 40 | 41 | self.ui.tabla_productos.setRowCount(i) 42 | tablerow = 0 43 | for row in datos: 44 | self.ui.tabla_productos.setItem(tablerow,0,QtWidgets.QTableWidgetItem(row[1])) 45 | self.ui.tabla_productos.setItem(tablerow,1,QtWidgets.QTableWidgetItem(row[2])) 46 | self.ui.tabla_productos.setItem(tablerow,2,QtWidgets.QTableWidgetItem(row[3])) 47 | self.ui.tabla_productos.setItem(tablerow,3,QtWidgets.QTableWidgetItem(row[4])) 48 | self.ui.tabla_productos.setItem(tablerow,4,QtWidgets.QTableWidgetItem(row[5])) 49 | tablerow +=1 50 | def insert_productos(self): 51 | codigo = self.ui.codigoA.text() 52 | nombre = self.ui.nombreA.text() 53 | modelo = self.ui.modeloA.text() 54 | precio = self.ui.precioA.text() 55 | cantidad = self.ui.cantidadA.text() 56 | 57 | self.datosTotal.inserta_producto(codigo, nombre, modelo, precio, cantidad) 58 | self.ui.codigoA.clear() 59 | self.ui.nombreA.clear() 60 | self.ui.modeloA.clear() 61 | self.ui.precioA.clear() 62 | self.ui.cantidadA.clear() 63 | 64 | def modificar_productos(self): 65 | id_producto = self.ui.id_producto.text() 66 | id_producto = str("'" + id_producto + "'") 67 | nombreXX = self.datosTotal.busca_producto(id_producto) 68 | 69 | if nombreXX != None: 70 | self.ui.id_buscar.setText("ACTUALIZAR") 71 | codigoM = self.ui.codigo_actualizar.text() 72 | nombreM = self.ui.nombre_actualizar.text() 73 | modeloM = self.ui.modelo_actualizar.text() 74 | precioM = self.ui.precio_actualizar.text() 75 | cantidadM = self.ui.cantidad_actualizar.text() 76 | act = self.datosTotal.actualiza_productos(codigoM,nombreM , modeloM, precioM, cantidadM) 77 | if act == 1: 78 | self.ui.id_buscar.setText("ACTUALIZADO") 79 | self.ui.codigo_actualizar.clear() 80 | self.ui.nombre_actualizar.clear() 81 | self.ui.modelo_actualizar.clear() 82 | self.ui.precio_actualizar.clear() 83 | self.ui.cantidad_actualizar.clear() 84 | self.ui.id_producto.clear() 85 | elif act == 0: 86 | self.ui.id_buscar.setText("ERROR") 87 | else: 88 | self.ui.id_buscar.setText("INCORRECTO") 89 | else: 90 | self.ui.id_buscar.setText("NO EXISTE") 91 | 92 | def buscar_producto(self): 93 | nombre_producto = self.ui.codigoB.text() 94 | nombre_producto = str("'" + nombre_producto + "'") 95 | 96 | datosB = self.datosTotal.busca_producto(nombre_producto) 97 | i = len(datosB) 98 | 99 | self.ui.tabla_buscar.setRowCount(i) 100 | tablerow = 0 101 | for row in datosB: 102 | self.ui.tabla_buscar.setItem(tablerow,0,QtWidgets.QTableWidgetItem(row[1])) 103 | self.ui.tabla_buscar.setItem(tablerow,1,QtWidgets.QTableWidgetItem(row[2])) 104 | self.ui.tabla_buscar.setItem(tablerow,2,QtWidgets.QTableWidgetItem(row[3])) 105 | self.ui.tabla_buscar.setItem(tablerow,3,QtWidgets.QTableWidgetItem(row[4])) 106 | self.ui.tabla_buscar.setItem(tablerow,4,QtWidgets.QTableWidgetItem(row[5])) 107 | tablerow +=1 108 | 109 | def eliminar_producto(self): 110 | eliminar = self.ui.codigo_borrar.text() 111 | eliminar = str("'"+ eliminar + "'") 112 | resp = (self.datosTotal.elimina_productos(eliminar)) 113 | datos = self.datosTotal.buscar_productos() 114 | i = len(datos) 115 | self.ui.tabla_borrar.setRowCount(i) 116 | tablerow = 0 117 | for row in datos: 118 | self.ui.tabla_borrar.setItem(tablerow,0,QtWidgets.QTableWidgetItem(row[1])) 119 | self.ui.tabla_borrar.setItem(tablerow,1,QtWidgets.QTableWidgetItem(row[2])) 120 | self.ui.tabla_borrar.setItem(tablerow,2,QtWidgets.QTableWidgetItem(row[3])) 121 | self.ui.tabla_borrar.setItem(tablerow,3,QtWidgets.QTableWidgetItem(row[4])) 122 | self.ui.tabla_borrar.setItem(tablerow,4,QtWidgets.QTableWidgetItem(row[5])) 123 | tablerow +=1 124 | if resp == None: 125 | self.ui.borrar_ok.setText("NO EXISTE") 126 | elif resp == 0: 127 | self.ui.borrar_ok.setText("NO EXISTE") 128 | else: 129 | self.ui.borrar_ok.setText("SE ELIMINO") 130 | 131 | if __name__ == "__main__": 132 | app = QtWidgets.QApplication(sys.argv) 133 | mi_app = MiApp() 134 | mi_app.show() 135 | sys.exit(app.exec_()) 136 | --------------------------------------------------------------------------------