| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- #include "dialogchangepass.h"
- #include "ui_dialogchangepass.h"
- #include "WSSSO.h"
- #include "respchangepass.h"
- #include <QtGui>
- DialogChangePass::DialogChangePass(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::DialogChangePass)
- {
- ui->setupUi(this);
- ui->buttonBox->button(QDialogButtonBox::Ok)->setText("更改");
- ui->buttonBox->button(QDialogButtonBox::Cancel)->setText("关闭");
- }
- DialogChangePass::~DialogChangePass()
- {
- delete ui;
- qDebug()<<QDateTime::currentDateTime().toString("yyyy-MM-dd HH:mm:ss")\
- <<"SNCUser.DialogChangePass Destroyed.";
- }
- void DialogChangePass::setUserHash(QString userHash)
- {
- this->userHash = userHash;
- }
- void DialogChangePass::setHost(QString host)
- {
- this->host = host;
- }
- void DialogChangePass::on_buttonBox_accepted()
- {
- QString oldPass = this->ui->oldPassEdit->text();
- QString newPass2 = this->ui->newPass2Edit->text();
- QString newPass = this->ui->newPassEdit->text();
- if(newPass2!=newPass)
- {
- QMessageBox::critical(this,"结果","两次输入的密码不一致!",QMessageBox::Ok);
- return ;
- }
- if(oldPass.isEmpty() ||newPass.isEmpty())
- {
- QMessageBox::critical(this,"结果","密码不能为空!",QMessageBox::Ok);
- return ;
- }
- this->ui->buttonBox->setEnabled(false);
- WSSSO *client = new WSSSO();
- QString json = client->changePass(oldPass,newPass,this->userHash);
- this->ui->buttonBox->setEnabled(true);
- bool ok = false;
- if(json.isEmpty())
- {
- QMessageBox::warning(this,"结果","网络连接失败!",QMessageBox::Ok);
- }
- else
- {
- RespChangePass *response = new RespChangePass(json);
- if(response->getRtnCode()==1)
- {
- this->ui->oldPassEdit->setText("");
- this->ui->newPassEdit->setText("");
- this->ui->newPass2Edit->setText("");
- ok = true;
- QMessageBox::information(this,"结果","密码修改成功!",QMessageBox::Ok);
- }
- else if(response->getRtnCode()==-1)
- {
- QMessageBox::critical(this,"结果","登录超时,请重新登录!",QMessageBox::Ok);
- }
- else
- {
- QMessageBox::critical(this,"结果",response->getRtnMemo(),QMessageBox::Ok);
- }
- delete response;
- }
- if(ok)
- this->close();
- delete client;
- }
|