def check_tel(request, tel): sql = "select * from t_supplier where tel=%s" user = db.query_one(sql, args=(tel, )) if user is None: return JsonResponse({"status": True, "msg": ""}) return JsonResponse({"status": False, "msg": "手机号已存在!!"})
def providerupdate(request, pk): if request.method == "GET": sql = "select * from t_supplier where id=%s" data = db.query_one(sql, args=(pk, )) return render(request, "providerupdate.html", {"data": data}) param = request.POST.dict() param.setdefault("id", pk) sql = "update t_supplier set code=%(code)s,s_name=%(s_name)s,contacts=%(contacts)s,tel=%(tel)s,addr=%(addr)s,fax=%(fax)s,create_time=now(),s_desc=%(s_desc)s where id = %(id)s" db.update(sql, args=param) return redirect(to="/providerlist")
def update(request, id): if request.method == 'GET': sql = "select * from t_user where id = %s" user = db.query_one(sql, args=(id, )) return render(request, 'userUpdate.html', {"user": user}) param = request.POST.dict() param.setdefault("id", id) sql = """ update t_user set username=%(username)s,sex=%(sex)s,birth=%(birth)s, tel=%(tel)s,addr=%(addr)s,s_type=%(s_type)s where id = %(id)s """ db.update(sql, args=param) return redirect(to='/user/index')
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")
def billView(request, pk): sql = "select * from t_bill where id=%s" data = db.query_one(sql, args=(pk,)) return render(request, 'billView.html', {"data": data})
def check_code(request, code): sql = "select * from t_bill where code =%s" cod = db.query_one(sql, args=(code,)) if cod is None: return JsonResponse({"status": True, "msg": ""}) return JsonResponse({"status": False, "msg": "账单编码已存在"})
def check_code(request, code): sql = "select * from t_user where code = %s" user = db.query_one(sql, args=(code, )) if user is None: return JsonResponse({"status": True, "msg": ""}) return JsonResponse({"status": False, "msg": "该编码已存在"})
def detail(request, id): sql = "select * from t_user where id = %s" user = db.query_one(sql, args=(id, )) return render(request, 'userDetail.html', {"user": user})
def providerview(request, pk): sql = "select * from t_supplier where id=%s" data = db.query_one(sql, args=(pk, )) return render(request, "providerview.html", {"data": data})