forked from pvbgfm6cj/hotel
Compare commits
31 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
0e1f560d20 | 2 years ago |
|
|
694efb40df | 2 years ago |
|
|
5d2f6bb6bb | 2 years ago |
|
|
bdaeb06d87 | 2 years ago |
|
|
06700dff52 | 2 years ago |
|
|
b6c9de9d23 | 2 years ago |
|
|
7cda93a33c | 2 years ago |
|
|
15a4f2403e | 2 years ago |
|
|
0732c2ec8a | 2 years ago |
|
|
8f504cfc91 | 2 years ago |
|
|
c41c516502 | 2 years ago |
|
|
c478e48755 | 2 years ago |
|
|
08ede05b40 | 2 years ago |
|
|
d317218856 | 2 years ago |
|
|
b633b99448 | 2 years ago |
|
|
d948c53351 | 2 years ago |
|
|
9bfc0a8eb3 | 2 years ago |
|
|
14adcb035b | 2 years ago |
|
|
112b11bb82 | 2 years ago |
|
|
1d673cab7f | 2 years ago |
|
|
ca1b9ea3b4 | 2 years ago |
|
|
ae9b3cf942 | 2 years ago |
|
|
803f33734d | 2 years ago |
|
|
72dd10d7a9 | 2 years ago |
|
|
69da6c2007 | 2 years ago |
|
|
2d0592906a | 2 years ago |
|
|
1e222668ae | 2 years ago |
|
|
ad4f1952a0 | 2 years ago |
|
|
30ab777369 | 2 years ago |
|
|
7b4196485c | 2 years ago |
|
|
08dfe9c660 | 2 years ago |
@ -1,2 +1,7 @@
|
||||
# hotel
|
||||
# 基于Qt开发的宾馆客房管理系统
|
||||
|
||||
## 系统的基本功能
|
||||
|
||||
1. 客房各种信息,包括客房的类别、当前的状态、负责人等;
|
||||
2. 客房信息的查询和修改,包括按房间号查询住宿情况、按客户信息查询房间状态等;
|
||||
3. 退房、订房、换房等信息的修改,对查询、统计结果打印输出。
|
||||
|
||||
@ -0,0 +1,42 @@
|
||||
#include "add_administration.h"
|
||||
#include "ui_add_administration.h"
|
||||
#include "administration.h"
|
||||
|
||||
add_administration::add_administration(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::add_administration)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QIcon logo(":/image/icon/logo.png");
|
||||
this->setWindowIcon(logo);
|
||||
this->setWindowTitle("提示");
|
||||
this->setFixedSize(400,300);
|
||||
bg = new QLabel(this);
|
||||
bg->setScaledContents(true);
|
||||
bg->setPixmap(QPixmap(":/image/bg/add.jpg"));
|
||||
bg->lower();
|
||||
|
||||
}
|
||||
|
||||
add_administration::~add_administration()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void add_administration::paintEvent(QPaintEvent*)
|
||||
{
|
||||
bg->resize(ui->widget->size());
|
||||
}
|
||||
|
||||
void add_administration::on_pushButton_clicked()
|
||||
{
|
||||
//administration *ad = new administration;
|
||||
QSqlQuery query((db));
|
||||
query.prepare("INSERT into room VALUES(:n,1,1,1,1,NULL,NULL);");
|
||||
query.bindValue(":n",ui->lineEdit->text());
|
||||
query.exec();
|
||||
QMessageBox::information(this,tr("提示"),("添加成功,请刷新"));
|
||||
this->hide();
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
#ifndef ADD_ADMINISTRATION_H
|
||||
#define ADD_ADMINISTRATION_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <qsqldatabase.h>
|
||||
#include <administration.h>
|
||||
#include <QLabel>
|
||||
|
||||
namespace Ui {
|
||||
class add_administration;
|
||||
}
|
||||
|
||||
class add_administration : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit add_administration(QWidget *parent = nullptr);
|
||||
~add_administration();
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent*);
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::add_administration *ui;
|
||||
QSqlDatabase db;
|
||||
QLabel *bg;
|
||||
};
|
||||
|
||||
#endif // ADD_ADMINISTRATION_H
|
||||
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>add_administration</class>
|
||||
<widget class="QDialog" name="add_administration">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>50</x>
|
||||
<y>90</y>
|
||||
<width>301</width>
|
||||
<height>81</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>房间号:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>230</y>
|
||||
<width>100</width>
|
||||
<height>30</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确定</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -1,14 +1,515 @@
|
||||
#include "administration.h"
|
||||
#include "ui_administration.h"
|
||||
#include "registers.h"
|
||||
#include "add_administration.h"
|
||||
|
||||
administration::administration(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::administration)
|
||||
ui(new Ui::administration){
|
||||
init();
|
||||
}
|
||||
void administration::paintEvent(QPaintEvent*)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
labels->resize(ui->widget->size());
|
||||
}
|
||||
|
||||
void administration::init()
|
||||
{
|
||||
ui->setupUi(this);
|
||||
this->setFixedSize(1920,1080);
|
||||
this->setWindowTitle("用户界面");
|
||||
this->setWindowIcon(QIcon(":image/icon/logo"));
|
||||
|
||||
labels = new QLabel(this);
|
||||
labels->setScaledContents(true);
|
||||
labels->setFixedSize(1920,1080);
|
||||
labels->setPixmap(QPixmap(":/image/bg/login.png"));
|
||||
labels->lower();
|
||||
ui->HotelTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
ui->AcounTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
ui->AcounTable->horizontalHeader()->setStyleSheet("QHeaderView::section{background-color: rgb(0, 0, 0,30);}");//表头透明度
|
||||
ui->AcounTable->verticalHeader()->setStyleSheet("QHeaderView::section{background-color: rgb(0, 0, 0,30);}");//行头透明度
|
||||
ui->HotelTable->horizontalHeader()->setStyleSheet("QHeaderView::section{background-color: rgb(0, 0, 0,30);}");//表头透明度
|
||||
ui->HotelTable->verticalHeader()->setStyleSheet("QHeaderView::section{background-color: rgb(0, 0, 0,30);}");//行头透明度
|
||||
ui->Add->setEnabled(false);//初始退订按钮灰色
|
||||
ui->Del->setEnabled(false);//初始退订按钮灰色
|
||||
ui->Modify->setEnabled(false);//初始退订按钮灰色
|
||||
ui->Search->setEnabled(false);//初始退订按钮灰色
|
||||
ui->AcounTable->hide();
|
||||
ui->HotelTable->hide();
|
||||
on_Hman_clicked();
|
||||
|
||||
}
|
||||
|
||||
void administration::init_account(){
|
||||
findall2();
|
||||
flush_data2(userinfo);
|
||||
value_customer = ui->AcounTable->model()->rowCount();
|
||||
findall3();
|
||||
flush_data3(userinfo);
|
||||
|
||||
ui->AcounTable->setHorizontalHeaderLabels({"客户账号","密码","姓名","性别","身份证"});
|
||||
}
|
||||
|
||||
void administration::init_hotel(){
|
||||
findall();
|
||||
flush_data(userinfo);
|
||||
ui->HotelTable->setHorizontalHeaderLabels({"房间号","房间类型","是否带窗","负责人","状态"});
|
||||
}
|
||||
|
||||
administration::~administration()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//切换到Hotel table,同时关闭Acount table
|
||||
void administration::on_Hman_clicked()
|
||||
{
|
||||
ui->Add->setEnabled(true);//初始退订按钮灰色
|
||||
ui->Del->setEnabled(true);//初始退订按钮灰色
|
||||
ui->Modify->setEnabled(true);//初始退订按钮灰色
|
||||
ui->Search->setEnabled(true);//初始退订按钮灰色
|
||||
init_hotel();
|
||||
ui->HotelTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
||||
ui->HotelTable->setSelectionBehavior(QAbstractItemView::SelectRows); //整行选中的方式
|
||||
ui->HotelTable->setSelectionMode(QAbstractItemView::SingleSelection); //设置可以选中单个
|
||||
ui->HotelTable->show();
|
||||
ui->AcounTable->hide();
|
||||
tool = 1;
|
||||
}
|
||||
|
||||
|
||||
//切换到Acount table,同时关闭Hotel table
|
||||
void administration::on_Aman_clicked()
|
||||
{
|
||||
ui->Add->setEnabled(true);//初始退订按钮灰色
|
||||
ui->Del->setEnabled(true);//初始退订按钮灰色
|
||||
ui->Modify->setEnabled(true);//初始退订按钮灰色
|
||||
ui->Search->setEnabled(true);//初始退订按钮灰色
|
||||
init_account();
|
||||
ui->AcounTable->setSelectionBehavior(QAbstractItemView::SelectRows); //整行选中的方式
|
||||
ui->AcounTable->setSelectionMode(QAbstractItemView::SingleSelection); //设置可以选中单个
|
||||
ui->HotelTable->hide();
|
||||
ui->AcounTable->show();
|
||||
tool = 0;
|
||||
}
|
||||
//增加行 完成
|
||||
void administration::on_Add_clicked()
|
||||
{
|
||||
if(tool == 0){
|
||||
registers *reg = new registers;
|
||||
reg->settype(2);
|
||||
reg->show();
|
||||
/*int cols=ui->AcounTable->columnCount();
|
||||
int rows=ui->AcounTable->rowCount();
|
||||
qDebug()<<rows;
|
||||
ui->AcounTable->insertRow(rows);
|
||||
for(int i=0;i<cols;i++)
|
||||
{
|
||||
ui->AcounTable->setItem(rows,i,new QTableWidgetItem(""));
|
||||
}
|
||||
ui->AcounTable->selectRow(rows);
|
||||
QSqlQuery query((db));
|
||||
query.prepare("INSERT into customer VALUES(:n,1,1,1,1,NULL);");
|
||||
|
||||
query.bindValue(":n",QRandomGenerator::global()->bounded(10000));//随机数 一万以内正整数
|
||||
query.exec();
|
||||
QMessageBox::information(this,tr("提示"),("添加成功"));
|
||||
init_account();*/
|
||||
|
||||
}
|
||||
else if(tool == 1){
|
||||
int cols=ui->HotelTable->columnCount();
|
||||
int rows=ui->HotelTable->rowCount();
|
||||
ui->HotelTable->insertRow(rows);
|
||||
for(int i=0;i<cols;i++)
|
||||
{
|
||||
ui->HotelTable->setItem(rows,i,new QTableWidgetItem(""));
|
||||
}
|
||||
ui->HotelTable->selectRow(rows);
|
||||
add_administration *ad = new add_administration;
|
||||
ad->show();
|
||||
}
|
||||
else QMessageBox::about(this,"警告","出错");
|
||||
}
|
||||
|
||||
//删除操作 完成
|
||||
void administration::on_Del_clicked()
|
||||
{
|
||||
if(tool == 0){
|
||||
//if(row <= value_customer-userinfo.size()+1){
|
||||
QSqlQuery query((db));
|
||||
QTableWidgetItem *item = ui->AcounTable->currentItem();
|
||||
QString n = 0;
|
||||
n = ui->AcounTable->model()->index(item->row(),0).data().toString();
|
||||
//int num = n.toInt();
|
||||
query.prepare("DELETE from customer where account = :num ");
|
||||
query.bindValue(":num",n);
|
||||
query.exec();
|
||||
query.prepare("DELETE from employee where account = :num ");
|
||||
query.bindValue(":num",n);
|
||||
query.exec();
|
||||
if(item==Q_NULLPTR)return;
|
||||
ui->AcounTable->removeRow(item->row());
|
||||
QMessageBox::information(this,tr("提示"),("删除成功"));
|
||||
init_account();
|
||||
// }
|
||||
/* else if(row > value_customer-userinfo.size()){
|
||||
QSqlQuery query((db));
|
||||
QTableWidgetItem *item = ui->AcounTable->currentItem();
|
||||
QString n = 0;
|
||||
n = ui->AcounTable->model()->index(item->row(),0).data().toString();//n是房间号
|
||||
int num = n.toInt();
|
||||
|
||||
if(item==Q_NULLPTR)return;
|
||||
ui->AcounTable->removeRow(item->row());
|
||||
QMessageBox::information(this,tr("提示"),("删除成功"));
|
||||
init_account();
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
else if(tool == 1){
|
||||
QSqlQuery query((db));
|
||||
QTableWidgetItem *item = ui->HotelTable->currentItem();
|
||||
QString n = 0;
|
||||
n = ui->HotelTable->model()->index(item->row(),0).data().toString();//n是房间号
|
||||
int num = n.toInt();
|
||||
query.prepare("DELETE from room where room_num = :num ");
|
||||
query.bindValue(":num",num);
|
||||
query.exec();
|
||||
if(item==Q_NULLPTR)return;
|
||||
ui->HotelTable->removeRow(item->row());
|
||||
QMessageBox::information(this,tr("提示"),("删除成功"));
|
||||
}
|
||||
else QMessageBox::about(this,"警告","出错");
|
||||
|
||||
|
||||
}
|
||||
|
||||
//修改操作
|
||||
void administration::on_Modify_clicked()
|
||||
{
|
||||
int c = row;
|
||||
if(tool == 0){
|
||||
//if(row <= value_customer-userinfo.size()){
|
||||
QSqlQuery query((db));
|
||||
QString n1 = 0;
|
||||
n1 = ui->AcounTable->model()->index(c,0).data().toString();//n是房间号
|
||||
num = n1.toInt();
|
||||
QString n2 = "0";
|
||||
n2 = ui->AcounTable->model()->index(c,1).data().toString();
|
||||
query.prepare("UPDATE customer set password=:QS where account = :num");
|
||||
query.bindValue(":QS",n2);
|
||||
query.bindValue(":num",n1);
|
||||
query.exec();
|
||||
QString n3 = 0;
|
||||
n3 = ui->AcounTable->model()->index(c,2).data().toString();
|
||||
query.prepare("UPDATE customer set name=:QS where account = :num");
|
||||
query.bindValue(":QS",n3);
|
||||
query.bindValue(":num",n1);
|
||||
query.exec();
|
||||
QString n4 = 0;
|
||||
n4 = ui->AcounTable->model()->index(c,3).data().toString();
|
||||
query.prepare("UPDATE customer set gender=:QS where account = :num");
|
||||
query.bindValue(":QS",n4);
|
||||
query.bindValue(":num",n1);
|
||||
query.exec();
|
||||
QString n5 = 0;
|
||||
n5 = ui->AcounTable->model()->index(c,4).data().toString();
|
||||
query.prepare("UPDATE customer set id=:QS where account = :num");
|
||||
query.bindValue(":QS",n5);
|
||||
query.bindValue(":num",n1);
|
||||
query.exec();
|
||||
query.prepare("UPDATE employee set password=:QS where account = :num");
|
||||
query.bindValue(":QS",n2);
|
||||
query.bindValue(":num",n1);
|
||||
query.exec();
|
||||
init_account();
|
||||
|
||||
// }
|
||||
/* else if(row > value_customer-userinfo.size()){
|
||||
QSqlQuery query((db));
|
||||
QString n1 = 0;
|
||||
n1 = ui->AcounTable->model()->index(row,0).data().toString();//n是房间号
|
||||
num = n1.toInt();
|
||||
QString n2 = "0";
|
||||
n2 = ui->AcounTable->model()->index(row,1).data().toString();
|
||||
|
||||
init_account();*/
|
||||
//}
|
||||
}
|
||||
|
||||
else if(tool == 1){
|
||||
QSqlQuery query((db));
|
||||
QString n1 = 0;
|
||||
n1 = ui->HotelTable->model()->index(c,0).data().toString();//n是房间号
|
||||
num = n1.toInt();
|
||||
QString n2 = "0";
|
||||
n2 = ui->HotelTable->model()->index(c,1).data().toString();
|
||||
query.prepare("UPDATE room set type=:QS where room_num = :num");
|
||||
query.bindValue(":QS",n2);
|
||||
query.bindValue(":num",num);
|
||||
query.exec();
|
||||
QString n3 = 0;
|
||||
n3 = ui->HotelTable->model()->index(c,2).data().toString();
|
||||
query.prepare("UPDATE room set withwindow=:QS where room_num = :num");
|
||||
query.bindValue(":QS",n3);
|
||||
query.bindValue(":num",num);
|
||||
query.exec();
|
||||
QString n4 = 0;
|
||||
n4 = ui->HotelTable->model()->index(c,3).data().toString();
|
||||
query.prepare("UPDATE room set responsible_person=:QS where room_num = :num");
|
||||
query.bindValue(":QS",n4);
|
||||
query.bindValue(":num",num);
|
||||
query.exec();
|
||||
QString n5 = 0;
|
||||
n5 = ui->HotelTable->model()->index(c,4).data().toString();
|
||||
query.prepare("UPDATE room set status=:QS where room_num = :num");
|
||||
query.bindValue(":QS",n5);
|
||||
query.bindValue(":num",num);
|
||||
query.exec();
|
||||
init_hotel();
|
||||
}
|
||||
QMessageBox::information(this,tr("提示"),("修改成功"));
|
||||
}
|
||||
|
||||
//插入账号数据
|
||||
void administration::flush_data2(QVector<QVector<QString>>&userinfo)//插入数据 完成
|
||||
{
|
||||
ui->AcounTable->clear();
|
||||
if(!userinfo.size())return;
|
||||
ui->AcounTable->setRowCount(userinfo.size());//行
|
||||
ui->AcounTable->setColumnCount(5);//列
|
||||
|
||||
for(int i=0;i<userinfo.size();i++)
|
||||
{
|
||||
for(int j=0;j<userinfo[0].size();j++)
|
||||
{
|
||||
QTableWidgetItem *QW = new QTableWidgetItem(userinfo[i][j]);
|
||||
ui->AcounTable->setItem(i,j,QW);//行 列 内容
|
||||
QW->setTextAlignment(Qt::AlignCenter);//设置中心对齐
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//插入客房数据
|
||||
void administration::flush_data(QVector<QVector<QString>>&userinfo)//插入数据 完成
|
||||
{
|
||||
ui->HotelTable->clear();
|
||||
if(!userinfo.size())return;
|
||||
ui->HotelTable->setRowCount(userinfo.size());//行
|
||||
ui->HotelTable->setColumnCount(5);//列
|
||||
|
||||
for(int i=0;i<userinfo.size();i++)
|
||||
{
|
||||
for(int j=0;j<userinfo[0].size();j++)
|
||||
{
|
||||
QTableWidgetItem *QW = new QTableWidgetItem(userinfo[i][j]);
|
||||
ui->HotelTable->setItem(i,j,QW);//行 列 内容
|
||||
QW->setTextAlignment(Qt::AlignCenter);//设置中心对齐
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void administration::flush_data3(QVector<QVector<QString>>&userinfo)//插入数据 完成
|
||||
{
|
||||
//ui->AcounTable->clear();
|
||||
if(!userinfo.size())return;
|
||||
ui->AcounTable->setRowCount(userinfo.size()+ui->AcounTable->model()->rowCount());//行
|
||||
//ui->AcounTable->setColumnCount(5);//列
|
||||
for(int i=0;i<userinfo.size();i++)
|
||||
{
|
||||
for(int j=0;j<userinfo[0].size();j++)
|
||||
{
|
||||
QTableWidgetItem *QW = new QTableWidgetItem(userinfo[i][j]);
|
||||
QTableWidgetItem *QW2 = new QTableWidgetItem("/");
|
||||
QTableWidgetItem *QW3 = new QTableWidgetItem("/");
|
||||
QTableWidgetItem *QW4 = new QTableWidgetItem("/");
|
||||
ui->AcounTable->setItem(i+ui->AcounTable->model()->rowCount()-userinfo.size(),j,QW);//行 列 内容
|
||||
ui->AcounTable->setItem(i+ui->AcounTable->model()->rowCount()-userinfo.size(),2,QW2);
|
||||
ui->AcounTable->setItem(i+ui->AcounTable->model()->rowCount()-userinfo.size(),3,QW3);
|
||||
ui->AcounTable->setItem(i+ui->AcounTable->model()->rowCount()-userinfo.size(),4,QW4);
|
||||
QW->setTextAlignment(Qt::AlignCenter);//设置中心对齐
|
||||
QW2->setTextAlignment(Qt::AlignCenter);
|
||||
QW3->setTextAlignment(Qt::AlignCenter);
|
||||
QW4->setTextAlignment(Qt::AlignCenter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//搜索
|
||||
void administration::findall()//显示全部 完成
|
||||
{
|
||||
userinfo.clear();//清楚存储向量rec的向量的数据
|
||||
QSqlQuery query((db));
|
||||
query.prepare("select * from room");
|
||||
|
||||
if(query.exec())
|
||||
{
|
||||
while (query.next()) {
|
||||
QVector<QString>rec;
|
||||
for(int i=0;i<query.record().count();i++)
|
||||
{
|
||||
rec.push_back(query.record().value(i).toString());//将sql搜索到的一行记录塞入rec向量
|
||||
}
|
||||
userinfo.push_back(rec);//将rec向量塞入向量
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void administration::findall2()//显示全部 完成
|
||||
{
|
||||
userinfo.clear();//清楚存储向量rec的向量的数据
|
||||
QSqlQuery query((db));
|
||||
query.prepare("select * from customer");
|
||||
|
||||
if(query.exec())
|
||||
{
|
||||
while (query.next()) {
|
||||
QVector<QString>rec;
|
||||
for(int i=0;i<query.record().count();i++)
|
||||
{
|
||||
rec.push_back(query.record().value(i).toString());//将sql搜索到的一行记录塞入rec向量
|
||||
}
|
||||
userinfo.push_back(rec);//将rec向量塞入向量
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void administration::findall3()//显示全部 完成
|
||||
{
|
||||
userinfo.clear();//清楚存储向量rec的向量的数据
|
||||
QSqlQuery query((db));
|
||||
query.prepare("select * from employee");
|
||||
|
||||
if(query.exec())
|
||||
{
|
||||
while (query.next()) {
|
||||
QVector<QString>rec;
|
||||
for(int i=0;i<query.record().count();i++)
|
||||
{
|
||||
rec.push_back(query.record().value(i).toString());//将sql搜索到的一行记录塞入rec向量
|
||||
}
|
||||
userinfo.push_back(rec);//将rec向量塞入向量
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void administration::on_Search_clicked()
|
||||
{
|
||||
QString number=ui->lineEdit->text();
|
||||
|
||||
|
||||
if(number == NULL && tool == 0){
|
||||
init_account();
|
||||
}
|
||||
else if(number == NULL && tool == 1){
|
||||
init_hotel();
|
||||
}
|
||||
|
||||
else if(find_byname2(number) && tool == 0)
|
||||
{
|
||||
flush_data2(userinfo);
|
||||
userinfo.clear();
|
||||
if(ui->AcounTable->model()->index(0,0).data().toString() != NULL)condition_search = 1;
|
||||
|
||||
if(condition_search == 0 && find_byname3(number) && tool == 0){
|
||||
flush_data2(userinfo);
|
||||
userinfo.clear();
|
||||
|
||||
}
|
||||
condition_search = 0;
|
||||
ui->AcounTable->setHorizontalHeaderLabels({"客户账号","密码","姓名","性别","身份证"});
|
||||
}
|
||||
|
||||
else if(find_byname(number) && tool == 1){
|
||||
flush_data(userinfo);
|
||||
userinfo.clear();
|
||||
ui->HotelTable->setHorizontalHeaderLabels({"房间号","房间类型","是否带窗","负责人","状态"});
|
||||
}
|
||||
else QMessageBox::critical(nullptr, "错误", "未知的错误", QMessageBox::Retry);
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool administration::find_byname(QString n)//搜索 完成
|
||||
{
|
||||
int number = n.toInt();
|
||||
userinfo.clear();
|
||||
QSqlQuery query(db);
|
||||
query.prepare("select * from room where room_num like :number;");//以开头搜索 不行
|
||||
query.bindValue(":number",number);
|
||||
if(query.exec())
|
||||
{
|
||||
while (query.next()) {
|
||||
QVector<QString>rec;
|
||||
rec.push_back(query.record().value("room_num").toString());
|
||||
rec.push_back(query.record().value("type").toString());
|
||||
rec.push_back(query.record().value("withwindow").toString());
|
||||
rec.push_back(query.record().value("responsible_person").toString());
|
||||
rec.push_back(query.record().value("status").toString());
|
||||
rec.push_back(query.record().value("checkout_time").toString());
|
||||
rec.push_back(query.record().value("customer_id").toString());
|
||||
userinfo.push_back(rec);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool administration::find_byname2(QString n)//搜索
|
||||
{
|
||||
userinfo.clear();
|
||||
QSqlQuery query(db);
|
||||
query.prepare("select * from customer where account like :number;");//以开头搜索 不行
|
||||
query.bindValue(":number",n);
|
||||
if(query.exec())
|
||||
{
|
||||
while (query.next()) {
|
||||
QVector<QString>rec;
|
||||
rec.push_back(query.record().value("account").toString());
|
||||
rec.push_back(query.record().value("password").toString());
|
||||
rec.push_back(query.record().value("name").toString());
|
||||
rec.push_back(query.record().value("gender").toString());
|
||||
rec.push_back(query.record().value("id").toString());
|
||||
userinfo.push_back(rec);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool administration::find_byname3(QString n)//搜索
|
||||
{
|
||||
userinfo.clear();
|
||||
QSqlQuery query(db);
|
||||
query.prepare("select * from employee where account like :number;");//以开头搜索 不行
|
||||
query.bindValue(":number",n);
|
||||
if(query.exec())
|
||||
{
|
||||
while (query.next()) {
|
||||
QVector<QString>rec;
|
||||
rec.push_back(query.record().value("account").toString());
|
||||
rec.push_back(query.record().value("password").toString());
|
||||
userinfo.push_back(rec);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void administration::on_AcounTable_itemClicked(QTableWidgetItem *item)
|
||||
{
|
||||
row = item->row();
|
||||
qDebug() << "当前选中行: " << row;
|
||||
}
|
||||
|
||||
|
||||
void administration::on_HotelTable_itemClicked(QTableWidgetItem *item)
|
||||
{
|
||||
row = item->row();
|
||||
qDebug() << "当前选中行: " << row;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>cellstatus</class>
|
||||
<widget class="QWidget" name="cellstatus">
|
||||
<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">
|
||||
<item row="0" column="0">
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>订</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>退</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -0,0 +1,40 @@
|
||||
#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);
|
||||
}
|
||||
@ -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,51 @@
|
||||
<?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="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>查看</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -0,0 +1,57 @@
|
||||
#include "customerinfo.h"
|
||||
#include "ui_customerinfo.h"
|
||||
#include <QDebug>
|
||||
|
||||
customerinfo::customerinfo(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::customerinfo)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QIcon logo(":/image/icon/logo.png");
|
||||
this->setWindowIcon(logo);
|
||||
this->setWindowTitle("客户信息");
|
||||
this->setFixedSize(800,600);
|
||||
bg = new QLabel(this);
|
||||
bg->setScaledContents(true);
|
||||
bg->setPixmap(QPixmap(":/image/bg/register.jpg"));
|
||||
bg->lower();
|
||||
|
||||
ui->lineEdit->setEnabled(false);
|
||||
ui->lineEdit_2->setEnabled(false);
|
||||
ui->lineEdit_3->setEnabled(false);
|
||||
ui->lineEdit_4->setEnabled(false);
|
||||
}
|
||||
|
||||
customerinfo::~customerinfo()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void customerinfo::paintEvent(QPaintEvent*)
|
||||
{
|
||||
bg->resize(ui->widget->size());
|
||||
QSqlQuery query;
|
||||
query.prepare("select * from customer where room_num like :roomNum;");
|
||||
query.bindValue(":roomNum",roomNum);
|
||||
query.exec();
|
||||
if(query.next()){
|
||||
ui->lineEdit->setText(query.value(0).toString());
|
||||
ui->lineEdit_2->setText(query.value(2).toString());
|
||||
ui->lineEdit_3->setText(query.value(3).toString());
|
||||
ui->lineEdit_4->setText(query.value(4).toString());
|
||||
}
|
||||
}
|
||||
|
||||
void customerinfo::setroomNum(int roomNum){
|
||||
this->roomNum = roomNum;
|
||||
}
|
||||
|
||||
void customerinfo::setDB(QSqlDatabase db){
|
||||
this->db = db;
|
||||
}
|
||||
|
||||
void customerinfo::on_pushButton_clicked()
|
||||
{
|
||||
this->hide();
|
||||
}
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
#ifndef CUSTOMERINFO_H
|
||||
#define CUSTOMERINFO_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlQuery>
|
||||
#include <QLabel>
|
||||
|
||||
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);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent*);
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
private:
|
||||
Ui::customerinfo *ui;
|
||||
QSqlDatabase db;
|
||||
int roomNum;
|
||||
QLabel *bg;
|
||||
};
|
||||
|
||||
#endif // CUSTOMERINFO_H
|
||||
@ -0,0 +1,178 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>orderoom</class>
|
||||
<widget class="QWidget" name="orderoom">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>200</x>
|
||||
<y>60</y>
|
||||
<width>461</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">border-radius:15px;</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="btn_search">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>670</x>
|
||||
<y>60</y>
|
||||
<width>121</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>检索</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
<width>341</width>
|
||||
<height>131</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>检索客户信息:</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="horizontalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>-1</x>
|
||||
<y>489</y>
|
||||
<width>801</width>
|
||||
<height>111</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_registers">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>新建客户</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_order">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::NoFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>订房</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QTableWidget" name="tableWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>130</y>
|
||||
<width>781</width>
|
||||
<height>341</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">background-color: rgb(0, 0, 0,50);
|
||||
color: rgb(255, 255, 255);</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -1,14 +1,151 @@
|
||||
#include "receptionist.h"
|
||||
#include "ui_receptionist.h"
|
||||
#include "cellstatus.h"
|
||||
#include "checkbtn.h"
|
||||
|
||||
receptionist::receptionist(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
ui(new Ui::receptionist)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
QIcon logo(":/image/icon/logo.png");
|
||||
this->setWindowIcon(logo);
|
||||
this->setWindowTitle("宜客酒店");
|
||||
this->setFixedSize(1920,1080);
|
||||
bg = new QLabel(this);
|
||||
bg->setScaledContents(true);
|
||||
bg->setPixmap(QPixmap(":/image/bg/login.png"));
|
||||
bg->lower();
|
||||
|
||||
// 设置主窗口大小为1920x1080
|
||||
this->setFixedSize(1920,1080);
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
// 创建 QTableWidget 和其他组件
|
||||
ui->tableWidget->setRowCount(3);
|
||||
ui->tableWidget->setColumnCount(8);
|
||||
ui->tableWidget->verticalHeader()->setVisible(false);
|
||||
ui->tableWidget->setHorizontalHeaderLabels({"房间号","房间类型","是否带窗","负责人","状态","退房时间","客户信息","操作"});
|
||||
ui->tableWidget->horizontalHeader()->setStyleSheet("QHeaderView::section{background-color: rgb(0, 0, 0,30);}");//表头透明度
|
||||
ui->tableWidget->setStyleSheet("QTableWidget{border:2px groove gray;border-radius:15px;background-color: rgb(0, 0, 0,30);color: rgb(255, 255, 255);}");
|
||||
showall();
|
||||
}
|
||||
|
||||
receptionist::~receptionist()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void receptionist::paintEvent(QPaintEvent *)
|
||||
{
|
||||
QStyleOption opt;
|
||||
opt.init(this);
|
||||
QPainter p(this);
|
||||
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
|
||||
bg->resize(ui->widget->size());
|
||||
}
|
||||
|
||||
void receptionist::showall(){
|
||||
QSqlQuery query;
|
||||
query.exec("select * from room");
|
||||
ui->tableWidget->setRowCount(query.size());
|
||||
int i = 0;
|
||||
if(query.exec()){
|
||||
while(query.next()){
|
||||
//数据
|
||||
for(int j = 0;j<6;j++){
|
||||
QTableWidgetItem *twi = new QTableWidgetItem(query.value(j).toString());
|
||||
twi->setTextAlignment(Qt::AlignCenter);
|
||||
ui->tableWidget->setItem(i,j,twi);
|
||||
ui->tableWidget->setColumnWidth(j,259);
|
||||
}
|
||||
cellstatus* cell = new cellstatus();
|
||||
connect(cell,&cellstatus::flash,this,&receptionist::onflash);
|
||||
cell->setDB(db);
|
||||
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){
|
||||
cell->setisused(true);
|
||||
cbtn->setisused(true);
|
||||
}else{
|
||||
cell->setisused(false);
|
||||
cbtn->setisused(false);
|
||||
}
|
||||
cell->setbtn();
|
||||
cbtn->setbtn();
|
||||
|
||||
ui->tableWidget->setCellWidget(i,7,cell);
|
||||
ui->tableWidget->setCellWidget(i,6,cbtn);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void receptionist::search(QString str){
|
||||
int s = str.toInt();
|
||||
ui->tableWidget->setRowCount(1);
|
||||
ui->tableWidget->clear();
|
||||
ui->tableWidget->setHorizontalHeaderLabels({"房间号","房间类型","是否带窗","负责人","状态","退房时间","客户信息","操作"});
|
||||
QSqlQuery query;
|
||||
query.prepare("select * from room where room_num like :str;");
|
||||
query.bindValue(":str",s);
|
||||
if(query.exec()){
|
||||
while (query.next()){
|
||||
for(int j = 0;j<6;j++){
|
||||
QTableWidgetItem *twi = new QTableWidgetItem(query.value(j).toString());
|
||||
twi->setTextAlignment(Qt::AlignCenter);
|
||||
ui->tableWidget->setItem(0,j,twi);
|
||||
ui->tableWidget->setColumnWidth(j,259);
|
||||
}
|
||||
cellstatus* cell = new cellstatus();
|
||||
connect(cell,&cellstatus::flash,this,&receptionist::onflash);
|
||||
cell->setDB(db);
|
||||
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(0,4).data().toString(),"使用")==0){
|
||||
cell->setisused(true);
|
||||
cbtn->setisused(true);
|
||||
}else{
|
||||
cell->setisused(false);
|
||||
cbtn->setisused(false);
|
||||
}
|
||||
cell->setbtn();
|
||||
cbtn->setbtn();
|
||||
|
||||
ui->tableWidget->setCellWidget(0,7,cell);
|
||||
ui->tableWidget->setCellWidget(0,6,cbtn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void receptionist::on_pushButton_clicked()
|
||||
{
|
||||
QString str = ui->lineEdit->text();
|
||||
if(str == NULL){
|
||||
showall();
|
||||
}else{
|
||||
search(str);
|
||||
}
|
||||
}
|
||||
|
||||
void receptionist::onflash(){
|
||||
showall();
|
||||
}
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 167 KiB |
@ -0,0 +1,40 @@
|
||||
#ifndef REGISTERS_H
|
||||
#define REGISTERS_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QLabel>
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QMessageBox>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlQuery>
|
||||
|
||||
namespace Ui {
|
||||
class registers;
|
||||
}
|
||||
|
||||
class registers : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit registers(QWidget *parent = nullptr);
|
||||
~registers();
|
||||
void settype(int i);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent*);
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
|
||||
private:
|
||||
bool verify(int x);
|
||||
void sign_in();
|
||||
Ui::registers *ui;
|
||||
QLabel *bg;
|
||||
QSqlDatabase db;
|
||||
int type;
|
||||
};
|
||||
|
||||
#endif // REGISTERS_H
|
||||
@ -1,9 +1,14 @@
|
||||
<RCC>
|
||||
<qresource prefix="/image/bg">
|
||||
<file>login.png</file>
|
||||
<file>sea.jpg</file>
|
||||
<file>register.jpg</file>
|
||||
<file>order.png</file>
|
||||
<file>add.jpg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/image/icon">
|
||||
<file>info.png</file>
|
||||
<file>logo.png</file>
|
||||
<file>resetcode.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
|
After Width: | Height: | Size: 5.2 KiB |
@ -0,0 +1,39 @@
|
||||
#ifndef RESETMESSAGE_H
|
||||
#define RESETMESSAGE_H
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QLabel>
|
||||
#include <QDebug>
|
||||
#include <QString>
|
||||
#include <QMessageBox>
|
||||
#include <QSqlDatabase>
|
||||
#include <QSqlQuery>
|
||||
|
||||
namespace Ui {
|
||||
class ResetMessage;
|
||||
}
|
||||
|
||||
class ResetMessage : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ResetMessage(QWidget *parent = nullptr);
|
||||
~ResetMessage();
|
||||
void getid(QString str);
|
||||
protected:
|
||||
|
||||
|
||||
private:
|
||||
Ui::ResetMessage *ui;
|
||||
bool verify(int x);
|
||||
void sign_in();
|
||||
QLabel *bg;
|
||||
QSqlDatabase db;
|
||||
QString id;
|
||||
|
||||
private slots:
|
||||
void on_pushButton_clicked();
|
||||
};
|
||||
|
||||
#endif // RESETMESSAGE_H
|
||||
@ -0,0 +1,266 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ResetMessage</class>
|
||||
<widget class="QDialog" name="ResetMessage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<widget class="QLabel" name="label_code">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>70</y>
|
||||
<width>71</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 127);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>新密码</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_confirm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>160</y>
|
||||
<width>111</width>
|
||||
<height>41</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 127);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>确认密码</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_name">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>270</y>
|
||||
<width>101</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 127);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>姓名</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_id">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>370</y>
|
||||
<width>91</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 127);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>身份证</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="ID_card">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>370</y>
|
||||
<width>400</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="code">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>70</y>
|
||||
<width>400</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="confirm_code">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>170</y>
|
||||
<width>400</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="name">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>270</y>
|
||||
<width>400</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_gender">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>444</y>
|
||||
<width>61</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 127);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>性别</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_man">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>300</x>
|
||||
<y>444</y>
|
||||
<width>79</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
<bold>false</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 127);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>男</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QRadioButton" name="radioButton_woman">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>500</x>
|
||||
<y>444</y>
|
||||
<width>79</width>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(255, 255, 127);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>女</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>350</x>
|
||||
<y>520</y>
|
||||
<width>100</width>
|
||||
<height>50</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>15</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>更新</string>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><html><head/><body><p><img src=":/image/bg/sea.jpg"/></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
<zorder>label</zorder>
|
||||
<zorder>label_code</zorder>
|
||||
<zorder>label_confirm</zorder>
|
||||
<zorder>label_name</zorder>
|
||||
<zorder>label_id</zorder>
|
||||
<zorder>ID_card</zorder>
|
||||
<zorder>code</zorder>
|
||||
<zorder>confirm_code</zorder>
|
||||
<zorder>name</zorder>
|
||||
<zorder>label_gender</zorder>
|
||||
<zorder>radioButton_man</zorder>
|
||||
<zorder>radioButton_woman</zorder>
|
||||
<zorder>pushButton</zorder>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
After Width: | Height: | Size: 2.3 KiB |
Loading…
Reference in new issue