This repository has been archived by the owner on Apr 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cfenetreapprovisionnement.cpp
51 lines (39 loc) · 1.66 KB
/
cfenetreapprovisionnement.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
#include "cfenetreapprovisionnement.h"
#include "ui_cfenetreapprovisionnement.h"
CFenetreApprovisionnement::CFenetreApprovisionnement(MainWindow* main, CClient* client1, QWidget *parent) :
QDialog(parent),
ui(new Ui::CFenetreApprovisionnement)
{
ui->setupUi(this);
mainWindow = main;
client = client1;
ui->spinBox->setFocus();
connect( ui->boutonAnnuler, SIGNAL(clicked()), this, SLOT(close()) );
connect( ui->boutonAjouter, SIGNAL(clicked()), this, SLOT(validation()) );
}
CFenetreApprovisionnement::~CFenetreApprovisionnement()
{
delete ui;
}
void CFenetreApprovisionnement::validation()
{
if( ui->spinBox->value() > 0 )
{
QDate date = QDate::currentDate();
QTime time = QTime::currentTime();
QString dateString = date.toString( Qt::ISODate );
QString timeString = time.toString();
int idDate = CGestionBDD::addDate( dateString, timeString );
int idClient = client->getID();
CGestionBDD::addApprovisionnement( idClient, idDate, ui->spinBox->value() );
qDebug() << client->getDette();
client->ajouterApprovisionnement( ui->spinBox->value() );
qDebug() << client->getDette();
CGestionBDD::updateClient( *client );
CLog::ecrire( "Credit de : " + QString::number( ui->spinBox->value() ) + " à " + client->getNom() + " " + client->getPrenom() );
QMessageBox::information( this, "KFet", "Vous avez bien ajouté " + QString::number( ui->spinBox->value() ) + QString(8364) + " en crédit à " + client->getNom() +
" " + client->getPrenom() );
mainWindow->updateClient();
this->close();
}
}