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.
100 lines
3.3 KiB
100 lines
3.3 KiB
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)
|