Esempio n. 1
0
def inquire_bank(account, password):
    a = Money()
    database = a.getDatabase()
    if account in database:
        if password == database[account]["password"]:
            info = '''
                            ----------------账户信息----------------
                            账号:{account}
                            姓名:{username}
                            密码:{password}
                            地址信息:{adress}
                            余额:{money}
                            开户行名称:{bank_name}
                            开户时间:{time}
                            ----------------------------------------
                        '''
            print("以下是您的账户信息:")
            print(
                info.format(account=account,
                            username=database[account]["username"],
                            password=database[account]["password"],
                            adress=database[account]["address"],
                            money=database[account]["money"],
                            bank_name=database[account]["bank_name"],
                            time=database[account]["time"]))
        else:
            print("账号密码错误!")
    else:
        print("账号不存在!")
Esempio n. 2
0
def getmoney():
    file = open("users.txt", "r+", encoding="utf-8")
    a = Money()
    account = input("请输入账号:")
    password = input("请输入密码:")
    database = a.getDatabase()
    names = file.readlines()
    for item in names:
        its = item.split(",")
        database[its[0]] = {
            "account": its[0],
            "username": its[1],
            "password": its[2],
            "country": its[3],
            "province": its[4],
            "street": its[5],
            "door": its[6],
            "money": int(its[7]),
            "bank_name": its[8],
            "time": its[9]
        }
    file.close()
    status = a.getmoney_bank(account, password)
    if status == 1:
        print("账号不存在!")
    elif status == 2:
        print("账号或密码错误!")
    elif status == 3:
        print("余额不足!")
    else:
        print("取款成功!您的余额为:", database[account]["money"])
Esempio n. 3
0
def getmoney():
    a = Money()
    account = input("请输入账号:")
    password = input("请输入密码:")
    database = a.getDatabase()
    status = getmoney_bank(account, password)
    if status == 1:
        print("账号不存在!")
    elif status == 2:
        print("账号或密码错误!")
    elif status == 3:
        print("余额不足!")
    else:
        print("取款成功!您的余额为:", database[account]["money"])
Esempio n. 4
0
def bank_addUser(account, username, password, money, time, bank, address):
    a = Money()
    database = a.getDatabase()
    if len(database) >= 100:
        return 3
    elif account in database:
        return 2
    else:  # account : {username:username,password:password,.....}
        database[account] = {
            "username": username,
            "password": password,
            "address": address,
            "money": money,
            "bank_name": bank,
            "time": time
        }
        a.setDatabase(database)
        return 1
Esempio n. 5
0
def addUser():
    a = User()
    b = Money()
    database = b.getDatabase()
    account = a.getAccount()
    a.setUsername()
    username = a.getUsername()
    a.setPassword()
    password = a.getPassword()
    print("下面输入地址:")
    adress = a.address()
    a.setMoney()
    money = a.getMoney()
    time = a.getTime()
    bank = a.getBank_name()
    status = bank_addUser(account, username, password, money, time, bank,
                          adress)
    if status == 3:
        print("对不起,本银行用户库已满,请携带证件到其他银行办理!")
    elif status == 2:
        print("对不起,您的个人信息已存在!请稍后再试!")
    elif status == 1:
        info = '''
                ----------------开户信息----------------
                账号:{account}
                姓名:{username}
                密码:{password}
                地址信息:{adress}
                余额:{money}
                开户行名称:{bank_name}
                开户时间:{time}
                ----------------------------------------
            '''
        print("恭喜!开户成功!一下是您的开户信息:")

        # 获取银行的个人信息
        print(
            info.format(account=account,
                        username=database[account]["username"],
                        password=database[account]["password"],
                        adress=database[account]["address"],
                        money=database[account]["money"],
                        bank_name=database[account]["bank_name"],
                        time=database[account]["time"]))
Esempio n. 6
0
def move():
    file = open("users.txt", "r+", encoding="utf-8")
    a = Money()
    account = input("请输入账号:")
    password = input("请输入密码:")
    account1 = input("请输入转入账号:")
    money = input("请输入转账金额:")
    while True:
        if money.isdigit():
            money = int(money)
            break
        else:
            print("输入非法重新输入:")
            money = input("请输入转账金额:")
    database = a.getDatabase()
    names = file.readlines()
    for item in names:
        its = item.split(",")
        database[its[0]] = {
            "account": its[0],
            "username": its[1],
            "password": its[2],
            "country": its[3],
            "province": its[4],
            "street": its[5],
            "door": its[6],
            "money": int(its[7]),
            "bank_name": its[8],
            "time": its[9]
        }
    file.close()
    status = a.move_bank(account, account1, password, money)
    if status == 1:
        print("输入的转入账号不存在!")
    elif status == 2:
        print("账号密码错误!")
    elif status == 3:
        print("余额不足!")
    elif status == 4:
        print("账号不存在!")
    else:
        print("转账成功!您的余额为:", database[account]["money"])
Esempio n. 7
0
def move_bank(account, account1, password, money):
    a = Money()
    database = a.getDatabase()
    if account in database:
        if account1 in database:
            if password == database[account]["password"]:
                if money > database[account]["money"]:
                    return 3
                else:
                    database[account][
                        "money"] = database[account]["money"] - money
                    database[account1][
                        "money"] = database[account1]["money"] + money
                    return 0
            else:
                return 2
        else:
            return 1
    else:
        print("账号不存在!")
