示例#1
0
def updated_category():
    id_dm = request.args.get("id_dm", type=int)
    ten_dm = request.form.get("ten_dm")
    sql = f"update db_danhmuc set ten_dm = N'{ten_dm}'where id_dm = {id_dm}"
    cursor.execute(sql)
    connection.commit()
    return redirect("/admin/category")
示例#2
0
def product():
    id_sach = request.args.get("id_sach", type=int)
    sql = f"SELECT * from search_categories where id_sach = {id_sach};"
    cursor.execute(sql)
    rs = cursor.fetchall()
    sql_lq = f"select * from search_minmax_tacgia WHERE id_dm IN (SELECT id_dm FROM db_sach WHERE id_sach = {id_sach}) or id_tacgia IN (SELECT id_tacgia FROM db_sach WHERE id_sach = {id_sach}) limit 4;"
    cursor.execute(sql_lq)
    lq = cursor.fetchall()
    connection.commit()
    return render_template("product.html", rs=rs, lq=lq)
示例#3
0
def inserted_product():
    ten_sach = request.form.get("ten_sach")
    id_tacgia = request.form.get("id_tacgia")
    gia_sach = request.form.get("gia_sach")
    soluong = request.form.get("soluong")
    so_sao = request.form.get("so_sao")
    mota = request.form.get("mota")
    trang_thai = request.form.get("trang_thai")
    id_dm = request.form.get("id_dm")
    sql = f"insert into db_sach(ten_sach,id_tacgia,gia_sach,soluong,so_sao,mota,trang_thai,id_dm) values(N'{ten_sach}', {id_tacgia}, {gia_sach},{soluong},{so_sao},'{mota}',{trang_thai},{id_dm})"
    cursor.execute(sql)
    connection.commit()
    return redirect("/admin/product")
示例#4
0
def inserted_img():
    img = ""
    id_sach = request.form.get("id_sach")
    for uploaded_file in request.files.getlist("link_img"):
        if uploaded_file.filename != "":
            img = uploaded_file.filename
            print(uploaded_file.filename)
            uploaded_file.save(
                os.path.join("static/imgs", uploaded_file.filename))
            sql = f"insert into img_sach(link_img, id_sach) values('../static/imgs/{img}', '{id_sach}')"
            cursor.execute(sql)
            connection.commit()
    return redirect("/admin/img")
示例#5
0
def updated_product():
    id_sach = request.args.get("id_sach", type=int)
    ten_sach = request.form.get("ten_sach")
    id_tacgia = request.form.get("id_tacgia")
    gia_sach = request.form.get("gia_sach")
    soluong = request.form.get("soluong")
    so_sao = request.form.get("so_sao")
    mota = request.form.get("mota")
    trang_thai = request.form.get("trang_thai")
    id_dm = request.form.get("id_dm")
    sql = f"update db_sach set ten_sach = N'{ten_sach}',id_tacgia={id_tacgia}, gia_sach={gia_sach}, soluong={soluong}, so_sao={so_sao}, mota=N'{mota}', trang_thai={trang_thai},id_dm={id_dm} where id_sach = {id_sach}"
    cursor.execute(sql)
    connection.commit()
    return redirect("/admin/product")
示例#6
0
def updated_img():
    id_img = request.args.get("id_img", type=int)
    id_sach = request.form.get("id_sach")
    img = ""
    for uploaded_file in request.files.getlist("link_img"):
        if uploaded_file.filename != "":
            img = uploaded_file.filename
            print(uploaded_file.filename)
            uploaded_file.save(
                os.path.join("static/imgs", uploaded_file.filename))
    sql = f"update img_sach set link_img = '../static/imgs/{img}', id_sach = '{id_sach}' where id_img = {id_img}"
    cursor.execute(sql)
    connection.commit()
    return redirect("/admin/img")
示例#7
0
def updated():
    id_tacgia = request.args.get("id_tacgia", type=int)
    ten_tacgia = request.form.get("ten_tacgia")
    gioithieu = request.form.get("gioithieu")
    avt_tacgia = ""
    for uploaded_file in request.files.getlist("avt_tacgia"):
        if uploaded_file.filename != "":
            avt_tacgia = uploaded_file.filename
            print(uploaded_file.filename)
            uploaded_file.save(
                os.path.join("static/imgs", uploaded_file.filename))
    sql = f"update db_tacgia set ten_tacgia = N'{ten_tacgia}', avt_tacgia = '../static/imgs/{avt_tacgia}', gioi_thieu = N'{gioithieu}' where id_tacgia = {id_tacgia}"
    cursor.execute(sql)
    connection.commit()
    return redirect("/admin/author")
示例#8
0
def inserted_actor():
    avt = ""
    for uploaded_file in request.files.getlist("avt_tacgia"):
        if uploaded_file.filename != "":
            avt = uploaded_file.filename
            print(uploaded_file.filename)
            uploaded_file.save(
                os.path.join("static/imgs", uploaded_file.filename))

    ten_tacgia = request.form.get("ten_tacgia")
    gioi_thieu = request.form.get("gioithieu")
    sql = f"insert into db_tacgia(ten_tacgia, avt_tacgia, gioi_thieu) values(N'{ten_tacgia}', '../static/imgs/{avt}', N'{gioi_thieu}')"
    cursor.execute(sql)
    connection.commit()
    return redirect("/admin/author")
