|
|
|
@ -3,17 +3,38 @@
|
|
|
|
|
#include "cellstatus.h"
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QPainter>
|
|
|
|
|
#include <QTextCodec>
|
|
|
|
|
#include <QSqlDatabase>
|
|
|
|
|
#include <QSqlQuery>
|
|
|
|
|
#include <QSqlError>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QVBoxLayout> // 添加这一行
|
|
|
|
|
|
|
|
|
|
receptionist::receptionist(QWidget *parent) :
|
|
|
|
|
QMainWindow(parent),
|
|
|
|
|
ui(new Ui::receptionist)
|
|
|
|
|
{
|
|
|
|
|
// 设置主窗口大小为1920x1080
|
|
|
|
|
this->setFixedSize(1920,1080);
|
|
|
|
|
|
|
|
|
|
// 创建一个垂直布局管理器
|
|
|
|
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
|
|
|
|
|
|
|
|
|
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
|
|
|
|
|
db.setHostName("127.0.0.1");
|
|
|
|
|
db.setPort(3306);
|
|
|
|
|
db.setDatabaseName("hotel");
|
|
|
|
|
db.setUserName("root");
|
|
|
|
|
db.setPassword("111111");
|
|
|
|
|
qDebug() << db.open();
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
|
|
|
|
|
// 创建 QTableWidget 和其他组件
|
|
|
|
|
ui->tableWidget->setRowCount(4);
|
|
|
|
|
ui->tableWidget->verticalHeader()->setVisible(false);
|
|
|
|
|
QStringList strs = {QString::fromLocal8Bit("房间号"), QString::fromLocal8Bit(" 房间类型 "), QString::fromLocal8Bit(" 是否带窗 "),
|
|
|
|
|
QString::fromLocal8Bit(" 负责人 "),QString::fromLocal8Bit(" 状态 "),QString::fromLocal8Bit(" 退房时间 "),
|
|
|
|
|
QString::fromLocal8Bit("客户信息"),QString::fromLocal8Bit("操作")};
|
|
|
|
|
QStringList strs = {QString::fromLocal8Bit(u8"房间号"), QString::fromLocal8Bit(u8" 房间类型 "), QString::fromLocal8Bit(u8" 是否带窗 "),
|
|
|
|
|
QString::fromLocal8Bit(u8" 负责人 "),QString::fromLocal8Bit(u8" 状态 "),QString::fromLocal8Bit(u8" 退房时间 "),
|
|
|
|
|
QString::fromLocal8Bit(u8"客户信息"),QString::fromLocal8Bit(u8"操作")};
|
|
|
|
|
ui->tableWidget->setColumnCount(strs.size());
|
|
|
|
|
ui->tableWidget->setStyleSheet("QTableWidget{border:2px groove gray;border-radius:15px;background-color:rgba(255, 255, 255, 30%);}");
|
|
|
|
|
ui->tableWidget->horizontalHeader()->setVisible(false);
|
|
|
|
@ -23,44 +44,34 @@ receptionist::receptionist(QWidget *parent) :
|
|
|
|
|
{
|
|
|
|
|
ui->tableWidget->setItem(0,i,new QTableWidgetItem(strs[i]));
|
|
|
|
|
}
|
|
|
|
|
ui->tableWidget->setCellWidget(1,7,new cellstatus());
|
|
|
|
|
ui->tableWidget->setCellWidget(1,6,new QPushButton(QString::fromLocal8Bit("查看")));
|
|
|
|
|
|
|
|
|
|
ui->tableWidget->setCellWidget(2,7,new cellstatus());
|
|
|
|
|
ui->tableWidget->setCellWidget(2,6,new QPushButton(QString::fromLocal8Bit("查看")));
|
|
|
|
|
|
|
|
|
|
ui->tableWidget->setCellWidget(3,7,new cellstatus());
|
|
|
|
|
ui->tableWidget->setCellWidget(3,6,new QPushButton(QString::fromLocal8Bit("查看")));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QSqlQuery query;
|
|
|
|
|
query.exec("select * from room");
|
|
|
|
|
int i = 1;
|
|
|
|
|
while(query.next()){
|
|
|
|
|
//数据
|
|
|
|
|
ui->tableWidget->setItem(1,0,new QTableWidgetItem(QString::fromLocal8Bit("1101")));
|
|
|
|
|
ui->tableWidget->setItem(1,1,new QTableWidgetItem(QString::fromLocal8Bit("双床房")));
|
|
|
|
|
ui->tableWidget->setItem(1,2,new QTableWidgetItem(QString::fromLocal8Bit("是")));
|
|
|
|
|
ui->tableWidget->setItem(1,3,new QTableWidgetItem(QString::fromLocal8Bit("李田所")));
|
|
|
|
|
ui->tableWidget->setItem(1,4,new QTableWidgetItem(QString::fromLocal8Bit("使用")));
|
|
|
|
|
ui->tableWidget->setItem(1,5,new QTableWidgetItem(QString::fromLocal8Bit("8/22")));
|
|
|
|
|
|
|
|
|
|
ui->tableWidget->setItem(2,0,new QTableWidgetItem(QString::fromLocal8Bit("1102")));
|
|
|
|
|
ui->tableWidget->setItem(2,1,new QTableWidgetItem(QString::fromLocal8Bit("大床房")));
|
|
|
|
|
ui->tableWidget->setItem(2,2,new QTableWidgetItem(QString::fromLocal8Bit("是")));
|
|
|
|
|
ui->tableWidget->setItem(2,3,new QTableWidgetItem(QString::fromLocal8Bit("李田所")));
|
|
|
|
|
ui->tableWidget->setItem(2,4,new QTableWidgetItem(QString::fromLocal8Bit("空闲")));
|
|
|
|
|
ui->tableWidget->setItem(2,5,new QTableWidgetItem(QString::fromLocal8Bit("-/--")));
|
|
|
|
|
|
|
|
|
|
ui->tableWidget->setItem(3,0,new QTableWidgetItem(QString::fromLocal8Bit("1103")));
|
|
|
|
|
ui->tableWidget->setItem(3,1,new QTableWidgetItem(QString::fromLocal8Bit("电竞房")));
|
|
|
|
|
ui->tableWidget->setItem(3,2,new QTableWidgetItem(QString::fromLocal8Bit("否")));
|
|
|
|
|
ui->tableWidget->setItem(3,3,new QTableWidgetItem(QString::fromLocal8Bit("李田所")));
|
|
|
|
|
ui->tableWidget->setItem(3,4,new QTableWidgetItem(QString::fromLocal8Bit("空闲")));
|
|
|
|
|
ui->tableWidget->setItem(3,5,new QTableWidgetItem(QString::fromLocal8Bit("-/--")));
|
|
|
|
|
setStyleSheet("QWidget#Widget{border-image:url(:/image/bg/backgroud.jpg);"
|
|
|
|
|
"background-repeat:no-repeat;"
|
|
|
|
|
"background-position: center;}");
|
|
|
|
|
ui->tableWidget->setItem(i,0,new QTableWidgetItem(QString::fromLocal8Bit(query.value(0).toString().toUtf8().data())));
|
|
|
|
|
ui->tableWidget->setItem(i,1,new QTableWidgetItem(QString::fromLocal8Bit(query.value(1).toString().toUtf8().data())));
|
|
|
|
|
ui->tableWidget->setItem(i,2,new QTableWidgetItem(QString::fromLocal8Bit(query.value(2).toString().toUtf8().data())));
|
|
|
|
|
ui->tableWidget->setItem(i,3,new QTableWidgetItem(QString::fromLocal8Bit(query.value(3).toString().toUtf8().data())));
|
|
|
|
|
ui->tableWidget->setItem(i,4,new QTableWidgetItem(QString::fromLocal8Bit(query.value(4).toString().toUtf8().data())));
|
|
|
|
|
ui->tableWidget->setItem(i,5,new QTableWidgetItem(QString::fromLocal8Bit(query.value(5).toString().toUtf8().data())));
|
|
|
|
|
cellstatus* cell = new cellstatus();
|
|
|
|
|
cell->setroomNum(query.value(0).toInt());
|
|
|
|
|
cell->setDB(db);
|
|
|
|
|
ui->tableWidget->setCellWidget(i,7,cell);
|
|
|
|
|
ui->tableWidget->setCellWidget(i,6,new QPushButton(QString::fromLocal8Bit("查看")));
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*room* m_room = new room();
|
|
|
|
|
m_room->show();*/
|
|
|
|
|
// 将 QTableWidget 和其他组件添加到布局管理器中
|
|
|
|
|
layout->addWidget(ui->tableWidget); // 例如,添加您的表格
|
|
|
|
|
layout->addStretch(); // 添加伸缩项,将组件推到窗口中央
|
|
|
|
|
|
|
|
|
|
// 将布局管理器设置为主窗口的布局
|
|
|
|
|
QWidget *centralWidget = new QWidget(this);
|
|
|
|
|
centralWidget->setLayout(layout);
|
|
|
|
|
setCentralWidget(centralWidget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
receptionist::~receptionist()
|
|
|
|
|