fixed customerinfo

master
HOJI 2 years ago
parent 8f504cfc91
commit 0732c2ec8a

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 9.0.2, 2023-09-11T16:12:51. --> <!-- Written by QtCreator 9.0.2, 2023-09-11T22:40:52. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>

@ -52,7 +52,7 @@ void cellstatus::setDB(QSqlDatabase db)
void cellstatus::on_pushButton_clicked() void cellstatus::on_pushButton_clicked()
{ {
m_order->setrootNum(roomNum); m_order->setroomNum(roomNum);
m_order->setDB(db); m_order->setDB(db);
m_order->show(); m_order->show();
} }

@ -33,10 +33,8 @@ void checkbtn::on_pushButton_clicked()
void checkbtn::setisused(bool i){ void checkbtn::setisused(bool i){
isused = i; isused = i;
qDebug()<<isused;
} }
void checkbtn::setbtn(){ void checkbtn::setbtn(){
ui->pushButton->setEnabled(isused); ui->pushButton->setEnabled(isused);
qDebug()<<isused;
} }

@ -36,6 +36,9 @@
<pointsize>12</pointsize> <pointsize>12</pointsize>
</font> </font>
</property> </property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="text"> <property name="text">
<string>查看</string> <string>查看</string>
</property> </property>

@ -1,11 +1,25 @@
#include "customerinfo.h" #include "customerinfo.h"
#include "ui_customerinfo.h" #include "ui_customerinfo.h"
#include <QDebug>
customerinfo::customerinfo(QWidget *parent) : customerinfo::customerinfo(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::customerinfo) ui(new Ui::customerinfo)
{ {
ui->setupUi(this); 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() customerinfo::~customerinfo()
@ -13,6 +27,21 @@ customerinfo::~customerinfo()
delete ui; 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){ void customerinfo::setroomNum(int roomNum){
this->roomNum = roomNum; this->roomNum = roomNum;
} }
@ -20,3 +49,9 @@ void customerinfo::setroomNum(int roomNum){
void customerinfo::setDB(QSqlDatabase db){ void customerinfo::setDB(QSqlDatabase db){
this->db = db; this->db = db;
} }
void customerinfo::on_pushButton_clicked()
{
this->hide();
}

@ -4,6 +4,7 @@
#include <QMainWindow> #include <QMainWindow>
#include <QSqlDatabase> #include <QSqlDatabase>
#include <QSqlQuery> #include <QSqlQuery>
#include <QLabel>
namespace Ui { namespace Ui {
class customerinfo; class customerinfo;
@ -19,10 +20,17 @@ public:
void setDB(QSqlDatabase db); void setDB(QSqlDatabase db);
void setroomNum(int roomNum); void setroomNum(int roomNum);
protected:
void paintEvent(QPaintEvent*);
private slots:
void on_pushButton_clicked();
private: private:
Ui::customerinfo *ui; Ui::customerinfo *ui;
QSqlDatabase db; QSqlDatabase db;
int roomNum; int roomNum;
QLabel *bg;
}; };
#endif // CUSTOMERINFO_H #endif // CUSTOMERINFO_H

@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<author/>
<comment/>
<exportmacro/>
<class>customerinfo</class> <class>customerinfo</class>
<widget class="QMainWindow" name="customerinfo"> <widget class="QMainWindow" name="customerinfo">
<property name="geometry"> <property name="geometry">
@ -15,10 +13,166 @@
<property name="windowTitle"> <property name="windowTitle">
<string>MainWindow</string> <string>MainWindow</string>
</property> </property>
<widget class="QMenuBar" name="menubar"/> <widget class="QWidget" name="centralwidget">
<widget class="QWidget" name="centralwidget"/> <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="QFrame" name="frame">
<property name="geometry">
<rect>
<x>50</x>
<y>50</y>
<width>700</width>
<height>450</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>12</pointsize>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>账号(手机号)</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="font">
<font>
<pointsize>12</pointsize>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>姓名:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_2">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="font">
<font>
<pointsize>12</pointsize>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>性别:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_3">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="font">
<font>
<pointsize>12</pointsize>
<bold>true</bold>
</font>
</property>
<property name="styleSheet">
<string notr="true">color: rgb(255, 255, 255);</string>
</property>
<property name="text">
<string>身份证号:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_4">
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>325</x>
<y>500</y>
<width>150</width>
<height>50</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
</widget>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>17</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
</widget> </widget>
<pixmapfunction/> <resources/>
<connections/> <connections/>
</ui> </ui>

@ -39,9 +39,9 @@ orderoom::~orderoom()
delete ui; delete ui;
} }
void orderoom::setrootNum(int rootNum) void orderoom::setroomNum(int roomNum)
{ {
this->rootNum = rootNum; this->roomNum = roomNum;
} }
void orderoom::setDB(QSqlDatabase db){ void orderoom::setDB(QSqlDatabase db){
@ -84,14 +84,16 @@ void orderoom::on_btn_order_clicked()
if(findcustomer){ if(findcustomer){
QDate date = QDate::currentDate(); QDate date = QDate::currentDate();
int account = ui->tableWidget->model()->index(0,0).data().toString().toInt(); int account = ui->tableWidget->model()->index(0,0).data().toString().toInt();
QString sql1 = QString("UPDATE room set customer_id = %1 where room_num = %2").arg(account).arg(rootNum); QString sql1 = QString("UPDATE room set customer_id = %1 where room_num = %2").arg(account).arg(roomNum);
QString sql2 = QString("UPDATE room set status='使用' where room_num = %1").arg(rootNum); QString sql2 = QString("UPDATE room set status='使用' where room_num = %1").arg(roomNum);
QString sql3 = QString("UPDATE customer set room_num=%1 where account = %2").arg(roomNum).arg(ui->tableWidget->model()->index(0,0).data().toString());
QSqlQuery query; QSqlQuery query;
query.exec(sql1); query.exec(sql1);
query.exec(sql2); query.exec(sql2);
query.exec(sql3);
query.prepare("UPDATE room set checkout_time=DATE_ADD(:date, INTERVAL 1 DAY) where room_num = :num"); query.prepare("UPDATE room set checkout_time=DATE_ADD(:date, INTERVAL 1 DAY) where room_num = :num");
query.bindValue(":date",date); query.bindValue(":date",date);
query.bindValue(":num",rootNum); query.bindValue(":num",roomNum);
query.exec(); query.exec();
emit ordersuccess(); emit ordersuccess();
this->close(); this->close();

@ -21,7 +21,7 @@ class orderoom : public QWidget
public: public:
explicit orderoom(QWidget *parent = nullptr); explicit orderoom(QWidget *parent = nullptr);
~orderoom(); ~orderoom();
void setrootNum(int rootNum); void setroomNum(int roomNum);
void setDB(QSqlDatabase db); void setDB(QSqlDatabase db);
private slots: private slots:
@ -35,7 +35,7 @@ private slots:
private: private:
Ui::orderoom *ui; Ui::orderoom *ui;
QLabel *bg; QLabel *bg;
int rootNum; int roomNum;
QSqlDatabase db; QSqlDatabase db;
bool findcustomer; bool findcustomer;

@ -97,25 +97,40 @@ void receptionist::showall(){
void receptionist::search(QString str){ void receptionist::search(QString str){
int s = str.toInt(); int s = str.toInt();
ui->tableWidget->setRowCount(1);
ui->tableWidget->clear(); ui->tableWidget->clear();
ui->tableWidget->setHorizontalHeaderLabels({"房间号","房间类型","是否带窗","负责人","状态","退房时间","客户信息","操作"}); ui->tableWidget->setHorizontalHeaderLabels({"房间号","房间类型","是否带窗","负责人","状态","退房时间","客户信息","操作"});
QSqlQuery query; QSqlQuery query;
query.prepare("select * from room where room_num like :str;"); query.prepare("select * from room where room_num like :str;");
query.bindValue(":str",s); query.bindValue(":str",s);
int i = 0;
if(query.exec()){ if(query.exec()){
while (query.next()){ while (query.next()){
for(int j = 0;j<6;j++){ for(int j = 0;j<6;j++){
QTableWidgetItem *twi = new QTableWidgetItem(query.value(j).toString()); QTableWidgetItem *twi = new QTableWidgetItem(query.value(j).toString());
twi->setTextAlignment(Qt::AlignCenter); twi->setTextAlignment(Qt::AlignCenter);
ui->tableWidget->setItem(i,j,twi); ui->tableWidget->setItem(0,j,twi);
ui->tableWidget->setColumnWidth(j,259); ui->tableWidget->setColumnWidth(j,259);
} }
cellstatus* cell = new cellstatus(); cellstatus* cell = new cellstatus();
cell->setroomNum(query.value(0).toInt()); connect(cell,&cellstatus::flash,this,&receptionist::onflash);
cell->setDB(db); cell->setDB(db);
ui->tableWidget->setCellWidget(i,7,cell); cell->setroomNum(query.value(0).toInt());
ui->tableWidget->setCellWidget(i,6,new QPushButton("查看")); 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);
} }
} }
} }

Loading…
Cancel
Save