-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstu_alter_passwd.cpp
76 lines (71 loc) · 1.89 KB
/
stu_alter_passwd.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "stu_alter_passwd.h"
#include "ui_stu_alter_passwd.h"
Stu_Alter_Passwd::Stu_Alter_Passwd(QWidget *parent) :
QWidget(parent),
ui(new Ui::Stu_Alter_Passwd)
{
ui->setupUi(this);
}
Stu_Alter_Passwd::~Stu_Alter_Passwd()
{
delete ui;
}
void Stu_Alter_Passwd::receive_from_stu()
{
this->show();
}
void Stu_Alter_Passwd::on_alter_passwd_accepted()
{
QString origin=ui->origin->text();
QString select_sql="select passwd from Student where Sno=?";
QSqlQuery sql_query(db);
sql_query.prepare(select_sql);
sql_query.addBindValue(usename_global);
if(!sql_query.exec())
{
sql_query.lastError();
}
else
{
if(sql_query.first())
{
if(origin==sql_query.value(0))
{
if(ui->new_2->text()==ui->renew->text())
{
QString update_sql="update Student set passwd=? where Sno=?";
sql_query.prepare(update_sql);
sql_query.addBindValue(ui->new_2->text());
sql_query.addBindValue(usename_global);
if(!sql_query.exec())
{
qDebug()<<sql_query.lastError();
}
else
{
qDebug()<<"更改成功";
this->hide();
ui->origin->clear();
ui->new_2->clear();
ui->renew->clear();
}
}
else
{
qDebug()<<"两个密码不一致";
}
}
else
{
qDebug()<<"密码输入错误";
}
}
}
}
void Stu_Alter_Passwd::on_alter_passwd_rejected()
{
this->hide();
ui->origin->clear();
ui->new_2->clear();
ui->renew->clear();
}