Skip to content

Commit

Permalink
所有功能已实现
Browse files Browse the repository at this point in the history
  • Loading branch information
jijijitian committed Jul 14, 2023
1 parent 62f5774 commit ef977be
Show file tree
Hide file tree
Showing 43 changed files with 2,918 additions and 84 deletions.
28 changes: 26 additions & 2 deletions cell/cell.pri
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@ FORMS += \
$$PWD/cell_studentborrowing.ui \
$$PWD/cell_studentmain.ui \
$$PWD/cell_usermanager.ui \
$$PWD/dlg_login.ui
$$PWD/dlg_addbook.ui \
$$PWD/dlg_borrowbook.ui \
$$PWD/dlg_changebook.ui \
$$PWD/dlg_changepassword.ui \
$$PWD/dlg_deletebook.ui \
$$PWD/dlg_deleterecord.ui \
$$PWD/dlg_deleteuser.ui \
$$PWD/dlg_login.ui \
$$PWD/dlg_returnbook.ui

HEADERS += \
$$PWD/cell_accountmanager.h \
Expand All @@ -18,7 +26,15 @@ HEADERS += \
$$PWD/cell_studentborrowing.h \
$$PWD/cell_studentmain.h \
$$PWD/cell_usermanager.h \
$$PWD/dlg_login.h
$$PWD/dlg_addbook.h \
$$PWD/dlg_borrowbook.h \
$$PWD/dlg_changebook.h \
$$PWD/dlg_changepassword.h \
$$PWD/dlg_deletebook.h \
$$PWD/dlg_deleterecord.h \
$$PWD/dlg_deleteuser.h \
$$PWD/dlg_login.h \
$$PWD/dlg_returnbook.h

SOURCES += \
$$PWD/cell_accountmanager.cpp \
Expand All @@ -29,5 +45,13 @@ SOURCES += \
$$PWD/cell_studentborrowing.cpp \
$$PWD/cell_studentmain.cpp \
$$PWD/cell_usermanager.cpp \
$$PWD/dlg_addbook.cpp \
$$PWD/dlg_borrowbook.cpp \
$$PWD/dlg_changebook.cpp \
$$PWD/dlg_changepassword.cpp \
$$PWD/dlg_deletebook.cpp \
$$PWD/dlg_deleterecord.cpp \
$$PWD/dlg_deleteuser.cpp \
$$PWD/dlg_login.cpp \
$$PWD/dlg_returnbook.cpp \
$$PWD/main.cpp
7 changes: 7 additions & 0 deletions cell/cell_accountmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ Cell_AccountManager::~Cell_AccountManager()
{
delete ui;
}

void Cell_AccountManager::on_pushButton_clicked()
{
Dlg_ChangePassword dlg;
dlg.exec();
}

4 changes: 4 additions & 0 deletions cell/cell_accountmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <QWidget>
#include <QStandardItemModel>
#include <lib/sqlmanager.h>
#include "dlg_changepassword.h"

