-
Notifications
You must be signed in to change notification settings - Fork 0
/
club.cpp
124 lines (96 loc) · 3.15 KB
/
club.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#include "club.h"
#include <QDebug>
Club::Club()
{
id=0;
nom="";
responsable=0;
jour="";
salle=0;
}
Club::Club(int id,QString nom,int responsable,QString jour,int salle)
{
this->id=id;
this->nom=nom;
this->responsable=responsable;
this->jour=jour;
this->salle=salle;
}
QString Club::get_nom(){return nom;}
int Club::get_responsable(){return responsable;}
QString Club::get_jour(){return jour;}
int Club::get_id(){return id;}
int Club::get_salle(){return salle;}
bool Club::ajouter_club()
{
QSqlQuery query;
QString res= QString::number(id);
query.prepare("INSERT INTO club (ID, NOM, RESPONSABLE, JOUR, SALLE) "
"VALUES (:id, :nom, :responsable, :jour, :salle)");
query.bindValue(":id", res);
query.bindValue(":nom", nom);
query.bindValue(":responsable", responsable);
query.bindValue(":jour", jour);
query.bindValue(":salle", salle);
return query.exec();
}
QSqlQueryModel * Club::afficher_club()
{QSqlQueryModel * model= new QSqlQueryModel();
model->setQuery("select * from club");
model->setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
model->setHeaderData(1, Qt::Horizontal, QObject::tr("Nom "));
model->setHeaderData(2, Qt::Horizontal, QObject::tr("Responsable"));
model->setHeaderData(3, Qt::Horizontal, QObject::tr("Jour"));
model->setHeaderData(4, Qt::Horizontal, QObject::tr("Salle"));
return model;
}
bool Club::supprimer_club(int idd)
{
QSqlQuery query;
QString res= QString::number(idd);
query.prepare("Delete from club where ID = :id ");
query.bindValue(":id", res);
return query.exec();
}
bool Club::modifier_club(int id,QString nom,int responsable,QString jour,int salle)
{
QSqlQuery qry;
qry.prepare("UPDATE club set NOM=(?),RESPONSABLE=(?),JOUR=(?),SALLE=(?) where ID=(?) ");
qry.addBindValue(nom);
qry.addBindValue(responsable);
qry.addBindValue(jour);
qry.addBindValue(salle);
qry.addBindValue(id);
return qry.exec();
}
QSqlQuery Club::rechercher_id_club(int id)
{
QSqlQuery query;
query.prepare("SELECT * from club where ID = :id");
query.bindValue(":id", id);
query.exec();
return query;
}
QSqlQueryModel * Club::rechercher_club (const QString &aux)
{
QSqlQueryModel * model = new QSqlQueryModel();
model->setQuery("select * from club where ( LOWER (ID || NOM || RESPONSABLE || JOUR ) LIKE '%"+aux+"%')");
model->setHeaderData(0, Qt::Horizontal, QObject::tr("Id"));
model->setHeaderData(1, Qt::Horizontal, QObject::tr("Nom "));
model->setHeaderData(2, Qt::Horizontal, QObject::tr("Responsable"));
model->setHeaderData(3, Qt::Horizontal, QObject::tr("Jour"));
model->setHeaderData(4, Qt::Horizontal, QObject::tr("Salle"));
return model;
}
QSqlQueryModel * Club::afficher_salle(){
QSqlQueryModel * model= new QSqlQueryModel();
model->setQuery("select NUMS from salles");
model->setHeaderData(0, Qt::Horizontal, QObject::tr("salle"));
return model;
}
QSqlQueryModel * Club::afficher_responsable(){
QSqlQueryModel * model= new QSqlQueryModel();
model->setQuery("select ID from instituteur");
model->setHeaderData(0, Qt::Horizontal, QObject::tr("responsable"));
return model;
}