예제 #1
0
파일: views.py 프로젝트: yin13221/test2
def query(request):
    sql = "select * from t_supplier"
    sup = db.query_list(sql)
    s_name = request.POST.dict()["s_name"]
    sup_name = request.POST.dict()["sup_name"]
    state = request.POST.dict()["state"]
    # sql = "select * from t_bill where s_name like %s and sup_name = %s  and state = %s order  by code"
    if s_name != '' and sup_name != '' and state != '':
        sql = "select * from t_bill where s_name  like %s and  sup_name=%s and state=%s order  by  code"
        data = db.query_list(sql, args=(f"%{s_name}%", sup_name, state))
    elif s_name != '' and sup_name != '' and state == '':
        sql = "select * from t_bill where s_name like %s and sup_name=%s  order  by  code"
        data = db.query_list(sql, args=(f"%{s_name}%", sup_name))
    elif s_name != '' and sup_name == '' and state != '':
        sql = "select * from t_bill where s_name  like %s and state=%s order  by  code"
        data = db.query_list(sql, args=(f"%{s_name}%", state))
    elif s_name == '' and sup_name != '' and state != '':
        sql = "select * from t_bill where  sup_name = %s and state=%s order  by  code"
        data = db.query_list(sql, args=(sup_name, state))
    elif s_name != '' and sup_name == '' and state == '':
        sql = "select * from t_bill where s_name like %s order  by  code"
        data = db.query_list(sql, args=(f"%{s_name}%",))
    elif s_name == '' and sup_name != '' and state == '':
        sql = "select * from t_bill where  sup_name = %s order  by  code"
        data = db.query_list(sql, args=(sup_name,))
    elif s_name == '' and sup_name == '' and state != '':
        sql = "select * from t_bill where state = %s order  by  code"
        data = db.query_list(sql, args=(state,))
    else:
        sql = "select * from t_bill where s_name like %s order  by  code"
        data = db.query_list(sql, args=(f"%{s_name}%",))
    return render(request, "billList.html", {"data": data, "sup": sup})
예제 #2
0
파일: views.py 프로젝트: yin13221/test2
def billAdd(request):
    if request.method == "GET":
        sql = "select * from t_supplier"
        sup = db.query_list(sql)
        return render(request, 'billAdd.html', {"sup": sup})
    param = request.POST.dict()
    sql = """
           insert into t_bill(code,s_name,unit,num,price,sup_name,state)
           values(%(code)s,%(s_name)s,%(unit)s,%(num)s,%(price)s,%(sup_name)s,%(state)s)
       """
    db.update(sql, args=param)
    return redirect(to="/billList")
예제 #3
0
파일: views.py 프로젝트: yin13221/test2
def billUpdate(request, pk):
    if request.method == "GET":
        sql = "select * from t_bill where  id=%s"
        data = db.query_one(sql, args=(pk,))
        sql = "select * from t_supplier"
        sup = db.query_list(sql)
        return render(request, 'billUpdate.html', {"data": data, "sup": sup})
    param = request.POST.dict()
    param.setdefault("id", pk)
    sql = """
          update t_bill set code = %(code)s, s_name = %(s_name)s ,unit = %(unit)s ,num = %(num)s, price = %(price)s,
          sup_name = %(sup_name)s ,state = %(state)s where id = %(id)s
       """
    db.update(sql, args=param)
    return redirect(to="/billList")
예제 #4
0
파일: views.py 프로젝트: yin13221/test2
def search(request):
    sear = request.POST.dict()["sear"]
    sql = "select * from t_user where username like %s order by code"
    user = db.query_list(sql, args=(f"%{sear}%", ))
    return render(request, 'userIndex.html', {"user": user})
예제 #5
0
파일: views.py 프로젝트: yin13221/test2
def index(request):
    sql = "select t.id,t.code,t.username,t.sex,t.birth,t.tel,t.s_type from t_user t order by t.code"
    user = db.query_list(sql)
    return render(request, 'userIndex.html', {"user": user})
예제 #6
0
파일: views.py 프로젝트: yin13221/test2
def search(request):
    search = request.POST.dict()["search"]
    sql = "select * from t_supplier where s_name like %s order by code"
    data = db.query_list(sql, args=(f"%{search}%", ))
    return render(request, "providerlist.html", {"data": data})