-
Notifications
You must be signed in to change notification settings - Fork 6
/
dialog.cpp
46 lines (43 loc) · 1 KB
/
dialog.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
#include "dialog.h"
#include "ui_dialog.h"
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
}
Dialog::~Dialog()
{
delete ui;
}
bool Dialog::checkUser(){
QString username = ui->username->text();
QString password = ui->password->text();
qDebug() << username;
QSqlQuery qry;
qry.prepare( "SELECT * FROM `user` WHERE `username` = '"+username+"' and `password` = '"+password+"' LIMIT 1" );
if( !qry.exec() ){
qDebug() << qry.lastError();
return false;
} else {
if( qry.next() ){
qDebug()<<qry.value(0).toString();
return true;
} else {
return false;
}
}
}
void Dialog::on_login_clicked()
{
if(this -> checkUser()) {
admin *adminWindow;
adminWindow = new admin();
this -> close();
adminWindow -> show();
} else {
QMessageBox msgBox;
msgBox.setText("用户名密码错误!");
msgBox.exec();
}
}