master
HOJI 2 years ago
parent c478e48755
commit c41c516502

@ -11,7 +11,9 @@ CONFIG += c++17
SOURCES += \ SOURCES += \
administration.cpp \ administration.cpp \
cellstatus.cpp \ cellstatus.cpp \
checkbtn.cpp \
customer.cpp \ customer.cpp \
customerinfo.cpp \
main.cpp \ main.cpp \
login.cpp \ login.cpp \
orderoom.cpp \ orderoom.cpp \
@ -22,7 +24,9 @@ SOURCES += \
HEADERS += \ HEADERS += \
administration.h \ administration.h \
cellstatus.h \ cellstatus.h \
checkbtn.h \
customer.h \ customer.h \
customerinfo.h \
login.h \ login.h \
orderoom.h \ orderoom.h \
receptionist.h \ receptionist.h \
@ -32,7 +36,9 @@ HEADERS += \
FORMS += \ FORMS += \
administration.ui \ administration.ui \
cellstatus.ui \ cellstatus.ui \
checkbtn.ui \
customer.ui \ customer.ui \
customerinfo.ui \
login.ui \ login.ui \
orderoom.ui \ orderoom.ui \
receptionist.ui \ receptionist.ui \

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 9.0.2, 2023-09-11T04:29:46. --> <!-- Written by QtCreator 9.0.2, 2023-09-11T15:55:13. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

