Beispiel #1
0
def sousuo(user):
    retval = g.buttonbox(msg="你需要哪种搜索?", title="搜索", choices=\
    ("完成订单数量最多的用户",
     "每个行政区内,共享单车数低于区域内街道平均共享单车数的街道",
     #"对于在某个街道内有骑行记录的用户,找出这些用户的总消费金额",
     "附近单车",
     "xml应用"))
    print retval
    if retval == "完成订单数量最多的用户":
        result = net.sent('sousuo 1')
    elif retval == "每个行政区内,共享单车数低于区域内街道平均共享单车数的街道":
        result = net.sent('sousuo 2')
    #elif retval == "对于在某个街道内有骑行记录的用户,找出这些用户的总消费金额":
        #result = net.sent('sousuo 3')
    elif retval == "附近单车":
        district = ["jiaoxuequ", "shenghuoqu"]
        street = [["lijiao", "erjiao", "yannan"], ["xuewu", "yiyuan"]]
        seed1 = random.randint(0, 1)
        seed2 = random.randint(0, 1)
        dins = district[seed1]
        stre = street[seed1][seed2]
        result = "nearby bike ID: " + net.sent('fujin %s %s' % (dins, stre))
    elif retval == "xml应用":
        district = ["jiaoxuequ", "shenghuoqu"]
        street = [["lijiao", "erjiao", "yannan"], ["xuewu", "yiyuan"]]
        seed1 = random.randint(0, 1)
        seed2 = random.randint(0, 1)
        dins = district[seed1]
        stre = street[seed1][seed2]
        result = net.sent('xml %s %s %s' % (user, dins, stre))
    g.textbox(msg=("搜索结果"), title="搜索结果", text=result)
Beispiel #2
0
def danche():
    while True:
        retval = g.buttonbox(msg="您想要对单车做什么?",
                             title="管理单车",
                             choices=("增加单车", "删除单车", "查询单车"))
        if retval == None:
            break
        if retval == "增加单车":
            fieldNames = ["ID", "type", "state", "cost", "district", "street", "longitude", "latitude"]
            fieldValues = []
            fieldValues = g.multenterbox("填写单车信息", "增加单车", fieldNames)
            if fieldValues == None:
                continue
            if net.sent("jiache " + " ".join(fieldValues)) == "ok":
                g.msgbox("增加成功", title="增加单车")
            else:
                g.msgbox("单车已经存在", title="增加单车")
        elif retval == "删除单车":
            fieldNames = ["ID"]
            fieldValues = []
            fieldValues = g.multenterbox("填写单车信息", "删除单车", fieldNames)
            if fieldValues == None:
                continue
            l = net.sent("shanche " + " ".join(fieldValues))
            if l == "ok":
                g.msgbox("删除成功", title="删除单车")
            elif l == "not_exist":
                g.msgbox("单车不存在", title="删除单车")
        elif retval == "查询单车":
            fieldNames = ["ID"]
            fieldValues = []
            fieldValues = g.multenterbox("填写单车信息", "查询单车", fieldNames)
            if fieldValues == None:
                continue
            l = net.sent("chache " + " ".join(fieldValues)).split()
            if l[0] == "ok":
                s = "单车编号: " + fieldValues[0] + "\n"
                s += "单车类型: " + l[1] + "\n"
                s += "单车状态: " + l[2] + "\n"
                s += "单车单价: " + l[3] + "\n"
                s += "单车区域: " + l[4] + "\n"
                s += "单车街道: " + l[5] + "\n"
                s += "经度: " + l[6] + "\n"
                s += "维度: " + l[7] + "\n"
                g.textbox(msg="单车信息如下:", title="单车信息", text=s)
            elif l[0] == "not_exist":
                g.msgbox("单车不存在", title="删除单车")
    return
