コード例 #1
0
ファイル: 银行.py プロジェクト: 143034/python-study
def main():
    #存储用户信息
    #allUsers = {}
    #管理员对象
    view = Admin()
    view.printAdminView()
    if view.adminOption() == -1:
        return -1

    filepath = os.path.join(os.getcwd(), 'allusers.txt')
    f = open(filepath, 'rb')
    allUsers = pickle.load(f)
    print(allUsers)
    atm = ATM(allUsers)

    while True:
        view.sysFunctionView()
        option = input('请输入操作:')
        if option == '1':
            print('开户')
            atm.createUser()
        elif option == '2':
            print('查询')
            atm.searchUserInfo()
        elif option == '3':
            print('取款')
            atm.getMoney()
        elif option == '4':
            print('存款')
            atm.saveMoney()
        elif option == '5':
            print('转账')
            atm.transferMoney()
        elif option == '6':
            print('改密')
            atm.changePasswd()
        elif option == '7':
            print('锁定')
            atm.lockUser()
        elif option == '8':
            print('解锁')
            atm.unlockUser()
        elif option == '9':
            print('补卡')
            atm.newCard()
        elif option == '0':
            print('销户')
            atm.killUser()
        elif option == 'a':
            print('退出')
            if not view.adminOption() == -1:

                #将用户保存到文件中
                #filepath = os.path.join(os.getcwd(), '账户信息.txt')
                f = open(filepath, 'wb')
                pickle.dump(atm.allUsers, f)
                f.close()
                #print(filepath)
                return -1
        time.sleep(2)
コード例 #2
0
def main():
    #存储所有用户的信息
    allUsers = {}

    #管理员对象
    admin = Admin()
    #管理员开机
    admin.printAdminView()
    if admin.adminOption():
        return -1

    #提款机对象
    filePath = os.path.join(os.getcwd(), 'allusers.txt')
    f = open(filePath, 'rb')
    allUsers = pickle.load(f)
    atm = ATM(allUsers)

    while True:
        admin.printSysFunctionView()
        #等待用户的操作
        option = raw_input('请输入您的操作:')
        if option == '1':
            #print '开户'
            atm.createUser()
        elif option == '2':
            #print '查询'
            atm.searchUserInfo()
        elif option == '3':
            #print '取款'
            atm.getMoney()
        elif option == '4':
            print '存款'
        elif option == '5':
            print '转账'
        elif option == '6':
            print '改密'
        elif option == '7':
            #print '锁定'
            atm.lockUser()
        elif option == '8':
            #print '解锁'
            atm.unlockUser()
        elif option == '9':
            print '补卡'
        elif option == '0':
            print '销户'
        elif option == 't':
            if not admin.adminOption():

                #将当前系统中的用户信息保存到文件中
                #path = r'D:\test\bank.txt'
                #filePath = os.path.join(os.getcwd(), 'allusers.txt')
                f = open(filePath, 'wb')
                pickle.dump(atm.allUsers, f)
                f.close()
                return -1

        time.sleep(2)
コード例 #3
0
def main():

    #实例化Admin对象
    admin=Admin()

    #管理员开机(显示系统欢迎界面)
    admin.printaDMINvIEW()

    #验证管理员身份
    if admin.adminOption():
        return

    '''
    序列化allUsers散装数据到程序中还原成为allUsers对象
    '''
    try:
        with open('allUsers.txt','rb') as fr:
            allUsers=pickle.load(fr)
            print(allUsers)
            #实例化ATM对象
            atm=ATM(allUsers)
    except:
        print('except...')

        #实例化ATM对象
        allUsers={}
        atm=ATM(allUsers)

    while 1:
        #如果程序能够执行到此处说明身份信息没问题
        admin.printSysFuncView()
        num=input('请选择您需要执行的操作...')
        if num=='1':
            atm.createUser()
        elif num=='2':
            atm.searchUserInfo()
        elif num=='3':
            atm.getMoney()
        elif num == '4':
            atm.saveMoney()
        elif num == '5':
            atm.transferMoney()
        elif num == '6':
            atm.updatePWD()
        elif num == '7':
            atm.unlockCard()
        elif num == '8':
            atm.lockCard()
        elif num=='t':
            '''
            对象序列化操作:将allUsers对象数据存储到allUser.txt文件中
            '''
            with open('allUser.txt','wb') as fw:
                pickle.dump(atm.allUsers,fw)
            return

        time.sleep(2)
