Repository navigation
Expand file tree
/
Copy pathstatisticspage.cpp
More file actions
56 lines (54 loc) · 1.82 KB
/
Copy pathstatisticspage.cpp
File metadata and controls
56 lines (54 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "statisticspage.h"
#include "ui_statisticspage.h"
#include "adminpage.h"
#include "book.h"
#include "borrow.h"
#include "dialog.h"
extern vector<book> vecbook;
extern book bookCEO;
extern vector<borrow>vecbor;
extern borrow borCEO;
extern User CEO;
extern QString DIALOGMSG;
statisticsPage::statisticsPage(QWidget *parent) :
QWidget(parent),
ui(new Ui::statisticsPage)
{
ui->setupUi(this);
//读入数据
borCEO.read();
//禁止用户编辑表格
ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
vector<string> bookname = borCEO.getBooknames();
vector<string> readername = borCEO.getReaders();
vector<string> borrowDate = borCEO.getBorrowBookDates();
vector<string> returnDate = borCEO.getReturnBookDates();
for(int i = 0;i < vecbor.size();i++){
int row = ui->tableWidget->rowCount();
ui->tableWidget->insertRow(row);
ui->tableWidget->setItem(row,0,new QTableWidgetItem(QString::fromStdString(bookname[i])));
ui->tableWidget->setItem(row,1,new QTableWidgetItem(QString::fromStdString(readername[i])));
ui->tableWidget->setItem(row,2,new QTableWidgetItem(QString::fromStdString(borrowDate[i])));
ui->tableWidget->setItem(row,3,new QTableWidgetItem(QString::fromStdString(returnDate[i])));
}
int borrowCount = borCEO.getBorrowCount();
QString temp = ui->labelBorrowed->text();
temp += QString::number(borrowCount);
ui->labelBorrowed->setText(temp);
temp = ui->labelInLibrary->text();
int inLibrary = vecbook.size();
inLibrary -= borrowCount;
temp += QString::number(inLibrary);
ui->labelInLibrary->setText(temp);
}
statisticsPage::~statisticsPage()
{
delete ui;
}
//返回按钮
void statisticsPage::on_pushButton_clicked()
{
auto a = new adminPage;
a->show();
this->close();
}