def searchFunction(self, e: str = 'BID'): # 搜索书号 if e == 'BID': self.borrow_list = database.get_borrowing_books(self.searchInput.text(), True) else: # 搜索学号 self.borrow_list = database.get_borrowing_books(self.searchInput.text()) self.SID = self.searchInput.text() if self.borrow_list == []: print('未找到') if self.table is not None: self.table.deleteLater() self.setTable()
def retrurnBook(self, BID: str): ans = database.return_book(BID, self.stu_mes['SID']) # 刷新表格 if ans: self.book_list = database.get_borrowing_books(self.stu_mes['SID']) self.table.deleteLater() self.setTable()
def pay(self, BID: str, PUNISH): ans = database.pay(BID, self.stu_mes['SID'], PUNISH) # 刷新表格 if ans: self.book_list = database.get_borrowing_books(self.stu_mes['SID']) self.table.deleteLater() self.setTable()
def setTable(self, val: dict = None): self.table = QTableWidget(1, 6) self.table.setContentsMargins(10, 10, 10, 10) self.table.verticalHeader().setVisible(False) self.table.horizontalHeader().setVisible(False) self.table.setEditTriggers(QAbstractItemView.NoEditTriggers) self.table.setFocusPolicy(Qt.NoFocus) self.table.setColumnWidth(0, 150) self.table.setColumnWidth(1, 150) self.table.setColumnWidth(2, 175) self.table.setColumnWidth(3, 175) self.table.setColumnWidth(4, 100) self.table.setColumnWidth(5, 150) self.table.setItem(0, 0, QTableWidgetItem('书号')) self.table.setItem(0, 1, QTableWidgetItem('书名')) self.table.setItem(0, 2, QTableWidgetItem('借书日期')) self.table.setItem(0, 3, QTableWidgetItem('还书日期')) self.table.setItem(0, 4, QTableWidgetItem('罚金')) self.table.setItem(0, 5, QTableWidgetItem('操作')) for i in range(6): self.table.item(0, i).setTextAlignment(Qt.AlignCenter) self.table.item(0, i).setFont(QFont('微软雅黑', 15)) self.body.addWidget(self.table) # 显示借阅详情 self.book_list = database.get_borrowing_books(self.stu_mes['SID']) for i in self.book_list: self.insertRow(i) self.table.setStyleSheet(''' *{ font-size:18px; color: black; background-color: white; font-family: 微软雅黑; } ''')