parent
abcabd757a
commit
483fc9e741
@ -0,0 +1,99 @@
|
||||
import wx
|
||||
import pymysql
|
||||
from MySQL import Make_bill, function
|
||||
import threading
|
||||
import time
|
||||
|
||||
|
||||
class Deposit1(wx.App):
|
||||
def doClose(self, j):
|
||||
time.sleep(j)
|
||||
self.frame.Close()
|
||||
|
||||
def __init__(self, YuanZhangH):
|
||||
|
||||
self.YuanZhangH = YuanZhangH
|
||||
wx.App.__init__(self)
|
||||
self.frame = wx.Frame(parent=None, title='存 款', size=(535, 450),
|
||||
style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER ^ wx.MAXIMIZE_BOX)
|
||||
|
||||
panel = wx.Panel(self.frame, -1)
|
||||
panel.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBack)
|
||||
label_pass = wx.StaticText(panel, -1, "存款金额:", pos=(80, 200))
|
||||
# style 为设置输入
|
||||
self.JinE = wx.TextCtrl(panel, -1, size=(250, 35), pos=(140, 190))
|
||||
|
||||
self.QueDing_button = wx.Button(panel, -1, "确 认", size=(80, 60), pos=(120, 280))
|
||||
self.QuXiao_button = wx.Button(panel, -1, "返 回", size=(80, 60), pos=(340, 280))
|
||||
|
||||
self.QueDing_button.SetBackgroundColour('#0a74f7')
|
||||
self.QuXiao_button.SetBackgroundColour('#0a74f7')
|
||||
|
||||
self.Bind(wx.EVT_BUTTON, self.CunK, self.QueDing_button)
|
||||
self.Bind(wx.EVT_BUTTON, self.QU, self.QuXiao_button)
|
||||
|
||||
self.frame.Center()
|
||||
self.frame.Show(True)
|
||||
|
||||
def show_message(self, word=""):
|
||||
dlg = wx.MessageDialog(None, word, u"错误", wx.YES_NO | wx.ICON_QUESTION)
|
||||
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
# self.Close(True)
|
||||
pass
|
||||
dlg.Destroy()
|
||||
|
||||
def show_check(self, word=""):
|
||||
dlg = wx.MessageDialog(None, word, u"提示", wx.YES_NO | wx.ICON_QUESTION)
|
||||
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
# self.Close(True)
|
||||
pass
|
||||
dlg.Destroy()
|
||||
|
||||
def QU(self, event):
|
||||
t = threading.Thread(target=self.doClose, args=(0.05,))
|
||||
t.start()
|
||||
jie = function.Jiemian(self.YuanZhangH)
|
||||
jie.MainLoop()
|
||||
|
||||
def CunK(self, event):
|
||||
# 连接到本地数据库
|
||||
|
||||
z2 = self.JinE.GetValue()
|
||||
YuanZhangH = self.YuanZhangH
|
||||
# sql = """ UPDATE card set 余额=余额+z2 WHERE Card_Number= '%s' """ % (z1)
|
||||
sql = "update card set 余额 = 余额+'{}' where Card_Number = '{}'".format(float(z2), YuanZhangH)
|
||||
|
||||
# 判断,查看用户名和密码名是否为空
|
||||
# 不为空之后在进行查询和判断
|
||||
# 不然当密码或用户名为空时会出现会导致出错
|
||||
if z2:
|
||||
db = pymysql.connect(host="localhost", user="root",
|
||||
password="lwh20021210...", db="atm", port=3306)
|
||||
# 使用cursor()方法获取操作游标
|
||||
cur = db.cursor()
|
||||
try:
|
||||
cur.execute(sql) # 执行sql语句
|
||||
db.commit()
|
||||
Make_bill.Make_Bill(YuanZhangH, "存款", float(z2), "无")
|
||||
self.show_check(word='存款成功')
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
|
||||
|
||||
finally:
|
||||
|
||||
db.close() # 关闭连接
|
||||
else:
|
||||
self.show_message(word='存款金额不能为空')
|
||||
|
||||
def OnEraseBack(self, event):
|
||||
dc = event.GetDC()
|
||||
if not dc:
|
||||
dc = wx.ClientDC(self)
|
||||
rect = self.GetUpdateRegion().GetBox()
|
||||
dc.SetClippingRect(rect)
|
||||
dc.Clear()
|
||||
bmp = wx.Bitmap('img\\instagram.jpg')
|
||||
dc.DrawBitmap(bmp, 0, 0)
|
@ -0,0 +1,95 @@
|
||||
import wx
|
||||
import pymysql, threading, time
|
||||
from MySQL import function
|
||||
|
||||
|
||||
class Gaim1(wx.App):
|
||||
def doClose(self, j):
|
||||
time.sleep(j)
|
||||
self.frame.Close()
|
||||
|
||||
def __init__(self, YuanZhangH):
|
||||
|
||||
self.YuanZhangH = YuanZhangH
|
||||
wx.App.__init__(self)
|
||||
self.frame = wx.Frame(parent=None, title='修改密码', size=(535, 450),
|
||||
style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER ^ wx.MAXIMIZE_BOX)
|
||||
panel = wx.Panel(self.frame, -1)
|
||||
panel.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBack)
|
||||
label_user = wx.StaticText(panel, -1, "密 码:", pos=(80, 160))
|
||||
label_pass = wx.StaticText(panel, -1, "确认密码:", pos=(80, 215))
|
||||
self.mim = wx.TextCtrl(panel, -1, size=(250, 35), pos=(140, 150), style=wx.TE_PASSWORD)
|
||||
# style 为设置输入
|
||||
self.qmim = wx.TextCtrl(panel, -1, size=(250, 35), pos=(140, 205), style=wx.TE_PASSWORD)
|
||||
|
||||
self.QueDing_button = wx.Button(panel, -1, "修 改", size=(80, 60), pos=(120, 280))
|
||||
self.QuXiao_button = wx.Button(panel, -1, "返 回", size=(80, 60), pos=(340, 280))
|
||||
|
||||
self.QueDing_button.SetBackgroundColour('#0a74f7')
|
||||
self.QuXiao_button.SetBackgroundColour('#0a74f7')
|
||||
|
||||
self.Bind(wx.EVT_BUTTON, self.Xiu, self.QueDing_button)
|
||||
self.Bind(wx.EVT_BUTTON, self.QU, self.QuXiao_button)
|
||||
|
||||
self.frame.Center()
|
||||
self.frame.Show(True)
|
||||
|
||||
def show_message(self, word=""):
|
||||
dlg = wx.MessageDialog(None, word, u"错误", wx.YES_NO | wx.ICON_QUESTION)
|
||||
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
# self.Close(True)
|
||||
pass
|
||||
dlg.Destroy()
|
||||
|
||||
def show_check(self, word=""):
|
||||
dlg = wx.MessageDialog(None, word, u"提示", wx.YES_NO | wx.ICON_QUESTION)
|
||||
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
# self.Close(True)
|
||||
pass
|
||||
dlg.Destroy()
|
||||
|
||||
def Xiu(self, event):
|
||||
YuanZhangH = self.YuanZhangH
|
||||
z1 = self.mim.GetValue()
|
||||
z2 = self.qmim.GetValue()
|
||||
sql = "update card set password = '{}' where Card_Number = '{}'".format(z1, YuanZhangH)
|
||||
if z1 and z2:
|
||||
db = pymysql.connect(host="localhost", user="root",
|
||||
password="lwh20021210...", db="atm", port=3306)
|
||||
# 使用cursor()方法获取操作游标
|
||||
cur = db.cursor()
|
||||
try:
|
||||
if z1 == z2:
|
||||
cur.execute(sql) # 执行sql语句
|
||||
db.commit()
|
||||
self.show_check(word='密码修改成功')
|
||||
results = cur.fetchall() # 获取查询的所有记录
|
||||
# 返回值是一个元组的形式
|
||||
else:
|
||||
self.show_message(word='请确保两次输入密码相同')
|
||||
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
|
||||
|
||||
finally:
|
||||
db.close() # 关闭连接
|
||||
pass
|
||||
|
||||
def OnEraseBack(self, event):
|
||||
dc = event.GetDC()
|
||||
if not dc:
|
||||
dc = wx.ClientDC(self)
|
||||
rect = self.GetUpdateRegion().GetBox()
|
||||
dc.SetClippingRect(rect)
|
||||
dc.Clear()
|
||||
bmp = wx.Bitmap('img\\instagram.jpg')
|
||||
dc.DrawBitmap(bmp, 0, 0)
|
||||
|
||||
def QU(self, event):
|
||||
t = threading.Thread(target=self.doClose, args=(0.05,))
|
||||
t.start()
|
||||
jie = function.Jiemian(self.YuanZhangH)
|
||||
jie.MainLoop()
|
@ -0,0 +1,38 @@
|
||||
import random
|
||||
import time
|
||||
import pymysql
|
||||
|
||||
class Make_Bill():
|
||||
def __init__(self, Num, stt, val, Mnum):
|
||||
self.Num = Num
|
||||
self.stt = stt
|
||||
self.val = val
|
||||
self.Mnum = Mnum
|
||||
self.Make(self.Num)
|
||||
def makeid(self):
|
||||
return int(random.uniform(10000001, 10999999))
|
||||
def Make(self, Num):
|
||||
|
||||
sql = "SELECT card类型,Card_Number FROM card WHERE Card_Number = %s" % (self.Num)
|
||||
db = pymysql.connect(host="localhost", user="root",
|
||||
password="lwh20021210...", db="atm", port=3306)
|
||||
cur = db.cursor()
|
||||
try:
|
||||
cur.execute(sql) # 执行sql语句
|
||||
results = cur.fetchall()
|
||||
print(type(results))
|
||||
YH = results[0][0]
|
||||
YC = results[0][1]
|
||||
tim = time.strftime('%Y-%m-%d %H:%M:%S ', time.localtime(time.time()))
|
||||
sql2 = "INSERT INTO bill VALUES ('%s',%s, '%s','%s', %s,'%s','%s')" % (
|
||||
tim, self.makeid(), YH, self.stt, self.val, YC, self.Mnum)
|
||||
cur.execute(sql2)
|
||||
db.commit()
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
finally:
|
||||
|
||||
db.close() # 关闭连接
|
||||
|
||||
# MM=Make_Bill("62155504510128","转账",1000,"62155504510112")
|
||||
|
@ -0,0 +1,95 @@
|
||||
import wx, threading, time
|
||||
import pymysql
|
||||
from MySQL import function
|
||||
|
||||
|
||||
class Query(wx.App):
|
||||
def doClose(self, j):
|
||||
time.sleep(j)
|
||||
self.frame.Close()
|
||||
|
||||
def __init__(self, card):
|
||||
self.card = card
|
||||
wx.App.__init__(self)
|
||||
self.frame = wx.Frame(parent=None, title='查询', size=(700, 600),
|
||||
style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER ^ wx.MAXIMIZE_BOX)
|
||||
|
||||
self.panel = wx.Panel(self.frame, -1)
|
||||
self.panel.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBack)
|
||||
|
||||
self.tex1 = wx.StaticText(self.panel, -1,
|
||||
"交易时间 订 单 ID 所属银行 交易类型 交易金额 账户信息 目标账户",
|
||||
pos=(70, 220))
|
||||
# self.entry_tim = wx.TextCtrl(panel,-1,size=(150,35), pos=(120,120))
|
||||
# self.entry_ztim = wx.TextCtrl(panel,-1, size=(150,35), pos=(370,120))
|
||||
|
||||
self.button = wx.Button(self.panel, -1, "查 询", size=(100, 35), pos=(210, 120))
|
||||
self.button2 = wx.Button(self.panel, -1, "返 回", size=(100, 35), pos=(400, 120))
|
||||
self.sampleList = []
|
||||
self.Bind(wx.EVT_BUTTON, self.Query_transaction_records, self.button)
|
||||
self.Bind(wx.EVT_BUTTON, self.QU, self.button2)
|
||||
# listBox.SetSelection(3)
|
||||
self.frame.Center()
|
||||
self.frame.Show(True)
|
||||
|
||||
def QU(self, event):
|
||||
t = threading.Thread(target=self.doClose, args=(0.05,))
|
||||
t.start()
|
||||
jie = function.Jiemian(self.card)
|
||||
jie.MainLoop()
|
||||
|
||||
def Query_transaction_records(self, event):
|
||||
sql = "SELECT * FROM bill where 银行卡号='{}'".format(self.card)
|
||||
|
||||
db = pymysql.connect(host="localhost", user="root",
|
||||
password="lwh20021210...", db="atm", port=3306)
|
||||
# 使用cursor()方法获取操作游标
|
||||
cur = db.cursor()
|
||||
try:
|
||||
cur.execute(sql)
|
||||
results = cur.fetchall()
|
||||
print(len(results))
|
||||
sampleList = []
|
||||
# self.sampleList.extend(sample)
|
||||
print(self.sampleList)
|
||||
if results:
|
||||
for i in range(len(results)):
|
||||
wor = ""
|
||||
for j in range(len(results[i])):
|
||||
print(results[i][j], end=" ")
|
||||
wor += str(results[i][j])
|
||||
wor += " "
|
||||
print("")
|
||||
sampleList.append(wor)
|
||||
listBox = wx.ListBox(self.panel, -1, (20, 250), (680, 350), sampleList, wx.LB_SINGLE)
|
||||
listBox.SetSelection(3)
|
||||
else:
|
||||
self.show_message(word="交易记录为空")
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
|
||||
|
||||
finally:
|
||||
|
||||
db.close() # 关闭连接
|
||||
|
||||
def show_message(self, word=""):
|
||||
dlg = wx.MessageDialog(None, word, u"提示", wx.YES_NO | wx.ICON_QUESTION)
|
||||
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
# self.Close(True)
|
||||
pass
|
||||
dlg.Destroy()
|
||||
def OnEraseBack(self, event):
|
||||
dc = event.GetDC()
|
||||
if not dc:
|
||||
dc = wx.ClientDC(self)
|
||||
rect = self.GetUpdateRegion().GetBox()
|
||||
dc.SetClippingRect(rect)
|
||||
dc.Clear()
|
||||
bmp = wx.Bitmap('img\\instagram.jpg')
|
||||
dc.DrawBitmap(bmp, 0, 0)
|
||||
|
||||
# if __name__ == '__main__':
|
||||
# app=Query("62155504510128")
|
||||
# app.MainLoop()
|
@ -0,0 +1,97 @@
|
||||
import wx
|
||||
import pymysql, time, threading
|
||||
from MySQL import Make_bill, function
|
||||
|
||||
|
||||
class Withdrawal1(wx.App):
|
||||
def doClose(self, j):
|
||||
time.sleep(j)
|
||||
self.frame.Close()
|
||||
|
||||
def __init__(self, YuanZhangH):
|
||||
self.YuanZhangH = YuanZhangH
|
||||
wx.App.__init__(self)
|
||||
self.frame = wx.Frame(parent=None, title='取 款', size=(535, 450),
|
||||
style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER ^ wx.MAXIMIZE_BOX)
|
||||
|
||||
panel = wx.Panel(self.frame, -1)
|
||||
panel.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBack)
|
||||
label_pass = wx.StaticText(panel, -1, "取款金额:", pos=(80, 200))
|
||||
# style 为设置输入
|
||||
self.JinE = wx.TextCtrl(panel, -1, size=(250, 35), pos=(140, 190))
|
||||
|
||||
self.QueDing_button = wx.Button(panel, -1, "确 认", size=(80, 60), pos=(120, 280))
|
||||
self.QuXiao_button = wx.Button(panel, -1, "反 回", size=(80, 60), pos=(340, 280))
|
||||
|
||||
self.QueDing_button.SetBackgroundColour('#0a74f7')
|
||||
self.QuXiao_button.SetBackgroundColour('#0a74f7')
|
||||
|
||||
self.Bind(wx.EVT_BUTTON, self.QuK, self.QueDing_button)
|
||||
self.Bind(wx.EVT_BUTTON, self.QU, self.QuXiao_button)
|
||||
self.frame.Center()
|
||||
self.frame.Show(True)
|
||||
|
||||
def show_message(self, word=""):
|
||||
dlg = wx.MessageDialog(None, word, u"错误", wx.YES_NO | wx.ICON_QUESTION)
|
||||
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
# self.Close(True)
|
||||
pass
|
||||
dlg.Destroy()
|
||||
|
||||
def show_check(self, word=""):
|
||||
dlg = wx.MessageDialog(None, word, u"提示", wx.YES_NO | wx.ICON_QUESTION)
|
||||
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
# self.Close(True)
|
||||
pass
|
||||
dlg.Destroy()
|
||||
|
||||
def QuK(self, event):
|
||||
# 连接到本地数据库
|
||||
z2 = self.JinE.GetValue()
|
||||
YuanZhangH = self.YuanZhangH
|
||||
sql1 = "SELECT 余额 FROM card WHERE Card_Number = %s" % (YuanZhangH)
|
||||
sql2 = "update card set 余额 = 余额-'{}' where Card_Number = '{}'".format(float(z2), YuanZhangH)
|
||||
# 判断,查看用户名和密码名是否为空
|
||||
# 不为空之后在进行查询和判断
|
||||
# 不然当密码或用户名为空时会出现会导致出错
|
||||
if z2:
|
||||
db = pymysql.connect(host="localhost", user="root",
|
||||
password="lwh20021210...", db="atm", port=3306)
|
||||
# 使用cursor()方法获取操作游标
|
||||
cur = db.cursor()
|
||||
try:
|
||||
cur.execute(sql1)
|
||||
results = cur.fetchall()
|
||||
if results[0][0] >= float(z2):
|
||||
cur.execute(sql2)
|
||||
db.commit()
|
||||
Make_bill.Make_Bill(YuanZhangH, "取款", float(z2), "无")
|
||||
self.show_check(word='取款成功')
|
||||
else:
|
||||
self.show_message(word='余额不足')
|
||||
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
finally:
|
||||
|
||||
db.close() # 关闭连接
|
||||
else:
|
||||
self.show_message(word='取款金额不能为空')
|
||||
|
||||
def OnEraseBack(self, event):
|
||||
dc = event.GetDC()
|
||||
if not dc:
|
||||
dc = wx.ClientDC(self)
|
||||
rect = self.GetUpdateRegion().GetBox()
|
||||
dc.SetClippingRect(rect)
|
||||
dc.Clear()
|
||||
bmp = wx.Bitmap('img\\instagram.jpg')
|
||||
dc.DrawBitmap(bmp, 0, 0)
|
||||
|
||||
def QU(self, event):
|
||||
t = threading.Thread(target=self.doClose, args=(0.05,))
|
||||
t.start()
|
||||
jie = function.Jiemian(self.YuanZhangH)
|
||||
jie.MainLoop()
|
@ -0,0 +1,125 @@
|
||||
/*
|
||||
Navicat MySQL Data Transfer
|
||||
|
||||
Source Server : atm
|
||||
Source Server Version : 80033
|
||||
Source Host : localhost:3306
|
||||
Source Database : atm
|
||||
|
||||
Target Server Type : MYSQL
|
||||
Target Server Version : 80033
|
||||
File Encoding : 65001
|
||||
|
||||
Date: 2024-05-31 14:54:56
|
||||
*/
|
||||
|
||||
SET FOREIGN_KEY_CHECKS=0;
|
||||
-- ----------------------------
|
||||
-- Table structure for `bank`
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `bank`;
|
||||
CREATE TABLE `bank` (
|
||||
`bank_key` int NOT NULL,
|
||||
`银行名称` char(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
||||
PRIMARY KEY (`bank_key`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of bank
|
||||
-- ----------------------------
|
||||
INSERT INTO bank VALUES ('1', '中国银行');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for `bill`
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `bill`;
|
||||
CREATE TABLE `bill` (
|
||||
`时间` datetime NOT NULL,
|
||||
`订单ID` int NOT NULL,
|
||||
`银行` char(50) NOT NULL,
|
||||
`操作方式` char(50) NOT NULL,
|
||||
`金额` float NOT NULL,
|
||||
`银行卡号` char(30) NOT NULL,
|
||||
`目标账户` char(30) DEFAULT NULL,
|
||||
PRIMARY KEY (`时间`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of bill
|
||||
-- ----------------------------
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:05:53', '10744925', '中国银行', '取款', '111', '111', '无');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:09:08', '10788140', '中国银行', '存款', '1', '111', '无');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:09:39', '10939119', '中国银行', '存款', '111', '111', '无');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:09:42', '10613347', '中国银行', '取款', '1', '111', '无');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:10:57', '10946847', '中国银行', '转账', '0', '111', '222');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:13:31', '10074488', '', '转账', '1', '222', '111');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:19:10', '10516740', '中国银行', '存款', '33333', '111', '无');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:20:42', '10517518', '中国银行', '转账', '0', '111', '333');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:22:47', '10019783', '中国银行', '存款', '22', '111', '无');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:23:47', '10431147', '中国银行', '存款', '3333', '333', '无');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:23:54', '10390544', '中国银行', '转账', '1', '333', '111');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:24:03', '10284427', '中国银行', '转账', '22', '333', '111');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:24:20', '10429608', '', '转账', '22', '222', '111');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:24:42', '10548491', '中国银行', '转账', '111', '111', '333');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:25:58', '10599121', '中国银行', '转账', '111', '333', '111');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:27:57', '10451816', '', '转账', '111', '222', '333');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:28:07', '10920179', '', '转账', '222', '222', '111');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:28:10', '10317065', '', '转账', '2222', '222', '111');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:30:29', '10919022', '中国银行', '转账', '1', '111', '222');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:31:07', '10283188', '', '转账', '1', '444', '111');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:31:20', '10528188', '', '存款', '111', '444', '无');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:31:27', '10851448', '', '取款', '11', '444', '无');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:31:41', '10858951', '', '转账', '1', '444', '111');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:32:28', '10417171', '中国银行', '转账', '1', '111', '222');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:36:32', '10530239', '中国银行', '转账', '11', '111', '222');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:36:49', '10442202', '中国银行', '转账', '111', '111', '333');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:37:23', '10051895', '中国银行', '转账', '111', '111', '222');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:43:27', '10163236', '中国银行', '转账', '1', '111', '222');
|
||||
INSERT INTO bill VALUES ('2024-05-31 11:44:37', '10549313', '中国银行', '转账', '111', '111', '222');
|
||||
INSERT INTO bill VALUES ('2024-05-31 12:05:07', '10871814', '中国银行', '转账', '1', '111', '222');
|
||||
INSERT INTO bill VALUES ('2024-05-31 13:36:13', '10654129', '', '转账', '1', '000', '111');
|
||||
INSERT INTO bill VALUES ('2024-05-31 13:43:53', '10097456', '', '存款', '2999', '888', '无');
|
||||
INSERT INTO bill VALUES ('2024-05-31 13:43:57', '10663217', '', '取款', '2', '888', '无');
|
||||
INSERT INTO bill VALUES ('2024-05-31 13:44:12', '10549945', '', '转账', '11', '888', '111');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for `card`
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `card`;
|
||||
CREATE TABLE `card` (
|
||||
`Card_Number` char(30) NOT NULL,
|
||||
`持卡人姓名` char(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'yonghu',
|
||||
`身份证号` char(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
||||
`余额` float NOT NULL DEFAULT '0',
|
||||
`card类型` char(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
|
||||
`password` int NOT NULL,
|
||||
PRIMARY KEY (`Card_Number`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of card
|
||||
-- ----------------------------
|
||||
INSERT INTO card VALUES ('000', '用户', '37000000000', '-1', '', '0');
|
||||
INSERT INTO card VALUES ('111', '小明', '111111', '1666', '中国银行', '111');
|
||||
INSERT INTO card VALUES ('222', '小华', '333333', '2237', '', '222');
|
||||
INSERT INTO card VALUES ('333', '小东', '666666', '2111', '中国银行', '333');
|
||||
INSERT INTO card VALUES ('444', '用户', '37000000000', '98', '', '444');
|
||||
INSERT INTO card VALUES ('777', '用户', '37000000000', '0', '', '777');
|
||||
INSERT INTO card VALUES ('888', '用户', '37000000000', '2986', '', '888');
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for `user`
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `user`;
|
||||
CREATE TABLE `user` (
|
||||
`User_key` int NOT NULL,
|
||||
`姓名` char(50) NOT NULL,
|
||||
`性别` char(20) NOT NULL,
|
||||
`身份证号` char(30) NOT NULL,
|
||||
PRIMARY KEY (`User_key`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
||||
|
||||
-- ----------------------------
|
||||
-- Records of user
|
||||
-- ----------------------------
|
||||
INSERT INTO user VALUES ('1', '小明', '男', '111111');
|
@ -0,0 +1,84 @@
|
||||
import wx
|
||||
from MySQL import transfer, Deposit, Withdrawal, Gaim, Make_bill, Query
|
||||
import threading, time
|
||||
|
||||
class Jiemian(wx.App):
|
||||
def doClose(self, j):
|
||||
time.sleep(j)
|
||||
self.frame.Close()
|
||||
|
||||
def __init__(self, Num):
|
||||
wx.App.__init__(self)
|
||||
self.Num = Num
|
||||
self.frame = wx.Frame(parent=None, title='自助存取款机', size=(1000, 750),
|
||||
style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER ^ wx.MAXIMIZE_BOX)
|
||||
|
||||
panel = wx.Panel(self.frame, -1)
|
||||
# img=wx.Icon(name='logo.png',type=wx.BITMAP_TYPE_PNG)
|
||||
# wx.StaticBitmap(panel,-1,bitmap=img,pos=(0,0))
|
||||
# image = wx.Image("instagram.jpg", wx.BITMAP_TYPE_JPEG).ConvertToBitmap()
|
||||
panel.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBack)
|
||||
self.Query_transaction_records_button = wx.Button(panel, -1, "查询交易记录", size=(200, 60), pos=(0, 250))
|
||||
self.transfer_accounts_button = wx.Button(panel, -1, "转 账", size=(200, 60), pos=(0, 375))
|
||||
self.deposit = wx.Button(panel, -1, "存 款", size=(200, 60), pos=(800, 375))
|
||||
self.withdrawal = wx.Button(panel, -1, "取 款", size=(200, 60), pos=(800, 250))
|
||||
self.gaimi = wx.Button(panel, -1, "改 密", size=(200, 60), pos=(0, 500))
|
||||
self.tuichu = wx.Button(panel, -1, "退 卡", size=(200, 60), pos=(800, 500))
|
||||
|
||||
self.Bind(wx.EVT_BUTTON, self.qery, self.Query_transaction_records_button)
|
||||
self.Bind(wx.EVT_BUTTON, self.transf, self.transfer_accounts_button)
|
||||
self.Bind(wx.EVT_BUTTON, self.depos, self.deposit)
|
||||
self.Bind(wx.EVT_BUTTON, self.withdraw, self.withdrawal)
|
||||
self.Bind(wx.EVT_BUTTON, self.gaim, self.gaimi)
|
||||
self.Bind(wx.EVT_BUTTON, self.Tui, self.tuichu)
|
||||
self.frame.Center()
|
||||
self.frame.Show(True)
|
||||
|
||||
def OnEraseBack(self, event):
|
||||
dc = event.GetDC()
|
||||
if not dc:
|
||||
dc = wx.ClientDC(self)
|
||||
rect = self.GetUpdateRegion().GetBox()
|
||||
dc.SetClippingRect(rect)
|
||||
dc.Clear()
|
||||
bmp = wx.Bitmap('img\\z.png')
|
||||
dc.DrawBitmap(bmp, 0, 0)
|
||||
|
||||
def transf(self, event):
|
||||
Num = self.Num
|
||||
t = threading.Thread(target=self.doClose, args=(0.05,))
|
||||
t.start()
|
||||
app = transfer.Transfer(Num)
|
||||
app.MainLoop()
|
||||
|
||||
def depos(self, event):
|
||||
Num = self.Num
|
||||
t = threading.Thread(target=self.doClose, args=(0.05,))
|
||||
t.start()
|
||||
app = Deposit.Deposit1(Num)
|
||||
app.MainLoop()
|
||||
|
||||
def withdraw(self, event):
|
||||
Num = self.Num
|
||||
t = threading.Thread(target=self.doClose, args=(0.05,))
|
||||
t.start()
|
||||
app = Withdrawal.Withdrawal1(Num)
|
||||
app.MainLoop()
|
||||
|
||||
def gaim(self, event):
|
||||
Num = self.Num
|
||||
t = threading.Thread(target=self.doClose, args=(0.05,))
|
||||
t.start()
|
||||
app = Gaim.Gaim1(Num)
|
||||
app.MainLoop()
|
||||
|
||||
def Tui(self, event):
|
||||
t = threading.Thread(target=self.doClose, args=(0.05,))
|
||||
t.start()
|
||||
|
||||
def qery(self, event):
|
||||
t = threading.Thread(target=self.doClose, args=(0.05,))
|
||||
t.start()
|
||||
app = Query.Query(self.Num)
|
||||
app.MainLoop()
|
||||
|
@ -0,0 +1,4 @@
|
||||
from MySQL import t1 #从 MySQL 模块导入t1
|
||||
if __name__=='__main__': #当前的文件作为主程序运行
|
||||
app = t1.MyApp() #创建了一个名为 app 的对象,该对象是 t1 组件中 MyApp 类的一个实例,初始化一个应用程序
|
||||
app.MainLoop() #应用程序的事件循环,使窗口保持打开并能够响应用户操作
|
@ -0,0 +1,148 @@
|
||||
import wx
|
||||
import pymysql, time, threading
|
||||
from MySQL import Make_bill, function
|
||||
|
||||
|
||||
class Transfer(wx.App):
|
||||
def doClose(self, j):
|
||||
time.sleep(j)
|
||||
self.frame.Close()
|
||||
|
||||
def __init__(self, YuanZhangH):
|
||||
self.YuanZhangH = YuanZhangH
|
||||
wx.App.__init__(self)
|
||||
self.frame = wx.Frame(parent=None, title='转 账', size=(535, 450),
|
||||
style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER ^ wx.MAXIMIZE_BOX)
|
||||
|
||||
panel = wx.Panel(self.frame, -1)
|
||||
panel.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBack)
|
||||
label_user = wx.StaticText(panel, -1, "账 号:", pos=(80, 160))
|
||||
label_pass = wx.StaticText(panel, -1, "转账金额:", pos=(80, 215))
|
||||
self.ZhangHao = wx.TextCtrl(panel, -1, size=(250, 35), pos=(140, 150))
|
||||
# style 为设置输入
|
||||
self.JinE = wx.TextCtrl(panel, -1, size=(250, 35), pos=(140, 205))
|
||||
|
||||
self.YanZheng_button = wx.Button(panel, -1, "验证", size=(50, 35), pos=(400, 150))
|
||||
self.QueDing_button = wx.Button(panel, -1, "转 账", size=(80, 60), pos=(120, 280))
|
||||
self.QuXiao_button = wx.Button(panel, -1, "返 回", size=(80, 60), pos=(340, 280))
|
||||
|
||||
self.YanZheng_button.SetBackgroundColour('#0a74f7')
|
||||
self.QueDing_button.SetBackgroundColour('#0a74f7')
|
||||
self.QuXiao_button.SetBackgroundColour('#0a74f7')
|
||||
|
||||
self.Bind(wx.EVT_BUTTON, self.YanCard, self.YanZheng_button)
|
||||
|
||||
self.Bind(wx.EVT_BUTTON, self.ZhuanZhang, self.QueDing_button)
|
||||
self.Bind(wx.EVT_BUTTON, self.QU, self.QuXiao_button)
|
||||
|
||||
self.frame.Center()
|
||||
self.frame.Show(True)
|
||||
|
||||
def show_message(self, word=""):
|
||||
dlg = wx.MessageDialog(None, word, u"错误", wx.YES_NO | wx.ICON_QUESTION)
|
||||
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
# self.Close(True)
|
||||
pass
|
||||
dlg.Destroy()
|
||||
|
||||
def show_check(self, word=""):
|
||||
dlg = wx.MessageDialog(None, word, u"提示", wx.YES_NO | wx.ICON_QUESTION)
|
||||
|
||||
if dlg.ShowModal() == wx.ID_YES:
|
||||
# self.Close(True)
|
||||
pass
|
||||
dlg.Destroy()
|
||||
|
||||
def QU(self, event):
|
||||
t = threading.Thread(target=self.doClose, args=(0.05,))
|
||||
t.start()
|
||||
jie = function.Jiemian(self.YuanZhangH)
|
||||
jie.MainLoop()
|
||||
|
||||
def YanCard(self, event):
|
||||
z1 = self.ZhangHao.GetValue()
|
||||
sql = """select 持卡人姓名,card类型 from card where Card_Number ='%s' """ % (z1)
|
||||
if z1 != self.YuanZhangH:
|
||||
db = pymysql.connect(host="localhost", user="root",
|
||||
password="lwh20021210...", db="atm", port=3306)
|
||||
# 使用cursor()方法获取操作游标
|
||||
cur = db.cursor()
|
||||
try:
|
||||
cur.execute(sql) # 执行sql语句
|
||||
results = cur.fetchall() # 获取查询的所有记录
|
||||
# 返回值是一个元组的形式
|
||||
|
||||
print(type(results))
|
||||
if results:
|
||||
# print(type(results[0][0]))
|
||||
# print(results[0][0])
|
||||
stt = "持卡人姓名:" + results[0][0] + " " + "银行类型:" + results[0][1]
|
||||
self.show_check(stt)
|
||||
|
||||
print(results[0][0], " ", results[0][1])
|
||||
else:
|
||||
self.show_message(word='账号不存在')
|
||||
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
|
||||
|
||||
finally:
|
||||
db.close() # 关闭连接
|
||||
else:
|
||||
self.show_message(word="转账账号不能与自己相同")
|
||||
|
||||
def ZhuanZhang(self, event):
|
||||
# 连接到本地数据库
|
||||
z1 = self.ZhangHao.GetValue()
|
||||
z2 = self.JinE.GetValue()
|
||||
YuanZhangH = self.YuanZhangH
|
||||
# sql = """ UPDATE card set 余额=余额+z2 WHERE Card_Number= '%s' """ % (z1)
|
||||
sql = "update card set 余额 = 余额+'{}' where Card_Number = '{}'".format(float(z2), z1)
|
||||
sql1 = "SELECT 余额 FROM card WHERE Card_Number = %s" % (z1)
|
||||
sql2 = "update card set 余额 = 余额-'{}' where Card_Number = '{}'".format(float(z2), YuanZhangH)
|
||||
if z1 != self.YuanZhangH:
|
||||
if z1 and z2:
|
||||
db = pymysql.connect(host="localhost", user="root",
|
||||
password="lwh20021210...", db="atm", port=3306)
|
||||
# 使用cursor()方法获取操作游标
|
||||
cur = db.cursor()
|
||||
try:
|
||||
cur.execute(sql1)
|
||||
results = cur.fetchall()
|
||||
if results[0][0] >= float(z2):
|
||||
cur.execute(sql) # 执行sql语句
|
||||
db.commit()
|
||||
cur.execute(sql2)
|
||||
db.commit()
|
||||
Make_bill.Make_Bill(YuanZhangH, "转账", float(z2), z1)
|
||||
self.show_check(word='转账成功')
|
||||
else:
|
||||
self.show_message(word='余额不足')
|
||||
|
||||
except Exception as e:
|
||||
db.rollback()
|
||||
|
||||
|
||||
finally:
|
||||
|
||||
db.close() # 关闭连接
|
||||
else:
|
||||
self.show_message(word='账号和转账金额不能为空')
|
||||
else:
|
||||
self.show_message(word="转账账号不能与自己相同")
|
||||
|
||||
def OnEraseBack(self, event):
|
||||
dc = event.GetDC()
|
||||
if not dc:
|
||||
dc = wx.ClientDC(self)
|
||||
rect = self.GetUpdateRegion().GetBox()
|
||||
dc.SetClippingRect(rect)
|
||||
dc.Clear()
|
||||
bmp = wx.Bitmap('img\\instagram.jpg')
|
||||
dc.DrawBitmap(bmp, 0, 0)
|
||||
|
||||
# if __name__=='__main__':
|
||||
# app = Transfer("62155504510128")
|
||||
# app.MainLoop()
|
Loading…
Reference in new issue