-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathautentification.cpp
executable file
·58 lines (51 loc) · 1.57 KB
/
autentification.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
#include "autentification.h"
#include "ui_autentification.h"
#include "mainwindow.h"
Autentification::Autentification(QWidget *parent) :
QDialog(parent),
ui(new Ui::Autentification)
{
ui->setupUi(this);
}
Autentification::~Autentification()
{
delete ui;
}
void Autentification::on_afficherMotDePasseCheckBox_clicked(bool checked)
{
if(checked) {
ui->motDePasseLineEdit->setEchoMode(QLineEdit::Normal);
return;
}
ui->motDePasseLineEdit->setEchoMode(QLineEdit::Password);
}
void Autentification::on_pushButton_2_clicked()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
db.setHostName("localhost");
db.setUserName("root");
db.setPassword("root");
db.setDatabaseName("java");
if(db.open())
{
QSqlQuery query;
if(query.exec("SELECT * FROM user"))
{
while(query.next())
{
if(query.value(1).toString()==ui->loginLineEdit->text() && query.value(3).toString()==ui->motDePasseLineEdit->text())
{QMessageBox::information(this,"Succés","Bienvenue "+ui->loginLineEdit->text());
db.close();
MainWindow *mw=new MainWindow();
mw->showMaximized();
Autentification::close();
return;}
}
QMessageBox::critical(this, "Erreur de connection", "Vos données de connexion sont erronés, veuillez réessayer !");
}
else {
qDebug() << "Error = " << db.lastError().text();
}
db.close();
}
}