-
Notifications
You must be signed in to change notification settings - Fork 0
/
compagne.cpp
108 lines (87 loc) · 2.44 KB
/
compagne.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
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
#include "compagne.h"
#include<QVariant>
#include <QTableView>
#include <QString>
#include "connection.h"
#include <QSqlDatabase>
#include <QSql>
#include <QSqlError>
#include <QSqlQuery>
#include <QPrinter>
#include <QPrintDialog>
#include <QPainter>
Compagne::Compagne()
{
}
Compagne::Compagne(int a, QString b, QString c, QString d, QString e, QString f, QString g, QString h, int i)
{
id=a;
nom=b;
type=c;
autorisation=d;
duree=e;
priorite=f;
description=g;
cible=h;
budget=i;
}
bool Compagne::ajoutercompagne()
{
QSqlQuery q;
q.prepare("insert into compagne(id,nom,type,autorisation,duree,priorite,description,cible,budget) values(?,?,?,?,?,?,?,?,?)");
q.addBindValue(id);
q.addBindValue(nom);
q.addBindValue(type);
q.addBindValue(autorisation);
q.addBindValue(duree);
q.addBindValue(priorite);
q.addBindValue(description);
q.addBindValue(cible);
q.addBindValue(budget);
if (q.exec())return true; return false;
}
QSqlQueryModel* Compagne::affichercompagne()
{
QSqlQueryModel *m= new QSqlQueryModel();
QSqlQuery q;
q.prepare("select * from compagne");
q.exec();
m->setQuery(q);
return m;
}
void Compagne::supprimercompagne(int a)
{
QSqlQuery q;
q.prepare("Delete from compagne where id =?");
q.addBindValue(a);
q.exec();
}
void Compagne::modifiercompagne()
{
QSqlQuery q;
q.prepare("update compagne set nom=?,type=?,autorisation=?,duree=?,priorite=?,description=?,cible=?,budget=? where id=?");
q.addBindValue(nom);
q.addBindValue(type);
q.addBindValue(autorisation);
q.addBindValue(duree);
q.addBindValue(priorite);
q.addBindValue(description);
q.addBindValue(cible);
q.addBindValue(budget);
q.addBindValue(id);
q.exec();
}
bool Compagne::verifier()
{
if (nom==""||type==""||duree==""||priorite==""|| autorisation=="" || duree==""|| description==""||cible=="")
{return false;}
return true;
}
void Compagne::recherchercompagne (QString a,QTableView *g)
{QSqlQuery qry ;
QSqlQueryModel *m= new QSqlQueryModel ();
qry.prepare("SELECT * FROM COMPAGNE WHERE NOM like '%"+a+"%' OR TYPE like '%"+a+"%' or AUTORISATION like '%"+a+"%' OR PRIORITE like '%"+a+"%' OR DESCRIPTION like '%"+a+"%' OR CIBLE like '%"+a+"%'");
qry.exec();
m->setQuery(qry);
g->setModel(m);
}