Пример #1
0
 def renew_done(self, tag):
     if tag:
         msg_box(self, '提示', self.book_name_label.text() + '成功!')
         self.close()
     else:
         msg_box(self, '提示', self.book_name_label.text() + '失败!')
         self.close()
Пример #2
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()
Пример #3
0
 def renew(self):
     if self.renew_days_lineEdit.text() == '':
         msg_box(self, '提示', '请输入续借的天数!')
         return
     try:
         th = Thread(target=self.execute_renew)
         th.start()
     except:
         import traceback
         traceback.print_exc()
Пример #4
0
 def btn_slot(self, tag):
     if tag == 'close':
         self.close()
     if tag == 'submit':
         if self.textEdit.toPlainText() == '':
             msg_box(self, '提示', '请输入催还理由!')
             return
         ask_reason = self.textEdit.toPlainText()
         self.data.insert(2, ask_reason)
         th = Thread(target=self.insert_ask_return_info, args=(self.data, ))
         th.start()
Пример #5
0
 def handle_login(self, login_result):
     if login_result == 1:
         msg_box(self, '提示', '用户名不存在,请重试!')
         return
     if login_result == 11:
         msg_box(self, '提示', '用户名或密码错误!')
         return
     if login_result == 111:
         username = self.username_lineEdit.text()
         self.main_window = MainWindow(username=username, role=self.role)
         self.main_window.show()
         self.close()
Пример #6
0
    def btn_slot(self, tag):
        if tag == 'register':
            self.register_win = RegisterWindow()
            self.register_win.show()

        if tag == 'login':
            username = self.username_lineEdit.text()
            password = self.password_lineEdit.text()
            if username == '' or password == '':
                msg_box(self, '提示', '请输入用户名或密码!')
                return
            login_th = Thread(target=self.login, args=(username, password))
            login_th.start()
Пример #7
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()
Пример #8
0
 def search_borrow_info(self):
     if self.borrow_user_search_lineEdit.text() == '':
         msg_box(self, '提示', '请输入需要搜索的内容!')
         return
     if self.user_role == '管理员':
         search_type = self.comboBox.currentText()
         search_content = self.borrow_user_search_lineEdit.text()
         db = DBHelp()
         count, res = db.query_super(
             table_name='borrow_info',
             column_name=SEARCH_CONTENT_MAP.get(search_type),
             condition=search_content)
         if count == 0:
             msg_box(widget=self, title='提示', msg='未找到相关记录!')
             return
         self.get_data_from_database(db, res=res)
Пример #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()
Пример #11
0
    def handle_login(self, login_result):
        """
        执行登陆结果
        :param login_result: 登陆处理TAG
        :return: 登陆出错返回
        """
        if login_result == 1:
            msg_box(self, '提示', '用户名不存在,请重试!')
            return

        if login_result == 11:
            msg_box(self, '提示', '用户名或密码错误!')
            return

        if login_result == 111:
            username = self.username_lineEdit.text()
            self.main_window = MainWindow(login=self,
                                          username=username,
                                          role=self.role)
            self.main_window.show()
            self.close()
Пример #12
0
    def btn_slot(self, tag):
        """
        按钮点击事件槽函数
        :param tag: 点击的按钮的TAG
        :return: 出错返回,不执行后续操作逻辑
        """

        # 注册
        if tag == 'register':
            self.register_win = RegisterWindow()
            self.register_win.show()

        # 登陆
        if tag == 'login':
            username = self.username_lineEdit.text()
            password = self.password_lineEdit.text()
            if '' in [username, password]:
                msg_box(self, '提示', '请输入用户名或密码!')
                return
            login_th = Thread(target=self.login, args=(username, password))
            login_th.start()
Пример #13
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, '提示', '添加新图书成功!')
Пример #14
0
    def btn_slot(self, tag):
        if tag == 'add':
            self.add_book_win = AddBookWindow()
            self.add_book_win.add_book_don_signal.connect(self.add_book_done)
            self.add_book_win.show()

        if tag == 'search':
            search_type = self.search_comboBox.currentText()
            search_content = self.book_search_content_lineEdit.text()
            if search_content == '':
                msg_box(self, '提示', '请输入搜索内容~')
                return
            db = DBHelp()
            count, res = db.query_super(table_name='book', column_name=SEARCH_CONTENT_MAP.get(search_type),
                                        condition=search_content)
            if count == 0:
                msg_box(self, '提示', '您所搜索的图书不存在!')
                return
            self.show_book([count, res])

        if tag == 'refresh':
            self.get_book_info()
Пример #15
0
 def close_win(self, tag):
     if tag == 1:
         msg_box(self, '提示', '图书催还成功!')
         self.close()