コード例 #4
0
def main():
    # 管理员对象
    view = Admin()
    # 管理员开机
    view.printAdminView()

    if view.adminOption():
        return -1
    print("登陆成功!")
    time.sleep(1)

    #提款机对象
    filePath = os.path.join(os.getcwd(), "alluser.txt")
    f= open(filePath,"rb")
    allUser = pickle.load(f)

    atm=ATM(allUser)


    while True:
        view.printsysFunctionView()
        #等待用户操作
        option =input("请输入您的选择:")
        if option =="1":
            atm.createUser()
            time.sleep(1)
        elif option=="2":
            atm.searchUserInfo()
            time.sleep(1)
        elif option == "3":
            atm.getMoney()
        elif option == "4":
            atm.saveMoney()
        elif option == "5":
            atm.transferMoney()
        elif option == "6":
            print('改密')
        elif option == "7":
            atm.lockUser()
        elif option == "8":
            atm.unlockUser()
        elif option == "9":
            print('补卡')
        elif option == "0":
            print('销户')
        elif option == 'Q':
            if not view.adminOption():

                #将当前的用户信息保存到文件中

                f= open(filePath,"wb")
                pickle.dump(atm.allUser,f)
                f.close()
                print('退出成功!')
                return -1
        time.sleep(2)
コード例 #5
0
def main():
    # 字典写有问题,如果创建的文件中没有数据会报错
    absPath = os.getcwd()  # 获取当前程序文件所在路径
    filepath = os.path.join(absPath,
                            "allusers.txt")  # 在当前路径下创建一个名为alluser.txt的文件
    f = open(filepath, "rb")
    allUsers = pickle.load(f)
    # print(allUsers)

    admin = Admin()
    admin.printAdminView()
    if admin.adminLong():
        return -1
    atm = ATM(allUsers)
    while True:
        print(allUsers)
        admin.printsysFunctionView()
        option = input("请输入您的操作:")
        if option == "1":  #  当用户选择选项后调用ATM类
            #  开户
            atm.createUser()
        elif option == "2":
            #  查询
            atm.searchUserInfo()
        elif option == "3":
            #  取款
            atm.getMoney()
        elif option == "4":
            #  存款
            atm.saveMoney()
        elif option == "5":
            #  转账
            atm.transferMoney()
        elif option == "6":
            #  改密码
            atm.changePasswd()
        elif option == "7":
            #  锁定
            atm.lockUser()
        elif option == "8":
            #  解锁
            atm.unlokUser()
        elif option == "9":
            #  补卡
            atm.newCard()
        elif option == "0":
            #  销户
            atm.killUser()
        elif option == "q":
            #  如果输入的账号和密码正确判定为false就结束程序,如果账号密码是错误的就判断为正确的继续循环执行程序
            if not admin.adminLong():
                f = open(filepath, "wb")
                pickle.dump(atm.allUser, f)
                f.close()
                return -1
コード例 #6
0
def main():
    # 管理员对象
    admin = Admin()
    # 管理员开机
    admin.printAdminView()
    if admin.adminOption():
        return -1
    # 提款机对象
    filepath = os.path.join(os.getcwd(), "allusers1.txt")
    if not os.path.isfile(filepath):
        with open(filepath, 'a') as f1:
            pass
    f = open(filepath, "rb")
    if not f.readline():
        allUsers = {}
    else:
        f.seek(0)
        allUsers = pickle.load(f)
    print("*******")
    print(allUsers)
    atm = ATM(allUsers)
    while True:
        admin.sysFunctionView()
        # 等待用户的操作
        option = input("请输入您的操作:")
        if option == "1":
            atm.createUser()
        elif option == "2":
            atm.searchUserInfo()
        elif option == "3":
            atm.getMoney()
        elif option == "4":
            print("存储")
            atm.saveMoney()
        elif option == "5":
            print("转账")
        elif option == "6":
            print("改密")
        elif option == "7":
            atm.lockUser()
        elif option == "8":
            atm.unlockUser()
        elif option == "9":
            print("补卡")
        elif option == "0":
            print("销户")
        elif option == "t":
            if not admin.adminOption():
                # 将当前系统中的用户信息保存到文件中
                f = open(filepath, "wb")
                pickle.dump(atm.allUsers, f)
                f.close()
                return -1