Beispiel #3
0
def yonghu():
    while True:
        retval = g.buttonbox(msg="您想要对用户做什么?",
                             title="管理用户",
                             choices=("查看账户", "查看订单", "删除用户"))
        if retval == None:
            break
        if retval == "查看账户":
            fieldval = g.enterbox("请输入您要查看的用户名", title="查看账户")
            if fieldval == None:
                continue
            user.zhanghu(fieldval)
        if retval == "查看订单":
            fieldval = g.enterbox("请输入您要查看的用户名", title="查看订单")
            if fieldval == None:
                continue
            user.dingdan(fieldval)
        elif retval == "删除用户":
            fieldval = g.enterbox("请输入您要删除的用户名", title="删除用户")
            if fieldval == None:
                continue
            l = net.sent("shanchu " + fieldval)
            if l == "ok":
                g.msgbox("删除成功", title="管理用户")
            elif l == "not_exist":
                g.msgbox("用户不存在", title="管理用户")
    return
Beispiel #4
0
def zhanghu(user):
    content = net.sent("zhanghu " + user).split()
    s = ""
    s += "用户名: " + content[0] + "\n"
    s += "性别: " + content[1] + "\n"
    s += "职业: " + content[2] + "\n" 
    s += "用户类型: " + content[3] + "\n"
    s += "账户余额: " + content[4] + "\n"
    g.textbox(msg=("账户信息:"), title="账户信息", text=s)
Beispiel #5
0
def dingdan(user):
    content = net.sent("dingdan " + user)
    res = "用户名: " + user + "\n\n"
    for s in content.strip().split("\n"):
        s2 = s.split()
        res += "订单号: " + s2[0] + "\n"
        res += "单车号: " + s2[1] + "\n"
        res += "是否仍在租借: " + s2[3] + "\n"
        res += "\n"
    g.textbox(msg=("订单信息"), title="订单信息", text=res)
Beispiel #6
0
def chongzhi(user):
    fieldval = g.enterbox("请输入您要充值的金额", title="充值")
    while True:
        if fieldval == None:
            break
        errmsg = ""
        try:
            if float(fieldval) == 0:
                errmsg += "请输入合法的金额数  "
        except:
            errmsg += "请输入合法的金额数  "
        if errmsg == "":
            retval = net.sent("chongzhi " + user + " " + fieldval)
            g.msgbox(msg="充值成功,现在您的账户余额是%s"%retval, title="系统消息")
            break
        fieldval = g.enterbox(errmsg, title="租车界面")
    return
Beispiel #7
0
def zuche(user):
    maxTime = 10
    fieldval = g.enterbox("请输入您要租的单车编号",title="租车界面")
    while True:
        if fieldval == None:
            break
        errmsg = ""
        if fieldval.strip() == "":
            errmsg += "单车号不能为空  "
        if errmsg == "":
            retval = net.sent("zuche " + user + " " + fieldval)
            if retval == "ok":

                def jishi():
                    time.sleep(maxTime)
                    if not finish:
                        g.msgbox("您已经使用了很长时间,请还车", title="系统消息")

                finish = False
                t1 = threading.Thread(target=jishi)
                t1.setDaemon(True)
                t1.start()

                begin_time = time.time()
                g.msgbox(msg="租车成功,到达目的地后请还车,祝您使用愉快",
                         title="系统消息", ok_button="确定")
                finish = True
                end_time = time.time()

                huanche(user, int(end_time - begin_time + 1 - 1e-10))
                break
            elif retval == "used":
                errmsg = "该车已经被人租借"
            elif retval == "not_exist":
                errmsg = "该编号不存在"
            elif retval == "broken":
                errmsg = "该车已经损坏"
            elif retval == "one_bike_only":
                errmsg = "您一次只能租一辆车"
            elif retval == "no_money":
                errmsg = "您已经欠费,请您充值"
        fieldval = g.enterbox(errmsg, title="租车界面")
    return
Beispiel #8
0
def huanche(user, time):
    retval = net.sent("huanche " + user + " " + str(time))
    g.msgbox(msg=("还车成功,扣款%s元,请支付"%retval),
             title="系统消息", ok_button="支付")
    return