|
|
#include "resetmessage.h"
|
|
|
#include "QIcon"
|
|
|
#include "QLabel"
|
|
|
#include "ui_resetmessage.h"
|
|
|
|
|
|
ResetMessage::ResetMessage(QWidget *parent) :
|
|
|
QDialog(parent),
|
|
|
ui(new Ui::ResetMessage)
|
|
|
{
|
|
|
ui->setupUi(this);
|
|
|
QIcon logo(":/image/icon/logo.png");
|
|
|
this->setWindowIcon(logo);
|
|
|
setWindowTitle("宜客酒店");
|
|
|
this->setFixedSize(800,600);
|
|
|
|
|
|
QPalette q;//调色板
|
|
|
q.setBrush(QPalette::Window,QBrush(QPixmap("/image/bg/sea,jpg")));
|
|
|
this->setPalette(q);
|
|
|
|
|
|
ui->code->setEchoMode(QLineEdit::Password);
|
|
|
ui->confirm_code->setEchoMode(QLineEdit::Password);
|
|
|
ui->radioButton_man->setChecked(1);
|
|
|
|
|
|
db = QSqlDatabase::addDatabase("QMYSQL");
|
|
|
db.setDatabaseName("hotel");
|
|
|
db.setHostName("localhost");
|
|
|
db.setPort(3306);
|
|
|
db.setUserName("root");
|
|
|
db.setPassword("111111");
|
|
|
if(db.open()){
|
|
|
qDebug("database connect succeed");
|
|
|
}else{
|
|
|
qDebug("database connect failed");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ResetMessage::~ResetMessage()
|
|
|
{
|
|
|
delete ui;
|
|
|
}
|
|
|
|
|
|
bool ResetMessage::verify(int x){
|
|
|
if(x==2){//密码判别
|
|
|
if(ui->code->text().size()<6||ui->code->text().size()>16){
|
|
|
return false;
|
|
|
}else{
|
|
|
QString str = ui->code->text();
|
|
|
int num = str.size();
|
|
|
for(int i=0;i<num;i++){
|
|
|
if(!(std::isalnum(str.at(i).unicode()))){
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
}else if(x==3){//密码二次输入判别
|
|
|
if(QString::compare(ui->code->text(),ui->confirm_code->text())==0){
|
|
|
return true;
|
|
|
}else{
|
|
|
return false;
|
|
|
}
|
|
|
}else if(x==4){//姓名判别
|
|
|
if(ui->name->text().size()>14||ui->name->text()==NULL){
|
|
|
return false;
|
|
|
}else{
|
|
|
return true;
|
|
|
}
|
|
|
}else if(x==5){//身份证号判别
|
|
|
if(ui->ID_card->text().size()!=18){
|
|
|
return false;
|
|
|
}else{
|
|
|
QString str = ui->ID_card->text();
|
|
|
int num = str.size();
|
|
|
for(int i=0;i<num;i++){
|
|
|
if(str.at(i)!='1'&&str.at(i)!='2'&&str.at(i)!='3'&&str.at(i)!='4'&&str.at(i)!='5'&&str.at(i)!='6'&&str.at(i)!='7'&&str.at(i)!='8'&&str.at(i)!='9'&&str.at(i)!='0'&&str.at(i)!='X'){
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
}else{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void ResetMessage::on_pushButton_clicked()
|
|
|
{
|
|
|
if(!verify(2)){
|
|
|
QMessageBox::warning(this, tr("提示"), tr("请检查密码是否符合规范,密码应由6-16位字母或数字组成!"));
|
|
|
}else if(!verify(3)){
|
|
|
QMessageBox::warning(this, tr("提示"), tr("两次输入密码不相同,请重新输入!"));
|
|
|
}else if(!verify(4)){
|
|
|
QMessageBox::warning(this, tr("提示"), tr("姓名字数为空或超出,请重新输入!"));
|
|
|
}else if(!verify(5)){
|
|
|
QMessageBox::warning(this, tr("提示"), tr("请检查身份证信息是否符合规范并重新输入!\n请注意X为大写字母"));
|
|
|
}else{
|
|
|
sign_in();
|
|
|
QMessageBox::information(this, tr("提示"), tr("更新成功!"));
|
|
|
this->hide();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
void ResetMessage::getid(QString str){
|
|
|
id = str;
|
|
|
}
|
|
|
|
|
|
void ResetMessage::sign_in(){
|
|
|
QString gender;
|
|
|
if(ui->radioButton_man->isChecked()){
|
|
|
gender = "男";
|
|
|
}else{
|
|
|
gender = "女";
|
|
|
}
|
|
|
QSqlQuery query;
|
|
|
query.prepare("UPDATE customer set password = :p where account = :a");
|
|
|
query.bindValue(":p",ui->code->text());
|
|
|
query.bindValue(":a",id);
|
|
|
query.exec();
|
|
|
query.prepare("UPDATE customer set name = :n where account = :a");
|
|
|
query.bindValue(":n",ui->name->text());
|
|
|
query.bindValue(":a",id);
|
|
|
query.exec();
|
|
|
query.prepare("UPDATE customer set gender = :g where account = :a");
|
|
|
query.bindValue(":g",gender);
|
|
|
query.bindValue(":a",id);
|
|
|
query.exec();
|
|
|
query.prepare("UPDATE customer set id = :id where account = :a");
|
|
|
query.bindValue(":id",ui->ID_card->text());
|
|
|
query.bindValue(":a",id);
|
|
|
query.exec();
|
|
|
}
|