-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTDBClopesCreation.cpp
55 lines (40 loc) · 1.31 KB
/
TDBClopesCreation.cpp
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
#include "TDBClopesCreation.h"
TDBClopesCreation::TDBClopesCreation(QWidget* parent) :
QDialog(parent)
{
setWindowTitle("Création de clopes");
marque_label = new QLabel("Marque", this);
prix_label = new QLabel("Prix", this);
marque_edit = new QLineEdit(this);
prix_edit = new QLineEdit(this);
layout = new QGridLayout(this);
layout->addWidget(marque_label, 0, 0);
layout->addWidget(prix_label, 1, 0);
layout->addWidget(marque_edit, 0, 1);
layout->addWidget(prix_edit, 1, 1);
ok_button = new QPushButton("OK", this);
layout->addWidget(ok_button, 2, 0);
cancel_button = new QPushButton("Cancel", this);
layout->addWidget(cancel_button, 2, 1);
setLayout(layout);
connect(cancel_button, SIGNAL(pressed()), this, SLOT(cancel_pressed()));
connect(ok_button, SIGNAL(pressed()), this, SLOT(ok_pressed()));
}
TDBClopesCreation::~TDBClopesCreation()
{
}
void TDBClopesCreation::cancel_pressed()
{
reject();
}
void TDBClopesCreation::ok_pressed()
{
TDBDatabase::open();
QSqlQuery query;
query.prepare("INSERT INTO clopes (marque, prix) VALUES (:marque, :prix)");
query.bindValue(":marque", marque_edit->text());
query.bindValue(":prix", (int)(prix_edit->text().toDouble()*100+0.5));
query.exec();
TDBDatabase::open();
accept();
}