示例#9
0
def sendData(taskId,userId,output):
    # write output to a new json file
    with open('../output/' + taskId + '.json', 'w') as outfile:
        json.dump(output, outfile)

    # tell the database that we've finished processing
    try:
        cursor = connection.cursor()
        sql = "UPDATE Task SET taskState = 2 WHERE taskId = " + taskId
        cursor.execute(sql)
        connection.commit()

    except Exception as e:
        print(e)

    finally:
        cursor.close()
        connection.close()
示例#10
0
def signup_dk():
    us = request.form.get("user_name")
    pa = request.form.get("pass_word")
    rpa = request.form.get("rpass_word")
    email = request.form.get("email")
    sdt = request.form.get("sdt")

    if len(pa) < 6:
        err = 'Mật khẩu phải lớn hơn 6 kí tự'
    elif pa != rpa:
        err = 'Mật khẩu không trùng nhau'
    else:
        sql = f"select * from db_user where us like '{us}'"
        cursor.execute(sql)
        connection.commit()
        record = cursor.fetchall()
        if len(record) == 0:
            sql_signup = f"insert into db_user(us, email, sdt, pa) values('{us}', '{email}', '{sdt}', '{pa}')"
            cursor.execute(sql_signup)
            connection.commit()
            return redirect("/login")
        else:
            err = 'Tài khoản đã tồn tại'
    return render_template("signup.html", err=err)
示例#11
0
def shop():
    keyword = request.args.get("search", type=str)
    max_s = request.args.get("max", type=int)
    min_s = request.args.get("min", type=int)
    dm = request.args.get("dm", type=int)
    tg = request.args.get("tg", type=int)
    sql = f"SELECT * FROM shop;"
    if keyword != None:
        sql = f"select * from search_keyword WHERE ten_sach LIKE N'%{keyword}%' OR ten_dm LIKE N'%{keyword}%' OR ten_tacgia LIKE N'%{keyword}%';"
    elif max_s != None and min_s != None:
        sql = f"select * from search_minmax_tacgia WHERE gia_sach BETWEEN '{min_s}' AND '{max_s}';"
    elif dm != None:
        sql = f"select * from search_categories where id_dm = {dm};"
    elif tg != None:
        sql = f"select * from search_minmax_tacgia where id_tacgia = {tg};"
    cursor.execute(sql)
    record = cursor.fetchall()
    sql_tacgia = f"select * from db_tacgia;"
    cursor.execute(sql_tacgia)
    record_tacgia = cursor.fetchall()
    sql_count_tacgia = f"select * from count_author"
    cursor.execute(sql_count_tacgia)
    record_count_tacgia = cursor.fetchall()
    sql_danhmuc = f"select * from db_danhmuc;"
    cursor.execute(sql_danhmuc)
    record_danhmuc = cursor.fetchall()
    sql_count_danhmuc = f"select * from count_category"
    cursor.execute(sql_count_danhmuc)
    record_count_danhmuc = cursor.fetchall()
    connection.commit()
    return render_template("shop.html",
                           record_tacgia=record_tacgia,
                           record_count_tacgia=record_count_tacgia,
                           record_danhmuc=record_danhmuc,
                           record_count_danhmuc=record_count_danhmuc,
                           record=record)
示例#12
0
with open(os.path.join(input_subdir, json_name), 'r') as json_file:
    incomingData = json.load(json_file)
    for key, value in incomingData.items():
        if key == 'taskId':
            taskId = value
        elif key == 'userId':
            userId = value
        else:
            boxes.append(value)

# tell the database that we've started processing
try:
    cursor = connection.cursor()
    sql = "UPDATE Task SET taskState = 0 WHERE taskId = " + taskId
    cursor.execute(sql)
    connection.commit()
    cursor.close()

except Exception as e:
    print(e)
    quit()

width, height =  img.shape[:2]
gauges=[]
for box in boxes:
    gaugeType=str(box.get('gaugeType'))
    cx1=int(float(box.get('coordinates').get('start_x'))*height)
    cy1=int(float(box.get('coordinates').get('start_y'))*width)
    cx2=int(float(box.get('coordinates').get('end_x'))*height)
    cy2=int(float(box.get('coordinates').get('end_y'))*width)
    print(cy1)
示例#13
0
def delete_product():
    id_sach = request.args.get("id_sach", type=int)
    sql = f"delete from db_sach where id_sach = {id_sach}"
    cursor.execute(sql)
    connection.commit()
    return redirect("/admin/product")
示例#14
0
def delete():
    id_tacgia = request.args.get("id_tacgia", type=int)
    sql = f"delete from db_tacgia where id_tacgia = {id_tacgia}"
    cursor.execute(sql)
    connection.commit()
    return redirect("/admin/author")
示例#15
0
def delete_category():
    id_dm = request.args.get("id_dm", type=int)
    sql = f"delete from db_danhmuc where id_dm = {id_dm}"
    cursor.execute(sql)
    connection.commit()
    return redirect("/admin/category")
示例#16
0
def inserted_category():
    ten_dm = request.form.get("ten_dm")
    sql = f"insert into db_danhmuc(ten_dm, trang_thai) values(N'{ten_dm}', '1')"
    cursor.execute(sql)
    connection.commit()
    return redirect("/admin/category")
示例#17
0
def delete_img():
    id_img = request.args.get("id_img", type=int)
    sql = f"delete from img_sach where id_img = {id_img}"
    cursor.execute(sql)
    connection.commit()
    return redirect("/admin/img")