You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.4 KiB

6 months ago
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()