|
|
|
@ -7,7 +7,7 @@ customer::customer(QWidget *parent) :
|
|
|
|
|
{
|
|
|
|
|
init();
|
|
|
|
|
ResetMessage *RM = new ResetMessage;
|
|
|
|
|
RM->getid(id);
|
|
|
|
|
RM->getid(id);//将id传过去
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -23,15 +23,17 @@ void customer::paintEvent(QPaintEvent*)
|
|
|
|
|
labelone->resize(ui->widget->size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void customer::init()//初始化
|
|
|
|
|
void customer::init()//初始化 完成
|
|
|
|
|
{
|
|
|
|
|
account_roomaccount = 0;//账户订房的数量
|
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
this->setFixedSize(1920,1080);
|
|
|
|
|
this->setWindowTitle("用户界面");
|
|
|
|
|
this->setWindowIcon(QIcon(":image/icon/logo"));//创造本界面
|
|
|
|
|
|
|
|
|
|
rm = new ResetMessage(this);
|
|
|
|
|
rm->hide();//创造副界面
|
|
|
|
|
|
|
|
|
|
labelone = new QLabel(this);
|
|
|
|
|
labelone->setScaledContents(true);
|
|
|
|
|
labelone->setPixmap(QPixmap(":/image/bg/login.png"));
|
|
|
|
@ -40,19 +42,19 @@ void customer::init()//初始化
|
|
|
|
|
findall();
|
|
|
|
|
flush_data(userinfo);//初始显示全部
|
|
|
|
|
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->tableWidget->setColumnHidden(5, true);//隐藏列
|
|
|
|
|
ui->tableWidget->setColumnHidden(6, true);
|
|
|
|
|
ui->Reservation1->setEnabled(false);//初始退订按钮
|
|
|
|
|
ui->checking_out1->setEnabled(false);
|
|
|
|
|
ui->tableWidget->setColumnHidden(5, true);
|
|
|
|
|
ui->tableWidget->setColumnHidden(6, true);//隐藏列
|
|
|
|
|
ui->Reservation1->setEnabled(false);
|
|
|
|
|
ui->checking_out1->setEnabled(false);//初始退订按钮灰色
|
|
|
|
|
ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
|
|
|
|
|
ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);//表格不可编辑
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void customer::setid(QString str){
|
|
|
|
|
void customer::setid(QString str)
|
|
|
|
|
{
|
|
|
|
|
id = str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -68,20 +70,21 @@ void customer::setmousehand()//鼠标小手 完成
|
|
|
|
|
void customer::on_checking_out1_clicked()//退房 完成
|
|
|
|
|
{
|
|
|
|
|
int c = row;//总之是获取选中的行
|
|
|
|
|
if( ui->tableWidget->model()->index(c,6).data().toString() == id ){
|
|
|
|
|
if( ui->tableWidget->model()->index(c,6).data().toString() == id )//id对上
|
|
|
|
|
{
|
|
|
|
|
account_roomaccount = 0;
|
|
|
|
|
QString QS = "空闲";
|
|
|
|
|
QSqlQuery query((db));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString n = 0;
|
|
|
|
|
n = ui->tableWidget->model()->index(c,0).data().toString();
|
|
|
|
|
n = ui->tableWidget->model()->index(c,0).data().toString();//n是房间号
|
|
|
|
|
int num = n.toInt();
|
|
|
|
|
|
|
|
|
|
query.prepare("UPDATE room set status=:QS where room_num = :num");
|
|
|
|
|
query.bindValue(":QS",QS);
|
|
|
|
|
query.bindValue(":num",num);
|
|
|
|
|
query.exec();//开始操作数据库
|
|
|
|
|
query.exec();
|
|
|
|
|
query.prepare("UPDATE room set checkout_time=NULL where room_num = :num");
|
|
|
|
|
query.bindValue(":num",num);
|
|
|
|
|
query.exec();
|
|
|
|
@ -90,16 +93,16 @@ void customer::on_checking_out1_clicked()//退房 完成
|
|
|
|
|
query.exec();
|
|
|
|
|
query.prepare("UPDATE customer set room_num=NULL where account = :a");
|
|
|
|
|
query.bindValue(":a",id);
|
|
|
|
|
query.exec();
|
|
|
|
|
query.exec();//开始操作数据库
|
|
|
|
|
|
|
|
|
|
if(c >= 0){
|
|
|
|
|
QTableWidgetItem *Q1 = new QTableWidgetItem(QS);
|
|
|
|
|
ui->tableWidget->setItem(c,4,Q1);
|
|
|
|
|
ui->tableWidget->setItem(c,6,NULL);
|
|
|
|
|
Q1->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
ui->tableWidget->setItem(c,6,NULL);//修改隐藏的第七列以供其他函数使用
|
|
|
|
|
Q1->setTextAlignment(Qt::AlignCenter);//中心
|
|
|
|
|
QMessageBox::about(this,"提示","退房成功");
|
|
|
|
|
ui->Reservation1->setEnabled(true);
|
|
|
|
|
ui->checking_out1->setEnabled(false);//开始操作表格
|
|
|
|
|
ui->checking_out1->setEnabled(false);//合理设置按钮
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -135,18 +138,18 @@ void customer::on_Reservation1_clicked()//订房 完成
|
|
|
|
|
query.prepare("UPDATE customer set room_num=:rn where account = :a");
|
|
|
|
|
query.bindValue(":a",id);
|
|
|
|
|
query.bindValue(":rn",num);
|
|
|
|
|
query.exec();
|
|
|
|
|
query.exec();//操作数据库
|
|
|
|
|
|
|
|
|
|
if(c>=0){
|
|
|
|
|
QTableWidgetItem *Q1 = new QTableWidgetItem(QS);
|
|
|
|
|
QTableWidgetItem *Q3 = new QTableWidgetItem(id);
|
|
|
|
|
ui->tableWidget->setItem(c,4,Q1);
|
|
|
|
|
ui->tableWidget->setItem(c,6,Q3);
|
|
|
|
|
ui->tableWidget->setItem(c,6,Q3);//修改隐藏的第七列以供其他函数使用
|
|
|
|
|
Q1->setTextAlignment(Qt::AlignCenter);
|
|
|
|
|
|
|
|
|
|
QMessageBox::about(this,"提示","订房成功");
|
|
|
|
|
ui->Reservation1->setEnabled(false);
|
|
|
|
|
ui->checking_out1->setEnabled(true);
|
|
|
|
|
ui->checking_out1->setEnabled(true);//合理设置按钮
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else QMessageBox::about(this,"警告","一个账户只能预定一个房间");
|
|
|
|
@ -154,12 +157,12 @@ void customer::on_Reservation1_clicked()//订房 完成
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void customer::on_pushButton_clicked()//修改 完成
|
|
|
|
|
void customer::on_pushButton_clicked()//显示修改密码界面 完成
|
|
|
|
|
{
|
|
|
|
|
rm->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void customer::on_checkBox_clicked(bool checked)//装饰品
|
|
|
|
|
void customer::on_checkBox_clicked(bool checked)//装饰品 完成
|
|
|
|
|
{
|
|
|
|
|
if(checked){
|
|
|
|
|
ui->tableWidget->horizontalHeader()->show();
|
|
|
|
@ -167,7 +170,7 @@ void customer::on_checkBox_clicked(bool checked)//装饰品
|
|
|
|
|
else ui->tableWidget->horizontalHeader()->hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void customer::on_checkBox_2_clicked(bool checked)//装饰品
|
|
|
|
|
void customer::on_checkBox_2_clicked(bool checked)//装饰品 完成
|
|
|
|
|
{
|
|
|
|
|
if(checked){
|
|
|
|
|
ui->tableWidget->verticalHeader()->show();
|
|
|
|
@ -219,12 +222,12 @@ void customer::on_tableWidget_itemClicked(QTableWidgetItem *item)//点击表格
|
|
|
|
|
row = item->row();
|
|
|
|
|
if(ui->tableWidget->model()->index(row,4).data().toString() == "空闲"){
|
|
|
|
|
ui->Reservation1->setEnabled(true);
|
|
|
|
|
ui->checking_out1->setEnabled(false);
|
|
|
|
|
ui->checking_out1->setEnabled(false);//合理设置按钮
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else if(ui->tableWidget->model()->index(row,4).data().toString() == "使用"){
|
|
|
|
|
ui->checking_out1->setEnabled(true);
|
|
|
|
|
ui->Reservation1->setEnabled(false);
|
|
|
|
|
ui->Reservation1->setEnabled(false);//合理设置按钮
|
|
|
|
|
}
|
|
|
|
|
else QMessageBox::about(this,"警告","未知错误");
|
|
|
|
|
|
|
|
|
@ -235,7 +238,8 @@ void customer::on_search_clicked()//搜索 不能部分找到全部
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
QString number=ui->lineEdit_2->text();
|
|
|
|
|
if(number == NULL){
|
|
|
|
|
if(number == NULL)//搜索栏空就显示全部
|
|
|
|
|
{
|
|
|
|
|
findall();
|
|
|
|
|
flush_data(userinfo);
|
|
|
|
|
}
|
|
|
|
@ -247,7 +251,7 @@ void customer::on_search_clicked()//搜索 不能部分找到全部
|
|
|
|
|
}else QMessageBox::critical(nullptr, "错误", "未知的错误", QMessageBox::Retry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool customer::find_byname(QString n)//搜索?
|
|
|
|
|
bool customer::find_byname(QString n)//搜索 完成
|
|
|
|
|
{
|
|
|
|
|
int number = n.toInt();
|
|
|
|
|
userinfo.clear();
|
|
|
|
@ -264,7 +268,7 @@ bool customer::find_byname(QString n)//搜索?
|
|
|
|
|
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());
|
|
|
|
|
rec.push_back(query.record().value("customer_id").toString());//一行数据全部塞进向量rec
|
|
|
|
|
|
|
|
|
|
userinfo.push_back(rec);
|
|
|
|
|
}
|
|
|
|
|