@ -1,7 +1,6 @@
#include "administration.h" #include "administration.h"
#include "qmessagebox.h"
#include "ui_administration.h" #include "ui_administration.h"
#include <QDebug> #include "registers.h"
administration::administration(QWidget *parent) : administration::administration(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
@ -37,6 +36,7 @@ void administration::paintEvent(QPaintEvent*)
ui->Search->setEnabled(false);//初始退订按钮灰色 ui->Search->setEnabled(false);//初始退订按钮灰色
ui->AcounTable->hide(); ui->AcounTable->hide();
ui->HotelTable->hide(); ui->HotelTable->hide();
on_Hman_clicked();
} }
void administration::init_account(){ void administration::init_account(){
@ -91,7 +91,10 @@ void administration::on_Aman_clicked()
void administration::on_Add_clicked() void administration::on_Add_clicked()
{ {
if(tool == 0){ if(tool == 0){
int cols=ui->AcounTable->columnCount(); registers *reg = new registers;
reg->settype(2);
reg->show();
/*int cols=ui->AcounTable->columnCount();
int rows=ui->AcounTable->rowCount(); int rows=ui->AcounTable->rowCount();
qDebug()<<rows; qDebug()<<rows;
ui->AcounTable->insertRow(rows); ui->AcounTable->insertRow(rows);
@ -106,7 +109,7 @@ void administration::on_Add_clicked()
query.bindValue(":n",QRandomGenerator::global()->bounded(10000));//随机数 一万以内正整数 query.bindValue(":n",QRandomGenerator::global()->bounded(10000));//随机数 一万以内正整数
query.exec(); query.exec();
QMessageBox::information(this,tr("提示"),("添加成功")); QMessageBox::information(this,tr("提示"),("添加成功"));
init_account(); init_account();*/
} }
else if(tool == 1){ else if(tool == 1){

@ -15,6 +15,7 @@
#include <resetmessage.h> #include <resetmessage.h>
#include <QDate> #include <QDate>
#include <QRandomGenerator> #include <QRandomGenerator>
#include <QDebug>
namespace Ui { namespace Ui {
class administration; class administration;

@ -17,8 +17,8 @@
<widget class="QWidget" name="widget" native="true"> <widget class="QWidget" name="widget" native="true">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>50</x> <x>0</x>
<y>-20</y> <y>0</y>
<width>1920</width> <width>1920</width>
<height>1080</height> <height>1080</height>
</rect> </rect>
@ -29,9 +29,9 @@
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>-10</x> <x>20</x>
<y>-20</y> <y>-10</y>
<width>531</width> <width>831</width>
<height>321</height> <height>321</height>
</rect> </rect>
</property> </property>
@ -59,7 +59,8 @@
</font> </font>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(85, 170, 255);</string> <string notr="true">background-color: rgb(85, 170, 255);
border-radius:15px;</string>
</property> </property>
<property name="text"> <property name="text">
<string>客房管理</string> <string>客房管理</string>
@ -80,7 +81,8 @@
</font> </font>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(85, 170, 255);</string> <string notr="true">background-color: rgb(85, 170, 255);
border-radius:15px;</string>
</property> </property>
<property name="text"> <property name="text">
<string>账号管理</string> <string>账号管理</string>
@ -145,7 +147,8 @@ color: rgb(255, 255, 255);</string>
</font> </font>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(85, 170, 255);</string> <string notr="true">background-color: rgb(85, 170, 255);
border-radius:15px;</string>
</property> </property>
<property name="text"> <property name="text">
<string>更改</string> <string>更改</string>
@ -187,7 +190,8 @@ color: rgb(255, 255, 255);</string>
</font> </font>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(85, 170, 255);</string> <string notr="true">background-color: rgb(85, 170, 255);
border-radius:15px;</string>
</property> </property>
<property name="text"> <property name="text">
<string>添加</string> <string>添加</string>
@ -208,7 +212,8 @@ color: rgb(255, 255, 255);</string>
</font> </font>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(85, 170, 255);</string> <string notr="true">background-color: rgb(85, 170, 255);
border-radius:15px;</string>
</property> </property>
<property name="text"> <property name="text">
<string>删除</string> <string>删除</string>
@ -276,7 +281,7 @@ color: rgb(255, 255, 255);</string>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>2079</width> <width>2079</width>
<height>18</height> <height>17</height>
</rect> </rect>
</property> </property>
</widget> </widget>

@ -1,6 +1,7 @@
#include "cellstatus.h" #include "cellstatus.h"
#include "ui_cellstatus.h" #include "ui_cellstatus.h"
cellstatus::cellstatus(QWidget *parent) : cellstatus::cellstatus(QWidget *parent) :
QWidget(parent), QWidget(parent),
ui(new Ui::cellstatus) ui(new Ui::cellstatus)
@ -35,6 +36,10 @@ void cellstatus::setbtn(){
ui->pushButton_2->setEnabled(isused); ui->pushButton_2->setEnabled(isused);
} }
void cellstatus::setcbtn(checkbtn* cbtn){
this->cbtn = cbtn;
}
void cellstatus::setroomNum(int roomNum) void cellstatus::setroomNum(int roomNum)
{ {
this->roomNum = roomNum; this->roomNum = roomNum;
@ -75,6 +80,8 @@ void cellstatus::on_pushButton_2_clicked()
QMessageBox::information(this," 预定信息 "," 退房成功 "); QMessageBox::information(this," 预定信息 "," 退房成功 ");
ui->pushButton->setEnabled(true); ui->pushButton->setEnabled(true);
ui->pushButton_2->setEnabled(false); ui->pushButton_2->setEnabled(false);
cbtn->setisused(false);
cbtn->setbtn();
emit flash(); emit flash();
} }
@ -83,5 +90,7 @@ void cellstatus::onordersuccess()
QMessageBox::information(this,"预定信息","订房成功"); QMessageBox::information(this,"预定信息","订房成功");
ui->pushButton->setEnabled(false); ui->pushButton->setEnabled(false);
ui->pushButton_2->setEnabled(true); ui->pushButton_2->setEnabled(true);
cbtn->setisused(true);
cbtn->setbtn();
emit flash(); emit flash();
} }

@ -7,6 +7,7 @@
#include <QSqlQuery> #include <QSqlQuery>
#include <QSqlError> #include <QSqlError>
#include <QMessageBox> #include <QMessageBox>
#include "checkbtn.h"
namespace Ui { namespace Ui {
class cellstatus; class cellstatus;
@ -23,6 +24,7 @@ public:
void setDB(QSqlDatabase db); void setDB(QSqlDatabase db);
void setisused(bool i); void setisused(bool i);
void setbtn(); void setbtn();
void setcbtn(checkbtn* cbtn);
private slots: private slots:
void on_pushButton_clicked(); void on_pushButton_clicked();
@ -35,6 +37,7 @@ private:
Ui::cellstatus *ui; Ui::cellstatus *ui;
int roomNum; int roomNum;
orderoom *m_order; orderoom *m_order;
checkbtn *cbtn;
QSqlDatabase db; QSqlDatabase db;
bool isused; bool isused;
signals: signals:

@ -0,0 +1,41 @@
#include "checkbtn.h"
#include "ui_checkbtn.h"
#include "customerinfo.h"
#include <QDebug>
checkbtn::checkbtn(QWidget *parent) :
QWidget(parent),
ui(new Ui::checkbtn)
{
ui->setupUi(this);
}
checkbtn::~checkbtn()
{
delete ui;
}
void checkbtn::setroomNum(int roomNum){
this->roomNum = roomNum;
}
void checkbtn::setDB(QSqlDatabase db){
this->db = db;
}
void checkbtn::on_pushButton_clicked()
{
customerinfo *info = new customerinfo;
info->setDB(db);
info->setroomNum(roomNum);
info->show();
}
void checkbtn::setisused(bool i){
isused = i;
}
void checkbtn::setbtn(){
ui->pushButton->setEnabled(!isused);
qDebug()<<"ssss";
}

@ -0,0 +1,33 @@
#ifndef CHECKBTN_H
#define CHECKBTN_H
#include <QWidget>
#include <QSqlDatabase>
namespace Ui {
class checkbtn;
}
class checkbtn : public QWidget
{
Q_OBJECT
public:
explicit checkbtn(QWidget *parent = nullptr);
~checkbtn();
void setroomNum(int roomNum);
void setDB(QSqlDatabase db);
void setisused(bool i);
void setbtn();
private slots:
void on_pushButton_clicked();
private:
Ui::checkbtn *ui;
int roomNum;
QSqlDatabase db;
bool isused;
};
#endif // CHECKBTN_H

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>checkbtn</class>
<widget class="QWidget" name="checkbtn">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QPushButton" name="pushButton">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>查看</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

@ -99,6 +99,9 @@
<pointsize>14</pointsize> <pointsize>14</pointsize>
</font> </font>
</property> </property>
<property name="styleSheet">
<string notr="true">border-radius:15px;</string>
</property>
</widget> </widget>
<widget class="QLabel" name="label_2"> <widget class="QLabel" name="label_2">
<property name="geometry"> <property name="geometry">
@ -188,7 +191,8 @@ color: rgb(255, 255, 255);
</font> </font>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">background-color: rgb(108, 162, 162); <string notr="true">border-radius:15px;
background-color: rgb(108, 162, 162);
color: rgb(255, 255, 255);</string> color: rgb(255, 255, 255);</string>
</property> </property>
<property name="text"> <property name="text">
@ -264,7 +268,7 @@ background-color: rgba(0, 0, 0, 0);
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1920</width> <width>1920</width>
<height>18</height> <height>17</height>
</rect> </rect>
</property> </property>
</widget> </widget>

@ -0,0 +1,22 @@
#include "customerinfo.h"
#include "ui_customerinfo.h"
customerinfo::customerinfo(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::customerinfo)
{
ui->setupUi(this);
}
customerinfo::~customerinfo()
{
delete ui;
}
void customerinfo::setroomNum(int roomNum){
this->roomNum = roomNum;
}
void customerinfo::setDB(QSqlDatabase db){
this->db = db;
}

@ -0,0 +1,28 @@
#ifndef CUSTOMERINFO_H
#define CUSTOMERINFO_H
#include <QMainWindow>
#include <QSqlDatabase>
#include <QSqlQuery>
namespace Ui {
class customerinfo;
}
class customerinfo : public QMainWindow
{
Q_OBJECT
public:
explicit customerinfo(QWidget *parent = nullptr);
~customerinfo();
void setDB(QSqlDatabase db);
void setroomNum(int roomNum);
private:
Ui::customerinfo *ui;
QSqlDatabase db;
int roomNum;
};
#endif // CUSTOMERINFO_H

@ -0,0 +1,24 @@
<ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>customerinfo</class>
<widget class="QMainWindow" name="customerinfo">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QMenuBar" name="menubar"/>
<widget class="QWidget" name="centralwidget"/>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<pixmapfunction/>
<connections/>
</ui>

@ -127,6 +127,7 @@ void login::on_btn_login_clicked()
void login::on_btn_register_clicked() void login::on_btn_register_clicked()
{ {
registers *reg = new registers; registers *reg = new registers;
reg->settype(1);
reg->show(); reg->show();
} }

@ -62,6 +62,9 @@
<pointsize>16</pointsize> <pointsize>16</pointsize>
</font> </font>
</property> </property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text"> <property name="text">
<string>登录</string> <string>登录</string>
</property> </property>
@ -83,6 +86,9 @@
<pointsize>16</pointsize> <pointsize>16</pointsize>
</font> </font>
</property> </property>
<property name="styleSheet">
<string notr="true">radius:15px;</string>
</property>
<property name="text"> <property name="text">
<string>注册</string> <string>注册</string>
</property> </property>
@ -143,6 +149,9 @@
<pointsize>15</pointsize> <pointsize>15</pointsize>
</font> </font>
</property> </property>
<property name="styleSheet">
<string notr="true">border-radius:15px;</string>
</property>
</widget> </widget>
<widget class="QLineEdit" name="lineEdit_password"> <widget class="QLineEdit" name="lineEdit_password">
<property name="geometry"> <property name="geometry">
@ -158,6 +167,9 @@
<pointsize>15</pointsize> <pointsize>15</pointsize>
</font> </font>
</property> </property>
<property name="styleSheet">
<string notr="true">border-radius:15px;</string>
</property>
</widget> </widget>
<widget class="QPushButton" name="btn_info"> <widget class="QPushButton" name="btn_info">
<property name="geometry"> <property name="geometry">

@ -31,6 +31,9 @@
<height>41</height> <height>41</height>
</rect> </rect>
</property> </property>
<property name="styleSheet">
<string notr="true">border-radius:15px;</string>
</property>
</widget> </widget>
<widget class="QPushButton" name="btn_search"> <widget class="QPushButton" name="btn_search">
<property name="geometry"> <property name="geometry">

@ -1,6 +1,7 @@
#include "receptionist.h" #include "receptionist.h"
#include "ui_receptionist.h" #include "ui_receptionist.h"
#include "cellstatus.h" #include "cellstatus.h"
#include "checkbtn.h"
receptionist::receptionist(QWidget *parent) : receptionist::receptionist(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
@ -73,14 +74,21 @@ void receptionist::showall(){
connect(cell,&cellstatus::flash,this,&receptionist::onflash); connect(cell,&cellstatus::flash,this,&receptionist::onflash);
cell->setDB(db); cell->setDB(db);
cell->setroomNum(query.value(0).toInt()); cell->setroomNum(query.value(0).toInt());
checkbtn* cbtn = new checkbtn;
cbtn->setroomNum(query.value(0).toInt());
cbtn->setDB(db);
cell->setcbtn(cbtn);
if(QString::compare(ui->tableWidget->model()->index(i,4).data().toString(),"使用")==0){ if(QString::compare(ui->tableWidget->model()->index(i,4).data().toString(),"使用")==0){
cell->setisused(true); cell->setisused(true);
cbtn->setisused(true);
}else{ }else{
cell->setisused(false); cell->setisused(false);
cbtn->setisused(false);
} }
cell->setbtn(); cell->setbtn();
ui->tableWidget->setCellWidget(i,7,cell); ui->tableWidget->setCellWidget(i,7,cell);
ui->tableWidget->setCellWidget(i,6,new QPushButton("查看")); ui->tableWidget->setCellWidget(i,6,cbtn);
i++; i++;
} }
} }

@ -34,8 +34,8 @@
<rect> <rect>
<x>10</x> <x>10</x>
<y>20</y> <y>20</y>
<width>711</width> <width>1211</width>
<height>181</height> <height>201</height>
</rect> </rect>
</property> </property>
<property name="font"> <property name="font">
@ -43,6 +43,9 @@
<pointsize>70</pointsize> <pointsize>70</pointsize>
</font> </font>
</property> </property>
<property name="layoutDirection">
<enum>Qt::LeftToRight</enum>
</property>
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">color: rgb(85, 255, 255);</string> <string notr="true">color: rgb(85, 255, 255);</string>
</property> </property>
@ -101,6 +104,9 @@ color: rgb(255, 255, 255);</string>
<pointsize>14</pointsize> <pointsize>14</pointsize>
</font> </font>
</property> </property>
<property name="styleSheet">
<string notr="true">border-radius:15px;</string>
</property>
</widget> </widget>
<widget class="QPushButton" name="pushButton"> <widget class="QPushButton" name="pushButton">
<property name="geometry"> <property name="geometry">
@ -116,6 +122,9 @@ color: rgb(255, 255, 255);</string>
<pointsize>12</pointsize> <pointsize>12</pointsize>
</font> </font>
</property> </property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text"> <property name="text">
<string>查找</string> <string>查找</string>
</property> </property>

@ -39,58 +39,110 @@ registers::~registers()
void registers::paintEvent(QPaintEvent*) void registers::paintEvent(QPaintEvent*)
{ {
bg->resize(ui->widget->size()); bg->resize(ui->widget->size());
if(type==2){
ui->label->setText("账号(工号)");
ui->label_4->hide();
ui->label_5->hide();
ui->label_6->hide();
ui->lineEdit_id->hide();
ui->lineEdit_name->hide();
ui->frame_2->hide();
}
}
void registers::settype(int i){
type = i;
} }
bool registers::verify(int x){ bool registers::verify(int x){
if(x==1){//账号(手机号)判别 if(type==1){
if(ui->lineEdit_account->text().size()!=11){ if(x==1){//账号(手机号)判别
return false; if(ui->lineEdit_account->text().size()!=11){
}else{ return false;
QString str = ui->lineEdit_account->text(); }else{
for(int i=0;i<11;i++){ QString str = ui->lineEdit_account->text();
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'){ for(int i=0;i<11;i++){
return false; 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'){
return false;
}
} }
return true;
} }
return true; }else if(x==2){//密码判别
} if(ui->lineEdit_password->text().size()<6||ui->lineEdit_password->text().size()>16){
}else if(x==2){//密码判别 return false;
if(ui->lineEdit_password->text().size()<6||ui->lineEdit_password->text().size()>16){ }else{
return false; QString str = ui->lineEdit_password->text();
}else{ int num = str.size();
QString str = ui->lineEdit_password->text(); for(int i=0;i<num;i++){
int num = str.size(); if(!(std::isalnum(str.at(i).unicode()))){
for(int i=0;i<num;i++){ return false;
if(!(std::isalnum(str.at(i).unicode()))){ }
return false;
} }
return true;
}
}else if(x==3){//密码二次输入判别
if(QString::compare(ui->lineEdit_password->text(),ui->lineEdit_password_r->text())==0){
return true;
}else{
return false;
}
}else if(x==4){//姓名判别
if(ui->lineEdit_name->text().size()>14||ui->lineEdit_name->text()==NULL){
return false;
}else{
return true;
}
}else if(x==5){//身份证号判别
if(ui->lineEdit_id->text().size()!=18){
return false;
}else{
QString str = ui->lineEdit_id->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;
} }
return true;
}
}else if(x==3){//密码二次输入判别
if(QString::compare(ui->lineEdit_password->text(),ui->lineEdit_password_r->text())==0){
return true;
}else{ }else{
return false; return false;
} }
}else if(x==4){//姓名判别 }else if(type == 2){
if(ui->lineEdit_name->text().size()>14||ui->lineEdit_name->text()==NULL){ if(x==1){//账号(工号)判别
return false; if(ui->lineEdit_account->text().size()!=12){
}else{ return false;
return true; }else{
} QString str = ui->lineEdit_account->text();
}else if(x==5){//身份证号判别 for(int i=0;i<12;i++){
if(ui->lineEdit_id->text().size()!=18){ 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'){
return false; return false;
}else{ }
QString str = ui->lineEdit_id->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;
} }
return true; }else if(x==2){//密码判别
if(ui->lineEdit_password->text().size()<6||ui->lineEdit_password->text().size()>16){
return false;
}else{
QString str = ui->lineEdit_password->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->lineEdit_password->text(),ui->lineEdit_password_r->text())==0){
return true;
}else{
return false;
}
}else{
return false;
} }
}else{ }else{
return false; return false;
@ -99,31 +151,51 @@ bool registers::verify(int x){
void registers::on_pushButton_clicked() void registers::on_pushButton_clicked()
{ {
if(!verify(1)){ if(type== 1){
QMessageBox::warning(this, tr("提示"), tr("请检查账号是否符合规范,目前仅限中国大陆用户注册,手机号应为+86 11位号码")); if(!verify(1)){
}else if(!verify(2)){ QMessageBox::warning(this, tr("提示"), tr("请检查账号是否符合规范,目前仅限中国大陆用户注册,手机号应为+86 11位号码"));
QMessageBox::warning(this, tr("提示"), tr("请检查密码是否符合规范密码应由6-16位字母或数字组成")); }else if(!verify(2)){
}else if(!verify(3)){ QMessageBox::warning(this, tr("提示"), tr("请检查密码是否符合规范密码应由6-16位字母或数字组成"));
QMessageBox::warning(this, tr("提示"), tr("两次输入密码不相同,请重新输入!")); }else if(!verify(3)){
}else if(!verify(4)){ QMessageBox::warning(this, tr("提示"), tr("两次输入密码不相同,请重新输入!"));
QMessageBox::warning(this, tr("提示"), tr("姓名字数为空或超出,请重新输入!")); }else if(!verify(4)){
}else if(!verify(5)){ QMessageBox::warning(this, tr("提示"), tr("姓名字数为空或超出,请重新输入!"));
QMessageBox::warning(this, tr("提示"), tr("请检查身份证信息是否符合规范并重新输入!\n请注意X为大写字母")); }else if(!verify(5)){
QMessageBox::warning(this, tr("提示"), tr("请检查身份证信息是否符合规范并重新输入!\n请注意X为大写字母"));
}else{
sign_in();
QMessageBox::information(this, tr("提示"), tr("注册成功!"));
this->hide();
}
}else{ }else{
sign_in(); if(!verify(1)){
QMessageBox::information(this, tr("提示"), tr("注册成功!")); QMessageBox::warning(this, tr("提示"), tr("请检查账号是否符合规范账号应为12位纯数字工号"));
this->hide(); }else if(!verify(2)){
QMessageBox::warning(this, tr("提示"), tr("请检查密码是否符合规范密码应由6-16位字母或数字组成"));
}else if(!verify(3)){
QMessageBox::warning(this, tr("提示"), tr("两次输入密码不相同,请重新输入!"));
}else{
sign_in();
QMessageBox::information(this, tr("提示"), tr("注册成功!"));
this->hide();
}
} }
} }
void registers::sign_in(){ void registers::sign_in(){
QString gender; if(type==1){
if(ui->radioButton_M->isChecked()){ QString gender;
gender = ""; if(ui->radioButton_M->isChecked()){
gender = "";
}else{
gender = "";
}
QString sql = QString("INSERT INTO customer VALUES('%1','%2','%3','%4','%5',NULL);").arg(ui->lineEdit_account->text()).arg(ui->lineEdit_password->text()).arg(ui->lineEdit_name->text()).arg(gender).arg(ui->lineEdit_id->text());
QSqlQuery query;
query.exec(sql);
}else{ }else{
gender = ""; QString sql = QString("INSERT INTO employee VALUES('%1','%2');").arg(ui->lineEdit_account->text()).arg(ui->lineEdit_password->text());
QSqlQuery query;
query.exec(sql);
} }
QString sql = QString("INSERT INTO customer VALUES('%1','%2','%3','%4','%5',NULL);").arg(ui->lineEdit_account->text()).arg(ui->lineEdit_password->text()).arg(ui->lineEdit_name->text()).arg(gender).arg(ui->lineEdit_id->text());
QSqlQuery query;
query.exec(sql);
} }

@ -20,6 +20,7 @@ class registers : public QMainWindow
public: public:
explicit registers(QWidget *parent = nullptr); explicit registers(QWidget *parent = nullptr);
~registers(); ~registers();
void settype(int i);
protected: protected:
void paintEvent(QPaintEvent*); void paintEvent(QPaintEvent*);
@ -33,6 +34,7 @@ private:
Ui::registers *ui; Ui::registers *ui;
QLabel *bg; QLabel *bg;
QSqlDatabase db; QSqlDatabase db;
int type;
}; };
#endif // REGISTERS_H #endif // REGISTERS_H

Loading…
Cancel
Save