-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddbook.cpp
More file actions
76 lines (69 loc) · 2.35 KB
/
Copy pathaddbook.cpp
File metadata and controls
76 lines (69 loc) · 2.35 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "addbook.h"
#include "ui_addbook.h"
#include "allclass.h"
#include <QMessageBox>
#include <QDebug>
AddBook::AddBook(QWidget *parent) :
QDialog(parent),
ui(new Ui::AddBook)
{
ui->setupUi(this);
}
AddBook::~AddBook()
{
delete ui;
}
extern book_shelf library;
void AddBook::on_pushButton_clicked()
{
QString booktype = ui->booktype->currentText();
QString bookname = ui->bookname->text();
QString bookauther = ui->bookauther->text();
QString booknum = ui->booknum->text();
QString bookpress = ui->press->text();
QString bookprice = ui->bookprice->text();
QString bookpermission = ui->bookpermission->text();
string type = booktype.toStdString();
string name = bookname.toStdString();
string auther = bookauther.toStdString();
int num = booknum.toInt();
string press = bookpress.toStdString();
double price = bookprice.toDouble();
int permission = bookpermission.toInt();
if(booktype == NULL)
QMessageBox::warning(this, tr("提示!"),
tr("请输入书类型!"),
QMessageBox::Yes);
else if(bookname == NULL)
QMessageBox::warning(this, tr("提示!"),
tr("请输入书名!"),
QMessageBox::Yes);
else if(bookauther == NULL)
QMessageBox::warning(this, tr("提示!"),
tr("请输入书作者!"),
QMessageBox::Yes);
else if(booknum == NULL)
QMessageBox::warning(this, tr("提示!"),
tr("请输入书数量!"),
QMessageBox::Yes);
else if(bookpress == NULL)
QMessageBox::warning(this, tr("提示!"),
tr("请输入出版社!"),
QMessageBox::Yes);
else if(bookprice == NULL)
QMessageBox::warning(this, tr("提示!"),
tr("请输入书价格!"),
QMessageBox::Yes);
else if(bookpermission == NULL)
QMessageBox::warning(this, tr("提示!"),
tr("请输入书借阅权限!"),
QMessageBox::Yes);
else
{
library.buybook(type,name,auther,num,press,price,permission);
QMessageBox::warning(this, tr("提示!"),
tr("添加成功!"),
QMessageBox::Yes);
this->close();
}
}