-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchangepassworddialog.cpp
69 lines (67 loc) · 1.83 KB
/
changepassworddialog.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
#include "changepassworddialog.h"
#include "ui_changepassworddialog.h"
#include<QMessageBox>
changePasswordDialog::changePasswordDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::changePasswordDialog)
{
ui->setupUi(this);
connect(ui->lineEdit,SIGNAL(textChanged(const QString&)),this,SLOT(enableOkButton()));
connect(ui->lineEdit_2,SIGNAL(textChanged(const QString&)),this,SLOT(enableOkButton()));
}
changePasswordDialog::~changePasswordDialog()
{
delete ui;
}
void changePasswordDialog::enableOkButton()
{
if(ui->lineEdit->text()!=NULL&&ui->lineEdit_2->text()!=NULL)
ui->pushButton_1->setEnabled(1);
else
ui->pushButton_1->setEnabled(0);
}
void changePasswordDialog::on_pushButton_1_clicked()
{
if(type==0)//学生改密
{
studentList *stu=new studentList;
stu->initList();
QString str1=ui->lineEdit->text();
QString str2=ui->lineEdit_2->text();
if(str1!=stu->findStudent(id)->getPassword())
{
QMessageBox::warning(NULL,"失败","旧密码不匹配");
return;
}
stu->findStudent(id)->setPassword(str2);
stu->save();
emit display(2);
}
else if(type==1)//教师改密
{
teacherList *tea=new teacherList;
tea->initList();
QString str1=ui->lineEdit->text();
QString str2=ui->lineEdit_2->text();
if(str1!=tea->findTeacher(id)->getPassword())
{
QMessageBox::warning(NULL,"失败","旧密码不匹配");
return;
}
tea->findTeacher(id)->setPassword(str2);
tea->save();
emit display(3);
}
}
void changePasswordDialog::on_pushButton_2_clicked()
{
if(type==0)
emit display(2);
else if(type==1)
emit display(3);
}
void changePasswordDialog::recSignal(int t,int i)
{
type=t;
id=i;
}