This repository has been archived by the owner on Aug 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
modifieretudiant.cpp
78 lines (70 loc) · 2.02 KB
/
modifieretudiant.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
#include "modifieretudiant.h"
#include "ui_modifieretudiant.h"
#include <QDebug>
ModifierEtudiant::ModifierEtudiant(Etudiant& etu, QWidget *parent) :
QDialog(parent), etudiant(&etu),
ui(new Ui::ModifierEtudiant)
{
ui->setupUi(this);
b=1;
ui->INE->setText(QString::number(etu.getIne()));
ui->Prenom->setText(etu.getPrenom());
ui->Nom->setText(etu.getNom());
ui->dateNaissance->setDate(etu.getDateNaissance());
QObject::connect(ui->OK, SIGNAL(clicked()), this, SLOT(ok()) );
QObject::connect(ui->Annuler, SIGNAL(clicked()), this, SLOT(cancel()) );
QObject::connect(ui->Dossier, SIGNAL(clicked()), this, SLOT(editDossier()));
}
ModifierEtudiant::ModifierEtudiant(QWidget *parent) :
QDialog(parent),
ui(new Ui::ModifierEtudiant)
{
Dossier dos=Dossier();
etudiant=new Etudiant(dos);
b=0;
ui->setupUi(this);
QObject::connect(ui->OK, SIGNAL(clicked()), this, SLOT(ok()) );
QObject::connect(ui->Annuler, SIGNAL(clicked()), this, SLOT(cancel()) );
QObject::connect(ui->Dossier, SIGNAL(clicked()), this, SLOT(editDossier()));
}
ModifierEtudiant::~ModifierEtudiant()
{
delete ui;
}
void ModifierEtudiant::ok()
{
try
{
if(!b)
{
Dossier dos=etudiant->getDossier();
Etudiant(dos, ui->INE->text().toUInt(), ui->Nom->text(), ui->Prenom->text(), ui->dateNaissance->date());
}
else
{
etudiant->setIne(ui->INE->text().toInt());
etudiant->setNom(ui->Nom->text());
etudiant->setPrenom(ui->Prenom->text());
etudiant->setDateNaissance(ui->dateNaissance->date());
}
this->close();
}
catch(std::exception& e)
{
QMessageBox::warning(this, "Erreur", e.what());
}
}
void ModifierEtudiant::cancel()
{
this->close();
}
void ModifierEtudiant::editDossier()
{
creerDossier* fenModif=new creerDossier(*etudiant);
fenModif->exec();
delete fenModif;
}
void ModifierEtudiant::closeEvent(QCloseEvent *event)
{
if(!b) delete etudiant;
}