updata receptionist

master
HOJI 2 years ago
parent b633b99448
commit d317218856

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 9.0.2, 2023-09-10T22:27:21. -->
<!-- Written by QtCreator 9.0.2, 2023-09-10T22:50:15. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>

@ -27,8 +27,20 @@ cellstatus::~cellstatus()
delete ui;
}
void cellstatus::setroomNum(int roomNum)
{
this->roomNum = roomNum;
}
void cellstatus::setDB(QSqlDatabase db)
{
this->db = db;
}
void cellstatus::on_pushButton_clicked()
{
m_order->setDB(db);
m_order->setrootNum(roomNum);
m_order->show();
}

@ -3,7 +3,9 @@
#include <QWidget>
#include "orderoom.h"
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
namespace Ui {
class cellstatus;
}
@ -15,6 +17,8 @@ class cellstatus : public QWidget
public:
explicit cellstatus(QWidget *parent = nullptr);
~cellstatus();
void setroomNum(int roomNum);
void setDB(QSqlDatabase db);
private slots:
void on_pushButton_clicked();
@ -25,8 +29,9 @@ private slots:
private:
Ui::cellstatus *ui;
int roomNum;
orderoom *m_order;
QSqlDatabase db;
};
#endif // CELLSTATUS_H

@ -1,6 +1,9 @@
#include "orderoom.h"
#include "ui_orderoom.h"
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QDebug>
orderoom::orderoom(QWidget *parent) :
QWidget(parent),
ui(new Ui::orderoom)
@ -13,8 +16,38 @@ orderoom::~orderoom()
delete ui;
}
void orderoom::setrootNum(int rootNum)
{
this->rootNum = rootNum;
}
void orderoom::setDB(QSqlDatabase db)
{
this->db = db;
}
void orderoom::on_pushButton_2_clicked()
{
QString phone = ui->lineEdit_2->text();
QString name = ui->lineEdit_3->text();
QString gender = ui->lineEdit_4->text();
QString user_id = ui->lineEdit_5->text();
//插入记录
QString sql = QString("insert into customer(account, name, gender,id ,room_num) "
"VALUES ('%1','%2', '%3','%4','%5')")
.arg(phone).arg(name).arg(gender).arg(user_id).arg(rootNum);
QSqlQuery query;
if(query.exec(sql)) //执行sql语句是否成功
{
qDebug()<<"insert success";
}else
{
qDebug()<<query.lastError();
}
emit ordersuccess();
this->close();
}

@ -2,7 +2,9 @@
#define ORDEROOM_H
#include <QWidget>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
namespace Ui {
class orderoom;
}
@ -14,12 +16,16 @@ class orderoom : public QWidget
public:
explicit orderoom(QWidget *parent = nullptr);
~orderoom();
void setrootNum(int rootNum);
void setDB(QSqlDatabase db);
private slots:
void on_pushButton_2_clicked();
private:
Ui::orderoom *ui;
int rootNum;
QSqlDatabase db;
signals:
void ordersuccess();

@ -38,7 +38,7 @@
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>客户检索:</string>
<string/>
</property>
</widget>
</item>
@ -51,8 +51,14 @@
</item>
<item row="1" column="0" colspan="4">
<widget class="QLabel" name="label_2">
<property name="minimumSize">
<size>
<width>800</width>
<height>600</height>
</size>
</property>
<property name="text">
<string>*** * *************</string>
<string/>
</property>
</widget>
</item>
@ -82,7 +88,7 @@
<item row="0" column="3">
<widget class="QPushButton" name="pushButton_3">
<property name="text">
<string>检索</string>
<string/>
</property>
</widget>
</item>

@ -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()

@ -2,7 +2,6 @@
#define RECEPTIONIST_H
#include <QMainWindow>
namespace Ui {
class receptionist;
}

@ -6,10 +6,16 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
<width>1920</width>
<height>1080</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>1920</width>
<height>1080</height>
</size>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
@ -60,8 +66,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>17</height>
<width>1920</width>
<height>21</height>
</rect>
</property>
</widget>

Loading…
Cancel
Save