コード例 #1
0
 def update_book_info(self):
     book_name = self.book_name_lineEdit.text()
     author = self.author_lineEdit.text()
     publish_company = self.publish_company_lineEdit.text()
     publish_time = self.publish_date_lineEdit.text()
     store_num = int(self.store_num_lineEdit.text())
     new_book_info = [
         book_name, author, publish_company, publish_time, store_num
     ]
     is_update = False
     if '' in new_book_info:
         msg_box(self, '错误', '图书的关键信息不能为空!')
         return
     for new_info in new_book_info:
         if new_info not in self.current_book_info:
             db = DBHelp()
             db.update_super(table_name='book',
                             column_name='id',
                             condition=self.current_book_info[0],
                             data=new_book_info)
             db.db_commit()
             db.instance = None
             del db
             self.close()
             is_update = True
     if is_update:
         msg_box(self, '提示', '图书信息更新成功!')
     self.close()
コード例 #2
0
 def register(self):
     username = self.username_lineEdit.text()
     password = self.password_lineEdit.text()
     confirm = self.confirm_password_lineEdit.text()
     if '' in [username, password, confirm]:
         msg_box(self, '提示', '关键信息不能为空!')
         return
     db = DBHelp()
     count, res = db.query_super(table_name='user',
                                 column_name='username',
                                 condition=username)
     if count != 0:
         msg_box(self, '提示', '用户名已存在!')
         return
     if password != confirm:
         msg_box(self, '错误', '两次输入密码不一致!')
         return
     user_info = [
         get_uuid(), username,
         get_md5(password), 1,
         get_current_time(), 0,
         get_current_time()
     ]
     db.add_user(user_info)
     db.db_commit()
     db.instance = None
     del db
     msg_box(self, '提示', '注册成功!')
     self.close()
コード例 #3
0
 def return_book(self, borrow_id):
     db = DBHelp()
     db.update_borrow_statue(borrow_id)
     db.db_commit()
     db.instance = None
     del db
     self.init_data()
コード例 #4
0
 def add(self):
     book_name = self.book_name_lineEdit.text()
     author = self.author_lineEdit.text()
     publish_company = self.publish_company_lineEdit.text()
     publish_date = self.publish_date_lineEdit.text()
     store_num = self.store_num_lineEdit.text()
     if '' in [book_name, author, publish_company, publish_date, store_num]:
         msg_box(self, '错误', '请输入图书的关键信息!')
         return
     db = DBHelp()
     count, res = db.query_super(table_name='book',
                                 column_name='book_name',
                                 condition=book_name)
     if count:
         msg_box(self, '错误', '已存在同名书籍!')
         return
     book_info = [
         get_uuid(), book_name, author, publish_company, store_num, 0,
         get_current_time(), publish_date
     ]
     db.add_book(data=book_info)
     db.db_commit()
     db.instance = None
     del db
     self.add_book_don_signal.emit()
     self.close()
     msg_box(self, '提示', '添加新图书成功!')
コード例 #5
0
 def insert_ask_return_info(self, data):
     db = DBHelp()
     db.insert_ask_return_info(data=data)
     db.db_commit()
     db.instance = None
     del db
     self.insert_ask_info_done_signal.emit(1)
コード例 #6
0
 def get_book_info(self):
     db = DBHelp()
     count, res = db.query_super(table_name='book',
                                 column_name='booK_name',
                                 condition=self.book_info)
     self.current_book_info = list(res[0])
     self.init_book_info_done_signal.emit()
     db.instance = None
     del db
コード例 #7
0
 def execute_renew(self):
     try:
         day = int(self.renew_days_lineEdit.text())
         return_time = self.return_date_lineEdit.text()
         db = DBHelp()
         db.update_renew([day, return_time, self.borrow_id])
         db.db_commit()
         db.instance = None
         del db
         self.renew_done_signal.emit(1)
     except:
         self.renew_done_signal.emit(0)
コード例 #8
0
    def init_data(self):
        try:
            db = DBHelp()
            count, res = db.query_super(table_name='borrow_info',
                                        column_name='id',
                                        condition=self.borrow_id)
            self.origin_return_time = res[0][7]
            self.origin_borrow_day = res[0][5]
            self.book_name_label.setText('书籍《' + res[0][2] + '》续借')
            self.return_date_lineEdit.setText(str(res[0][7]))
            db.instance = None
            del db

        except:
            self.renew_done_signal.emit(0)
コード例 #9
0
 def borrow_book(self):
     borrow_day = self.borrow_day_lineEdit.text()
     if borrow_day == '':
         msg_box(self, '提示', '借阅天数不能为空!')
         return
     db = DBHelp()
     db.update_borrow(book_id=self.book_id)
     borrow_info = [
         get_uuid(), self.book_id, self.book_name, self.current_user, 1,
         borrow_day,
         get_current_time(),
         get_return_day(int(borrow_day)), 0
     ]
     db.insert_borrow_info(data=borrow_info)
     db.db_commit()
     db.instance = None
     del db
     self.close()
     msg_box(self, '提示', '借阅成功')
コード例 #10
0
    def generate_menu(self, pos):
        row_num = -1
        for i in self.tableWidget.selectionModel().selection().indexes():
            row_num = i.row()
        if row_num == -1:
            return
        if self.user_role == '管理员':
            menu = QMenu()
            edit_action = QAction(u'编辑书本')
            edit_action.setIcon(QIcon(EDIT_ICON))
            menu.addAction(edit_action)

            delete_action = QAction(u'删除书本')
            delete_action.setIcon(QIcon(DELETE_ICON))
            menu.addAction(delete_action)
            action = menu.exec_(self.tableWidget.mapToGlobal(pos))
            if action == edit_action:
                self.book_edit_win = BookEditWindow(book_info=self.tableWidget.item(row_num, 0).text())
                self.book_edit_win.show()

            if action == delete_action:
                reply = QMessageBox.warning(self, '消息', '确定删除该书籍吗?',
                                            QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
                if reply == QMessageBox.Yes:
                    db = DBHelp()
                    db.delete(table_name='book', column_name='id', condition=self.book_id[row_num])
                    db.db_commit()
                    db.instance = None
                    del db
                    self.refresh_pushButton.click()
                    msg_box(self, '提示', '删除书本操作成功!')
        else:
            menu = QMenu()
            borrow_action = QAction(u'借书')
            borrow_action.setIcon(QIcon(BORROW_BOOK))
            menu.addAction(borrow_action)
            action = menu.exec_(self.tableWidget.mapToGlobal(pos))
            if action == borrow_action:
                self.borrow_boo_win = BorrowBookWindow(book_id=self.book_id[row_num],
                                                       book_name=self.tableWidget.item(row_num, 0).text(),
                                                       current_user=self.username)
                self.borrow_boo_win.show()