-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadminwindow.cpp
More file actions
83 lines (60 loc) · 1.75 KB
/
adminwindow.cpp
File metadata and controls
83 lines (60 loc) · 1.75 KB
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
79
80
81
82
#include "adminwindow.h"
#include "ui_adminwindow.h"
#include "dbhandler.h"
#include "adminpanel.h"
AdminWindow::AdminWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::AdminWindow)
{
ui->setupUi(this);
}
AdminWindow::~AdminWindow()
{
delete ui;
}
void AdminWindow::on_checkBox_stateChanged(int arg1)
{
//ui->passwordLineEdit->setEchoMode(QLineEdit::Normal);
ui->checkBox->checkState() ? ui->passwordLineEdit->setEchoMode(QLineEdit::Normal) :ui->passwordLineEdit->setEchoMode(QLineEdit::Password);
}
void AdminWindow::on_pushButton_clicked()
{
QMessageBox msgBox;
DbHandler dbHandler(DATABASE_PATH,DATABASE_CONNECTION_NAME);
if(dbHandler.open())
{
QSqlQuery query;
QString username = ui->usernameLineEdit->text();
QString password = ui->passwordLineEdit->text();
QString result;
if(query.exec("SELECT ID FROM Account WHERE Username='"+username+"' AND Password='"+password+"'"))
{
query.next();
result = query.value(0).toString();
if(result=="")
{
msgBox.setText("incorrect!");
msgBox.exec();
}
else
{
//msgBox.setText("Successful!");
//msgBox.exec();
AdminPanel *form;
form=new AdminPanel(this);
form->show();
close();
//ManagerWindow *managerForm;
//hide();
// managerForm = new ManagerWindow(this);
//managerForm->show();
}
}
dbHandler.close();
}
else
{
msgBox.setText(FAILED_MESSAGE_DATABASE_OPENING);
msgBox.exec();
}
}