Ejemplo n.º 1
0
    def bank_withdraw(self, account, password, withdraw_money):
        #数据库
        sql5 = "select count(*) from bank where bank.account = %s"
        param5 = [account]
        data5 = Mysql.Select(sql5, param5)

        if data5[0][0] == 1:  #存在
            sql6 = "select count(*) from bank where bank.account = %s and bank.password = %s"
            param6 = [account, password]
            data6 = Mysql.Select(sql6, param6)

            if data6[0][0] == 1:
                sqldx = "select * from bank where bank.account = %s"
                paramdx = [account]
                datadx = Mysql.Select(sqldx, paramdx)
                num = datadx[0][7]
                if num >= withdraw_money:
                    sql7 = "update bank set bank.money =bank.money - %s where bank.money >= %s"
                    param7 = [withdraw_money, withdraw_money]
                    Mysql.Update(sql7, param7)
                    return 0
                else:
                    return 3
            else:
                return 2
        else:
            return 1
Ejemplo n.º 2
0
    def bank_ransferA(self, chu_account, ru_account, password, chu_money):
        sql8 = "select count(account) from bank where bank.account = %s or bank.account = %s"
        param8 = [chu_account, ru_account]
        data8 = Mysql.Select(sql8, param8)

        if data8[0][0] == 2:
            sql9 = "select count(account) from bank where bank.account = %s and bank.password = %s"
            param9 = [chu_account, password]
            data9 = Mysql.Select(sql9, param9)
            if data9[0][0] == 1:
                sqldx1 = "select * from bank where bank.account = %s"
                paramdx1 = [chu_account]
                datadx = Mysql.Select(sqldx1, paramdx1)
                num1 = datadx[0][7]

                if num1 >= chu_money:
                    sql10 = "update bank set bank.money = bank.money - %s where bank.account = %s"
                    param10 = [chu_money, chu_account]
                    Mysql.Update(sql10, param10)
                    sql11 = "update bank set bank.money = bank.money + %s where bank.account = %s"
                    param11 = [chu_money, ru_account]
                    Mysql.Update(sql11, param11)
                    return 0
                else:
                    return 3
            else:
                return 2
        else:
            return 1
Ejemplo n.º 3
0
    def bank_inquire(self, account, password):
        sql12 = "select count(*) from bank where bank.account = %s"
        param12 = [account]
        data12 = Mysql.Select(sql12, param12)
        if data12[0][0] == 1:
            sql13 = "select count(*) from bank where bank.account = %s and bank.password = %s"
            param13 = [account, password]
            data13 = Mysql.Select(sql13, param13)

            if data13[0][0] == 1:
                return 0
            else:
                return 2
        else:
            return 1
Ejemplo n.º 4
0
class Db_to_excel:
    sql = "select * from bank"
    data = Mysql.Select(sql,[])
    for i in data:
        i = list(i)
        ku.append(i)
    print(ku)


    #把数据库信息写入Excel表中
    # 空的工作簿
    wb = xlwt.Workbook()
    # 添加
    sheet = wb.add_sheet("用户管理")
    # 向选项卡里添加数据
    a = 0
    for i in range(len(ku)):

        for j in range(len(ku[i])):
            num = ku[i][j]

            sheet.write(i,j,num)

    # 保存
    wb.save("去往Excel表.xls")
Ejemplo n.º 5
0
    def bank_inquire(self, account, password):
        sql12 = "select count(*) from bank where bank.account = %s"
        param12 = [account]
        data12 = Mysql.Select(sql12, param12)
        if data12[0][0] == 1:
            sql13 = "select count(*) from bank where bank.account = %s and bank.password = %s"
            param13 = [account, password]
            data13 = Mysql.Select(sql13, param13)

            if data13[0][0] == 1:
                return 0
            else:
                return 2
        else:
            return 1


# import random
# from DBUtils import Mysql
# #开户方法
# class AddUser:
#
#     def addUser(self,account,username,password,country,province,street,door,money,bank_name):
#         sql = "select count(*) from bank"
#         data = Mysql.Select(sql,[])  # ((72),(),())
#         if len(data) >= 100:
#             return 3
#
#         sql1 = "select * from bank where account = %s"
#         data1 = Mysql.Select(sql1,account)
#         # 判断是否存在
#         if len(data1) != 0:
#             return 2
#
#         # 准备一条sql语句
#         sql2 = "insert into bank  values(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
#         param2 = [account,username,password,country,province,street,door,0,self.__bank_name]
#         # 让控制台执行sql
#         Mysql.Update(sql2,param2)
#         return 1
Ejemplo n.º 6
0
    def bank_addUser(self, account, username, password, country, province,
                     street, door):
        sql = "select count(*) from bank"
        data = Mysql.Select(sql, [])  # ((72),(),())
        if len(data) >= 100:
            return 3

        sql1 = "select * from bank where account = %s"
        data1 = Mysql.Select(sql1, account)
        # 判断是否存在
        if len(data1) != 0:
            return 2

        # 准备一条sql语句
        sql2 = "insert into bank values(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        param2 = [
            account, username, password, country, province, street, door,
            self.__money, self.__bank_name
        ]
        # 让控制台执行sql
        Mysql.Update(sql2, param2)
        return 1
Ejemplo n.º 7
0
    def bank_deposit(self, account, money):
        #判断有无账户存在

        sql3 = "select count(*) from bank where bank.account = %s"
        param3 = [account]
        data3 = Mysql.Select(sql3, param3)

        if data3[0][0] == 1:
            sql4 = "update bank set money = money + %s where account = %s"
            param4 = [money, account]
            Mysql.Update(sql4, param4)
            return True
        else:
            # print("账户不存在!!!")
            return False
Ejemplo n.º 8
0
def inquire():
    account = utils.inputHelp("转出的账号:")
    user.setPassword(utils.inputHelp("密码:"))

    status4 = bank.bank_inquire(account, user.getPassword())

    if status4 == 0:
        sql14 = "select * from bank where bank.account = %s"
        param14 = [account]
        data14 = Mysql.Select(sql14, param14)
        for i in data14:
            account = data14[0][0]
            username = data14[0][1]
            password = data14[0][2]
            country = data14[0][3]
            province = data14[0][4]
            street = data14[0][5]
            door = data14[0][6]
            money = data14[0][7]
            bank_name = data14[0][8]

            print("当前账号信息:")
            info = '''
                ------------个人信息----------------
                当前当前账号:%s,
                用户名:%s,
                取款密码:%s,
                地址信息:
                    国家:%s,
                    省份:%s,
                    街道:%s, 
                    门牌号:%s,
                余额:%s,
                开户行:%s
                -----------------------------------
            '''

            print(info % (account, username, password, country, province,
                          street, door, money, bank_name))

    if status4 == 1:
        print("该用户不存在!!!")

    if status4 == 2:
        print("密码不正确!!!")