Esempio n. 1
0
def prompt_for_new_sku_id():
    """ 提示用户输入新的产品sku_id并返回新产品ID,或者返回None """
    while True:
        sku_id = input("请输入新的产品ID:")
        if sku_id == "": return None
        elif sku_id in data.get_products():
            print("该产品已经存在,请重新输入")
        else:
            return sku_id
Esempio n. 2
0
def prompt_for_old_sku_id():
    """提示用户输入有效的产品sku_id并返回有效产品ID, 或者返回None"""
    while True:
        sku_id = input("请输入产品ID:")
        if sku_id == "":
            return None
        elif sku_id not in data.get_products():
            print("该产品不存在,请重新输入")
        else:
            return sku_id
Esempio n. 3
0
def register_order():
    if request.method == 'GET':
        data = {
            'products': D.get_products(),
        }
        return render_template('register_order.html', **data)
    elif request.method == 'POST':
        data = request.form
        print(data, sys.stdout)
        try:
            for i in data:
                print(i, data[i])
            for item in data['selected_item']:
                print(item, '*')
            # D.insert_order(data)
            # D.insert_order_product_relation(data)
            return redirect(url_for('index'))
        except Exception as e:
            print(e, sys.stderr)
            return redirect(url_for('register_order'))
Esempio n. 4
0
def index():
    products = D.get_products()
    authors = D.get_authors()
    data = {'products': products, 'authors': authors}
    return render_template('index.html', **data)
Esempio n. 5
0
def report_products():
    """产品信息报表"""
    for (k, v) in data.get_products().items():
        print('{0:8} {1}'.format(k, v))
Esempio n. 6
0
def report_items():
    """库存信息报表"""
    for (k, v) in data.get_items():
        sku_name = data.get_products()[k]
        loc_name = data.get_locations()[v]
        print('{0:8} {1}: {2:8} {3}'.format(k, sku_name, v, loc_name))