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()
Beispiel #2
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, '提示', '添加新图书成功!')
 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
 def book_info_th(self):
     if self.user_role == '管理员':
         db = DBHelp()
         count, res = db.query_all(table_name='borrow_info')
         self.method_name(db, res)
     else:
         db = DBHelp()
         count, res = db.query_super(table_name='borrow_info',
                                     column_name='borrow_user',
                                     condition=self.username)
         self.method_name(db, res)
Beispiel #5
0
 def login(self, username, password):
     db = DBHelp()
     count, res = db.query_super(table_name='user',
                                 column_name='username',
                                 condition=username)
     if count == 0:
         self.login_done_signal.emit(1)
         return
     if get_md5(password) != res[0][2]:
         self.login_done_signal.emit(11)
         return
     self.role = res[0][3]
     self.login_done_signal.emit(111)
    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)
 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)
Beispiel #8
0
 def login(self, username, password):
     """
     登陆子线程用户验证
     :param username: 需要验证的用户名
     :param password: 匹配的密码
     :return: 验证出错返回,并发射相应TAG的信号
     """
     db = DBHelp()
     count, res = db.query_super(table_name='user',
                                 column_name='username',
                                 condition=username)
     if count == 0:
         self.login_done_signal.emit(1)
         return
     if get_md5(password) != res[0][2]:
         self.login_done_signal.emit(11)
         return
     self.role = res[0][3]
     self.login_done_signal.emit(111)
Beispiel #9
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()