コード例 #7
0
def main():
    # 管理员对象
    admin = Admin()
    # 管理员开机
    admin.printAdminView()
    if admin.adminOption():
        return -1

    #提款机对象
    filepath = os.path.join(os.getcwd(), "allusers.txt")
    try:
        f = open(filepath, "rb")
        allUsers = pickle.load(f)
        f.close()
    except Exception as e:
        print(e)
        allUsers = {}
    print(allUsers)
    atm = ATM(allUsers)

    while True:
        admin.printSysFunctionView()
        #等待用户的操作
        option = input("请输入您的操作:")
        if option == "1":
            atm.createUser()
        elif option == "2":
            atm.searchUserInfo()
        elif option == "3":
            atm.getMoney()
        elif option == "4":
            atm.saveMoney()
        elif option == "5":
            atm.transferMoney()
        elif option == "6":
            atm.changePasswd()
        elif option == "7":
            atm.lockUser()
        elif option == "8":
            atm.unlockUser()
        elif option == "9":
            atm.newCard()
        elif option == "0":
            atm.killUser()
        elif option == "t":
            if not admin.adminOption():
                #将当前系统中的用户信息保存到文件中
                f = open(filepath, "wb")
                pickle.dump(atm.allUsers, f)
                f.close()
                return -1
        time.sleep(2)
コード例 #8
0
def main():
    #管理员对象
    admin = Admin()
    admin.printAdminView()
    # 数字是0,就会被认为是False 然后函数结束
    if admin.adminOption():
        return -1
    #存储所有用户的信息
    filepath = os.path.join(os.getcwd(), "alluser.data")
    try:
        with open(filepath, "rb") as f:
            allUsers = pickle.load(f)
    except FileNotFoundError:
        allUsers = {}
    atm = ATM(allUsers)

    while True:
        i = os.system("cls")
        admin.sysFunctionView()
        option = input("请输入您的操作:")
        if option == '1':
            atm.createUser()
        elif option == '2':
            atm.searchUserInfo()
            time.sleep(5)
        elif option == '3':
            atm.getMoney()
        elif option == '4':
            atm.saveMoney()
        elif option == '5':
            atm.transferMoney()
        elif option == '6':
            atm.changePasswd()
        elif option == '7':
            atm.lockUser()
        elif option == '8':
            atm.unLockUser()
        elif option == '9':
            atm.newCard()
        elif option == '0':
            atm.killUser()
        elif option == 't':
            if not admin.adminOption():
                print("退出系统")
                return -1
        with open(filepath, "wb") as f:
            pickle.dump(allUsers, f)
        time.sleep(1)
コード例 #9
0
def main():
    #界面对象
    view = View()
    #管理员开机
    view.printAdminView()
    #view.adminOption()
    view.login()
    app = mySql()
    # with open(os.path.join(os.getcwd(), 'pwd.txt'), 'rb')as f:
    #     allUser = pickle.load(f)
    #allUser = {}
    atm = ATM(app)
    # print(allUser)

    while True:
        view.printSysFunctionView()
        #等待用户操作
        option = input("请输入您的操作: ")
        if option == '1':
            atm.createUser()
        elif option == '2':
            atm.searchUserInfo()
        elif option == '3':
            atm.getMoney()
        elif option == '4':
            atm.saveMoney()
        elif option == '5':
            atm.transferMoney()
        elif option == '6':
            atm.changePwd()
        elif option == '7':
            atm.lockUser()
        elif option == '8':
            atm.unlockUser()
        elif option == '9':
            atm.newCard()
        elif option == '0':
            atm.killUser()
        elif option == 't':
            return -1

            # if not view.adminOption():
            #     with open(os.path.join(os.getcwd(), 'pwd.txt'), 'wb')as f1:
            #         pickle.dump(allUser, f1)
            #     return -1

        time.sleep(2)
コード例 #10
0
ファイル: bank.py プロジェクト: goddess5321/python_bank-1
def main():
    admin = Admin()
    admin.adminView()
    if admin.adminLogin():
        return -1
    path = os.path.join(os.getcwd(), 'allUsers.txt')
    f = open(path, 'rb')
    allUsers = pickle.load(f)
    atm = ATM(allUsers)

    while True:
        admin.sysFunctionView()
        # 等待用户的操作
        option = input('请选择业务:')
        if option == '1':
            # outer装饰器,装饰createUser
            atm.outer(atm.createUser)
        elif option == '2':
            atm.searchInfo()
        elif option == '3':
            atm.getMoney()
        elif option == '4':
            atm.saveMoney()
        elif option == '5':
            atm.transferMoney()
        elif option == '6':
            atm.changePasswd()
        elif option == '7':
            atm.lockUser()
        elif option == '8':
            atm.unlockUser()
        elif option == '9':
            atm.report()
        elif option == '0':
            atm.destory()
        elif option == 'q':
            if not admin.adminLogin():
                path = os.path.join(os.getcwd(), 'allUsers.txt')
                f = open(path, 'wb')
                pickle.dump(atm.allUsers, f)
                f.close()
                return -1
        elif option == 'a':
            atm.admin()

        time.sleep(2)
