|
|
@ -1,8 +1,5 @@
|
|
|
|
#include "customer.h"
|
|
|
|
#include "customer.h"
|
|
|
|
#include "login.h"
|
|
|
|
|
|
|
|
#include "registers.h"
|
|
|
|
|
|
|
|
#include "ui_customer.h"
|
|
|
|
#include "ui_customer.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* ID从数据库的提取
|
|
|
|
* ID从数据库的提取
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -29,13 +26,12 @@ void customer::paintEvent(QPaintEvent*)
|
|
|
|
|
|
|
|
|
|
|
|
void customer::init()//初始化
|
|
|
|
void customer::init()//初始化
|
|
|
|
{
|
|
|
|
{
|
|
|
|
customer_id = "123";
|
|
|
|
id = "123";
|
|
|
|
|
|
|
|
//id = login->ui->lineEdit_account->text();崩溃
|
|
|
|
ui->setupUi(this);
|
|
|
|
ui->setupUi(this);
|
|
|
|
this->setFixedSize(1920,1080);
|
|
|
|
this->setFixedSize(1920,1080);
|
|
|
|
this->setWindowTitle("用户界面");
|
|
|
|
this->setWindowTitle("用户界面");
|
|
|
|
this->setWindowIcon(QIcon(":image/icon/logo"));//创造本界面
|
|
|
|
this->setWindowIcon(QIcon(":image/icon/logo"));//创造本界面
|
|
|
|
lg = new login(this);
|
|
|
|
|
|
|
|
lg->hide();
|
|
|
|
|
|
|
|
rm = new ResetMessage(this);
|
|
|
|
rm = new ResetMessage(this);
|
|
|
|
rm->hide();//创造副界面
|
|
|
|
rm->hide();//创造副界面
|
|
|
|
labelone = new QLabel(this);
|
|
|
|
labelone = new QLabel(this);
|
|
|
@ -46,9 +42,14 @@ void customer::init()//初始化
|
|
|
|
findall();
|
|
|
|
findall();
|
|
|
|
flush_data(userinfo);//初始显示全部
|
|
|
|
flush_data(userinfo);//初始显示全部
|
|
|
|
setmousehand();//装饰鼠标
|
|
|
|
setmousehand();//装饰鼠标
|
|
|
|
|
|
|
|
ui->tableWidget->horizontalHeader()->setStyleSheet("QHeaderView::section{background-color: rgb(0, 0, 0,30);}");//表头透明度
|
|
|
|
|
|
|
|
ui->tableWidget->verticalHeader()->setStyleSheet("QHeaderView::section{background-color: rgb(0, 0, 0,30);}");//行头透明度
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui->Reservation1->setEnabled(false);
|
|
|
|
ui->tableWidget->setColumnHidden(5, true);//隐藏列
|
|
|
|
ui->checking_out1->setEnabled(false);//初始退订按钮
|
|
|
|
ui->tableWidget->setColumnHidden(6, true);
|
|
|
|
|
|
|
|
ui->Reservation1->setEnabled(false);//初始退订按钮
|
|
|
|
|
|
|
|
ui->checking_out1->setEnabled(false);
|
|
|
|
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
|
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
|
ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);//表格不可编辑
|
|
|
|
ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);//表格不可编辑
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -65,7 +66,7 @@ void customer::setmousehand()//鼠标小手 完成
|
|
|
|
void customer::on_checking_out1_clicked()//退房 完成
|
|
|
|
void customer::on_checking_out1_clicked()//退房 完成
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int c = row;//总之是获取选中的行
|
|
|
|
int c = row;//总之是获取选中的行
|
|
|
|
if( ui->tableWidget->model()->index(c,6).data().toString() == "123" ){
|
|
|
|
if( ui->tableWidget->model()->index(c,6).data().toString() == id ){
|
|
|
|
QString QS = "空闲";
|
|
|
|
QString QS = "空闲";
|
|
|
|
QSqlQuery query((db));
|
|
|
|
QSqlQuery query((db));
|
|
|
|
|
|
|
|
|
|
|
@ -101,7 +102,7 @@ void customer::on_checking_out1_clicked()//退房 完成
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void customer::on_Reservation1_clicked()//订房 id是什么
|
|
|
|
void customer::on_Reservation1_clicked()//订房 完成
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int c = row;//总之是获取选中的行
|
|
|
|
int c = row;//总之是获取选中的行
|
|
|
|
QString QS = "使用";
|
|
|
|
QString QS = "使用";
|
|
|
@ -121,7 +122,7 @@ void customer::on_Reservation1_clicked()//订房 id是什么
|
|
|
|
query.bindValue(":num",num);
|
|
|
|
query.bindValue(":num",num);
|
|
|
|
query.exec();
|
|
|
|
query.exec();
|
|
|
|
query.prepare("UPDATE room set customer_id=:id where room_num = :num");
|
|
|
|
query.prepare("UPDATE room set customer_id=:id where room_num = :num");
|
|
|
|
query.bindValue(":id",123);
|
|
|
|
query.bindValue(":id",id);
|
|
|
|
query.bindValue(":num",num);
|
|
|
|
query.bindValue(":num",num);
|
|
|
|
query.exec();
|
|
|
|
query.exec();
|
|
|
|
|
|
|
|
|
|
|
@ -160,14 +161,6 @@ void customer::on_checkBox_2_clicked(bool checked)//装饰品
|
|
|
|
else ui->tableWidget->verticalHeader()->hide();
|
|
|
|
else ui->tableWidget->verticalHeader()->hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void customer::on_checkBox_3_clicked(bool checked)//装饰品
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if(checked){
|
|
|
|
|
|
|
|
ui->tableWidget->setAlternatingRowColors(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else ui->tableWidget->setAlternatingRowColors(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void customer::findall()//显示全部 完成
|
|
|
|
void customer::findall()//显示全部 完成
|
|
|
|
{
|
|
|
|
{
|
|
|
|
userinfo.clear();//清楚存储向量rec的向量的数据
|
|
|
|
userinfo.clear();//清楚存储向量rec的向量的数据
|
|
|
@ -193,7 +186,7 @@ void customer::flush_data(QVector<QVector<QString>>&userinfo)//插入数据 完
|
|
|
|
ui->tableWidget->clear();
|
|
|
|
ui->tableWidget->clear();
|
|
|
|
if(!userinfo.size())return;
|
|
|
|
if(!userinfo.size())return;
|
|
|
|
ui->tableWidget->setRowCount(userinfo.size());//行
|
|
|
|
ui->tableWidget->setRowCount(userinfo.size());//行
|
|
|
|
ui->tableWidget->setColumnCount(5);//列
|
|
|
|
ui->tableWidget->setColumnCount(7);//列
|
|
|
|
|
|
|
|
|
|
|
|
for(int i=0;i<userinfo.size();i++)
|
|
|
|
for(int i=0;i<userinfo.size();i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -204,7 +197,7 @@ void customer::flush_data(QVector<QVector<QString>>&userinfo)//插入数据 完
|
|
|
|
QW->setTextAlignment(Qt::AlignCenter);//设置中心对齐
|
|
|
|
QW->setTextAlignment(Qt::AlignCenter);//设置中心对齐
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ui->tableWidget->setHorizontalHeaderLabels({"房间号","房间类型","是否带窗","负责人","状态"});//设置表头
|
|
|
|
//ui->tableWidget->setHorizontalHeaderLabels({"房间号","房间类型","是否带窗","负责人","状态"});//设置表头
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void customer::on_tableWidget_itemClicked(QTableWidgetItem *item)//点击表格格子 获取行数 完成
|
|
|
|
void customer::on_tableWidget_itemClicked(QTableWidgetItem *item)//点击表格格子 获取行数 完成
|
|
|
@ -245,9 +238,9 @@ bool customer::find_byname(QString n)//搜索?
|
|
|
|
int number = n.toInt();
|
|
|
|
int number = n.toInt();
|
|
|
|
userinfo.clear();
|
|
|
|
userinfo.clear();
|
|
|
|
QSqlQuery query(db);
|
|
|
|
QSqlQuery query(db);
|
|
|
|
query.prepare("select * from room where room_num like :number;");//以开头搜索 不行
|
|
|
|
query.prepare("select * from room where room_num like :number;");//以开头搜索 不行
|
|
|
|
query.bindValue(":number",number);
|
|
|
|
query.bindValue(":number",number);
|
|
|
|
if(query.exec())
|
|
|
|
if(query.exec())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
while (query.next()) {
|
|
|
|
while (query.next()) {
|
|
|
|
QVector<QString>rec;
|
|
|
|
QVector<QString>rec;
|
|
|
|