예제 #1
0
def produceParts():
    """Workshops produce parts and store them in warehouses"""
    part_id = request.form['part_id']
    weight = request.form['weight']
    price = request.form['price']
    warehouse_id = request.form['warehouse_id']
    workshop_id = request.form['workshop_id']
    sql = SQL_Server()
    SF = sql.produceParts(part_id, weight, price, warehouse_id, workshop_id)
    table = 'MAKE'
    attribute = '*'
    results = sql.selectFromTable(table, attribute)
    attributeList = sql.getAttributeListForSelectShow(table, attribute)
    if len(results) != 0:
        col = len(results[0])
    else:
        col = 0
    return render_template('produce_parts_result.html',
                           table=table,
                           attributeList=attributeList,
                           results=results,
                           attribute=attribute,
                           row=len(results),
                           col=col,
                           SF=SF)
예제 #2
0
def assembleProducts():
    """Assemble parts to generate products and store them in warehouse"""
    product_id = request.form['product_id']
    class_ = request.form['class']
    price = request.form['price']
    part_id = request.form['part_id']
    warehouse_id = request.form['warehouse_id']
    sql = SQL_Server()
    SF = sql.assembleProducts(product_id, class_, price, part_id, warehouse_id)
    table = 'ASSEMBLE'
    attribute = '*'
    results = sql.selectFromTable(table, attribute)
    attributeList = sql.getAttributeListForSelectShow(table, attribute)
    if len(results) != 0:
        col = len(results[0])
    else:
        col = 0
    return render_template('assemble_products_result.html',
                           table=table,
                           attributeList=attributeList,
                           results=results,
                           attribute=attribute,
                           row=len(results),
                           col=col,
                           SF=SF)
예제 #3
0
def userSelectResult():
    """show select option result"""
    global table
    attribute = request.form['attribute']
    sql = SQL_Server()
    results = sql.selectFromTable(table, attribute)
    attributeList = sql.getAttributeListForSelectShow(table, attribute)
    if len(results) != 0:
        col = len(results[0])
    else:
        col = 0
    return render_template('user_select_result.html',
                           table=table,
                           attributeList=attributeList,
                           results=results,
                           attribute=attribute,
                           row=len(results),
                           col=col)
예제 #4
0
def userInsertResult():
    """show result after insertion"""
    global table
    attribute = '*'
    sql = SQL_Server()
    insertSQL = request.form['insertSQL']
    # do insertion
    SF = sql.insertIntoTable(table, insertSQL)
    results = sql.selectFromTable(table, attribute)
    attributeList = sql.getAttributeListForSelectShow(table, attribute)
    if len(results) != 0:
        col = len(results[0])
    else:
        col = 0
    return render_template('user_insert_result.html',
                           table=table,
                           attributeList=attributeList,
                           results=results,
                           attribute=attribute,
                           row=len(results),
                           col=col,
                           SF=SF)
예제 #5
0
def deleteResult():
    """show result after deletion"""
    global table
    attribute = '*'
    sql = SQL_Server()
    deleteSQL = request.form['deleteSQL']
    # do deletion
    SF = sql.deleteFromUserTable(table, deleteSQL)
    results = sql.selectFromTable(table, attribute)
    attributeList = sql.getAttributeListForSelectShow(table, attribute)
    if len(results) != 0:
        col = len(results[0])
    else:
        col = 0
    return render_template('developer_delete_result.html',
                           table=table,
                           attributeList=attributeList,
                           results=results,
                           attribute=attribute,
                           row=len(results),
                           col=col,
                           SF=SF)
예제 #6
0
def updateResult():
    """show result after insertion"""
    global table
    attribute = '*'
    sql = SQL_Server()
    updateSQL = request.form['updateSQL']
    pending = request.form['pending']
    # do insertion
    SF = sql.updateTable(table, updateSQL, pending)
    results = sql.selectFromTable(table, attribute)
    attributeList = sql.getAttributeListForSelectShow(table, attribute)
    if len(results) != 0:
        col = len(results[0])
    else:
        col = 0
    return render_template('developer_update_result.html',
                           table=table,
                           attributeList=attributeList,
                           results=results,
                           attribute=attribute,
                           row=len(results),
                           col=col,
                           SF=SF)
예제 #7
0
def userInsertPanel():
    """detect the table which is to be inserted"""
    global table
    table = request.form['table']
    sql = SQL_Server()
    # detect if the table is in db
    if not sql.tableDetect(table):
        # exceptions.BadRequestKeyError here
        return redirect('/developer')
    attribute = '*'
    results = sql.selectFromTable(table, attribute)
    attributeList = sql.getAttributeListOfTable(table)
    if len(results) != 0:
        col = len(results[0])
    else:
        col = 0
    return render_template('user_insert.html',
                           table=table,
                           attributeList=attributeList,
                           results=results,
                           attribute=attribute,
                           row=len(results),
                           col=col,
                           attributeLen=len(attributeList))