コード例 #11
0
def main():

    admin = Admin()

    if admin.adminOption():
        return -1

    # admin.printAdminView()
    # path = r"/home/intfreedom/PycharmProjects/identify/20180628/allUsers.txt"
    filepath = os.path.join(os.getcwd(), 'allusers.txt')
    # f = open(path, "rb")
    f = open(filepath, "rb")
    allUsers = pickle.load(f)
    # print("**********")
    # print(allUsers)
    # allUsers = {}
    atm = ATM(allUsers)

    while True:
        admin.printSysFunctionView()
        option = input("please input your move:")
        if option == "1":
            atm.createUser()
            print("kaihu")
        elif option == "2":
            atm.searchUserInfo()
            print("cunkuan")
        elif option == "3":
            atm.getMoney()
        elif option == "7":
            atm.lockUser()
        elif option == "t":
            if not admin.adminOption():

                filepath = os.path.join(os.getcwd(), 'allusers.txt')
                f = open(filepath, "wb")
                #     filepath = os.path.join(filepath, 'allusers.txt' )
                #     # print(filepath)
                #     f = open(filepath, "wb")
                pickle.dump(atm.allUsers, f)
                f.close()
                return -1

        time.sleep(2)
コード例 #12
0
def main():
    #界面对象
    admin = Admin()
    #用户管理员开机
    admin.printadminView()
    if admin.adminOption():
        return -1

    #提款机对象

    filePath = os.path.join(os.getcwd(), "alluser.txt")

    f = open(filePath,"rb")
    allUsers = pickle.load(f)
    print("*********")
    print(allUsers)
    atm = ATM(allUsers)





    while True:

        admin.printSysFunctionView()
        #启动后等待用户操作
        option = input("请输入您的操作:")
        if option =="1":
            atm.createUser()

        elif option == "2":
            atm.searchUserInfo()

        elif option == "3":
            atm.getMoney()

        elif option == "4":
            print("存款")

        elif option == "5":
            print("转账")

        elif option == "6":
            print("改密码")

        elif option == "7":
            atm.lockUser()

        elif option == "8":
            atm.unlockUser()

        elif option == "9":
            print("补卡")

        elif option == "0":
            print("销户")

        elif option == "q":
            if not admin.adminOption():
                #将当前系统中的用户信息保存到文件中

                f = open(filePath,"wb")
                pickle.dump(atm.allUsers,f)
                f.close()
                return -1



        time.sleep(2)
コード例 #13
0
def main():

    #管理员界面对象
    admin = Admin()

    #管理员登录界面
    admin.printAdminView()
    if admin.adminOption():
        return -1

    #提款机
    filepath = os.path.join(os.getcwd(), "alluser.txt")
    f = open(filepath, "rb")
    allUsers = pickle.load(f)
    print(allUsers)
    atm = ATM(allUsers)

    #功能界面
    while True:
        admin.printSysView()
        option = input("请输入您的操作:")
        if option == "1":
            print("开户")
            atm.createUser()
            time.sleep(1)

        elif option == "2":
            print("查询")
            atm.searchUserInfo()
            time.sleep(1)

        elif option == "3":
            print("取款")
            atm.getMoney()
            time.sleep(1)

        elif option == "4":
            print("存款")
            atm.saveMoney()
            time.sleep(1)

        elif option == "5":
            print("转账")
            atm.transferMoney()
            time.sleep(1)

        elif option == "6":
            print("改密")

        elif option == "7":
            print("锁卡")
            atm.lockUser()
            time.sleep(1)

        elif option == "8":
            print("解锁")
            atm.unlockUser()
            time.sleep(1)

        elif option == "9":
            print("补卡")

        elif option == "0":
            print("销户")

        elif option == "q":
            if not admin.adminOption():
                f = open(filepath, "wb")
                pickle.dump(atm.allUsers, f)
                f.close
                return -1

    time.sleep(2)
コード例 #14
0
ファイル: banksystem.py プロジェクト: Sycoi/bank
view = View("hss",'666')
view.interface()
atm = ATM()
view.login()
while True:
    view.funcInterface()
    choice = input("请选择您要办理的业务:")
    if choice == '1':
        atm.newAccount()
    elif choice == '2':
        atm.checkMoney()
    elif choice == '3':
        atm.saveMoney()
    elif choice == '4':
        atm.getMoney()
    elif choice == '5':
        atm.transferMoney()
    elif choice == '6':
        atm.changePassword()
    elif choice == '7':
        atm.lockAccount()
    elif choice == '8':
        atm.unlockAccount()
    # elif choice == '9':
    #     atm.reissueCard()
    elif choice == '9':
        atm.closeAccount()
    # elif choice == 'R'
    #     atm.ruturn()
    elif choice == 'Q':