def Borrow(self, evt): BookID = self.ID.GetValue() if BookID == "": warn = wx.MessageDialog(self, message="书籍编号不能为空", caption="错误警告", style=wx.YES_DEFAULT | wx.ICON_ERROR) warn.ShowModal() warn.Destroy() return else: book = Table.Book(BookID) L = self.helper.searchBook(book) if L == None or L == []: warn1 = wx.MessageDialog(self, message="图书库中不存在该书籍", caption="错误警告", style=wx.YES_DEFAULT | wx.ICON_ERROR) warn1.ShowModal() warn1.Destroy() return else: for k in L: if int(k[6]) <= 0: warn2 = wx.MessageDialog(self, message="该书暂无库存", caption="错误警告", style=wx.YES_DEFAULT | wx.ICON_ERROR) warn2.ShowModal() warn2.Destroy() return else: UserInfo = self.helper.getUserAccount(self.account) if int(UserInfo[3]) - int(UserInfo[4]) <= 0: for x in UserInfo: print(x) warn3 = wx.MessageDialog( self, message="当前账户无借书证或借书数已达上限", caption="错误警告", style=wx.YES_DEFAULT | wx.ICON_ERROR) warn3.ShowModal() warn3.Destroy() else: #借书成功 L = self.helper.getMaxBorrowID() if L != None and L[0] != None: LoanID = int(L[0]) + 1 else: LoanID = 10000 BorrowDate = time.strftime( '%Y-%m-%d', time.localtime(time.time())) DDL = time.strftime( '%Y-%m-%d', time.localtime(time.time() + 24 * 3600 * 60)) self.helper.updateNum(BookID, "-") #库存变化 借阅变化 更新借阅记录 Loan = Table.Loan(BookID, self.account, LoanID, BorrowDate, DeadLine=DDL) self.helper.LoanInsert(Loan) self.helper.updateUserBorrow(self.account, "+") warn4 = wx.MessageDialog(self, message="借阅成功", caption="借阅结果", style=wx.YES_DEFAULT) warn4.ShowModal() warn4.Destroy() self.Destroy()