namespace Ui {
class Cell_AccountManager;
Expand All @@ -17,6 +18,9 @@ class Cell_AccountManager : public QWidget
explicit Cell_AccountManager(QWidget *parent = nullptr);
~Cell_AccountManager();

private slots:
void on_pushButton_clicked();

private:
Ui::Cell_AccountManager *ui;
QStandardItemModel m_model;
Expand Down
52 changes: 52 additions & 0 deletions cell/cell_bookborrowing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,55 @@ Cell_BookBorrowing::~Cell_BookBorrowing()
{
delete ui;
}

void Cell_BookBorrowing::on_pushButton_clicked()
{
//调用借阅窗口
Dlg_BorrowBook dlg_borrow;
dlg_borrow.exec();
this->refreshTable();
}


void Cell_BookBorrowing::on_pushButton_3_clicked()
{
//调用归还窗口
Dlg_ReturnBook dlg_return;
dlg_return.exec();
this->refreshTable();
}


void Cell_BookBorrowing::on_btn_search_clicked()
{
//搜索图书实现
QString title = ui->lineEdit->text();
QString condition = QString("WHERE title LIKE '%%1%'").arg(title);
m_model.clear();
m_model.setHorizontalHeaderLabels(QStringList{"图书id", "书名", "作者", "库存", "出版社", "类型1", "类型2", "类型3"});
//将图书数据添加到ui界面
QVector<QStringList> vec = SqlManager::getInstance()->getBooks(condition);
for (const QStringList& row : vec) {
QList<QStandardItem*> items;
for (const QString& value : row) {
items.append(new QStandardItem(value));
}
m_model.appendRow(items);
}
}

void Cell_BookBorrowing::refreshTable()
{
m_model.clear();
m_model.setHorizontalHeaderLabels(QStringList{"图书id", "书名", "作者", "库存", "出版社", "类型1", "类型2", "类型3"});
//将图书数据添加到ui界面
QVector<QStringList> vec = SqlManager::getInstance()->getBooks();
for (const QStringList& row : vec) {
QList<QStandardItem*> items;
for (const QString& value : row) {
items.append(new QStandardItem(value));
}
m_model.appendRow(items);
}
}

12 changes: 12 additions & 0 deletions cell/cell_bookborrowing.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <QWidget>
#include <QStandardItemModel>
#include <lib/sqlmanager.h>
#include "dlg_borrowbook.h"
#include "dlg_returnbook.h"

namespace Ui {
class Cell_BookBorrowing;
Expand All @@ -15,8 +17,18 @@ class Cell_BookBorrowing : public QWidget

public:
explicit Cell_BookBorrowing(QWidget *parent = nullptr);

void refreshTable();

~Cell_BookBorrowing();

private slots:
void on_pushButton_clicked();

void on_pushButton_3_clicked();

void on_btn_search_clicked();

private:
Ui::Cell_BookBorrowing *ui;
QStandardItemModel m_model;
Expand Down
50 changes: 28 additions & 22 deletions cell/cell_bookborrowing.ui
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,27 @@
<item row="1" column="0">
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="5">
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>图书归还</string>
</property>
<property name="name" stdset="0">
<string>btn</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>图书借阅</string>
</property>
<property name="name" stdset="0">
<string>btn</string>
</property>
</widget>
</item>
<item row="0" column="6">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand All @@ -51,16 +71,6 @@
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>图书借阅</string>
</property>
<property name="name" stdset="0">
<string>btn</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit">
<property name="placeholderText">
<string>请输入书名</string>
Expand All @@ -70,23 +80,19 @@
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>图书归还</string>
</property>
<property name="name" stdset="0">
<string>btn</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<widget class="QPushButton" name="btn_search">
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>搜索</string>
</property>
<property name="name" stdset="0">
<string>label</string>
<string>btn</string>
</property>
</widget>
</item>
Expand Down
58 changes: 58 additions & 0 deletions cell/cell_bookmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,61 @@ Cell_BookManager::~Cell_BookManager()
{
delete ui;
}

void Cell_BookManager::on_pushButton_clicked()
{
Dlg_AddBook dlg;
dlg.exec();
this->refreshTable();
}


void Cell_BookManager::on_pushButton_3_clicked()
{
Dlg_ChangeBook dlg;
dlg.exec();
this->refreshTable();
}


void Cell_BookManager::on_pushButton_2_clicked()
{
Dlg_DeleteBook dlg;
dlg.exec();
this->refreshTable();
}

void Cell_BookManager::refreshTable()
{
m_model.clear();
m_model.setHorizontalHeaderLabels(QStringList{"图书id", "书名", "作者", "库存", "出版社", "类型1", "类型2", "类型3"});
//将图书数据添加到ui界面
QVector<QStringList> vec = SqlManager::getInstance()->getBooks();
for (const QStringList& row : vec) {
QList<QStandardItem*> items;
for (const QString& value : row) {
items.append(new QStandardItem(value));
}
m_model.appendRow(items);
}
}


void Cell_BookManager::on_pushButton_4_clicked()
{
//搜索图书实现
QString title = ui->lineEdit->text();
QString condition = QString("WHERE title LIKE '%%1%'").arg(title);
m_model.clear();
m_model.setHorizontalHeaderLabels(QStringList{"图书id", "书名", "作者", "库存", "出版社", "类型1", "类型2", "类型3"});
//将图书数据添加到ui界面
QVector<QStringList> vec = SqlManager::getInstance()->getBooks(condition);
for (const QStringList& row : vec) {
QList<QStandardItem*> items;
for (const QString& value : row) {
items.append(new QStandardItem(value));
}
m_model.appendRow(items);
}
}

15 changes: 15 additions & 0 deletions cell/cell_bookmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include <QWidget>
#include <QStandardItemModel>
#include <lib/sqlmanager.h>
#include "dlg_addbook.h"
#include "dlg_changebook.h"
#include "dlg_deletebook.h"

namespace Ui {
class Cell_BookManager;
Expand All @@ -15,8 +18,20 @@ class Cell_BookManager : public QWidget

public:
explicit Cell_BookManager(QWidget *parent = nullptr);

void refreshTable();

~Cell_BookManager();

private slots:
void on_pushButton_clicked();

void on_pushButton_3_clicked();

void on_pushButton_2_clicked();

void on_pushButton_4_clicked();

private:
Ui::Cell_BookManager *ui;
QStandardItemModel m_model;
Expand Down
36 changes: 21 additions & 15 deletions cell/cell_bookmanager.ui
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,19 @@
<item row="1" column="0">
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit">
<property name="placeholderText">
<string>请输入书名</string>
<item row="0" column="0">
<widget class="QPushButton" name="pushButton_4">
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>搜索</string>
</property>
<property name="name" stdset="0">
<string>le</string>
<string>btn</string>
</property>
</widget>
</item>
Expand All @@ -60,16 +66,6 @@
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>搜索</string>
</property>
<property name="name" stdset="0">
<string>label</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QPushButton" name="pushButton_3">
<property name="text">
Expand Down Expand Up @@ -100,6 +96,16 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit">
<property name="placeholderText">
<string>请输入书名</string>
</property>
<property name="name" stdset="0">
<string>le</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down
Loading

0 comments on commit ef977be

Please sign in to comment.