Esempio n. 8
0
def save():
    a = Money()
    account = input("请输入账号:")
    password = input("请输入密码:")
    database = a.getDatabase()
    if account in database:
        if password == database[account]["password"]:
            money = input("请输入金额:")
            while True:
                if money.isdigit():
                    money = int(money)
                    break
                else:
                    print("输入非法重新输入:")
                    money = input("请输入余额:")
            if save_bank(account, money):
                print("存款成功!您的余额为:", database[account]["money"])
        else:
            print("账号或密码错误!")
    else:
        print("账号不存在!")
Esempio n. 9
0
def getmoney_bank(account, password):
    a = Money()
    database = a.getDatabase()
    if account in database:
        if password == database[account]["password"]:
            money = input("请输入金额:")
            while True:
                if money.isdigit():
                    money = int(money)
                    break
                else:
                    print("输入非法重新输入:")
                    money = input("请输入金额:")
            if money > database[account]["money"]:
                return 3
            else:
                database[account]["money"] = database[account]["money"] - money
                return 0
        else:
            return 2
    else:
        return 1
Esempio n. 10
0
def save():
    file = open("users.txt", "r+", encoding="utf-8")
    a = Money()
    account = input("请输入账号:")
    password = input("请输入密码:")
    database = a.getDatabase()
    names = file.readlines()
    for item in names:
        its = item.split(",")
        database[its[0]] = {
            "account": its[0],
            "username": its[1],
            "password": its[2],
            "country": its[3],
            "province": its[4],
            "street": its[5],
            "door": its[6],
            "money": int(its[7]),
            "bank_name": its[8],
            "time": its[9]
        }
    file.close()

    if account in database:
        if password == database[account]["password"]:
            money = input("请输入金额:")
            while True:
                if money.isdigit():
                    money = int(money)
                    break
                else:
                    print("输入非法重新输入:")
                    money = input("请输入余额:")
            if a.save_bank(account, money):
                print("存款成功!您的余额为:", database[account]["money"])
        else:
            print("账号或密码错误!")
    else:
        print("账号不存在!")
Esempio n. 11
0
def move():
    a = Money()
    account = input("请输入账号:")
    password = input("请输入密码:")
    account1 = input("请输入转入账号:")
    money = input("请输入转账金额:")
    while True:
        if money.isdigit():
            money = int(money)
            break
        else:
            print("输入非法重新输入:")
            money = input("请输入转账金额:")
    database = a.getDatabase()
    status = move_bank(account, account1, password, money)
    if status == 1:
        print("输入的转入账号不存在!")
    elif status == 2:
        print("账号密码错误!")
    elif status == 3:
        print("余额不足!")
    else:
        print("转账成功!您的余额为:", database[account]["money"])
Esempio n. 12
0
def inquire():
    file = open("users.txt", "r+", encoding="utf-8")
    a = Money()
    account = input("请输入账号:")
    password = input("请输入密码:")
    database = a.getDatabase()
    names = file.readlines()
    for item in names:
        its = item.split(",")
        database[its[0]] = {
            "account": its[0],
            "username": its[1],
            "password": its[2],
            "country": its[3],
            "province": its[4],
            "street": its[5],
            "door": its[6],
            "money": int(its[7]),
            "bank_name": its[8],
            "time": its[9]
        }
    file.close()
    a.inquire_bank(account, password)
Esempio n. 13
0
def save_bank(account, money):
    a = Money()
    database = a.getDatabase()
    database[account]["money"] = database[account]["money"] + money
    return True
Esempio n. 14
0
def addUser():
    file = open("users.txt", "r+", encoding="utf-8")
    c = Money()
    account = getRandom()
    username = input("请输入姓名:")
    while True:
        password = input("请输入密码:")
        if len(password) != 6:
            print("输入不等于6位")
        else:
            if password.isdigit():
                break
            else:
                print("输入非法!")
    print("下面输入地址:")
    country = input("国家:")
    province = input("省份:")
    street = input("街道:")
    door = input("门牌号:")
    money = input("请输入余额:")
    while True:
        if money.isdigit():
            money = int(money)
            break
        else:
            print("输入非法重新输入:")
            money = input("请输入余额:")
    time1 = time.asctime(time.localtime(time.time()))
    bank = "中国工商银行昌平支行"
    address = Address(country, province, street, door)
    a = User(account, username, password, money, time1, bank, address)
    status = c.bank_addUser(a.getAccount(), a.getUsername(), a.getPassword(),
                            a.getMoney(), a.getTime(), a.getBank_name(),
                            a.getAddress().getCountry(),
                            a.getAddress().getProvince(),
                            a.getAddress().getStreet(),
                            a.getAddress().getDoor())
    if status == 3:
        print("对不起,本银行用户库已满,请携带证件到其他银行办理!")
    elif status == 2:
        print("对不起,您的个人信息已存在!请稍后再试!")
    elif status == 1:
        info = '''
                ----------------开户信息----------------
                账号:{account}
                姓名:{username}
                密码:{password}
                地址信息:
                    国家:{country}
                    省份:{province}
                    街道:{street}
                    门牌号:{door}
                余额:{money}
                开户行名称:{bank_name}
                开户时间:{time}
                ----------------------------------------
            '''
        print("恭喜!开户成功!以下是您的开户信息:")
        database = c.getDatabase()
        # 获取银行的个人信息
        print(
            info.format(account=account,
                        username=database[account]["username"],
                        password=database[account]["password"],
                        country=database[account]["country"],
                        province=database[account]["province"],
                        street=database[account]["street"],
                        door=database[account]["door"],
                        money=database[account]["money"],
                        bank_name=database[account]["bank_name"],
                        time=database[account]["time"]))
    file.close()