コード例 #1
0
def add(bom_name, bom_code, com_name, com_code, com_cnt, com_unit, com_unit_price, com_rate):
    print(com_unit_price)
    print(com_cnt)
    conn = get_conn()
    cur = conn.cursor()
    res = dict()
    if bom_code == com_code:
        res["status"] = 0
        res["msg"] = u"不能组成自身"
    elif check_add_exist(cur, bom_code, com_code):
        res["status"] = 0
        res["msg"] = u"组件已在该物料组成中"
    else:
        sql = "insert into " + table_name \
              + "(bom_name, bom_code, com_name, com_code, com_cnt, com_unit, " \
            "com_unit_price, com_rate) " \
            "VALUES ('%s','%s','%s','%s',%f,'%s',%f,%d)" % \
              (bom_name, bom_code, com_name, com_code, float(com_cnt), com_unit,
               float(com_unit_price), int(com_rate))
        cur.execute(sql)
        conn.commit()
        total = cur.rowcount
        # cur.close()
        # conn.close()
        res = get_res_dict(total)
    return res
コード例 #2
0
def delete(bom_id):
    res = dict()
    conn = get_conn()
    cur = conn.cursor()
    sql = "delete from  " + table_name + " where bom_id=%d" % (int(bom_id), )
    cur.execute(sql)
    conn.commit()
    total = cur.rowcount
    res = get_res_dict(total)
    return res
コード例 #3
0
def delete_by_bom_code(bom_code):
    res = dict()
    conn = get_conn()
    cur = conn.cursor()
    sql = "delete from  " + table_name + " where bom_code='%s'" % (bom_code,)
    print(sql)
    cur.execute(sql)
    conn.commit()
    total = cur.rowcount
    res = get_res_dict(total)
    return res
コード例 #4
0
ファイル: bom_product_mgr.py プロジェクト: xjs513/BOM
def add(bom_name, bom_code, factory_code):
    conn = get_conn()
    cur = conn.cursor()
    res = dict()
    if check_add_exist(cur, table_name, "bom_name", bom_name):
        res["status"] = 0
        res["msg"] = u"物料名称已存在"
    elif check_add_exist(cur, table_name, "bom_code", bom_code):
        res["status"] = 0
        res["msg"] = u"物料编码已存在"
    else:
        sql = "insert into " + table_name + "(bom_name, bom_code, factory_code) " \
            "VALUES ('%s','%s',%d)" % (bom_name, bom_code, int(factory_code))
        cur.execute(sql)
        conn.commit()
        total = cur.rowcount
        # cur.close()
        # conn.close()
        res = get_res_dict(total)
    return res
コード例 #5
0
def add(bom_name, bom_code, bom_rate, bom_unit, bom_unit_price, is_produce):
    conn = get_conn()
    cur = conn.cursor()
    res = dict()
    if check_add_exist(cur, table_name, "bom_name", bom_name):
        res["status"] = 0
        res["msg"] = u"用料名称已存在"
    elif check_add_exist(cur, table_name, "bom_code", bom_code):
        res["status"] = 0
        res["msg"] = u"用料编码已存在"
    else:
        sql = "insert into " + table_name + "(bom_name, bom_code, bom_rate, bom_unit, bom_unit_price, " \
                "is_produce) VALUES ('%s','%s',%d,'%s',%f,%d)" % \
              (bom_name, bom_code, int(bom_rate), bom_unit, float(bom_unit_price), int(is_produce))
        cur.execute(sql)
        conn.commit()
        total = cur.rowcount
        # cur.close()
        # conn.close()
        res = get_res_dict(total)
    return res
コード例 #6
0
def update(c_id, bom_name, bom_code, com_name, com_code, com_cnt, com_unit, com_unit_price, com_rate, factory_code):
    conn = get_conn()
    cur = conn.cursor()
    res = dict()
    # def check_update_exist(cur, c_id, bom_code, com_code):
    if check_update_exist(cur, c_id, bom_code, com_code):
        res["status"] = 0
        res["msg"] = u"组件已在该物料组成中"
    else:
        sql = "update " + table_name + " set bom_name='%s', bom_code='%s',com_name='%s', com_code='%s'," \
               "com_cnt=%f, com_unit='%s', com_unit_price=%f, com_rate=%d,factory_code=%d where id=%d" \
              % (bom_name, bom_code, com_name, com_code, float(com_cnt),
                 com_unit, float(com_unit_price), int(com_rate), int(factory_code), int(c_id))
        print(sql)
        cur.execute(sql)
        conn.commit()
        total = cur.rowcount
        cur.close()
        # conn.close()
        res = get_res_dict(total)
    return res
コード例 #7
0
ファイル: bom_product_mgr.py プロジェクト: xjs513/BOM
def update(bom_id, bom_name, bom_code, factory_code):
    conn = get_conn()
    cur = conn.cursor()
    res = dict()
    if check_update_exist(cur, table_name, "bom_name", bom_name, "bom_id",
                          int(bom_id)):
        res["status"] = 0
        res["msg"] = u"物料名称已存在"
    elif check_update_exist(cur, table_name, "bom_code", bom_code, "bom_id",
                            int(bom_id)):
        res["status"] = 0
        res["msg"] = u"物料编码已存在"
    else:
        sql = "update " + table_name + " set bom_name='%s', bom_code='%s', factory_code=%d " \
               "where bom_id=%d" \
              % (bom_name, bom_code, int(factory_code), int(bom_id))
        cur.execute(sql)
        conn.commit()
        total = cur.rowcount
        cur.close()
        # conn.close()
        res = get_res_dict(total)
    return res
コード例 #8
0
def update(bom_id, bom_name, bom_code, bom_rate, bom_unit, bom_unit_price,
           is_produce):
    conn = get_conn()
    cur = conn.cursor()
    res = dict()
    if check_update_exist(cur, table_name, "bom_name", bom_name, "bom_id",
                          int(bom_id)):
        res["status"] = 0
        res["msg"] = u"用料名称已存在"
    elif check_update_exist(cur, table_name, "bom_code", bom_code, "bom_id",
                            int(bom_id)):
        res["status"] = 0
        res["msg"] = u"用料编码已存在"
    else:
        sql = "update " + table_name + " set bom_name='%s', bom_code='%s', bom_rate=%d " \
               " , bom_unit='%s',bom_unit_price=%f, is_produce=%d where bom_id=%d" \
              % (bom_name, bom_code, int(bom_rate), bom_unit, float(bom_unit_price),int(is_produce), int(bom_id))
        cur.execute(sql)
        conn.commit()
        total = cur.rowcount
        cur.close()
        # conn.close()
        res = get_res_dict(total)
    return res