def updateCantidadProductoVenta(cantidad, idProducto): try: conn = conexion.getCon() sql = "SELECT cantidad FROM INVENTARIOS WHERE id = '%s'" % (idProducto) with conn.cursor() as cursor: cursor.execute(sql) data = cursor.fetchone() total = int(data[0]) - int(cantidad) sql = "UPDATE INVENTARIOS SET cantidad = '%s' WHERE id = '%s'" % (total, idProducto) with conn.cursor() as cursor: cursor.execute(sql) conn.commit() except(Exception) as e: conn.rollback print(e) finally: conn.close()
def updateProducto(nombre, tipo, cantidad, precioCompra, precioVenta, idProducto): try: conn = conexion.getCon() sql = "UPDATE INVENTARIOS SET nombre = '%s', tipo = '%s', cantidad = '%s', precio_compra = '%s', precio_venta = '%s' WHERE id = '%s'" % (nombre, tipo, cantidad, precioCompra, precioVenta, idProducto) with conn.cursor() as cursor: cursor.execute(sql) conn.commit() except(Exception) as e: conn.rollback print(e) finally: conn.close()
def cargarCompras(): try: conn = conexion.getCon() with conn.cursor() as cursor: cursor.execute("SELECT c.id, i.nombre, p.nombre, c.cantidad, c.precio, c.total, c.control FROM COMPRAS c, INVENTARIOS i, PROVEEDORES p WHERE c.id_producto = i.id AND c.id_proveedor = p.id") data = cursor.fetchall() if data is not None: return data except Exception as e: print("Error: ", e) finally: conn.close()
def updateProveedor(nombre, direccion, telefono, idProveedor): try: conn = conexion.getCon() sql = "UPDATE PROVEEDORES SET nombre = '%s', direccion = '%s', telefono = '%s' WHERE id = '%s'" % ( nombre, direccion, telefono, idProveedor) with conn.cursor() as cursor: cursor.execute(sql) conn.commit() except (Exception) as e: conn.rollback print(e) finally: conn.close()
def selectProveedor(): try: conn = conexion.getCon() with conn.cursor() as cursor: cursor.execute("SELECT id, nombre FROM PROVEEDORES") data = cursor.fetchall() if data is not None: return data except Exception as e: print("Error: ", e) finally: conn.close()
def cargarVentas(): try: conn = conexion.getCon() with conn.cursor() as cursor: cursor.execute("SELECT v.id, i.nombre, c.nombre, v.cantidad, v.precio, v.total, v.control FROM VENTAS v, INVENTARIOS i, CLIENTES c WHERE v.id_producto = i.id AND v.id_cliente = c.id") data = cursor.fetchall() if data is not None: return data except Exception as e: print("Error: ", e) finally: conn.close()
def selectInventario(): try: conn = conexion.getCon() with conn.cursor() as cursor: cursor.execute("SELECT id, nombre, precio_compra FROM INVENTARIOS") data = cursor.fetchall() if data is not None: return data except Exception as e: print("Error: ", e) finally: conn.close()
def cargarInventario(): try: conn = conexion.getCon() with conn.cursor() as cursor: cursor.execute("SELECT * FROM INVENTARIOS") data = cursor.fetchall() if data is not None: return data except Exception as e: print("Error: ", e) finally: conn.close()
def historicoCompras(): try: conn = conexion.getCon() with conn.cursor() as cursor: cursor.execute( "SELECT id, id_producto, id_proveedor, SUM(cantidad), precio, SUM(total), fecha, nombrep FROM HISTORICOCOMPRAS GROUP By nombrep" ) data = cursor.fetchall() if data is not None: return data except Exception as e: print("Error: ", e) finally: conn.close()