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
| #include <QtGui/QLineEdit>
#include <QTextEdit>
#include <QtGui/QFormLayout>
#include <QSqlQuery>
#include "Page6_Fournisseur.h"
FenFournisseur::FenFournisseur()
{
Fournisseur = new QLineEdit;
Adresse = new QTextEdit;
Contact = new QLineEdit;
Tel = new QLineEdit;
Fax = new QLineEdit;
Mail = new QLineEdit;
// DECLARATION Forme et Incrementation de l'affichage
QFormLayout *layoutAjout = new QFormLayout;
layoutAjout->addRow("Fournisseur", Fournisseur);
layoutAjout->addRow("Adresse", Adresse);
layoutAjout->addRow("Contact", Contact);
layoutAjout->addRow("Tel", Tel);
layoutAjout->addRow("Fax", Fax);
layoutAjout->addRow("Mail", Mail);
QHBoxLayout *BoutonAjoutFournisseur = new QHBoxLayout;
QPushButton *BoutonAjouter = new QPushButton("Ajouter");
QPushButton *BoutonAnuler = new QPushButton("Annuler");
BoutonAjoutFournisseur->addWidget(BoutonAjouter);
BoutonAjoutFournisseur->addWidget(BoutonAnuler);
// Cree une Grille d'affichage
QVBoxLayout *LayoutFenFournisseur = new QVBoxLayout;
LayoutFenFournisseur->addLayout(layoutAjout);
LayoutFenFournisseur->addLayout(BoutonAjoutFournisseur);
setLayout(LayoutFenFournisseur);
QObject::connect(BoutonAjouter, SIGNAL(clicked()),this, SLOT(ValidAjout()));
connect(BoutonAnuler, SIGNAL(clicked()), this, SLOT(close()));
}
void FenFournisseur::ValidAjout()
{
QSqlQuery AjoutFournisseur_query;
AjoutFournisseur_query.prepare("INSERT INTO fournisseur (id, fournisseur, adresse , contact, tel , fax , mail) "
"VALUES (:id, :fournisseur , :adresse , :contact , :tel , :fax , :mail )");
AjoutFournisseur_query.bindValue(":fournisseur", Fournisseur->text() );
AjoutFournisseur_query.bindValue(":adresse", Adresse->toPlainText() );
AjoutFournisseur_query.bindValue(":contact", Contact->text() );
AjoutFournisseur_query.bindValue(":tel", Tel->text() );
AjoutFournisseur_query.bindValue(":fax", Fax->text() );
AjoutFournisseur_query.bindValue(":mail", Mail->text() );
AjoutFournisseur_query.exec();
close();
}; |
Partager