-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeletebook.cpp
More file actions
53 lines (47 loc) · 1.21 KB
/
Copy pathdeletebook.cpp
File metadata and controls
53 lines (47 loc) · 1.21 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
#include "deletebook.h"
#include "ui_deletebook.h"
#include "allclass.h"
#include <QMessageBox>
deletebook::deletebook(QWidget *parent) :
QDialog(parent),
ui(new Ui::deletebook)
{
ui->setupUi(this);
}
deletebook::~deletebook()
{
delete ui;
}
bool isBook2(QString bookID);
extern book_shelf library;
void deletebook::on_pushButton_clicked()
{
QString deleteID = ui->IDdelete->text();
string ID = deleteID.toStdString();
if(deleteID == NULL)
QMessageBox::warning(this, tr("提示!"),
tr("请检查书ID!"),
QMessageBox::Yes);
else if(!isBook2(deleteID))
QMessageBox::warning(this, tr("提示!"),
tr("该书不存在!"),
QMessageBox::Yes);
else
{
library.delet_book(ID);
QMessageBox::warning(this, tr("提示!"),
tr("成功删除图书!"),
QMessageBox::Yes);
this->close();
}
}
bool isBook2(QString bookID)
{
for(int i = 0; i<library.booklib.size();++i)
{
QString q1 = QString::fromStdString(library.booklib[i].id);
if(!QString::compare(bookID,q1))
return true;
}
return false;
}