-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommande.cpp
More file actions
142 lines (115 loc) · 4.14 KB
/
commande.cpp
File metadata and controls
142 lines (115 loc) · 4.14 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include "commande.h"
#include <QDebug>
#include "connexion.h"
commande::commande()
{
}
commande::commande(QString id,QString nom,QString type,QString cinp,QString prix)
{
this->id=id;
this->nom=nom;
this->type=type;
this->cinp=cinp;
this->prix=prix;
}
QString commande::get_id(){return id;}
QString commande::get_nom(){return nom;}
QString commande::get_type(){return type;}
QString commande::get_cinp(){return cinp;}
QString commande::get_prix(){return prix;}
void commande::setid(QString id){ this->id=id;}
void commande::setnom(QString nom){ this->nom=nom;}
void commande::settype(QString type){ this->type=type;}
void commande::setcinp(QString cinp){ this->cinp=cinp;}
void commande::setprix(QString prix){ this->prix=prix;}
bool commande::ajouter()
{
QSqlQuery query;
query.prepare("INSERT INTO commande (ID, NOM, TYPE, CINP, PRIX) "
"VALUES (:id, :nom, :type, :cinp, :prix)");
query.bindValue(":id", id);
query.bindValue(":nom", nom);
query.bindValue(":type", type);
query.bindValue(":cinp", cinp);
query.bindValue(":prix", prix);
return query.exec();
}
QSqlQueryModel * commande::afficher()
{QSqlQueryModel * model= new QSqlQueryModel();
model->setQuery("select * from commande");
model->setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
model->setHeaderData(1, Qt::Horizontal, QObject::tr("NOM "));
model->setHeaderData(2, Qt::Horizontal, QObject::tr("TYPE"));
model->setHeaderData(3, Qt::Horizontal, QObject::tr("CINP"));
model->setHeaderData(4, Qt::Horizontal, QObject::tr("PRIX"));
return model;
}
bool commande::supprimer(QString id)
{
QSqlQuery query;
query.prepare("Delete from commande where id = :id ");
query.bindValue(":id", id);
return query.exec();
}
bool commande::modifier(QString id,QString nom,QString type,QString cinp,QString prix)
{
QSqlQuery query;
query.prepare("UPDATE commande SET id:=id, nom:=nom, type:=type, cinp:=acinp, prix:=prix");
query.bindValue(":id",id);
query.bindValue(":nom",nom);
query.bindValue(":type",type);
query.bindValue(":cinp",cinp);
query.bindValue(":prix",prix);
return query.exec();
}
QSqlQueryModel *commande::rechercher(QString rech)
{
QSqlQueryModel * model= new QSqlQueryModel();
model->setQuery("select * from commande where nom LIKE '"+rech+"%' or type LIKE '"+rech+"%'");
return model;
}
QSqlQueryModel *commande::tri()
{
QSqlQueryModel * model= new QSqlQueryModel();
model->setQuery("select * from client ORDER BY nom ");
model->setHeaderData(0, Qt::Horizontal, QObject::tr("id"));
model->setHeaderData(1, Qt::Horizontal, QObject::tr("nom"));
model->setHeaderData(2, Qt::Horizontal, QObject::tr("type"));
model->setHeaderData(3, Qt::Horizontal, QObject::tr("cinp"));
model->setHeaderData(4, Qt::Horizontal, QObject::tr("prix"));
return model;
}
bool commande::ajoutehis()
{
QSqlQuery query;
query.prepare("INSERT INTO historique (ID, NOM, TYPE, CINP, PRIX) "
"VALUES (:id, :nom, :type, :cinp, :prix)");
query.bindValue(":id", id);
query.bindValue(":nom", nom);
query.bindValue(":type", type);
query.bindValue(":cinp", cinp);
query.bindValue(":prix", prix);
return query.exec();
}
bool commande::modifierhis()
{
QSqlQuery query;
query.prepare("UPDATE historique SET nom='"+nom+"',type='"+type+"' where id='"+id+"' ;");
query.bindValue(":id",id);
query.bindValue(":nom", nom);
query.bindValue(":type", type);
query.bindValue(":cinp", cinp);
query.bindValue(":prix", prix);
return query.exec();
}
QSqlQueryModel * commande::afficherhis()
{
QSqlQueryModel * model= new QSqlQueryModel();
model->setQuery("select * from historique");
model->setHeaderData(0, Qt::Horizontal, QObject::tr("id"));
model->setHeaderData(1, Qt::Horizontal, QObject::tr("nom"));
model->setHeaderData(2, Qt::Horizontal, QObject::tr("type"));
model->setHeaderData(2, Qt::Horizontal, QObject::tr("cinp"));
model->setHeaderData(2, Qt::Horizontal, QObject::tr("prix"));
return model;
}