├── HotelPlatform.pro ├── HotelPlatform.pro.user ├── README.md ├── abstractuser.cpp ├── abstractuser.h ├── chooseroom.cpp ├── chooseroom.h ├── chooseroom.ui ├── customer.cpp ├── customer.h ├── enums.h ├── hotel.cpp ├── hotel.h ├── hotelmanager.cpp ├── hotelmanager.h ├── hotelregister.cpp ├── hotelregister.h ├── hotelregister.ui ├── loginwindow.h ├── loginwindow1.cpp ├── loginwindow1.h ├── loginwindow1.ui ├── main.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── mydatabase.cpp ├── mydatabase.h ├── newroom.cpp ├── newroom.h ├── newroom.ui ├── order.cpp ├── order.h ├── platform.cpp ├── platform.h ├── platform.ui ├── platformadmin.cpp ├── platformadmin.h ├── qtStyleSheet.txt ├── register.jpg ├── registerwindow.cpp ├── registerwindow.h ├── registerwindow.ui ├── res.qrc ├── room.cpp ├── room.h ├── roomchange.cpp ├── roomchange.h ├── roomchange.ui ├── standard.jpg ├── timg.jpg ├── wcomment.cpp ├── wcomment.h ├── wcomment.ui ├── whotel.cpp ├── whotel.h ├── whotel.ui └── 大作业报告.pdf /HotelPlatform.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2018-07-25T09:24:03 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | QT += sql 10 | 11 | 12 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 13 | 14 | TARGET = HotelPlatform 15 | TEMPLATE = app 16 | 17 | # The following define makes your compiler emit warnings if you use 18 | # any feature of Qt which has been marked as deprecated (the exact warnings 19 | # depend on your compiler). Please consult the documentation of the 20 | # deprecated API in order to know how to port your code away from it. 21 | DEFINES += QT_DEPRECATED_WARNINGS 22 | 23 | # You can also make your code fail to compile if you use deprecated APIs. 24 | # In order to do so, uncomment the following line. 25 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 26 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 27 | 28 | 29 | SOURCES += \ 30 | main.cpp \ 31 | mainwindow.cpp \ 32 | loginwindow1.cpp \ 33 | registerwindow.cpp \ 34 | abstractuser.cpp \ 35 | mydatabase.cpp \ 36 | customer.cpp \ 37 | hotel.cpp \ 38 | hotelmanager.cpp \ 39 | hotelregister.cpp \ 40 | room.cpp \ 41 | order.cpp \ 42 | chooseroom.cpp \ 43 | wcomment.cpp \ 44 | whotel.cpp \ 45 | platform.cpp \ 46 | platformadmin.cpp \ 47 | roomchange.cpp \ 48 | newroom.cpp 49 | 50 | 51 | 52 | HEADERS += \ 53 | mainwindow.h \ 54 | loginwindow1.h \ 55 | registerwindow.h \ 56 | abstractuser.h \ 57 | mydatabase.h \ 58 | enums.h \ 59 | customer.h \ 60 | hotel.h \ 61 | hotelmanager.h \ 62 | hotelregister.h \ 63 | room.h \ 64 | order.h \ 65 | chooseroom.h \ 66 | wcomment.h \ 67 | whotel.h \ 68 | newroom.h \ 69 | platform.h \ 70 | platformadmin.h \ 71 | roomchange.h 72 | 73 | FORMS += \ 74 | mainwindow.ui \ 75 | loginwindow1.ui \ 76 | registerwindow.ui \ 77 | hotelregister.ui \ 78 | chooseroom.ui \ 79 | wcomment.ui \ 80 | whotel.ui \ 81 | roomchange.ui \ 82 | newroom.ui \ 83 | platform.ui \ 84 | newroom.ui \ 85 | platform.ui \ 86 | roomchange.ui 87 | 88 | RESOURCES += \ 89 | res.qrc 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # -大一暑期C++大作业——酒店管理系统源码 2 | 3 | *** 4 | 5 | 这个是清华大学2017届自动化系C++暑期实践大作业的所有源码。因为自己在写大作业的时候意识到了网上的代码和攻略的重要性,这个大作也算是自己作为程序员的第一个 6 | 勉强能看的项目吧。上传一波作为自己第一次对社区的回馈。希望能帮到需要的人。具体的代码上的特点可在《大作业报告》中看到。 7 | -------------------------------------------------------------------------------- /abstractuser.cpp: -------------------------------------------------------------------------------- 1 | 2 | /************************************************************************** 3 | 文件名:abstractuser.cpp 4 | 功能模块和目的: 5 | 开发者:程晔安 6 | 日期:7.26 7 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 8 | 更改记录: 9 | **************************************************************************/ 10 | 11 | #include "AbstractUser.h" 12 | #include 13 | 14 | //构造函数 15 | AbstractUser::AbstractUser(QString newAccount, QString newPassword, 16 | QString newPhone): 17 | Account(newAccount),Password(newPassword),Phone(newPhone) 18 | { 19 | 20 | } 21 | 22 | 23 | //确定密码是否正确 24 | bool AbstractUser::IsCorrect(QString aPassword) 25 | { 26 | if(aPassword == Password) 27 | return true; 28 | return false; 29 | } 30 | 31 | 32 | -------------------------------------------------------------------------------- /abstractuser.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | 文件名:abstractuser.h 3 | 功能模块和目的:建立AbstractUser类 4 | 开发者:程晔安 5 | 日期:2018/7/28 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录:7/28最后修改 8 | **************************************************************************/ 9 | 10 | #ifndef AbstractUser_H 11 | #define AbstractUser_H 12 | 13 | #include"QString" 14 | 15 | /************************************************************************* 16 | 类名:AbstractUser.h 17 | 功能:作为用户基类 18 | 接口说明:外部可获取账号、密码、手机等信息; 19 | 可判断密码是否正确,手机是否已经用于注册; 20 | 可更改密码。 21 | 开发者:程晔安 22 | 日期:7/28 23 | 更改记录:7/28最后修改 24 | **************************************************************************/ 25 | 26 | class AbstractUser 27 | { 28 | 29 | public: 30 | //构造函数 31 | AbstractUser(QString newAccount, QString newPassword, 32 | QString newPhone); 33 | //默认构造函数 34 | AbstractUser() 35 | { 36 | 37 | } 38 | //析构函数 39 | ~AbstractUser(){} 40 | 41 | //获取账号、密码、手机号 42 | QString GetAccount() 43 | { 44 | return Account; 45 | } 46 | QString GetPassword() 47 | { 48 | return Password; 49 | } 50 | QString GetPhone() 51 | { 52 | return Phone; 53 | } 54 | 55 | //判断密码是否正确 56 | bool IsCorrect(QString aPassword); 57 | //设置密码 58 | void SetPassword(QString aPassword) 59 | { 60 | Password = aPassword; 61 | } 62 | 63 | //检查手机号是否已经注册,手机号对外不可见 64 | bool IsPhoneUsed(QString newPhone) 65 | { 66 | if(Phone == newPhone) 67 | return true; 68 | return false; 69 | } 70 | 71 | protected: 72 | //私有成员:账号、密码、手机 73 | QString Account; 74 | QString Password; 75 | QString Phone; 76 | 77 | 78 | 79 | }; 80 | 81 | #endif // AbstractUser_H 82 | -------------------------------------------------------------------------------- /chooseroom.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | /* 4 | 文件名:chooseroom.cpp 5 | 功能模块和目的:房间选择界面的功能实现 6 | 开发者:程晔安 7 | 日期:8.1 8 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 9 | 更改记录: 10 | */ 11 | 12 | #include "chooseroom.h" 13 | #include "ui_chooseroom.h" 14 | 15 | #include "QMessageBox" 16 | #include "qtablewidget.h" 17 | #include "Qdate" 18 | #include "mydatabase.h" 19 | 20 | #include "mainwindow.h" 21 | #include "order.h" 22 | #include "hotel.h" 23 | #include "room.h" 24 | 25 | using namespace std; 26 | extern QVectorg_Orderlist; 27 | extern QVectorRawRoomlist; 28 | 29 | ChooseRoom::ChooseRoom(MainWindow *newParent) : 30 | parent(newParent), 31 | ui(new Ui::ChooseRoom) 32 | { 33 | ui->setupUi(this); 34 | MakeAnOrder(); 35 | //装饰 36 | 37 | this->setWindowTitle("Choose your room!"); 38 | this->setFixedSize(this->width(),this->height()); 39 | 40 | 41 | ui->tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); 42 | ui->tableWidget->setSelectionMode(QAbstractItemView::SingleSelection); 43 | //接口 44 | 45 | //确定生成订单 46 | connect(ui->btnOrder, SIGNAL(clicked(bool)), this, SLOT(EnterOrder())); 47 | 48 | //关闭窗口操作 49 | connect(ui->btnBack, SIGNAL(clicked(bool)), this, SLOT(close())); 50 | connect(ui->btnBack, SIGNAL(clicked(bool)), parent, SLOT(show())); 51 | 52 | //刷新列表 53 | connect(ui->btnRefresh, SIGNAL(clicked(bool)), this, SLOT(MakeAnOrder())); 54 | } 55 | 56 | ChooseRoom::~ChooseRoom() 57 | { 58 | delete ui; 59 | } 60 | 61 | void ChooseRoom::MakeAnOrder() 62 | { 63 | //初始化这个列表 64 | tempRoomlist.clear(); 65 | ui->tableWidget->clear(); 66 | ui->tableWidget->setColumnCount(7); 67 | ui->tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem 68 | (QStringLiteral("房间图片"))); 69 | ui->tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem 70 | (QStringLiteral("房间类型"))); 71 | ui->tableWidget->setHorizontalHeaderItem(2, new QTableWidgetItem 72 | (QStringLiteral("房间价格"))); 73 | ui->tableWidget->setHorizontalHeaderItem(3, new QTableWidgetItem 74 | (QStringLiteral("房间折扣"))); 75 | ui->tableWidget->setHorizontalHeaderItem(4, new QTableWidgetItem 76 | (QStringLiteral("房间数量"))); 77 | ui->tableWidget->setHorizontalHeaderItem(5, new QTableWidgetItem 78 | (QStringLiteral("房间评分"))); 79 | ui->tableWidget->setHorizontalHeaderItem(6, new QTableWidgetItem 80 | (QStringLiteral("卖家描述"))); 81 | 82 | //开始进行显示 83 | //Hotel* tempHotel = parent->GetpHotel(); 84 | tempDate = parent->GetDate(); 85 | tempDays = parent->GetDays(); 86 | int tempType = parent->GetType(); 87 | 88 | //筛选可能的房间信息 89 | //如果有Type进行筛选 90 | if(tempType >= 0) 91 | { 92 | 93 | for(int i=0;iGetpHotel()->Roomlist.size();i++) 94 | { 95 | if(parent->GetpHotel()->Roomlist[i].GetType() == tempType) 96 | { 97 | tempRoomlist.push_back(&parent->GetpHotel()->Roomlist[i]); 98 | } 99 | 100 | } 101 | } 102 | else 103 | { 104 | for(int i=0;iGetpHotel()->Roomlist.size();i++) 105 | { 106 | tempRoomlist.push_back(&parent->GetpHotel()->Roomlist[i]); 107 | } 108 | } 109 | 110 | //筛选现在还剩下的房间 111 | //遍历订单筛选出已经被订的相应房间的时间,实现显示时显示剩余房间数 112 | for(int i = 0; i < tempRoomlist.size(); i++) 113 | { 114 | tempRoomlist[i]->curDays = tempRoomlist[i]->GetNumber(); 115 | for(int j = 0; j < g_Orderlist.size(); j++) 116 | { 117 | int token = 0; 118 | if((g_Orderlist[j].GetpRoom()->GetRoomId() == 119 | tempRoomlist[i]->GetRoomId()) 120 | &&(g_Orderlist[j].GetType() != 5)) 121 | { 122 | for(int k=0;k < g_Orderlist[j].GetDays(); k++) 123 | { 124 | QDate tempOrderDay = g_Orderlist[j].GetDate().addDays(k); 125 | for(int m = 0;m < tempDays;m++) 126 | { 127 | QDate tempRoomDate = tempDate.addDays(m); 128 | if(tempOrderDay == tempRoomDate) 129 | { 130 | 131 | token = 1; 132 | } 133 | } 134 | } 135 | } 136 | if(token == 1) 137 | { 138 | tempRoomlist[i]->curDays--; 139 | } 140 | } 141 | } 142 | 143 | //转换类型 144 | QString str_type[5] = {"钟点房", "大床房", "双人房", "奢华房", "总统套房"}; 145 | 146 | 147 | //输出筛选过后的酒店信息 148 | for(int i=0;icurDays > 0) 151 | { 152 | ui->tableWidget->setRowCount(i+1); 153 | ui->tableWidget->setRowHeight(i+1,100); 154 | 155 | QLabel *label = new QLabel(""); 156 | 157 | label->setPixmap(QPixmap(tempRoomlist[i]->GetImages()).scaled(125,150)); 158 | 159 | ui->tableWidget->setCellWidget(i, 0, label); 160 | ui->tableWidget->setItem(i, 1, new QTableWidgetItem 161 | (str_type[tempRoomlist[i]->GetType()])); 162 | int actPrice = tempRoomlist[i]->GetDiscount()*tempRoomlist[i]->GetPrice(); 163 | ui->tableWidget->setItem(i, 2, new QTableWidgetItem 164 | (QString::number(actPrice))); 165 | ui->tableWidget->setItem(i, 3, new QTableWidgetItem 166 | (QString::number(tempRoomlist[i]->GetDiscount(),'f',2))); 167 | ui->tableWidget->setItem(i, 4, new QTableWidgetItem 168 | (QString::number(tempRoomlist[i]->curDays))); 169 | ui->tableWidget->setItem(i, 5, new QTableWidgetItem 170 | (QString::number(tempRoomlist[i]->GetStar()))); 171 | ui->tableWidget->setItem(i, 6, new QTableWidgetItem 172 | (tempRoomlist[i]->GetDiscription())); 173 | } 174 | 175 | } 176 | //三种排列方式 177 | if(ui->rbtndefault->isChecked()) 178 | { 179 | 180 | } 181 | else if (ui->rbtnPrice->isChecked()) 182 | { 183 | //按照价格升序排列 184 | ui->tableWidget->sortByColumn(2, Qt::SortOrder::AscendingOrder); 185 | } 186 | else 187 | { 188 | //按照评分降序排列 189 | ui->tableWidget->sortByColumn(4, Qt::SortOrder::DescendingOrder); 190 | } 191 | } 192 | 193 | //确认订单 194 | void ChooseRoom::EnterOrder() 195 | { 196 | int row; 197 | 198 | row = ui->tableWidget->currentRow(); 199 | 200 | 201 | //选中判断 202 | if(row<0) 203 | { 204 | QMessageBox::information(this, "ERROR", 205 | "未选中订单", QMessageBox::Ok); 206 | return; 207 | } 208 | 209 | //新建订单 210 | Room* tempRoom = tempRoomlist[row]; 211 | 212 | Order newOrder(tempDate, tempDays, tempRoom, parent->GetpCustomer()); 213 | 214 | g_Orderlist.push_back(newOrder); 215 | 216 | QMessageBox::information(this, "SUCCESS", "订购成功!可以在订单列表中查询。", 217 | QMessageBox::Ok); 218 | } 219 | 220 | 221 | -------------------------------------------------------------------------------- /chooseroom.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | 文件名:ChooseRoom.h 3 | 功能模块和目的: 4 | 开发者:程晔安 5 | 日期: 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录: 8 | **************************************************************************/ 9 | #ifndef CHOOSEROOM_H 10 | #define CHOOSEROOM_H 11 | 12 | #include 13 | 14 | #include "customer.h" 15 | #include "hotel.h" 16 | #include "room.h" 17 | 18 | namespace Ui { 19 | class ChooseRoom; 20 | } 21 | 22 | class MainWindow; 23 | 24 | class ChooseRoom : public QDialog 25 | { 26 | Q_OBJECT 27 | 28 | public: 29 | explicit ChooseRoom(MainWindow *parent); 30 | ~ChooseRoom(); 31 | 32 | //函数作用:显示房间列表 33 | void ShowRoom(); 34 | 35 | public slots: 36 | //槽作用:做好建立订单之前的准备 37 | void MakeAnOrder(); 38 | //槽作用:新建订单 39 | void EnterOrder(); 40 | private: 41 | //私有指针: 42 | Ui::ChooseRoom *ui ; 43 | //回到MainWindow 44 | MainWindow *parent ; 45 | //建立针对某位用户的房间暂时列表 46 | QVectortempRoomlist ; 47 | //订单的起始日期和住房时长 48 | QDate tempDate ; 49 | int tempDays; 50 | }; 51 | 52 | #endif // CHOOSEROOM_H 53 | -------------------------------------------------------------------------------- /chooseroom.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ChooseRoom 4 | 5 | 6 | 7 | 0 8 | 0 9 | 946 10 | 634 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 20 20 | 50 21 | 261 22 | 91 23 | 24 | 25 | 26 | 27 | 微软雅黑 28 | 22 29 | 75 30 | true 31 | 32 | 33 | 34 | 可用的房间列表 35 | 36 | 37 | 38 | 39 | 40 | 0 41 | 200 42 | 951 43 | 441 44 | 45 | 46 | 47 | true 48 | 49 | 50 | 100 51 | 52 | 53 | 54 | 55 | 56 | 590 57 | 40 58 | 161 59 | 111 60 | 61 | 62 | 63 | 64 | 微软雅黑 65 | 18 66 | 75 67 | true 68 | 69 | 70 | 71 | 现在订购 72 | 73 | 74 | 75 | 76 | 77 | 760 78 | 40 79 | 161 80 | 111 81 | 82 | 83 | 84 | 85 | 微软雅黑 86 | 20 87 | 75 88 | true 89 | 90 | 91 | 92 | 后退 93 | 94 | 95 | 96 | 97 | 98 | 290 99 | 50 100 | 117 101 | 21 102 | 103 | 104 | 105 | 106 | 微软雅黑 107 | 75 108 | true 109 | 110 | 111 | 112 | 默认排序 113 | 114 | 115 | true 116 | 117 | 118 | 119 | 120 | 121 | 290 122 | 90 123 | 151 124 | 21 125 | 126 | 127 | 128 | 129 | 微软雅黑 130 | 75 131 | true 132 | 133 | 134 | 135 | 按价格高低排序 136 | 137 | 138 | 139 | 140 | 141 | 290 142 | 130 143 | 161 144 | 31 145 | 146 | 147 | 148 | 149 | 微软雅黑 150 | 75 151 | true 152 | 153 | 154 | 155 | 按评价好坏排序 156 | 157 | 158 | 159 | 160 | 161 | 430 162 | 40 163 | 151 164 | 111 165 | 166 | 167 | 168 | 169 | 微软雅黑 170 | 18 171 | 75 172 | true 173 | 174 | 175 | 176 | 刷新列表 177 | 178 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /customer.cpp: -------------------------------------------------------------------------------- 1 | #include "customer.h" 2 | #include 3 | 4 | /******************************************************************** 5 | 文件名:customer.cpp 6 | 功能模块和目的:实现customer类的功能 7 | 开发者:程晔安 8 | 日期:8.2 9 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 10 | 更改记录: 11 | **********************************************************************/ 12 | 13 | //用于从数据库中读取数据的构造函数 14 | Customer::Customer(QString newAccount, QString newPassord, 15 | QString newPhone,int newTotalCost): 16 | AbstractUser(newAccount, newPassord, newPhone),totalCost(newTotalCost) 17 | { 18 | 19 | } 20 | 21 | //用于在程序中新建用户类的构造函数 22 | 23 | Customer::Customer(QString newAccount, QString newPassword, 24 | QString newPhone): 25 | AbstractUser(newAccount, newPassword, newPhone) 26 | { 27 | totalCost = 0; 28 | } 29 | -------------------------------------------------------------------------------- /customer.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | 文件名:customer.h 3 | 功能模块和目的:创建Customer类 4 | 开发者:程晔安 5 | 日期:7/27 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录:最后更改 7/28 8 | **************************************************************************/ 9 | 10 | 11 | #ifndef CUSTOMER_H 12 | #define CUSTOMER_H 13 | 14 | #include "AbstractUser.h" 15 | #include "QString.h" 16 | #include "mydatabase.h" 17 | #include 18 | #include "order.h" 19 | 20 | using namespace std; 21 | 22 | /************************************************************************** 23 | 类名:Customer.h 24 | 功能:平台用户的信息存储和功能操作 25 | 接口说明: 26 | 开发者:程晔安 27 | 日期:7/28 28 | 更改记录: 29 | **************************************************************************/ 30 | 31 | class Customer:public AbstractUser 32 | { 33 | 34 | friend class myDatabase; 35 | 36 | 37 | public: 38 | Customer(QString newAccount, QString newPassword, 39 | QString Phone, int newTotalCost ); 40 | Customer(QString newAccount, QString newPassword, QString Phone ); 41 | Customer(){} 42 | 43 | //建立每个人的购物车总价,以便多个订单同时缴费 44 | int GetTotalCost() 45 | { 46 | return totalCost; 47 | } 48 | void SetTotalCost(int newTotalCost) 49 | { 50 | totalCost = newTotalCost; 51 | } 52 | 53 | 54 | 55 | private: 56 | //存在数据库中 57 | int totalCost; 58 | }; 59 | 60 | #endif // CUSTOMER_H 61 | -------------------------------------------------------------------------------- /enums.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | 文件名:enums.h 3 | 功能模块和目的:建立一些枚举型变量 4 | 开发者:程晔安 5 | 日期:7/26 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录:7/26最后更改 8 | **************************************************************************/ 9 | #ifndef ENUMS_H 10 | #define ENUMS_H 11 | enum RoomType{CLOCK, BIGBED, TWOBED, EXPENSIVE, PRESIDENT 12 | }; 13 | //房间的种类:钟点房、大床房、双人房、奢华房、总统套房 14 | enum QuestState{ BOOKED, PAIED, REFUND, INROOM, CHECKOUT, COMMENTED}; 15 | //订单的状态:已预定、已交款、退款、入住、退房、已评论 16 | 17 | #endif // ENUMS_H 18 | -------------------------------------------------------------------------------- /hotel.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 文件名:hotel.cpp 3 | 功能模块和目的: 4 | 开发者:程晔安 5 | 日期:8.2 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录: 8 | **********************************************************************/ 9 | 10 | #include "hotel.h" 11 | #include 12 | #include "room.h" 13 | 14 | //用于程序中创建酒店类的构造函数 15 | Hotel::Hotel(QString newhotelname, QString newaddress, 16 | QString newdistrict, QString newconsolePhone): 17 | HotelName(newhotelname), Address(newaddress), 18 | District(newdistrict), ConsolePhone(newconsolePhone) 19 | { 20 | Approved = false; 21 | 22 | } 23 | 24 | //用于从数据库中读取时的构造函数 25 | Hotel::Hotel(QString newhotelname, QString newaddress, 26 | QString newdistrict, QString newconsolePhone, 27 | bool newApproved): 28 | HotelName(newhotelname), Address(newaddress), 29 | District(newdistrict), ConsolePhone(newconsolePhone), 30 | Approved(newApproved) 31 | { 32 | 33 | 34 | } 35 | //建立两个函数而不直接使用默认值的原因是防止部分默认值被初始化。 36 | 37 | //获取用户评价星级 38 | float Hotel::GetStar() 39 | { 40 | float star = 0; 41 | for(int i=0;iRoomlist.size();i++) 42 | { 43 | star += this->Roomlist[i].GetStar(); 44 | } 45 | return (star/this->Roomlist.size()); 46 | } 47 | 48 | //获取本酒店中最低价格房间,以在房间列表显示 49 | int Hotel::GetMinPrice() 50 | { 51 | int min = this->Roomlist[0].GetRealPrice() ; 52 | //遍历搜索 53 | for(int i=0;iRoomlist.size();i++) 54 | { 55 | if(min > this->Roomlist[i].GetRealPrice()) 56 | min = this->Roomlist[i].GetRealPrice(); 57 | } 58 | return min; 59 | } 60 | -------------------------------------------------------------------------------- /hotel.h: -------------------------------------------------------------------------------- 1 | 2 | /************************************************************************** 3 | 文件名:hotel.h 4 | 功能模块和目的:创建基础的酒店列 5 | 开发者:程晔安 6 | 日期:7/30 7 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 8 | 更改记录: 9 | **************************************************************************/ 10 | #ifndef HOTEL_H 11 | #define HOTEL_H 12 | 13 | #include "QString" 14 | #include 15 | #include "room.h" 16 | 17 | /************************************************************************** 18 | 类名:hotel 19 | 功能:作为最基础的酒店类,存储酒店信息和所属的房间 20 | 接口说明:可以获取酒店相关信息,以及所属的房间的相关信息 21 | 开发者:程晔安 22 | 日期:7/31 23 | 更改记录: 24 | **************************************************************************/ 25 | using namespace std; 26 | 27 | class Room; 28 | 29 | class Hotel 30 | { 31 | public: 32 | //构造函数 33 | Hotel(QString hotelname, QString address, 34 | QString district, QString consolePhone, 35 | bool Approved); 36 | Hotel(QString hotelname, QString address, 37 | QString district,QString consolePhone); 38 | //析构函数 39 | Hotel(){} 40 | 41 | //端口函数 42 | QString GetHotelName() 43 | { 44 | return HotelName; 45 | } 46 | 47 | QString GetAddress() 48 | { 49 | return Address; 50 | } 51 | 52 | QString GetDistrict() 53 | { 54 | return District; 55 | } 56 | 57 | QString GetConsolePhone() 58 | { 59 | return ConsolePhone; 60 | } 61 | 62 | bool IsApproved() 63 | { 64 | return Approved; 65 | } 66 | void SetApproved(bool newApproved) 67 | { 68 | Approved = newApproved; 69 | } 70 | 71 | 72 | void SetRoomlist(QVectornewRoomlist) 73 | { 74 | Roomlist = newRoomlist; 75 | } 76 | float GetStar(); 77 | int GetMinPrice(); 78 | 79 | QVectorRoomlist; 80 | private: 81 | QString HotelName; 82 | QString Address; 83 | QString District; 84 | //咨询电话,如果不填默认和相关管理员电话相同 85 | QString ConsolePhone; 86 | 87 | //是否营业执照合格 88 | bool Approved; 89 | 90 | 91 | 92 | 93 | }; 94 | 95 | #endif // HOTEL_H 96 | -------------------------------------------------------------------------------- /hotelmanager.cpp: -------------------------------------------------------------------------------- 1 | 2 | /******************************************************************** 3 | 文件名:hotelmanager.cpp 4 | 功能模块和目的:实现hotelmanager类的构造函数 5 | 开发者:程晔安 6 | 日期:8.2 7 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 8 | 更改记录: 9 | **********************************************************************/ 10 | 11 | #include "hotelmanager.h" 12 | 13 | //hotelmanager类的默认构造函数 14 | //Lisence为营业执照,不再程序中体现作用,但是储存在数据库中, 15 | //用作之后其他查询和审查作用 16 | 17 | HotelManager::HotelManager(QString newAccount, QString newPassword, 18 | QString newPhone, 19 | QString newLisence, QString newHotelname): 20 | AbstractUser(newAccount, newPassword, newPhone), 21 | Lisence(newLisence), HotelName(newHotelname) 22 | { 23 | 24 | } 25 | -------------------------------------------------------------------------------- /hotelmanager.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | 文件名:hotelmanager.h 3 | 功能模块和目的:建立酒店管理员类 4 | 开发者:程晔安 5 | 日期:8.1 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录: 8 | **************************************************************************/ 9 | #ifndef HOTELMANAGER_H 10 | #define HOTELMANAGER_H 11 | 12 | #include "AbstractUser.h" 13 | #include "mydatabase.h" 14 | 15 | using namespace std; 16 | //建立酒店管理者。 17 | 18 | //AbstractUser为直接父类 19 | class HotelManager:public AbstractUser 20 | { 21 | //会有一些友元来处理订单 22 | 23 | 24 | public: 25 | //构造函数 26 | HotelManager(QString Account, QString Password, 27 | QString Phone, QString lisence, QString hotelname); 28 | //析构函数 29 | HotelManager(){} 30 | 31 | //获取酒店管理员创建酒店时所提交的营业执照号 32 | //之后可拓展:由其它外接数据库判断营业执照号是否有效 33 | QString GetLisence() 34 | { 35 | return Lisence; 36 | } 37 | //获取酒店管理者相对应的酒店名称 38 | QString GetHotelName() 39 | { 40 | return HotelName; 41 | } 42 | 43 | private: 44 | QString Lisence;//经营执照 45 | QString HotelName;//唯一对应一个酒店的名称 46 | 47 | }; 48 | 49 | #endif // HOTELMANAGER_H 50 | -------------------------------------------------------------------------------- /hotelregister.cpp: -------------------------------------------------------------------------------- 1 | 2 | /******************************************************************** 3 | 文件名: 4 | 功能模块和目的: 5 | 开发者:程晔安 6 | 日期:8.2 7 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 8 | 更改记录: 9 | **********************************************************************/ 10 | 11 | #include "hotelregister.h" 12 | #include "ui_hotelregister.h" 13 | #include "QMessageBox" 14 | #include "mydatabase.h" 15 | 16 | #include "hotelmanager.h" 17 | #include "hotel.h" 18 | 19 | extern QVectorg_HotelManagerlist; 20 | extern QVectorg_Hotellist; 21 | 22 | hotelregister::hotelregister(loginwindow1*l) : 23 | ui(new Ui::hotelregister) 24 | { 25 | ui->setupUi(this); 26 | parent = l; 27 | 28 | //装饰 29 | this->setWindowTitle("Get your own hotel!"); 30 | this->setFixedSize(this->width(),this->height()); 31 | 32 | this->setAutoFillBackground(true); 33 | QPalette palette = this->palette(); 34 | palette.setBrush(QPalette::Background, 35 | QBrush(QPixmap("://register.jpg").scaled( 36 | this->size(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation))); 37 | this->setPalette(palette); 38 | this->setFixedSize(this->width(),this->height()); 39 | 40 | //接口 41 | //返回之前列表 42 | connect(ui->btnCancle,SIGNAL(clicked(bool)),parent,SLOT(show())); 43 | connect(ui->btnCancle,SIGNAL(clicked(bool)),this,SLOT(hide())); 44 | 45 | //主要功能函数,创建相应的酒店管理员和酒店实例 46 | connect(ui->btnEnter,SIGNAL(clicked(bool)), this,SLOT(SendInfo())); 47 | 48 | 49 | 50 | } 51 | 52 | hotelregister::~hotelregister() 53 | { 54 | delete ui; 55 | } 56 | 57 | void hotelregister::SendInfo() 58 | { 59 | bool flag = false; 60 | 61 | //判断同时满足才可进行后续操作 62 | flag = CheckEntering() && CheckHtlInfo(); 63 | 64 | if(flag == true) 65 | { 66 | //之后可以扩展的功能单元——手机验证用户注册 67 | QMessageBox::information(this, "手机验证码", "请注意查收手机验证码", QMessageBox::Ok); 68 | 69 | //新建酒店管理员 70 | HotelManager newHtlManager(Account, Password, 71 | Phone, Lisence, HotelName); 72 | 73 | //加到全局变量中 74 | g_HotelManagerlist.push_back(newHtlManager); 75 | 76 | //新建酒店 77 | Hotel newHotel(HotelName, Address, 78 | District, ConsolePhone); 79 | 80 | //加到全局变量中 81 | g_Hotellist.push_back(newHotel); 82 | myDatabase Database; 83 | Database.Memory(); 84 | QMessageBox::information(this, "success!", "注册信息成功提交!等待平台管理员审核", QMessageBox::Ok); 85 | } 86 | 87 | this->close(); 88 | parent->show(); 89 | 90 | } 91 | 92 | //检查输入是否符合规范 93 | bool hotelregister::CheckEntering() 94 | { 95 | //检查输入是否符合规则 96 | bool flag = true; 97 | 98 | //获得局部变量 99 | Account = ui->lineAccount->text(); 100 | Password = ui->linePassword->text(); 101 | Password2 = ui->linePassword2->text(); 102 | Phone = ui->linePhone->text(); 103 | Lisence = ui->lineLisence->text(); 104 | HotelName = ui->lineHotelName->text(); 105 | ConsolePhone = ui->lineConsolePhone->text(); 106 | 107 | //concolephone可以缺省 108 | if(ConsolePhone.isEmpty()) 109 | ConsolePhone = Phone; 110 | 111 | 112 | Address = ui->lineAddress->text(); 113 | District = ui->lineDistrict->text(); 114 | 115 | //容错判断 116 | if(Password.isEmpty()) 117 | { 118 | QMessageBox::information(this, "entering Error", "输入密码不能为空", QMessageBox::Ok); 119 | flag = false; 120 | } 121 | if(Password.length()<6||Password.length()>11) 122 | { 123 | QMessageBox::information(this, "length Error", "密码长度应在6~11位以内", QMessageBox::Ok); 124 | flag = false; 125 | } 126 | if(Password != Password2) 127 | { 128 | QMessageBox::information(this, "different Entering", "两次密码输入不同", QMessageBox::Ok); 129 | flag = false; 130 | } 131 | if(Account.isEmpty()) 132 | { 133 | QMessageBox::information(this, "entering Error", "输入账户不能为空!",QMessageBox::Ok); 134 | flag = false; 135 | } 136 | if(Phone.isEmpty()) 137 | { 138 | QMessageBox::information(this, "entering Error", "输入电话不能为空!",QMessageBox::Ok); 139 | flag = false; 140 | } 141 | if(Phone.length()!=11) 142 | { 143 | QMessageBox::information(this, "entering Error", "输入电话号码应为11位!",QMessageBox::Ok); 144 | flag = false; 145 | } 146 | if(Lisence.isEmpty()) 147 | { 148 | QMessageBox::information(this, "entering Error", "输入营业证号不能为空!",QMessageBox::Ok); 149 | flag = false; 150 | } 151 | if(HotelName.isEmpty()) 152 | { 153 | QMessageBox::information(this, "entering Error", "输入酒店名称不能为空!",QMessageBox::Ok); 154 | flag = false; 155 | } 156 | if(Address.isEmpty()) 157 | { 158 | QMessageBox::information(this, "entering Error", "输入城市不能为空!",QMessageBox::Ok); 159 | flag = false; 160 | } 161 | if(District.isEmpty()) 162 | { 163 | QMessageBox::information(this, "entering Error", "输入地区不能为空!",QMessageBox::Ok); 164 | flag = false; 165 | } 166 | 167 | return flag; 168 | } 169 | 170 | //在已有的信息中查找是否有信息重复 171 | bool hotelregister::CheckHtlInfo() 172 | { 173 | bool flag = true; 174 | 175 | qDebug()< 21 | #include "loginwindow1.h" 22 | 23 | namespace Ui { 24 | class hotelregister; 25 | } 26 | //直接继承由登陆界面 27 | class loginwindow1; 28 | 29 | class hotelregister : public QWidget 30 | { 31 | Q_OBJECT 32 | 33 | public: 34 | explicit hotelregister(loginwindow1 *l ); 35 | ~hotelregister(); 36 | 37 | private: 38 | Ui::hotelregister *ui; 39 | 40 | //用于返回到登录界面 41 | loginwindow1 *parent; 42 | 43 | //局部变量 44 | QString Account; 45 | QString Password; 46 | QString Password2; 47 | QString Phone; 48 | QString Lisence; 49 | QString HotelName; 50 | QString ConsolePhone; 51 | QString Address; 52 | QString District; 53 | 54 | //检查输入是否合理 55 | bool CheckEntering(); 56 | //检查已有的酒店注册信息,防止重复 57 | bool CheckHtlInfo(); 58 | 59 | public slots: 60 | //保存和处理相关的信息 61 | void SendInfo(); 62 | 63 | }; 64 | 65 | #endif // hotelregister_H 66 | -------------------------------------------------------------------------------- /hotelregister.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | hotelregister 4 | 5 | 6 | 7 | 0 8 | 0 9 | 558 10 | 761 11 | 12 | 13 | 14 | 15 | 微软雅黑 16 | 75 17 | true 18 | 19 | 20 | 21 | Form 22 | 23 | 24 | 25 | 26 | 50 27 | 30 28 | 431 29 | 71 30 | 31 | 32 | 33 | 34 | 微软雅黑 35 | 36 36 | 50 37 | false 38 | 39 | 40 | 41 | 酒店管理员注册 42 | 43 | 44 | 45 | 46 | 47 | 40 48 | 140 49 | 481 50 | 471 51 | 52 | 53 | 54 | 55 | 56 | 57 | 请填写真名 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 微软雅黑 66 | 18 67 | 50 68 | false 69 | 70 | 71 | 72 | 确认密码 73 | 74 | 75 | 76 | 77 | 78 | 79 | 用于平台审核 80 | 81 | 82 | 83 | 84 | 85 | 86 | QLineEdit::Password 87 | 88 | 89 | 密码为6~11位 90 | 91 | 92 | 93 | 94 | 95 | 96 | 酒店名称在11个字符以下 97 | 98 | 99 | 100 | 101 | 102 | 103 | QLineEdit::Password 104 | 105 | 106 | 请两次输入保持一致 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 微软雅黑 115 | 18 116 | 50 117 | false 118 | 119 | 120 | 121 | 城市 122 | 123 | 124 | 125 | 126 | 127 | 128 | 仅用于平台联系的消息接收 129 | 130 | 131 | 132 | 133 | 134 | 135 | 请输入城市 136 | 137 | 138 | 139 | 140 | 141 | 142 | 用于酒店联系,不填则默认与个人手机相同 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 微软雅黑 151 | 18 152 | 50 153 | false 154 | 155 | 156 | 157 | 密码 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 微软雅黑 166 | 18 167 | 50 168 | false 169 | 170 | 171 | 172 | 酒店名称 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 微软雅黑 181 | 18 182 | 50 183 | false 184 | 185 | 186 | 187 | 营业执照号 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 微软雅黑 196 | 18 197 | 50 198 | false 199 | 200 | 201 | 202 | 个人手机 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 微软雅黑 211 | 18 212 | 50 213 | false 214 | 215 | 216 | 217 | 用户名 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 微软雅黑 226 | 16 227 | 50 228 | false 229 | 230 | 231 | 232 | 酒店联系电话 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 微软雅黑 241 | 18 242 | 50 243 | false 244 | 245 | 246 | 247 | 地区 248 | 249 | 250 | 251 | 252 | 253 | 254 | 请输入相应地区 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 70 264 | 630 265 | 191 266 | 101 267 | 268 | 269 | 270 | 271 | 微软雅黑 272 | 24 273 | 50 274 | false 275 | 276 | 277 | 278 | 确认注册 279 | 280 | 281 | 282 | 283 | 284 | 280 285 | 630 286 | 181 287 | 101 288 | 289 | 290 | 291 | 292 | 微软雅黑 293 | 26 294 | 50 295 | false 296 | 297 | 298 | 299 | 取消 300 | 301 | 302 | 303 | 304 | 305 | 306 | -------------------------------------------------------------------------------- /loginwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGINWINDOW_H 2 | #define LOGINWINDOW_H 3 | 4 | #include 5 | #include"loginwindow.h" 6 | 7 | namespace Ui { 8 | class loginwindow; 9 | } 10 | 11 | class loginwindow:public QWidget 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | explicit loginwindow(QWidget *parent = 0); 17 | ~loginwindow(); 18 | Ui::loginwindow *ui; 19 | 20 | public slots:void login(); 21 | private: 22 | 23 | 24 | } 25 | 26 | 27 | #endif // LOGINWINDOW_H 28 | -------------------------------------------------------------------------------- /loginwindow1.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 文件名:loginwindow1.cpp 3 | 功能模块和目的:实现登录操作,包括注册和进入主界面 4 | 开发者:程晔安 5 | 日期:8.2 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录: 8 | **********************************************************************/ 9 | 10 | #include "loginwindow1.h" 11 | #include "ui_loginwindow1.h" 12 | #include "qstring.h" 13 | #include 14 | #include "QRadioButton" 15 | #include "registerwindow.h" 16 | #include "mydatabase.h" 17 | #include "QDebug" 18 | 19 | 20 | #include "customer.h" 21 | #include "hotelmanager.h" 22 | #include "hotel.h" 23 | #include "platformadmin.h" 24 | #include "order.h" 25 | 26 | //外部变量 27 | extern QVectorg_Customerlist; 28 | extern QVectorg_HotelManagerlist; 29 | extern QVectorg_Hotellist; 30 | extern QVectorg_PlatformAdminlist; 31 | extern QVectorg_Orderlist; 32 | 33 | 34 | //清空密码,以便再次登陆 35 | void loginwindow1::ClearPassword() 36 | { 37 | ui->linePassword->clear(); 38 | } 39 | 40 | loginwindow1::loginwindow1(QWidget *parent) : 41 | QWidget(parent), 42 | ui(new Ui::loginwindow1) 43 | { 44 | ui->setupUi(this); 45 | 46 | //装饰 47 | 48 | 49 | this->setWindowTitle("APlaceToStay"); 50 | //this->setAutoFillBackground(true); 51 | QPalette palette = this->palette(); 52 | palette.setBrush(QPalette::Background, 53 | QBrush(QPixmap("./standard.jpg").scaled( 54 | this->size(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation))); 55 | this->setPalette(palette); 56 | this->setFixedSize(this->width(),this->height()); 57 | //this->setWindowFlags(Qt::FramelessWindowHint); 58 | 59 | ui->linePassword->setEchoMode(QLineEdit::Password); 60 | 61 | //初始化列表,将相应信息放在全局变量中 62 | 63 | myDatabase Database; 64 | Database.InitialCustomer(); 65 | Database.InitialRoom(); 66 | Database.InitialHotelmanager(); 67 | Database.InitialHotelAndRoom(); 68 | Database.InitialPlatformAdmin(); 69 | Database.InitialOrder(); 70 | 71 | 72 | //slots 73 | 74 | //点击注册,根据radiobutton的选择不同实现不同身份相应窗口的跳转 75 | connect(ui->btnRegister,SIGNAL(clicked(bool)),this,SLOT(RegisterChoose())); 76 | connect(ui->btnRegister,SIGNAL(clicked(bool)),this,SLOT(hide())); 77 | 78 | //确认登陆 79 | connect(ui->btnEnter,SIGNAL(clicked(bool)),this,SLOT(Login())); 80 | 81 | 82 | 83 | } 84 | 85 | loginwindow1::~loginwindow1() 86 | { 87 | delete ui; 88 | } 89 | 90 | void loginwindow1::Login() 91 | { 92 | //获取账号密码信息 93 | QString account = ui->lineAccount->text(); 94 | QString password = ui->linePassword->text(); 95 | 96 | //总体的容错判断 97 | if(password.isEmpty())//密码不能为空 98 | { 99 | QMessageBox msgBox; 100 | msgBox.setText("请输入密码"); 101 | msgBox.setWindowTitle("Error"); 102 | msgBox.exec(); 103 | return ; 104 | } 105 | //账号不能为空 106 | if(account.isEmpty()) 107 | { 108 | QMessageBox::information(this, "Error", "请输入用户名", QMessageBox::Ok); 109 | return ; 110 | } 111 | 112 | //判断用户名密码是否正确 113 | //登录用户界面 114 | if(ui->btnCustomer->isChecked()) 115 | { 116 | ui->lineAccount->clear(); 117 | ui->linePassword->clear(); 118 | bool flag = 0; 119 | //判断登陆信息 120 | for (int i=0;iclose(); 129 | pMainwindow = new MainWindow(this, &g_Customerlist[i]); 130 | pMainwindow->show(); 131 | } 132 | 133 | } 134 | if(flag == 0) 135 | { 136 | QMessageBox::information(this, "FAILED", "用户名或密码错误", 137 | QMessageBox::Ok); 138 | ui->linePassword->clear(); 139 | } 140 | } 141 | 142 | //登录酒店管理员界面 143 | else if(ui->btnHotelM->isChecked()) 144 | { 145 | ui->lineAccount->clear(); 146 | ui->linePassword->clear(); 147 | bool flag = false; 148 | 149 | //判断登陆信息 150 | for(int i=0;iclose(); 170 | pWHotel = new whotel(this, &g_Hotellist[j]); 171 | pWHotel->show(); 172 | } 173 | else 174 | { 175 | //如果酒店尚未通过平台审核,也不能登陆 176 | QMessageBox::information(this, "Failed", 177 | "酒店尚未通过平台审核", 178 | QMessageBox::Ok); 179 | ui->linePassword->clear(); 180 | } 181 | } 182 | } 183 | } 184 | 185 | 186 | } 187 | if(flag == false) 188 | { 189 | 190 | QMessageBox::information(this, "FAILED", "登录失败" 191 | , QMessageBox::Ok); 192 | ui->linePassword->clear(); 193 | } 194 | } 195 | 196 | //登录平台管理员界面 197 | else 198 | { 199 | ui->lineAccount->clear(); 200 | ui->linePassword->clear(); 201 | bool flag = 0; 202 | 203 | for (int i=0;iclose(); 212 | pPlatform = new Platform(this); 213 | pPlatform->show(); 214 | } 215 | 216 | } 217 | if(flag == 0) 218 | { 219 | QMessageBox::information(this, "FAILED", "用户名或密码错误", 220 | QMessageBox::Ok); 221 | ui->linePassword->clear(); 222 | } 223 | } 224 | } 225 | 226 | //选择用户或者酒店注册 227 | void loginwindow1::RegisterChoose() 228 | { 229 | 230 | //进入用户注册界面 231 | if(ui->btnCustomer->isChecked()) 232 | { 233 | pRegister = new registerWindow(this); 234 | pRegister->show(); 235 | } 236 | //平台管理员界面,唯一账号,不可注册 237 | //唯一账号: 238 | //账号:kkk 239 | //密码:1234567890 240 | else if (ui->btnPlatformM->isChecked()) 241 | { 242 | QMessageBox::information(this, 243 | "ERROR", 244 | "管理员账户不能被注册,请联系平台负责人找回账号", 245 | QMessageBox::Ok); 246 | 247 | } 248 | 249 | //进入酒店管理员注册界面 250 | else 251 | { 252 | pHtl = new hotelregister(this); 253 | pHtl->show(); 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /loginwindow1.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | 文件名:loginwindow1.h 3 | 功能模块和目的:创捷登录图形界面。 4 | 开发者:程晔安 5 | 日期:8.1 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录: 8 | **************************************************************************/ 9 | #ifndef loginwindow1_H 10 | #define loginwindow1_H 11 | 12 | #include 13 | #include "registerwindow.h" 14 | #include "hotelregister.h" 15 | #include "mainwindow.h" 16 | #include "whotel.h" 17 | #include "platform.h" 18 | 19 | /************************************************************************** 20 | 类名:loginwindow 21 | 功能:最开始的界面。连结两个注册界面和三个主要用户对象界面 22 | 接口说明:有指向hotelregister,mainwindow,platform,registerwindow,whotel的指针。 23 | 开发者:程晔安 24 | 日期:8.1 25 | 更改记录: 26 | **************************************************************************/ 27 | 28 | namespace Ui { 29 | class loginwindow1; 30 | } 31 | 32 | class registerWindow; 33 | class hotelregister; 34 | class MainWindow; 35 | class whotel; 36 | class Platform; 37 | 38 | class loginwindow1 : public QWidget 39 | { 40 | Q_OBJECT 41 | 42 | public: 43 | explicit loginwindow1(QWidget *parent = 0); 44 | ~loginwindow1(); 45 | void ClearPassword(); 46 | 47 | private: 48 | Ui::loginwindow1 *ui; 49 | 50 | //注册窗口 51 | registerWindow*pRegister ; 52 | hotelregister*pHtl ; 53 | 54 | //登录窗口,一共三个 55 | MainWindow*pMainwindow ; 56 | whotel *pWHotel ; 57 | Platform *pPlatform ; 58 | 59 | public slots: 60 | void Login(); 61 | void RegisterChoose(); 62 | 63 | signals: 64 | 65 | }; 66 | 67 | #endif // loginwindow1_H 68 | -------------------------------------------------------------------------------- /loginwindow1.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | loginwindow1 4 | 5 | 6 | 7 | 0 8 | 0 9 | 952 10 | 566 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | 21 | 0 22 | 0 23 | 24 | 25 | 26 | 27 | 10000 28 | 10000 29 | 30 | 31 | 32 | 33 | 微软雅黑 34 | 75 35 | true 36 | 37 | 38 | 39 | Form 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 20 48 | 30 49 | 531 50 | 151 51 | 52 | 53 | 54 | 55 | 微软雅黑 56 | 72 57 | 50 58 | false 59 | 60 | 61 | 62 | 一栖之地 63 | 64 | 65 | 66 | 67 | 68 | 250 69 | 180 70 | 681 71 | 51 72 | 73 | 74 | 75 | 76 | 微软雅黑 77 | 20 78 | 50 79 | false 80 | 81 | 82 | 83 | ——我们用心服务,为您找到最适合您的酒店 84 | 85 | 86 | 87 | 88 | true 89 | 90 | 91 | 92 | 100 93 | 290 94 | 251 95 | 61 96 | 97 | 98 | 99 | 100 | 微软雅黑 101 | 28 102 | 50 103 | false 104 | 105 | 106 | 107 | false 108 | 109 | 110 | 用户 111 | 112 | 113 | true 114 | 115 | 116 | 117 | 118 | true 119 | 120 | 121 | 122 | 100 123 | 360 124 | 261 125 | 61 126 | 127 | 128 | 129 | 130 | 微软雅黑 131 | 28 132 | 50 133 | false 134 | 135 | 136 | 137 | 酒店管理员 138 | 139 | 140 | 141 | 142 | true 143 | 144 | 145 | 146 | 100 147 | 440 148 | 261 149 | 51 150 | 151 | 152 | 153 | 154 | 微软雅黑 155 | 28 156 | 50 157 | false 158 | 159 | 160 | 161 | 平台管理员 162 | 163 | 164 | 165 | 166 | 167 | 730 168 | 370 169 | 171 170 | 121 171 | 172 | 173 | 174 | 175 | 微软雅黑 176 | 36 177 | 50 178 | false 179 | 180 | 181 | 182 | 登录 183 | 184 | 185 | 186 | 187 | 188 | 730 189 | 290 190 | 171 191 | 61 192 | 193 | 194 | 195 | 196 | 微软雅黑 197 | 20 198 | 50 199 | false 200 | 201 | 202 | 203 | 现在注册 204 | 205 | 206 | 207 | 208 | 209 | 420 210 | 290 211 | 271 212 | 191 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 微软雅黑 221 | 18 222 | 50 223 | false 224 | 225 | 226 | 227 | 账户 228 | 229 | 230 | 231 | 232 | 233 | 234 | true 235 | 236 | 237 | 238 | 239 | 240 | 241 | true 242 | 243 | 244 | 245 | 微软雅黑 246 | 18 247 | 50 248 | false 249 | 250 | 251 | 252 | 密码 253 | 254 | 255 | 256 | 257 | 258 | 259 | true 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | 2 | /******************************************************************** 3 | 文件名:main.cpp 4 | 功能模块和目的:主函数 5 | 开发者:程晔安 6 | 日期:7.27 7 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 8 | 更改记录: 9 | **********************************************************************/ 10 | 11 | #include "mainwindow.h" 12 | #include 13 | #include"loginwindow1.h" 14 | #include"mydatabase.h" 15 | 16 | #include 17 | 18 | #include "customer.h" 19 | #include "hotelmanager.h" 20 | #include "hotel.h" 21 | #include "order.h" 22 | #include "platformadmin.h" 23 | 24 | #include "QFile" 25 | using namespace std; 26 | 27 | //声明全局变量 28 | QVectorg_Customerlist; 29 | QVectorg_HotelManagerlist; 30 | QVectorg_Hotellist; 31 | QVectorg_Orderlist; 32 | QVectorg_PlatformAdminlist; 33 | 34 | //所有房间放在一个容器中 35 | QVectorRawRoomlist; 36 | 37 | //添加QSS 38 | QString getQssContent() 39 | { 40 | QFile styleSheet(":/qtStyleSheet.txt"); 41 | if (!styleSheet.open(QIODevice::ReadOnly)) 42 | { 43 | qWarning("Can't open the style sheet file."); 44 | return ""; 45 | } 46 | return styleSheet.readAll(); 47 | } 48 | 49 | //主函数 50 | int main(int argc, char *argv[]) 51 | { 52 | 53 | QApplication a(argc, argv); 54 | 55 | a.setStyleSheet(getQssContent()); 56 | 57 | //打开登陆界面 58 | loginwindow1 w; 59 | w.show(); 60 | return a.exec(); 61 | } 62 | -------------------------------------------------------------------------------- /mainwindow.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | 文件名:mainwindow.h 3 | 功能模块和目的:创建用户界面 4 | 开发者:程晔安 5 | 日期:8.1 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录: 8 | **************************************************************************/ 9 | #ifndef MAINWINDOW_H 10 | #define MAINWINDOW_H 11 | 12 | #include 13 | #include 14 | #include "QVector" 15 | 16 | #include "chooseroom.h" 17 | #include "loginwindow1.h" 18 | #include "customer.h" 19 | #include "hotel.h" 20 | #include "room.h" 21 | #include "order.h" 22 | #include "wcomment.h" 23 | 24 | /************************************************************************** 25 | 类名:mainwindow 26 | 功能:创建用户界面,处理用户输入信息,向用户呈现相关信息。 27 | 接口说明:有指向loginwindow,chooseroom,wcomment的指针 28 | 开发者:程晔安 29 | 日期:8.1 30 | 更改记录: 31 | **************************************************************************/ 32 | 33 | namespace Ui { 34 | class MainWindow; 35 | } 36 | 37 | class loginwindow1; 38 | 39 | class MainWindow : public QMainWindow 40 | { 41 | Q_OBJECT 42 | 43 | public: 44 | explicit MainWindow(loginwindow1*parent, Customer*pCustomer); 45 | ~MainWindow(); 46 | //提供用户界面的相关信息给chooseroom界面,以实现订单的创建。 47 | int GetType(); 48 | Customer* GetpCustomer(); 49 | Hotel* GetpHotel(); 50 | QDate GetDate(); 51 | int GetDays(); 52 | //将酒店列表打印出来 53 | void ShowHotel(int SortType); 54 | 55 | //第一个tab编辑页中的输入检测 56 | bool EnteringCheckP1(); 57 | public slots: 58 | //tab1 59 | void SearchARoomP1(); 60 | void SaveAndLogout(); 61 | void ShowDetail(); 62 | //tab2 63 | void ShowOrder(); 64 | 65 | void Pay(); 66 | void Refund(); 67 | void Comment(); 68 | 69 | //tab3 70 | //改变密码操作 71 | void ChangePassword(); 72 | 73 | private: 74 | Ui::MainWindow *ui; 75 | 76 | //指向不同界面的指针 77 | loginwindow1*parent ; 78 | 79 | ChooseRoom* pChooseRoom ; 80 | WComment* pComment ; 81 | 82 | //代表该用户界面所代表的用户的信息 83 | Customer* pCustomer ; 84 | 85 | //创建临时酒店指针列表 86 | QVectortemp_pHotellist; 87 | //创建临时订单列表 88 | QVectortemp_pOrderlist; 89 | }; 90 | 91 | #endif // MAINWINDOW_H 92 | -------------------------------------------------------------------------------- /mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1008 10 | 707 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 0 21 | 0 22 | 1011 23 | 711 24 | 25 | 26 | 27 | 28 | 微软雅黑 29 | 75 30 | true 31 | 32 | 33 | 34 | QTabWidget::Triangular 35 | 36 | 37 | 2 38 | 39 | 40 | 41 | 30 42 | 30 43 | 44 | 45 | 46 | Qt::ElideMiddle 47 | 48 | 49 | false 50 | 51 | 52 | false 53 | 54 | 55 | false 56 | 57 | 58 | false 59 | 60 | 61 | 62 | 搜索酒店 63 | 64 | 65 | 66 | 67 | 0 68 | 300 69 | 741 70 | 331 71 | 72 | 73 | 74 | 0 75 | 76 | 77 | 78 | 79 | 80 | 770 81 | 300 82 | 221 83 | 91 84 | 85 | 86 | 87 | 88 | 微软雅黑 89 | 28 90 | 91 | 92 | 93 | 查询 94 | 95 | 96 | 97 | 98 | 99 | 20 100 | 100 101 | 181 102 | 41 103 | 104 | 105 | 106 | 搜索城市 107 | 108 | 109 | 110 | 111 | 112 | 10 113 | 30 114 | 411 115 | 41 116 | 117 | 118 | 119 | 120 | 微软雅黑 121 | 24 122 | 123 | 124 | 125 | 搜索您中意的一栖之地 126 | 127 | 128 | Qt::AutoText 129 | 130 | 131 | 132 | 133 | 134 | 230 135 | 110 136 | 161 137 | 31 138 | 139 | 140 | 141 | 142 | 微软雅黑 143 | 12 144 | 145 | 146 | 147 | 默认排序 148 | 149 | 150 | true 151 | 152 | 153 | 154 | 155 | 156 | 230 157 | 220 158 | 171 159 | 41 160 | 161 | 162 | 163 | 164 | 微软雅黑 165 | 12 166 | 167 | 168 | 169 | 按评价好坏排序 170 | 171 | 172 | 173 | 174 | 175 | 230 176 | 170 177 | 171 178 | 31 179 | 180 | 181 | 182 | 183 | 微软雅黑 184 | 12 185 | 186 | 187 | 188 | 按价格高低排序 189 | 190 | 191 | 192 | 193 | 194 | 770 195 | 500 196 | 221 197 | 91 198 | 199 | 200 | 201 | 202 | 微软雅黑 203 | 16 204 | 75 205 | true 206 | 207 | 208 | 209 | 保存并退出登录 210 | 211 | 212 | 213 | 214 | 215 | 430 216 | 50 217 | 311 218 | 231 219 | 220 | 221 | 222 | 223 | 224 | 225 | 780 226 | 180 227 | 181 228 | 41 229 | 230 | 231 | 232 | 233 | 234 | 235 | 770 236 | 100 237 | 201 238 | 41 239 | 240 | 241 | 242 | 243 | 微软雅黑 244 | 16 245 | 246 | 247 | 248 | 请输入入住天数 249 | 250 | 251 | 252 | 253 | 254 | 500 255 | 10 256 | 131 257 | 31 258 | 259 | 260 | 261 | 262 | 微软雅黑 263 | 11 264 | 265 | 266 | 267 | 请选择入住日期 268 | 269 | 270 | 271 | 272 | 273 | 770 274 | 400 275 | 221 276 | 91 277 | 278 | 279 | 280 | 281 | 微软雅黑 282 | 20 283 | 75 284 | true 285 | 286 | 287 | 288 | 查看详细信息 289 | 290 | 291 | 292 | 293 | 294 | 20 295 | 160 296 | 181 297 | 41 298 | 299 | 300 | 301 | 搜索地区(可不填) 302 | 303 | 304 | 305 | 306 | 307 | 20 308 | 220 309 | 181 310 | 31 311 | 312 | 313 | 314 | 315 | 所有房型 316 | 317 | 318 | 319 | 320 | 钟点房 321 | 322 | 323 | 324 | 325 | 双人房 326 | 327 | 328 | 329 | 330 | 大床房 331 | 332 | 333 | 334 | 335 | 奢华房 336 | 337 | 338 | 339 | 340 | 总统套房 341 | 342 | 343 | 344 | 345 | 346 | 347 | 订单列表 348 | 349 | 350 | 351 | 352 | 0 353 | 90 354 | 791 355 | 501 356 | 357 | 358 | 359 | 360 | 361 | 362 | 270 363 | 10 364 | 241 365 | 71 366 | 367 | 368 | 369 | 370 | 36 371 | 50 372 | false 373 | 374 | 375 | 376 | 订单列表 377 | 378 | 379 | 380 | 381 | 382 | 810 383 | 210 384 | 181 385 | 111 386 | 387 | 388 | 389 | 390 | 24 391 | 392 | 393 | 394 | 确认付款 395 | 396 | 397 | 398 | 399 | 400 | 810 401 | 330 402 | 181 403 | 111 404 | 405 | 406 | 407 | 408 | 24 409 | 410 | 411 | 412 | 申请退款 413 | 414 | 415 | 416 | 417 | 418 | 810 419 | 450 420 | 181 421 | 111 422 | 423 | 424 | 425 | 426 | 24 427 | 428 | 429 | 430 | 评价订单 431 | 432 | 433 | 434 | 435 | 436 | 810 437 | 90 438 | 181 439 | 111 440 | 441 | 442 | 443 | 444 | 24 445 | 446 | 447 | 448 | 刷新列表 449 | 450 | 451 | 452 | 453 | 454 | 信息维护 455 | 456 | 457 | 458 | 459 | 30 460 | 30 461 | 941 462 | 111 463 | 464 | 465 | 466 | 467 | 微软雅黑 468 | 36 469 | 50 470 | false 471 | 472 | 473 | 474 | 一栖之地——酒店预订管理系统 475 | 476 | 477 | 478 | 479 | 480 | 220 481 | 150 482 | 571 483 | 101 484 | 485 | 486 | 487 | 488 | 36 489 | 50 490 | false 491 | 492 | 493 | 494 | C++程序设计与训练 495 | 496 | 497 | 498 | 499 | 500 | 670 501 | 480 502 | 121 503 | 61 504 | 505 | 506 | 507 | 508 | 24 509 | 50 510 | false 511 | 512 | 513 | 514 | 设计者 515 | 516 | 517 | 518 | 519 | 520 | 480 521 | 550 522 | 491 523 | 51 524 | 525 | 526 | 527 | 528 | 16 529 | 75 530 | true 531 | 532 | 533 | 534 | www.cya17@mails.tsinghua.edu.cn 535 | 536 | 537 | 538 | 539 | 540 | 820 541 | 480 542 | 131 543 | 61 544 | 545 | 546 | 547 | 548 | 24 549 | 50 550 | false 551 | 552 | 553 | 554 | 程晔安 555 | 556 | 557 | 558 | 559 | 560 | 120 561 | 350 562 | 191 563 | 31 564 | 565 | 566 | 567 | 请输入手机验证码 568 | 569 | 570 | 571 | 572 | 573 | 120 574 | 500 575 | 191 576 | 41 577 | 578 | 579 | 580 | 确认更改 581 | 582 | 583 | 584 | 585 | 586 | 120 587 | 400 588 | 191 589 | 31 590 | 591 | 592 | 593 | 请输入旧密码 594 | 595 | 596 | 597 | 598 | 599 | 120 600 | 450 601 | 191 602 | 31 603 | 604 | 605 | 606 | 请输入新密码 607 | 608 | 609 | 610 | 611 | 612 | 340 613 | 350 614 | 121 615 | 31 616 | 617 | 618 | 619 | 获取手机验证码 620 | 621 | 622 | 623 | 624 | 625 | 120 626 | 300 627 | 81 628 | 31 629 | 630 | 631 | 632 | 633 | 12 634 | 635 | 636 | 637 | 更改密码 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 0 647 | 0 648 | 1008 649 | 25 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | -------------------------------------------------------------------------------- /mydatabase.cpp: -------------------------------------------------------------------------------- 1 | 2 | /******************************************************************** 3 | 文件名:myDatabase.cpp 4 | 功能模块和目的:完成于数据库的连接 5 | 开发者:程晔安 6 | 日期:8.2 7 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 8 | 更改记录: 9 | **********************************************************************/ 10 | 11 | #include "mydatabase.h" 12 | #include "customer.h" 13 | #include "hotel.h" 14 | #include "hotelmanager.h" 15 | #include "room.h" 16 | #include "order.h" 17 | #include "platformadmin.h" 18 | 19 | extern QVectorg_Customerlist; 20 | extern QVectorg_Hotellist; 21 | extern QVectorg_HotelManagerlist; 22 | extern QVectorg_Orderlist; 23 | extern QVectorg_PlatformAdminlist; 24 | 25 | extern QVectorRawRoomlist; 26 | 27 | //在构造时完成connect,创建表 28 | myDatabase::myDatabase() 29 | { 30 | CreateConnection(); 31 | CreatTables(); 32 | 33 | } 34 | 35 | myDatabase::~myDatabase() 36 | { 37 | } 38 | 39 | //创建数据库连接 40 | bool myDatabase::CreateConnection() 41 | { 42 | db = QSqlDatabase::addDatabase("QSQLITE", "connection"); 43 | 44 | db.setDatabaseName("HotelManagement.db"); 45 | if(!db.open()) 46 | { 47 | QMessageBox msg; 48 | msg.setText("无法打开数据库"); 49 | msg.setWindowTitle("Error"); 50 | msg.exec(); 51 | return false; 52 | } 53 | return true; 54 | } 55 | 56 | //创建表头 57 | bool myDatabase::CreatTables() 58 | { 59 | QSqlQuery query(db); 60 | 61 | //创建用户列表 62 | query.prepare("create table IF NOT EXISTS Customer" 63 | "(Account VARCHAR, Password VARCHAR, Phone VARCHAR, Totalamount INT)"); 64 | if(!query.exec()) 65 | { QMessageBox msg; 66 | msg.setText("Fatal error!Failed to create table Customer!"); 67 | msg.setWindowTitle(QStringLiteral("Error!")); 68 | msg.exec(); 69 | return false;} 70 | 71 | 72 | //创建酒店管理员列表 73 | query.prepare("create table IF NOT EXISTS HotelManager" 74 | "(Account VARCHAR, Password VARCHAR, Phone VARCHAR, " 75 | "Lisence VARCHAR, Hotelname VARCHAR)"); 76 | if(!query.exec()) 77 | { QMessageBox msg; 78 | msg.setText("Fatal error!Failed to create table Hotelmanager!"); 79 | msg.setWindowTitle(QStringLiteral("Error!")); 80 | msg.exec(); 81 | return false;} 82 | 83 | 84 | //创建酒店列表 85 | query.prepare("create table IF NOT EXISTS Hotel" 86 | "(Hotelname VARCHAR, Address VARCHAR, " 87 | "District VARCHAR, " 88 | "Consolephone VARCHAR, Approved BOOLEAN)"); 89 | 90 | if(!query.exec()) 91 | { QMessageBox msg; 92 | msg.setText("Fatal error!Failed to create table Hotel!"); 93 | msg.setWindowTitle(QStringLiteral("Error!")); 94 | msg.exec(); 95 | return false;} 96 | 97 | //创建酒店房间大列表 98 | query.prepare("create table IF NOT EXISTS Room" 99 | "(Hotelname VARCHAR, Approved BOOLEAN, " 100 | "Price INT, Number INT, " 101 | "Type INT, Discount FLOAT, " 102 | "Images VARCHAR, Discription VARCHAR, " 103 | "Star INT)"); 104 | 105 | if(!query.exec()) 106 | { QMessageBox msg; 107 | msg.setText("Fatal error!Failed to create table Room!"); 108 | msg.setWindowTitle(QStringLiteral("Error!")); 109 | msg.exec(); 110 | return false;} 111 | 112 | //创建订单列表 113 | //Order为关键字,所以用Orderer作为表名 114 | query.prepare("create table IF NOT EXISTS Orderer" 115 | "(Date VARCHAR, Days INT, Types INT, " 116 | "RefundApproved BOOLEAN, CustomerName VARCHAR, " 117 | "RoomId VARCHAR)"); 118 | if(!query.exec()) 119 | { QMessageBox msg; 120 | msg.setText("Fatal error!Failed to create table Order!"); 121 | msg.setWindowTitle(QStringLiteral("Error!")); 122 | msg.exec(); 123 | return false;} 124 | 125 | //创建平台管理员列表 126 | query.prepare("create table IF NOT EXISTS PlatformAdmin" 127 | "(Account VARCHAR, Password VARCHAR, " 128 | "Phone VARCHAR)"); 129 | if(!query.exec()) 130 | { QMessageBox msg; 131 | msg.setText("Fatal error!Failed to create table PlatformAdmin!"); 132 | msg.setWindowTitle(QStringLiteral("Error!")); 133 | msg.exec(); 134 | return false;} 135 | 136 | return true; 137 | 138 | } 139 | 140 | //对各个列表进行初始化,即将其存储在全局变量之中 141 | 142 | //初始化顾客列表 143 | bool myDatabase::InitialCustomer() 144 | { 145 | QSqlQuery query(db); 146 | query.exec("select * from Customer"); 147 | 148 | //依次取出数据,初始化全局变量 149 | while(query.next()) 150 | { 151 | QString Account = query.value(0).toString(); 152 | QString Password = query.value(1).toString(); 153 | QString Phone = query.value(2).toString(); 154 | int TotalNum = query.value(3).toInt(); 155 | 156 | Customer c(Account, Password, Phone, TotalNum); 157 | g_Customerlist.append(c); 158 | } 159 | return true; 160 | } 161 | 162 | //初始化房间列表 163 | bool myDatabase::InitialRoom() 164 | { 165 | QSqlQuery query(db); 166 | query.exec("select * from Room"); 167 | 168 | while(query.next()) 169 | { 170 | QString newHotelName = query.value(0).toString(); 171 | bool newApproved = query.value(1).toBool(); 172 | int newPrice = query.value(2).toInt(); 173 | int newNumber = query.value(3).toInt(); 174 | int newType = query.value(4).toInt(); 175 | float newDiscount = query.value(5).toFloat(); 176 | QString newImages = query.value(6).toString(); 177 | QString newDiscription = query.value(7).toString(); 178 | int newStar = query.value(8).toInt(); 179 | 180 | //依次取出信息放在RawRoomlist中,作为初始的房间大名单 181 | Room newRoom(newHotelName, newApproved, newPrice, newNumber, 182 | newType, newDiscount, newImages, newDiscription, 183 | newStar); 184 | RawRoomlist.append(newRoom); 185 | 186 | } 187 | return true; 188 | } 189 | 190 | //初始化酒店管理员列表 191 | bool myDatabase::InitialHotelmanager() 192 | { 193 | QSqlQuery query(db); 194 | query.exec("select * from Hotelmanager"); 195 | 196 | while(query.next()) 197 | { 198 | QString Account = query.value(0).toString(); 199 | QString Password = query.value(1).toString(); 200 | QString Phone = query.value(2).toString(); 201 | QString Lisence = query.value(3).toString(); 202 | QString Hotelname = query.value(4).toString(); 203 | 204 | HotelManager h(Account, Password, Phone, Lisence, Hotelname); 205 | 206 | 207 | g_HotelManagerlist.append(h); 208 | } 209 | return true; 210 | } 211 | 212 | //在初始化Hotel类的同时,其实同时将Room的信息写入。 213 | bool myDatabase::InitialHotelAndRoom() 214 | { 215 | QSqlQuery query(db); 216 | query.exec("select * from Hotel"); 217 | 218 | while(query.next()) 219 | { 220 | QString Hotelname = query.value(0).toString(); 221 | QString Address = query.value(1).toString(); 222 | QString District = query.value(2).toString(); 223 | QString Consolephone = query.value(3).toString(); 224 | bool Approved = query.value(4).toBool(); 225 | 226 | 227 | 228 | 229 | Hotel h(Hotelname, Address, District, 230 | Consolephone, Approved); 231 | 232 | QVectortempRoomlist; 233 | 234 | //根据房间信息,将酒店房间的列表中的酒店放入酒店的私有成员中 235 | for(int i=0;iGetDiscription(); 302 | 303 | } 304 | return true; 305 | } 306 | 307 | //初始化平台管理员的全局变量 308 | bool myDatabase::InitialPlatformAdmin() 309 | { 310 | QSqlQuery query(db); 311 | query.exec("select * from PlatformAdmin"); 312 | 313 | while(query.next()) 314 | { 315 | QString Account = query.value(0).toString(); 316 | QString Password = query.value(1).toString(); 317 | QString Phone = query.value(2).toString(); 318 | 319 | 320 | //添加到全局变量中 321 | PlatformAdmin c(Account, Password, Phone); 322 | g_PlatformAdminlist.append(c); 323 | } 324 | return true; 325 | } 326 | 327 | //将全局变量中的信息存回数据库中 328 | bool myDatabase::Memory() 329 | { 330 | QSqlQuery query(db); 331 | 332 | //更新顾客列表 333 | query.exec("DELETE from Customer"); 334 | 335 | query.prepare("insert into Customer VALUES(?,?,?,?)"); 336 | 337 | for(int i=0;iGetAccount()); 444 | query.bindValue(5,g_Orderlist[i].GetpRoom()->GetRoomId()); 445 | 446 | bool success=query.exec(); 447 | if(!success) 448 | { 449 | QMessageBox msg; 450 | msg.setText(QStringLiteral("更新订单列表失败!")); 451 | msg.setWindowTitle(QStringLiteral("Error!")); 452 | msg.exec(); 453 | } 454 | } 455 | 456 | //更新平台管理员列表 457 | query.exec("DELETE from PlatformAdmin"); 458 | 459 | query.prepare("insert into PlatformAdmin VALUES(?,?,?)"); 460 | 461 | for(int i=0;i 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include"room.h" 25 | 26 | /************************************************************************** 27 | 类名:mydatabase 28 | 功能:实现与数据库的连接,将数据库中的数据传入内存中 29 | 30 | 接口说明:与数据库的链接以及以全局变量形式与主要程序连接 31 | 开发者:程晔安 32 | 日期:8.2 33 | 更改记录: 34 | **************************************************************************/ 35 | class myDatabase:public QObject 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | //默认构造函数,其中搭建与数据库的链接以及初始化列表 41 | myDatabase(); 42 | ~myDatabase(); 43 | QSqlDatabase db; 44 | 45 | //建立酒店房间大名单,用于初始化酒店列表 46 | //QVectorRawRoomlist; 47 | 48 | 49 | //进行相关初始化,将数据放在全局变量里面 50 | bool InitialCustomer(); 51 | bool InitialHotelmanager(); 52 | bool InitialHotelAndRoom(); 53 | bool InitialRoom(); 54 | bool InitialOrder(); 55 | bool InitialPlatformAdmin(); 56 | 57 | private: 58 | //建立链接 59 | bool CreateConnection(); 60 | //初始化数据库中的列表 61 | bool CreatTables(); 62 | 63 | //将数据重新从内存存入数据库 64 | public slots: 65 | bool Memory(); 66 | 67 | }; 68 | 69 | #endif // MYDATABASE_H 70 | 71 | 72 | 73 | 74 | //没解决的问题:怎么新加入房间 75 | -------------------------------------------------------------------------------- /newroom.cpp: -------------------------------------------------------------------------------- 1 | 2 | /******************************************************************** 3 | 文件名:newroom.cpp 4 | 功能模块和目的:创建界面以输入新房间信息 5 | 开发者:程晔安 6 | 日期:8.2 7 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 8 | 更改记录: 9 | **********************************************************************/ 10 | 11 | #include "newroom.h" 12 | #include "ui_newroom.h" 13 | 14 | #include "enums.h" 15 | #include "room.h" 16 | #include "hotel.h" 17 | 18 | using namespace std; 19 | 20 | extern QVectorg_Hotellist; 21 | extern QVectorRawRoomlist; 22 | 23 | //创建界面新建酒店房间 24 | NewRoom::NewRoom(whotel*newparent, Hotel*newHotel) : 25 | parent(newparent),pHotel(newHotel), 26 | ui(new Ui::NewRoom) 27 | { 28 | ui->setupUi(this); 29 | 30 | pRoom = new Room(pHotel->GetHotelName(), 500, 3, -1); 31 | //装饰 32 | this->setFixedSize(this->width(),this->height()); 33 | this->setWindowTitle("Create A New Room"); 34 | 35 | //slots 36 | 37 | connect(ui->btnCancel, SIGNAL(clicked(bool)), this, SLOT(Cancel())); 38 | connect(ui->btnEnter, SIGNAL(clicked(bool)), this, SLOT(Save())); 39 | connect(ui->btnOpen,SIGNAL(clicked(bool)), this, SLOT(OpenImag())); 40 | connect(ui->btnSaveImage, SIGNAL(clicked(bool)), this, SLOT(SaveImag())); 41 | 42 | } 43 | 44 | NewRoom::~NewRoom() 45 | { 46 | delete ui; 47 | } 48 | 49 | //取消返回 50 | void NewRoom::Cancel() 51 | { 52 | 53 | this->close(); 54 | parent->show(); 55 | } 56 | 57 | //打开酒店房间需要张贴的图片 58 | void NewRoom::OpenImag() 59 | { 60 | //获取文件exe路径 61 | runPath = QCoreApplication::applicationDirPath(); 62 | //新文件姓名 63 | hglpName = "photo"; 64 | //文件存储路径 65 | hglpPath = QString("%1/%2").arg(runPath).arg(hglpName); 66 | 67 | QString filename=QFileDialog::getOpenFileName(this,tr("选择图像"),"", 68 | tr("Images (*.png *.bmp *.jpg)")); 69 | //是否打开成功 70 | if(filename.isEmpty()) 71 | return; 72 | else 73 | { 74 | QImage img; 75 | if(!(img.load(filename))) //加载图像 76 | { 77 | QMessageBox::information(this, tr("打开图像失败"),tr("打开图像失败!")); 78 | return; 79 | } 80 | ui->lableImage->setPixmap(QPixmap::fromImage(img.scaled(ui->lableImage->size()))); 81 | } 82 | 83 | 84 | } 85 | 86 | //保存图片 87 | void NewRoom::SaveImag() 88 | { 89 | QScreen *screen = QGuiApplication::primaryScreen(); 90 | QString Name = ui->lineName->text(); 91 | screen->grabWindow(ui->lableImage->winId()).save(QString("%1/%2.jpg").arg(hglpPath).arg(Name)); 92 | 93 | pRoom->SetImages(QString("./photo/%1.jpg").arg(Name)); 94 | QMessageBox::information(this, "SAVED", "图片已保存在.exe文件路径的Photo文件夹中。", QMessageBox::Ok); 95 | 96 | } 97 | 98 | //保存所有信息 99 | void NewRoom::Save() 100 | { 101 | //检查输入 102 | bool flag0 = CheckEntering(); 103 | if(flag0 == false) 104 | return ; 105 | 106 | //房间数量 107 | int newNumber = ui->lineNum->text().toInt(); 108 | pRoom->SetNumber(newNumber); 109 | //酒店房间优惠,可以缺省 110 | if(!ui->lineDiscount->text().isEmpty()) 111 | { 112 | float newDiscount = ui->lineDiscount->text().toFloat(); 113 | pRoom->SetDiscount(newDiscount); 114 | } 115 | //酒店房间介绍,可以缺省 116 | if(!ui->lineDiscription->text().isEmpty()) 117 | { 118 | QString newDicription = ui->lineDiscription->text(); 119 | pRoom->SetDiscription(newDicription); 120 | } 121 | //价格 122 | int newprice = ui->linePrice->text().toInt(); 123 | pRoom->SetPrice(newprice); 124 | 125 | int newType = ui->comboBox->currentIndex(); 126 | pRoom->SetType(newType); 127 | //判断是否已经有相应类型的房间,如果有,不能重复创建,而应该在修改界面改变 128 | //相应房间数量 129 | 130 | bool flag = true; 131 | QVectortempRoomlist = pHotel->Roomlist; 132 | for(int i=0;iRoomlist.append(aRoom); 143 | QMessageBox::information(this, "SUCCESS", "成功添加!等待管理员审核", 144 | QMessageBox::Ok); 145 | 146 | //自动将审核过程调为“未审” 147 | pRoom->SetApproved(false); 148 | 149 | 150 | this->close(); 151 | parent->show(); 152 | } 153 | else 154 | { 155 | QMessageBox::information(this, "FAILED", "添加失败,已经有相应类型房间", 156 | QMessageBox::Ok); 157 | } 158 | 159 | 160 | } 161 | 162 | bool NewRoom::CheckEntering() 163 | { 164 | //价格、类型、数量必填 165 | if(ui->lineNum->text().isEmpty()|| 166 | ui->linePrice->text().isEmpty()|| 167 | ui->comboBox->currentText().isEmpty()) 168 | { 169 | QMessageBox::information(this, "ERROR", "信息不全", 170 | QMessageBox::Ok); 171 | return false; 172 | } 173 | return true; 174 | } 175 | -------------------------------------------------------------------------------- /newroom.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | 文件名:newroom.h 3 | 功能模块和目的:新建房间 4 | 开发者:程晔安 5 | 日期:7.29 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录: 8 | **************************************************************************/ 9 | #ifndef NEWROOM_H 10 | #define NEWROOM_H 11 | 12 | #include 13 | 14 | #include "QVector" 15 | #include "room.h" 16 | #include "hotel.h" 17 | #include "whotel.h" 18 | #include "room.h" 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | /************************************************************************** 28 | 类名:NewRoom 29 | 功能:新建房间 30 | 接口说明:有指向酒店界面的指针 31 | 开发者:程晔安 32 | 日期:7.29 33 | 更改记录: 34 | **************************************************************************/ 35 | 36 | namespace Ui { 37 | class NewRoom; 38 | } 39 | 40 | class whotel; 41 | 42 | class NewRoom : public QWidget 43 | { 44 | Q_OBJECT 45 | 46 | public: 47 | explicit NewRoom(whotel*parent, Hotel*pHotel); 48 | ~NewRoom(); 49 | bool CheckEntering(); 50 | private: 51 | Ui::NewRoom *ui; 52 | 53 | //指向酒店界面的指针 54 | whotel*parent; 55 | 56 | //记录相关信息 57 | Hotel*pHotel; 58 | Room*pRoom; 59 | 60 | //记录图片存储的方法 61 | QString runPath; 62 | QString hglpName; 63 | QString hglpPath; 64 | 65 | 66 | public slots: 67 | 68 | //保存相关信息 69 | void Save(); 70 | //打开图片 71 | void OpenImag(); 72 | //保存图片到相关路径下 73 | void SaveImag(); 74 | //取消,返回酒店界面 75 | void Cancel(); 76 | 77 | 78 | 79 | }; 80 | 81 | #endif // NEWROOM_H 82 | -------------------------------------------------------------------------------- /newroom.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | NewRoom 4 | 5 | 6 | 7 | 0 8 | 0 9 | 555 10 | 591 11 | 12 | 13 | 14 | 15 | 微软雅黑 16 | 75 17 | true 18 | 19 | 20 | 21 | Form 22 | 23 | 24 | 25 | 26 | 220 27 | 350 28 | 131 29 | 61 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 140 40 | 10 41 | 291 42 | 71 43 | 44 | 45 | 46 | 47 | 微软雅黑 48 | 28 49 | 50 50 | false 51 | 52 | 53 | 54 | 创建房间信息 55 | 56 | 57 | 58 | 59 | 60 | 90 61 | 100 62 | 111 63 | 31 64 | 65 | 66 | 67 | 68 | 12 69 | 75 70 | true 71 | 72 | 73 | 74 | 房间类型 75 | 76 | 77 | 78 | 79 | 80 | 90 81 | 150 82 | 141 83 | 31 84 | 85 | 86 | 87 | 88 | 12 89 | 75 90 | true 91 | 92 | 93 | 94 | 房间价格(/晚) 95 | 96 | 97 | 98 | 99 | 100 | 90 101 | 190 102 | 131 103 | 41 104 | 105 | 106 | 107 | 108 | 12 109 | 75 110 | true 111 | 112 | 113 | 114 | 房间数量 115 | 116 | 117 | 118 | 119 | 120 | 90 121 | 250 122 | 101 123 | 31 124 | 125 | 126 | 127 | 128 | 12 129 | 75 130 | true 131 | 132 | 133 | 134 | 房间折扣 135 | 136 | 137 | 138 | 139 | 140 | 90 141 | 390 142 | 91 143 | 31 144 | 145 | 146 | 147 | 148 | 12 149 | 150 | 151 | 152 | 房间图片 153 | 154 | 155 | 156 | 157 | 158 | 270 159 | 150 160 | 151 161 | 31 162 | 163 | 164 | 165 | 166 | 167 | 168 | 270 169 | 200 170 | 151 171 | 31 172 | 173 | 174 | 175 | 176 | 177 | 178 | 270 179 | 250 180 | 151 181 | 31 182 | 183 | 184 | 185 | 选填 186 | 187 | 188 | 189 | 190 | 191 | 270 192 | 300 193 | 151 194 | 31 195 | 196 | 197 | 198 | 选填 199 | 200 | 201 | 202 | 203 | 204 | 90 205 | 300 206 | 91 207 | 31 208 | 209 | 210 | 211 | 212 | 12 213 | 75 214 | true 215 | 216 | 217 | 218 | 房间描述 219 | 220 | 221 | 222 | 223 | 224 | 420 225 | 360 226 | 101 227 | 41 228 | 229 | 230 | 231 | 打开图片 232 | 233 | 234 | 235 | 236 | 237 | 420 238 | 420 239 | 101 240 | 41 241 | 242 | 243 | 244 | 保存图片 245 | 246 | 247 | 248 | 249 | 250 | 120 251 | 480 252 | 141 253 | 91 254 | 255 | 256 | 257 | 258 | 22 259 | 75 260 | true 261 | 262 | 263 | 264 | 返回 265 | 266 | 267 | 268 | 269 | 270 | 330 271 | 480 272 | 141 273 | 91 274 | 275 | 276 | 277 | 278 | 22 279 | 280 | 281 | 282 | 确定 283 | 284 | 285 | 286 | 287 | 288 | 270 289 | 100 290 | 151 291 | 31 292 | 293 | 294 | 295 | 296 | 钟点房 297 | 298 | 299 | 300 | 301 | 大床房 302 | 303 | 304 | 305 | 306 | 双人房 307 | 308 | 309 | 310 | 311 | 奢华房 312 | 313 | 314 | 315 | 316 | 总统套房 317 | 318 | 319 | 320 | 321 | 322 | 323 | 240 324 | 430 325 | 121 326 | 31 327 | 328 | 329 | 330 | 图片名称: 331 | 332 | 333 | 334 | 335 | 336 | 337 | -------------------------------------------------------------------------------- /order.cpp: -------------------------------------------------------------------------------- 1 | 2 | /******************************************************************** 3 | 文件名:order.cpp 4 | 功能模块和目的:实现Order类的构造函数 5 | 开发者:程晔安 6 | 日期:8.1 7 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 8 | 更改记录: 9 | **********************************************************************/ 10 | 11 | #include "order.h" 12 | 13 | //用于程序中创建时 14 | Order::Order(QDate newDate, int newDays, 15 | Room* new_pRoom, Customer* new_pCustomer): 16 | Date(newDate),Days(newDays), 17 | pRoom(new_pRoom),pCustomer(new_pCustomer) 18 | { 19 | RefundApproved = false; 20 | Type = 0; 21 | } 22 | 23 | //用于将数据库的信息放入内存中时 24 | Order::Order(QDate newDate, int newDays, int newType, 25 | bool newRefundApproved, 26 | Room* new_pRoom, Customer* new_pCustomer): 27 | Date(newDate),Days(newDays),Type(newType), 28 | RefundApproved(newRefundApproved), 29 | pRoom(new_pRoom),pCustomer(new_pCustomer) 30 | { 31 | 32 | } 33 | -------------------------------------------------------------------------------- /order.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | 文件名:order.h 3 | 功能模块和目的:创建基础的订单类 4 | 开发者:程晔安 5 | 日期:8.2 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录: 8 | **************************************************************************/ 9 | #ifndef ORDER_H 10 | #define ORDER_H 11 | 12 | #include "QDate" 13 | #include "customer.h" 14 | #include "room.h" 15 | 16 | /************************************************************************** 17 | 类名:Order.h 18 | 功能:记录订单信息 19 | 接口说明:有指向房间和用户的指针 20 | 开发者:程晔安 21 | 日期:8.2 22 | 更改记录: 23 | **************************************************************************/ 24 | 25 | class Customer; 26 | class Room; 27 | 28 | class Order 29 | { 30 | public: 31 | //两种构造函数,分别应用于实际创建对象和从数据库读取对象两种情况 32 | Order(QDate newDate, int newDays, 33 | Room* new_pRoom, Customer* new_pCustomer); 34 | Order(QDate newDate, int newDays, int newType, 35 | bool RefundApproved, 36 | Room* new_pRoom, Customer* new_pCustomer); 37 | 38 | 39 | Order(){} 40 | 41 | //获取房间指针 42 | Room* GetpRoom() 43 | { 44 | return pRoom; 45 | } 46 | //获取用户指针 47 | Customer* GetpCustomer() 48 | { 49 | return pCustomer; 50 | } 51 | 52 | //设置订单种类 53 | bool SetType(int newType) 54 | { 55 | if(newType >=0&&newType<6) 56 | Type = newType; 57 | else 58 | return false; 59 | return true; 60 | 61 | } 62 | 63 | //返回订单开始日期 64 | QDate GetDate() 65 | { 66 | return Date; 67 | } 68 | //返回订单订房时间 69 | int GetDays() 70 | { 71 | return Days; 72 | } 73 | //返回订单种类 74 | int GetType() 75 | { 76 | return Type; 77 | } 78 | //返回订单退款审核是否通过 79 | bool GetRefundApproved() 80 | { 81 | return RefundApproved; 82 | } 83 | //设置订单退款审核是否通过 84 | void SetRefundApproved(bool newApproved) 85 | { 86 | RefundApproved = newApproved; 87 | } 88 | 89 | 90 | private: 91 | QDate Date; 92 | //订购天数 93 | int Days; 94 | //订单的状态:已预定、已交款、退款、入住、退房、已评论 95 | int Type; 96 | 97 | bool RefundApproved; 98 | 99 | Room* pRoom ; 100 | Customer* pCustomer ; 101 | 102 | 103 | 104 | }; 105 | 106 | #endif // ORDER_H 107 | -------------------------------------------------------------------------------- /platform.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 文件名:platform.cpp 3 | 功能模块和目的:实现平台管理员类的函数 4 | 开发者:程晔安 5 | 日期:8.1 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录: 8 | **********************************************************************/ 9 | 10 | #include "platform.h" 11 | #include "ui_platform.h" 12 | 13 | #include "QMessageBox" 14 | #include "qtablewidget.h" 15 | #include "QDate" 16 | #include "mydatabase.h" 17 | #include "QVector" 18 | 19 | #include "order.h" 20 | #include "hotel.h" 21 | #include "room.h" 22 | 23 | #include "enums.h" 24 | 25 | using namespace std; 26 | 27 | extern QVectorg_Hotellist; 28 | extern QVectorg_Orderlist; 29 | extern QVectorRawRoomlist; 30 | 31 | extern QVectorg_Customerlist; 32 | 33 | Platform::Platform(loginwindow1 *newparent) : 34 | parent(newparent), 35 | ui(new Ui::Platform) 36 | { 37 | //将三种列表先显示出来 38 | ui->setupUi(this); 39 | ShowHotel(); 40 | ShowRoom(); 41 | ShowOrder(); 42 | 43 | ShowCustomer(); 44 | 45 | //装饰 46 | 47 | this->setFixedSize(this->width(),this->height()); 48 | this->setWindowTitle("A Place To Stay ::Platform"); 49 | //接口 50 | //刷新按钮 51 | connect(ui->btnRefreshtable1, SIGNAL(clicked(bool)), this, SLOT(Refresh1())); 52 | connect(ui->btnRefreshtable2, SIGNAL(clicked(bool)), this, SLOT(Refresh2())); 53 | connect(ui->btnRefreshtable3, SIGNAL(clicked(bool)), this, SLOT(Refresh3())); 54 | 55 | connect(ui->btnRefreshTable4, SIGNAL(clicked(bool)), this, SLOT(Refresh4())); 56 | 57 | //分别通过对酒店、房间、退款行为的显示。 58 | connect(ui->btnApproveHotel, SIGNAL(clicked(bool)), this, SLOT(ApproveHotel())); 59 | connect(ui->btnApproveRoom, SIGNAL(clicked(bool)), this, SLOT(ApproveRoom())); 60 | connect(ui->btnApproveOrder, SIGNAL(clicked(bool)), this, SLOT(ApproveOrder())); 61 | connect(ui->btnSTOP, SIGNAL(clicked(bool)), this, SLOT(STop())); 62 | 63 | connect(ui->btnDisable, SIGNAL(clicked(bool)), this, SLOT(DisAble())); 64 | 65 | //保存并退出 66 | connect(ui->btnSaveAndExit, SIGNAL(clicked(bool)), this, SLOT(SaveAndLogout())); 67 | 68 | } 69 | 70 | Platform::~Platform() 71 | { 72 | delete ui; 73 | } 74 | 75 | //显示酒店列表 76 | void Platform::ShowHotel() 77 | { 78 | //显示酒店列表表头 79 | ui->table1->clear(); 80 | ui->table1->setColumnCount(5); 81 | ui->table1->setHorizontalHeaderItem(0, new QTableWidgetItem 82 | (QStringLiteral("酒店名称"))); 83 | ui->table1->setHorizontalHeaderItem(1, new QTableWidgetItem 84 | (QStringLiteral("酒店城市"))); 85 | ui->table1->setHorizontalHeaderItem(2, new QTableWidgetItem 86 | (QStringLiteral("酒店地址"))); 87 | ui->table1->setHorizontalHeaderItem(3, new QTableWidgetItem 88 | (QStringLiteral("酒店联系电话"))); 89 | ui->table1->setHorizontalHeaderItem(4, new QTableWidgetItem 90 | (QStringLiteral("是否通过审查"))); 91 | 92 | ui->table1->setSelectionBehavior(QAbstractItemView::SelectRows); 93 | ui->table1->setSelectionMode(QAbstractItemView::SingleSelection); 94 | 95 | //显示未审核信息个数 96 | int num = 0; 97 | //显示酒店列表内容 98 | for(int i=0;itable1->setRowCount(i+1); 101 | ui->table1->setItem(i, 0, 102 | new QTableWidgetItem(g_Hotellist[i].GetHotelName())); 103 | ui->table1->setItem(i, 1, 104 | new QTableWidgetItem(g_Hotellist[i].GetAddress())); 105 | ui->table1->setItem(i, 2, 106 | new QTableWidgetItem(g_Hotellist[i].GetDistrict())); 107 | ui->table1->setItem(i, 3, 108 | new QTableWidgetItem(g_Hotellist[i].GetConsolePhone())); 109 | QString temp; 110 | if(g_Hotellist[i].IsApproved()) 111 | temp = "是"; 112 | else 113 | { 114 | temp = "否"; 115 | num++; 116 | } 117 | ui->table1->setItem(i, 4, 118 | new QTableWidgetItem(temp)); 119 | } 120 | 121 | ui->labelHotelNum->setText(QString::number(num) + "待审核"); 122 | 123 | } 124 | 125 | 126 | //显示酒店的房间列表 127 | void Platform::ShowRoom() 128 | { 129 | //显示表头 130 | ui->table2->clear(); 131 | ui->table2->setColumnCount(7); 132 | ui->table2->setHorizontalHeaderItem(0, new QTableWidgetItem 133 | (QStringLiteral("酒店名称"))); 134 | ui->table2->setHorizontalHeaderItem(1, new QTableWidgetItem 135 | (QStringLiteral("房间种类"))); 136 | 137 | ui->table2->setHorizontalHeaderItem(2, new QTableWidgetItem 138 | (QStringLiteral("房间照片"))); 139 | ui->table2->setHorizontalHeaderItem(3, new QTableWidgetItem 140 | (QStringLiteral("房间个数"))); 141 | ui->table2->setHorizontalHeaderItem(4, new QTableWidgetItem 142 | (QStringLiteral("房间价格"))); 143 | ui->table2->setHorizontalHeaderItem(5, new QTableWidgetItem 144 | (QStringLiteral("房间描述"))); 145 | ui->table2->setHorizontalHeaderItem(6, new QTableWidgetItem 146 | (QStringLiteral("是否通过审查"))); 147 | 148 | //行选中 149 | ui->table2->setSelectionBehavior(QAbstractItemView::SelectRows); 150 | ui->table2->setSelectionMode(QAbstractItemView::SingleSelection); 151 | 152 | //依次显示表的内容 153 | 154 | //显示未审核信息个数 155 | int num = 0; 156 | //显示信息的总行数 157 | int count = 1; 158 | 159 | for(int i=0;itempRoomlist = g_Hotellist[i].Roomlist; 165 | ui->table2->setRowCount(count); 166 | 167 | ui->table2->setItem(count-1, 0, 168 | new QTableWidgetItem(tempRoomlist[j].GetHotelName())); 169 | QString str_type[5] = {"钟点房", "大床房", "双人房", "奢华房", "总统套房"}; 170 | ui->table2->setItem(count-1, 1, 171 | new QTableWidgetItem(str_type[tempRoomlist[j].GetType()])); 172 | 173 | QLabel *label = new QLabel(""); 174 | 175 | label->setPixmap(QPixmap(tempRoomlist[j].GetImages()).scaled(125,150)); 176 | 177 | ui->table2->setCellWidget(count-1, 2, label); 178 | 179 | ui->table2->setItem(count-1, 3, 180 | new QTableWidgetItem(QString::number(tempRoomlist[j].GetNumber()))); 181 | ui->table2->setItem(count-1, 4, 182 | new QTableWidgetItem(QString::number(tempRoomlist[j].GetPrice()))); 183 | ui->table2->setItem(count-1, 5, 184 | new QTableWidgetItem(tempRoomlist[j].GetDiscription())); 185 | 186 | QString temp; 187 | if(tempRoomlist[j].IsApproved()) 188 | temp = "是"; 189 | else 190 | { 191 | temp = "否"; 192 | num++; 193 | } 194 | 195 | ui->table2->setItem(count-1, 6, 196 | new QTableWidgetItem(temp)); 197 | count++; 198 | } 199 | } 200 | 201 | ui->labelNum2->setText(QString::number(num) + "待审核"); 202 | 203 | } 204 | 205 | //显示订单列表 206 | void Platform::ShowOrder() 207 | { 208 | //显示表头 209 | ui->table3->clear(); 210 | ui->table3->setColumnCount(7); 211 | ui->table3->setHorizontalHeaderItem(0, new QTableWidgetItem 212 | (QStringLiteral("顾客账号"))); 213 | ui->table3->setHorizontalHeaderItem(1, new QTableWidgetItem 214 | (QStringLiteral("酒店姓名"))); 215 | ui->table3->setHorizontalHeaderItem(2, new QTableWidgetItem 216 | (QStringLiteral("房间类型"))); 217 | ui->table3->setHorizontalHeaderItem(3, new QTableWidgetItem 218 | (QStringLiteral("住房日期"))); 219 | ui->table3->setHorizontalHeaderItem(4, new QTableWidgetItem 220 | (QStringLiteral("住房天数"))); 221 | ui->table3->setHorizontalHeaderItem(5, new QTableWidgetItem 222 | (QStringLiteral("订单状态"))); 223 | ui->table3->setHorizontalHeaderItem(6, new QTableWidgetItem 224 | (QStringLiteral("是否允许退款"))); 225 | 226 | 227 | //单行选中 228 | ui->table3->setSelectionBehavior(QAbstractItemView::SelectRows); 229 | ui->table3->setSelectionMode(QAbstractItemView::SingleSelection); 230 | 231 | //显示内容 232 | 233 | //显示未审核信息个数 234 | int num = 0; 235 | for(int i=0;itable3->setRowCount(i+1); 238 | 239 | ui->table3->setItem(i, 0, 240 | new QTableWidgetItem(g_Orderlist[i].GetpCustomer()->GetAccount())); 241 | ui->table3->setItem(i, 1, 242 | new QTableWidgetItem(g_Orderlist[i].GetpRoom()->GetHotelName())); 243 | QString str_type[5] = {"钟点房", "大床房", "双人房", "奢华房", "总统套房"}; 244 | ui->table3->setItem(i, 2, 245 | new QTableWidgetItem(str_type[g_Orderlist[i].GetpRoom()->GetType()])); 246 | ui->table3->setItem(i, 3, 247 | new QTableWidgetItem(g_Orderlist[i].GetDate().toString("dd.MM.yyyy"))); 248 | ui->table3->setItem(i, 4, 249 | new QTableWidgetItem(QString::number(g_Orderlist[i].GetDays()))); 250 | QString str_OrderType[6] = {"已预订", "已交款", "退款", "已入住", "已退房", "已评论"}; 251 | ui->table3->setItem(i, 5, 252 | new QTableWidgetItem(str_OrderType[g_Orderlist[i].GetType()])); 253 | QString temp; 254 | if(g_Orderlist[i].GetRefundApproved()) 255 | temp = "是"; 256 | else 257 | { 258 | temp = "否"; 259 | 260 | } 261 | ui->table3->setItem(i, 6, 262 | new QTableWidgetItem(temp)); 263 | if((!g_Orderlist[i].GetRefundApproved())&&(g_Orderlist[i].GetType() == 2)) 264 | { 265 | num++; 266 | } 267 | 268 | } 269 | 270 | ui->labelRefundNum->setText(QString::number(num) + "待审核"); 271 | 272 | } 273 | 274 | //刷新界面即为重新显示三种表 275 | void Platform::Refresh1() 276 | { 277 | ShowHotel(); 278 | } 279 | 280 | void Platform::Refresh2() 281 | { 282 | ShowRoom(); 283 | } 284 | 285 | void Platform::Refresh3() 286 | { 287 | ShowOrder(); 288 | } 289 | 290 | //审核通过酒店列表 291 | void Platform::ApproveHotel() 292 | { 293 | int row; 294 | row = ui->table1->currentRow(); 295 | //是否选中的判断 296 | if(row == -1) 297 | { 298 | QMessageBox::information(this, "ERROR", "未选中酒店!", QMessageBox::Ok); 299 | return; 300 | } 301 | if(g_Hotellist[row].IsApproved() == false) 302 | { 303 | g_Hotellist[row].SetApproved(true); 304 | QMessageBox::information(this, "SUCCESS", "审核成功!", QMessageBox::Ok); 305 | } 306 | else 307 | { 308 | QMessageBox::information(this, "ERROR", "该酒店已经通过审核!", 309 | QMessageBox::Ok); 310 | } 311 | 312 | 313 | } 314 | 315 | //审核通过酒店的房间 316 | void Platform::ApproveRoom() 317 | { 318 | int row; 319 | row = ui->table2->currentRow(); 320 | //是否选中判断 321 | if(row == -1) 322 | { 323 | QMessageBox::information(this, "ERROR", "未选中房间!", QMessageBox::Ok); 324 | return ; 325 | } 326 | QString tempHotelName; 327 | int tempRoomType; 328 | QString tt = ui->table2->item(row, 1)->text(); 329 | 330 | //类型转换 331 | tempHotelName = ui->table2->item(row, 0)->text(); 332 | QString str_type[5] = {"钟点房", "大床房", "双人房", "奢华房", "总统套房"}; 333 | 334 | for(int i=0;i<5;i++) 335 | { 336 | if(str_type[i] == tt) 337 | { 338 | tempRoomType = i; 339 | } 340 | } 341 | 342 | 343 | //找到相应的酒店进行修改 344 | int inow, jnow; 345 | for(int i=0;itable3->currentRow(); 380 | //选中判断 381 | if(g_Orderlist[row].GetType() == 2) 382 | { 383 | if(g_Orderlist[row].GetRefundApproved() == false) 384 | { 385 | g_Orderlist[row].SetRefundApproved(true); 386 | 387 | QMessageBox::information(this, "SUCCESS", "允许退款成功!", 388 | QMessageBox::Ok); 389 | } 390 | else 391 | { 392 | QMessageBox::information(this, "ERROR", "订单已经退款,不必重复操作!", 393 | QMessageBox::Ok); 394 | } 395 | } 396 | //订单的状态判断 397 | else 398 | { 399 | QMessageBox::information(this, "ERROR", "订单不在退款阶段!", 400 | QMessageBox::Ok); 401 | } 402 | } 403 | 404 | //保存退出 405 | void Platform::SaveAndLogout() 406 | { 407 | //存入数据库 408 | myDatabase Database; 409 | Database.Memory(); 410 | 411 | //显示登陆页面 412 | this->close(); 413 | parent->show(); 414 | } 415 | 416 | void Platform::STop() 417 | { 418 | int row; 419 | row = ui->table1->currentRow(); 420 | //是否选中的判断 421 | if(row == -1) 422 | { 423 | QMessageBox::information(this, "ERROR", "未选中酒店!", QMessageBox::Ok); 424 | return; 425 | } 426 | if(g_Hotellist[row].IsApproved() == false) 427 | { 428 | 429 | QMessageBox::information(this, "ERROR", "酒店本来就未通过审核!", QMessageBox::Ok); 430 | } 431 | else 432 | { 433 | g_Hotellist[row].SetApproved(false); 434 | QMessageBox::information(this, "SUCCESS", "酒店信息下架成功!", 435 | QMessageBox::Ok); 436 | } 437 | 438 | 439 | } 440 | 441 | void Platform::ShowCustomer() 442 | { 443 | ui->table4->clear(); 444 | ui->table4->setColumnCount(3); 445 | 446 | ui->table4->setHorizontalHeaderItem(0, new QTableWidgetItem 447 | (QStringLiteral("账号名称"))); 448 | ui->table4->setHorizontalHeaderItem(1, new QTableWidgetItem 449 | (QStringLiteral("账号手机"))); 450 | ui->table4->setHorizontalHeaderItem(2, new QTableWidgetItem 451 | (QStringLiteral("账号密码"))); 452 | 453 | //行选中 454 | ui->table4->setSelectionBehavior(QAbstractItemView::SelectRows); 455 | ui->table4->setSelectionMode(QAbstractItemView::SingleSelection); 456 | 457 | for(int i=0;itable4->setRowCount(i+1); 460 | 461 | ui->table4->setItem(i, 0, 462 | new QTableWidgetItem(g_Customerlist[i].GetAccount())); 463 | ui->table4->setItem(i, 1, 464 | new QTableWidgetItem(g_Customerlist[i].GetPhone())); 465 | ui->table4->setItem(i, 2, 466 | new QTableWidgetItem(g_Customerlist[i].GetPassword())); 467 | } 468 | 469 | 470 | 471 | } 472 | 473 | void Platform::Refresh4() 474 | { 475 | ShowCustomer(); 476 | } 477 | 478 | void Platform::DisAble() 479 | { 480 | int row; 481 | row = ui->table4->currentRow(); 482 | //是否选中的判断 483 | if(row == -1) 484 | { 485 | QMessageBox::information(this, "ERROR", "未选中酒店!", QMessageBox::Ok); 486 | return; 487 | } 488 | g_Customerlist.erase(&g_Customerlist[row]); 489 | QMessageBox::information(this, "SUCCESS", "删除成功", QMessageBox::Ok); 490 | } 491 | 492 | -------------------------------------------------------------------------------- /platform.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | 文件名:platform.h 3 | 功能模块和目的:创建平台管理人员界面 4 | 开发者:程晔安 5 | 日期:8.1 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录: 8 | **************************************************************************/ 9 | #ifndef PLATFORM_H 10 | #define PLATFORM_H 11 | 12 | #include 13 | #include "QVector" 14 | #include "QtWidgets" 15 | #include "loginwindow1.h" 16 | 17 | #include "hotel.h" 18 | #include "room.h" 19 | #include "order.h" 20 | 21 | /************************************************************************** 22 | 类名:platform 23 | 功能:创建平台管理人员界面 24 | 接口说明:有指向newroom的指针 25 | 开发者:程晔安 26 | 日期:8.1 27 | 更改记录: 28 | **************************************************************************/ 29 | 30 | namespace Ui { 31 | class Platform; 32 | } 33 | 34 | class loginwindow1; 35 | 36 | class Platform : public QWidget 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | explicit Platform(loginwindow1*parent); 42 | ~Platform(); 43 | 44 | private: 45 | //传回登陆界面的指针 46 | Ui::Platform *ui; 47 | 48 | loginwindow1*parent; 49 | public slots: 50 | //刷新列表 51 | void Refresh1(); 52 | void Refresh2(); 53 | void Refresh3(); 54 | void Refresh4(); 55 | 56 | //显示列表 57 | void ShowHotel(); 58 | void ShowRoom(); 59 | void ShowOrder(); 60 | void ShowCustomer(); 61 | 62 | //审核通过列表 63 | void ApproveHotel(); 64 | void ApproveRoom(); 65 | void ApproveOrder(); 66 | 67 | //保存并退出列表 68 | void SaveAndLogout(); 69 | 70 | void STop(); 71 | 72 | void DisAble(); 73 | 74 | }; 75 | 76 | #endif // PLATFORM_H 77 | -------------------------------------------------------------------------------- /platform.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Platform 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1006 10 | 649 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 0 20 | 0 21 | 1021 22 | 651 23 | 24 | 25 | 26 | 27 | 微软雅黑 28 | 75 29 | true 30 | 31 | 32 | 33 | 0 34 | 35 | 36 | 37 | 酒店列表 38 | 39 | 40 | 41 | 42 | 0 43 | 170 44 | 1011 45 | 451 46 | 47 | 48 | 49 | 50 | 51 | 52 | 30 53 | 40 54 | 221 55 | 81 56 | 57 | 58 | 59 | 60 | 微软雅黑 61 | 24 62 | 75 63 | true 64 | 65 | 66 | 67 | 待审核酒店 68 | 69 | 70 | 71 | 72 | 73 | 250 74 | 60 75 | 101 76 | 51 77 | 78 | 79 | 80 | 81 | 12 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 510 92 | 30 93 | 131 94 | 91 95 | 96 | 97 | 98 | 99 | 微软雅黑 100 | 18 101 | 75 102 | true 103 | 104 | 105 | 106 | 通过审核 107 | 108 | 109 | 110 | 111 | 112 | 810 113 | 30 114 | 141 115 | 91 116 | 117 | 118 | 119 | 120 | 18 121 | 122 | 123 | 124 | 保存退出 125 | 126 | 127 | 128 | 129 | 130 | 660 131 | 30 132 | 131 133 | 91 134 | 135 | 136 | 137 | 138 | 18 139 | 140 | 141 | 142 | 刷新列表 143 | 144 | 145 | 146 | 147 | 148 | 370 149 | 30 150 | 121 151 | 91 152 | 153 | 154 | 155 | 156 | 16 157 | 75 158 | true 159 | 160 | 161 | 162 | 停业整改 163 | 164 | 165 | 166 | 167 | 168 | 房间列表 169 | 170 | 171 | 172 | 173 | 0 174 | 150 175 | 1001 176 | 471 177 | 178 | 179 | 180 | 100 181 | 182 | 183 | 184 | 185 | 186 | 580 187 | 30 188 | 181 189 | 101 190 | 191 | 192 | 193 | 194 | 24 195 | 75 196 | true 197 | 198 | 199 | 200 | 通过审核 201 | 202 | 203 | 204 | 205 | 206 | 50 207 | 30 208 | 241 209 | 81 210 | 211 | 212 | 213 | 214 | 28 215 | 75 216 | true 217 | 218 | 219 | 220 | 待审核房间 221 | 222 | 223 | 224 | 225 | 226 | 350 227 | 40 228 | 131 229 | 61 230 | 231 | 232 | 233 | 234 | 18 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 790 245 | 30 246 | 181 247 | 101 248 | 249 | 250 | 251 | 252 | 24 253 | 254 | 255 | 256 | 刷新列表 257 | 258 | 259 | 260 | 261 | 262 | 订单列表 263 | 264 | 265 | 266 | 267 | 0 268 | 140 269 | 1011 270 | 481 271 | 272 | 273 | 274 | 275 | 276 | 277 | 50 278 | 40 279 | 241 280 | 61 281 | 282 | 283 | 284 | 285 | 28 286 | 287 | 288 | 289 | 待审核退款 290 | 291 | 292 | 293 | 294 | 295 | 340 296 | 50 297 | 121 298 | 51 299 | 300 | 301 | 302 | 303 | 18 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 600 314 | 20 315 | 171 316 | 101 317 | 318 | 319 | 320 | 321 | 22 322 | 75 323 | true 324 | 325 | 326 | 327 | 通过审核 328 | 329 | 330 | 331 | 332 | 333 | 790 334 | 20 335 | 171 336 | 101 337 | 338 | 339 | 340 | 341 | 22 342 | 343 | 344 | 345 | 刷新列表 346 | 347 | 348 | 349 | 350 | 351 | 用户列表 352 | 353 | 354 | 355 | 356 | 0 357 | 150 358 | 1011 359 | 471 360 | 361 | 362 | 363 | 364 | 365 | 366 | 80 367 | 30 368 | 201 369 | 81 370 | 371 | 372 | 373 | 374 | 28 375 | 376 | 377 | 378 | 用户列表 379 | 380 | 381 | 382 | 383 | 384 | 780 385 | 30 386 | 171 387 | 91 388 | 389 | 390 | 391 | 392 | 20 393 | 75 394 | true 395 | 396 | 397 | 398 | 注销用户 399 | 400 | 401 | 402 | 403 | 404 | 560 405 | 30 406 | 151 407 | 91 408 | 409 | 410 | 411 | 412 | 18 413 | 75 414 | true 415 | 416 | 417 | 418 | 刷新列表 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | -------------------------------------------------------------------------------- /platformadmin.cpp: -------------------------------------------------------------------------------- 1 | 2 | /******************************************************************** 3 | 文件名:platformadmin.cpp 4 | 功能模块和目的:实现platform类的构造函数 5 | 开发者:程晔安 6 | 日期: 7 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 8 | 更改记录: 9 | **********************************************************************/ 10 | 11 | #include "platformadmin.h" 12 | #include "QString" 13 | 14 | //构造函数 15 | PlatformAdmin::PlatformAdmin(QString newAccount, QString newPassword, 16 | QString newPhone): 17 | AbstractUser(newAccount, newPassword, newPhone) 18 | { 19 | 20 | } 21 | -------------------------------------------------------------------------------- /platformadmin.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | 文件名:platformAdmin.h 3 | 功能模块和目的:创建平台管理员 4 | 开发者:程晔安 5 | 日期:8.1 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录: 8 | **************************************************************************/ 9 | #ifndef PLATFORMADMIN_H 10 | #define PLATFORMADMIN_H 11 | 12 | #include "abstractuser.h" 13 | #include "QString" 14 | #include "mydatabase.h" 15 | #include 16 | /************************************************************************** 17 | 类名:PlatformAdmin 18 | 功能:创建基础的平台管理员类 19 | 接口说明: 20 | 开发者:程晔安 21 | 日期: 22 | 更改记录: 23 | **************************************************************************/ 24 | using namespace std; 25 | 26 | class PlatformAdmin:public AbstractUser 27 | { 28 | 29 | friend class myDatabase; 30 | 31 | public: 32 | //构造函数 33 | PlatformAdmin(QString newAccount, QString newPassword, 34 | QString Phone); 35 | PlatformAdmin(){} 36 | 37 | 38 | }; 39 | 40 | #endif // PLATFORMADMIN_H 41 | -------------------------------------------------------------------------------- /qtStyleSheet.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LiquidAmmonia/BigAssignment-AHotelSystem/44e47d03d49cef23b6910438d47ad3a4ffcc01d9/qtStyleSheet.txt -------------------------------------------------------------------------------- /register.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LiquidAmmonia/BigAssignment-AHotelSystem/44e47d03d49cef23b6910438d47ad3a4ffcc01d9/register.jpg -------------------------------------------------------------------------------- /registerwindow.cpp: -------------------------------------------------------------------------------- 1 | 2 | /******************************************************************** 3 | 文件名:registerwindow.cpp 4 | 功能模块和目的:显示注册界面 5 | 开发者:程晔安 6 | 日期:8.1 7 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 8 | 更改记录: 9 | **********************************************************************/ 10 | 11 | #include "registerwindow.h" 12 | #include "ui_registerwindow.h" 13 | #include "QMessageBox" 14 | 15 | #include"customer.h" 16 | 17 | extern QVectorg_Customerlist; 18 | 19 | //可跳回登陆界面 20 | registerWindow::registerWindow(loginwindow1*l): 21 | ui(new Ui::registerWindow) 22 | { 23 | ui->setupUi(this); 24 | parent = l; 25 | //装饰 26 | ui->linePassword->setEchoMode(QLineEdit::Password); 27 | ui->linePassword2->setEchoMode(QLineEdit::Password); 28 | 29 | 30 | this->setWindowTitle("APlaceToStay--Register"); 31 | this->setAutoFillBackground(true); 32 | QPalette palette = this->palette(); 33 | palette.setBrush(QPalette::Background, 34 | QBrush(QPixmap("://register.jpg").scaled( 35 | this->size(),Qt::IgnoreAspectRatio,Qt::SmoothTransformation))); 36 | this->setPalette(palette); 37 | this->setFixedSize(this->width(),this->height()); 38 | 39 | //接口 40 | 41 | //返回登陆主界面 42 | connect(ui->btnCancel,SIGNAL(clicked(bool)),parent,SLOT(show())); 43 | connect(ui->btnCancel,SIGNAL(clicked(bool)),this,SLOT(hide())); 44 | 45 | //主要实现功能函数 46 | connect(ui->btnEnter,SIGNAL(clicked(bool)), this,SLOT(SendInfo())); 47 | 48 | } 49 | 50 | registerWindow::~registerWindow() 51 | { 52 | delete ui; 53 | } 54 | 55 | //接受用户输入并处理 56 | void registerWindow::SendInfo() 57 | { 58 | bool flag = false; 59 | 60 | //必须两次判断都成立才可进行之后操作 61 | flag = CheckEntering() && CheckCusInfo(); 62 | 63 | if(flag == true) 64 | { 65 | //之后可以扩展的功能单元——手机验证用户注册 66 | QMessageBox::information(this, "手机验证码", "请注意查收手机验证码", QMessageBox::Ok); 67 | 68 | //加入全局变量 69 | Customer newCustomer(Account,Password,Phone); 70 | 71 | g_Customerlist.push_back(newCustomer); 72 | 73 | QMessageBox::information(this, "success!", "注册成功!", QMessageBox::Ok); 74 | } 75 | 76 | //成功后返回主窗口 77 | this->close(); 78 | parent->show(); 79 | 80 | } 81 | 82 | //判断输入是否符合规定 83 | bool registerWindow::CheckEntering() 84 | { 85 | //检查账户和密码的输入是否符合规则 86 | bool flag = true; 87 | 88 | //接收用户输入 89 | Password = ui->linePassword->text(); 90 | Password2 = ui->linePassword2->text(); 91 | Account = ui->lineAccount->text(); 92 | Phone = ui->linePhone->text(); 93 | 94 | //判断 95 | if(Password.isEmpty()) 96 | { 97 | QMessageBox::information(this, "entering Error", "输入密码不能为空", QMessageBox::Ok); 98 | flag = false; 99 | } 100 | if(Password.length()<6||Password.length()>11) 101 | { 102 | QMessageBox::information(this, "length Error", "密码长度应在6~11位以内", QMessageBox::Ok); 103 | flag = false; 104 | } 105 | if(Password != Password2) 106 | { 107 | QMessageBox::information(this, "different Entering", "两次密码输入不同", QMessageBox::Ok); 108 | flag = false; 109 | } 110 | if(Account.isEmpty()) 111 | { 112 | QMessageBox::information(this, "entering Error", "输入账户不能为空!",QMessageBox::Ok); 113 | flag = false; 114 | } 115 | if(Phone.isEmpty()) 116 | { 117 | QMessageBox::information(this, "entering Error", "输入电话不能为空!",QMessageBox::Ok); 118 | flag = false; 119 | } 120 | if(Phone.length()!=11) 121 | { 122 | QMessageBox::information(this, "entering Error", "输入电话号码应为11位!",QMessageBox::Ok); 123 | flag = false; 124 | } 125 | return flag; 126 | 127 | } 128 | 129 | //判断是否与已有信息冲突,即不能重复注册 130 | bool registerWindow::CheckCusInfo() 131 | { 132 | bool flag = true; 133 | 134 | //账号重复 135 | for(int i=0;i 13 | #include "loginwindow1.h" 14 | 15 | /************************************************************************** 16 | 类名:registerwindow 17 | 功能:创建用户注册界面 18 | 接口说明:有指向loginwindow1的指针 19 | 开发者:程晔安 20 | 日期:8.1 21 | 更改记录: 22 | **************************************************************************/ 23 | 24 | namespace Ui { 25 | class registerWindow; 26 | } 27 | 28 | 29 | class loginwindow1; 30 | 31 | class registerWindow : public QWidget 32 | { 33 | Q_OBJECT 34 | 35 | public: 36 | explicit registerWindow(loginwindow1 *l); 37 | ~registerWindow(); 38 | 39 | private: 40 | Ui::registerWindow *ui; 41 | 42 | //回到登陆界面的指针 43 | loginwindow1 *parent; 44 | //界面上输入的信息作为私有成员 45 | QString Account; 46 | QString Password; 47 | QString Password2; 48 | QString Phone; 49 | 50 | //检查输入规范问题 51 | bool CheckEntering(); 52 | 53 | //检查已有的顾客名单的信息是否重复 54 | bool CheckCusInfo(); 55 | 56 | public slots: 57 | //主要的功能函数 58 | void SendInfo(); 59 | 60 | }; 61 | 62 | #endif // REGISTERWINDOW_H 63 | -------------------------------------------------------------------------------- /registerwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | registerWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 613 10 | 594 11 | 12 | 13 | 14 | 15 | 微软雅黑 16 | 75 17 | true 18 | 19 | 20 | 21 | Form 22 | 23 | 24 | 25 | 26 | 140 27 | 30 28 | 321 29 | 91 30 | 31 | 32 | 33 | 34 | 微软雅黑 35 | 48 36 | 50 37 | false 38 | 39 | 40 | 41 | 用户注册 42 | 43 | 44 | 45 | 46 | 47 | 90 48 | 430 49 | 161 50 | 121 51 | 52 | 53 | 54 | 55 | 微软雅黑 56 | 26 57 | 58 | 59 | 60 | 确定 61 | 62 | 63 | 64 | 65 | 66 | 340 67 | 430 68 | 161 69 | 121 70 | 71 | 72 | 73 | 74 | 微软雅黑 75 | 26 76 | 77 | 78 | 79 | 取消 80 | 81 | 82 | 83 | 84 | 85 | 40 86 | 130 87 | 511 88 | 281 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 微软雅黑 97 | 24 98 | 50 99 | false 100 | 101 | 102 | 103 | 用户名 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 微软雅黑 112 | 24 113 | 50 114 | false 115 | 116 | 117 | 118 | 请重新输入密码 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 请两次输入相同 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 6~11位 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 微软雅黑 157 | 24 158 | 50 159 | false 160 | 161 | 162 | 163 | 设置密码 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 微软雅黑 172 | 24 173 | 50 174 | false 175 | 176 | 177 | 178 | 手机号 179 | 180 | 181 | 182 | 183 | 184 | 185 | 仅用于发送消息和找回密码 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | -------------------------------------------------------------------------------- /res.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | standard.jpg 4 | qtStyleSheet.txt 5 | 6 | 7 | -------------------------------------------------------------------------------- /room.cpp: -------------------------------------------------------------------------------- 1 | 2 | /******************************************************************** 3 | 文件名:room.cpp 4 | 功能模块和目的:实现Room类的构造函数 5 | 开发者:程晔安 6 | 日期:7.29 7 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 8 | 更改记录: 9 | **********************************************************************/ 10 | 11 | #include "room.h" 12 | 13 | 14 | //从数据库读入时的构造函数 15 | Room::Room(QString newHotelName, 16 | bool newApproved, int newPrice, 17 | int newNumber, int newType, float newDiscount, 18 | QString newImages, QString newDiscription, 19 | int newStar): 20 | HotelName(newHotelName),Approved(newApproved), 21 | Price(newPrice), Number(newNumber), Type(newType), 22 | Discount(newDiscount), Images(newImages), 23 | Discription(newDiscription), 24 | Star(newStar) 25 | { 26 | //用作房间的唯一标志 27 | RoomID = HotelName + QString::number(Type); 28 | curDays = Number; 29 | 30 | 31 | } 32 | 33 | //新建房间对象时的构造函数 34 | Room::Room(QString newHotelName, int newPrice, 35 | int newNumber, int newType) 36 | { 37 | HotelName = newHotelName; 38 | Approved = false; 39 | Price = newPrice; 40 | Number = newNumber; 41 | Type = newType; 42 | Discount = 1.0; 43 | Images = ":/standard.jpg"; 44 | Discription = "商家很懒,什么也没留下。"; 45 | //0代表尚未有评论 46 | Star = 0; 47 | RoomID = HotelName + QString::number(Type); 48 | curDays = Number; 49 | } 50 | 51 | -------------------------------------------------------------------------------- /room.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | 文件名:room.h 3 | 功能模块和目的:创建基础的房间类 4 | 开发者:程晔安 5 | 日期:7.28 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录: 8 | **************************************************************************/ 9 | 10 | #ifndef ROOM_H 11 | #define ROOM_H 12 | 13 | #include "QString" 14 | 15 | /************************************************************************** 16 | 类名:Room 17 | 功能:作为基础的房间类 18 | 接口说明:可以获得房间类的各种属性 19 | 开发者:程晔安 20 | 日期:7.28 21 | 更改记录: 22 | **************************************************************************/ 23 | 24 | 25 | class Room 26 | { 27 | 28 | public: 29 | 30 | //构造函数 31 | Room(){} 32 | Room(QString newHotelName, 33 | bool newApproved, int newPrice, 34 | int newNumber, int newType, float newDiscount, 35 | QString newImages, QString newDiscription, 36 | int newStar); 37 | Room(QString hotelname, 38 | int Price, int Number, int Type); 39 | 40 | //接口函数 41 | QString GetHotelName() 42 | { 43 | return HotelName; 44 | } 45 | 46 | bool IsApproved() 47 | { 48 | return Approved; 49 | } 50 | void SetApproved(bool newApproved) 51 | { 52 | Approved = newApproved; 53 | } 54 | 55 | 56 | int GetPrice() 57 | { 58 | return Price; 59 | } 60 | void SetPrice(int newPrice) 61 | { 62 | Price = newPrice; 63 | } 64 | 65 | int GetNumber() 66 | { 67 | return Number; 68 | } 69 | void SetNumber(int newNumber) 70 | { 71 | Number = newNumber; 72 | } 73 | 74 | int GetType() 75 | { 76 | return Type; 77 | } 78 | void SetType(int newType) 79 | { 80 | Type = newType; 81 | } 82 | 83 | void SetDiscount(float newDiscount) 84 | { 85 | Discount = newDiscount; 86 | } 87 | float GetDiscount() 88 | { 89 | return Discount; 90 | } 91 | 92 | QString GetImages() 93 | { 94 | return Images; 95 | } 96 | void SetImages(QString newImages) 97 | { 98 | Images = newImages; 99 | } 100 | 101 | QString GetDiscription() 102 | { 103 | return Discription; 104 | } 105 | void SetDiscription(QString newDiscription) 106 | { 107 | Discription = newDiscription; 108 | } 109 | 110 | int GetStar() 111 | { 112 | return Star; 113 | } 114 | void SetStar(int newStar) 115 | { 116 | int temp = Star; 117 | Star = (newStar + temp)/2; 118 | } 119 | 120 | QString GetRoomId() 121 | { 122 | return RoomID; 123 | } 124 | 125 | int GetRealPrice() 126 | { 127 | return (int)(Price * Discount); 128 | } 129 | 130 | int curDays; 131 | private: 132 | QString HotelName; 133 | bool Approved; 134 | int Price; 135 | int Number; 136 | //总共有五种类型的房子 137 | int Type; 138 | float Discount; 139 | QString Images; 140 | QString Discription; 141 | //打分星级 142 | int Star; 143 | 144 | QString RoomID; 145 | }; 146 | 147 | #endif // ROOM_H 148 | -------------------------------------------------------------------------------- /roomchange.cpp: -------------------------------------------------------------------------------- 1 | /******************************************************************** 2 | 文件名:roomchange.cpp 3 | 功能模块和目的:实现对房间信息的修改 4 | 开发者:程晔安 5 | 日期:8.3 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录: 8 | **********************************************************************/ 9 | 10 | #include "roomchange.h" 11 | #include "ui_roomchange.h" 12 | 13 | #include "enums.h" 14 | #include "room.h" 15 | #include "hotel.h" 16 | 17 | 18 | 19 | using namespace std; 20 | 21 | extern QVectorg_Hotellist; 22 | 23 | 24 | RoomChange::RoomChange(whotel*newparent, Room*newpRoom) : 25 | parent(newparent),pRoom(newpRoom), 26 | ui(new Ui::RoomChange) 27 | { 28 | ui->setupUi(this); 29 | //装饰 30 | ShowOldInfo(); 31 | 32 | this->setFixedSize(this->width(),this->height()); 33 | this->setWindowTitle("APlaceToStay--Change Room"); 34 | 35 | //slots 36 | 37 | //返回酒店主界面 38 | connect(ui->btnCancel, SIGNAL(clicked(bool)), this, SLOT(Cancel())); 39 | 40 | //保存相关信息 41 | connect(ui->btnSave, SIGNAL(clicked(bool)), this, SLOT(Save())); 42 | 43 | //打开图片及显示 44 | connect(ui->btnOpen,SIGNAL(clicked(bool)), this, SLOT(OpenImag())); 45 | 46 | //保存图片到相关文件夹 47 | connect(ui->btnSaveImag, SIGNAL(clicked(bool)), this, SLOT(SaveImag())); 48 | 49 | 50 | 51 | } 52 | 53 | RoomChange::~RoomChange() 54 | { 55 | delete ui; 56 | } 57 | 58 | //返回 59 | void RoomChange::Cancel() 60 | { 61 | this->close(); 62 | parent->show(); 63 | } 64 | 65 | //打开图片并打印在预览界面中 66 | void RoomChange::OpenImag() 67 | { 68 | //获取文件exe路径 69 | runPath = QCoreApplication::applicationDirPath(); 70 | //新文件姓名 71 | hglpName = "photo"; 72 | //文件存储路径 73 | hglpPath = QString("%1/%2").arg(runPath).arg(hglpName); 74 | 75 | QString filename=QFileDialog::getOpenFileName(this,tr("选择图像"),"", 76 | tr("Images (*.png *.bmp *.jpg)")); 77 | if(filename.isEmpty()) 78 | return; 79 | else 80 | { 81 | QImage img; 82 | if(!(img.load(filename))) //加载图像 83 | { 84 | QMessageBox::information(this, tr("打开图像失败"),tr("打开图像失败!")); 85 | return; 86 | } 87 | ui->labelimag->setPixmap(QPixmap::fromImage(img.scaled(ui->labelimag->size()))); 88 | } 89 | 90 | 91 | } 92 | 93 | //保存图片文件 94 | void RoomChange::SaveImag() 95 | { 96 | QScreen *screen = QGuiApplication::primaryScreen(); 97 | QString Name = ui->lineName->text(); 98 | screen->grabWindow(ui->labelimag->winId()).save(QString("%1/%2.jpg").arg(hglpPath).arg(Name)); 99 | 100 | pRoom->SetImages(QString("./photo/%1.jpg").arg(Name)); 101 | 102 | QMessageBox::information(this, "SAVED", "图片已保存在.exe文件路径中", QMessageBox::Ok); 103 | 104 | } 105 | 106 | //保存相关信息 107 | void RoomChange::Save() 108 | { 109 | int newNumber = ui->lineNum->text().toInt(); 110 | pRoom->SetNumber(newNumber); 111 | float newDiscount = ui->lineDiscount->text().toFloat(); 112 | pRoom->SetDiscount(newDiscount); 113 | QString newDicription = ui->lineDiscription->text(); 114 | pRoom->SetDiscription(newDicription); 115 | int newprice = ui->linePrice->text().toInt(); 116 | pRoom->SetPrice(newprice); 117 | 118 | 119 | //自动将审核过程调为“未审” 120 | //更改完信息之后需要重新审核 121 | pRoom->SetApproved(false); 122 | QMessageBox::information(this, "SUCCESS", 123 | "保存成功!等待管理员审核", QMessageBox::Ok); 124 | this->close(); 125 | parent->show(); 126 | } 127 | 128 | //显示更改前信息作为lineEdit的老信息 129 | void RoomChange::ShowOldInfo() 130 | { 131 | ui->lineNum->setText(QString::number(pRoom->GetNumber())); 132 | ui->lineDiscount->setText(QString::number(pRoom->GetDiscount(), 'f', 2)); 133 | ui->lineDiscription->setText(pRoom->GetDiscription()); 134 | ui->linePrice->setText(QString::number(pRoom->GetPrice())); 135 | QImage img; 136 | if(!(img.load(pRoom->GetImages()))) //加载图像 137 | { 138 | QMessageBox::information(this, tr("打开图像失败"),tr("打开图像失败!")); 139 | return; 140 | } 141 | ui->labelimag->setPixmap(QPixmap::fromImage(img.scaled(ui->labelimag->size()))); 142 | 143 | 144 | } 145 | 146 | 147 | -------------------------------------------------------------------------------- /roomchange.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | 文件名:roomchange.h 3 | 功能模块和目的:更改房间信息 4 | 开发者:程晔安 5 | 日期:7.28 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录: 8 | **************************************************************************/ 9 | #ifndef ROOMCHANGE_H 10 | #define ROOMCHANGE_H 11 | 12 | #include 13 | 14 | #include "QVector" 15 | #include "room.h" 16 | #include "whotel.h" 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | 26 | /************************************************************************** 27 | 类名:Roomchange 28 | 功能:创建更改房间信息的相关操作和界面 29 | 接口说明:有指向whotel的指针 30 | 开发者:程晔安 31 | 日期:7.28 32 | 更改记录: 33 | **************************************************************************/ 34 | 35 | namespace Ui { 36 | class RoomChange; 37 | } 38 | 39 | class whotel; 40 | 41 | class RoomChange : public QWidget 42 | { 43 | Q_OBJECT 44 | 45 | public: 46 | explicit RoomChange(whotel*parent, Room*pRoom); 47 | ~RoomChange(); 48 | 49 | private: 50 | Ui::RoomChange *ui; 51 | 52 | //指向whotel以及记录信息 53 | whotel*parent; 54 | Room*pRoom; 55 | 56 | //储存图片用 57 | QString runPath; 58 | QString hglpName; 59 | QString hglpPath; 60 | 61 | public slots: 62 | //保存信息 63 | void Save(); 64 | //打开图片 65 | void OpenImag(); 66 | //保存图片到相关路径 67 | void SaveImag(); 68 | //取消操作 69 | void Cancel(); 70 | //显示旧的房间信息 71 | void ShowOldInfo(); 72 | }; 73 | 74 | #endif // ROOMCHANGE_H 75 | -------------------------------------------------------------------------------- /roomchange.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | RoomChange 4 | 5 | 6 | 7 | 0 8 | 0 9 | 603 10 | 638 11 | 12 | 13 | 14 | 15 | 微软雅黑 16 | 75 17 | true 18 | 19 | 20 | 21 | Form 22 | 23 | 24 | 25 | 26 | 110 27 | 20 28 | 401 29 | 81 30 | 31 | 32 | 33 | 34 | 微软雅黑 35 | 36 36 | 50 37 | false 38 | 39 | 40 | 41 | 更改房间属性 42 | 43 | 44 | 45 | 46 | 47 | 90 48 | 120 49 | 131 50 | 41 51 | 52 | 53 | 54 | 55 | 18 56 | 75 57 | true 58 | 59 | 60 | 61 | 房间数量 62 | 63 | 64 | 65 | 66 | 67 | 90 68 | 180 69 | 131 70 | 41 71 | 72 | 73 | 74 | 75 | 18 76 | 75 77 | true 78 | 79 | 80 | 81 | 房间价格 82 | 83 | 84 | 85 | 86 | 87 | 90 88 | 250 89 | 131 90 | 31 91 | 92 | 93 | 94 | 95 | 18 96 | 75 97 | true 98 | 99 | 100 | 101 | 房间折扣 102 | 103 | 104 | 105 | 106 | 107 | 90 108 | 410 109 | 131 110 | 41 111 | 112 | 113 | 114 | 115 | 18 116 | 75 117 | true 118 | 119 | 120 | 121 | 房间图片 122 | 123 | 124 | 125 | 126 | 127 | 90 128 | 310 129 | 131 130 | 41 131 | 132 | 133 | 134 | 135 | 18 136 | 75 137 | true 138 | 139 | 140 | 141 | 房间描述 142 | 143 | 144 | 145 | 146 | 147 | 300 148 | 130 149 | 161 150 | 41 151 | 152 | 153 | 154 | 155 | 156 | 157 | 300 158 | 190 159 | 161 160 | 41 161 | 162 | 163 | 164 | 165 | 166 | 167 | 300 168 | 250 169 | 161 170 | 41 171 | 172 | 173 | 174 | 选填 175 | 176 | 177 | 178 | 179 | 180 | 300 181 | 310 182 | 161 183 | 41 184 | 185 | 186 | 187 | 选填 188 | 189 | 190 | 191 | 192 | 193 | 240 194 | 380 195 | 141 196 | 61 197 | 198 | 199 | 200 | TextLabel 201 | 202 | 203 | 204 | 205 | 206 | 430 207 | 390 208 | 121 209 | 41 210 | 211 | 212 | 213 | 214 | 12 215 | 216 | 217 | 218 | 打开图片 219 | 220 | 221 | 222 | 223 | 224 | 430 225 | 450 226 | 121 227 | 41 228 | 229 | 230 | 231 | 232 | 12 233 | 234 | 235 | 236 | 保存图片 237 | 238 | 239 | 240 | 241 | 242 | 330 243 | 520 244 | 161 245 | 101 246 | 247 | 248 | 249 | 250 | 22 251 | 75 252 | true 253 | 254 | 255 | 256 | 确认保存 257 | 258 | 259 | 260 | 261 | 262 | 90 263 | 520 264 | 151 265 | 101 266 | 267 | 268 | 269 | 270 | 26 271 | 272 | 273 | 274 | 返回 275 | 276 | 277 | 278 | 279 | 280 | 240 281 | 470 282 | 151 283 | 31 284 | 285 | 286 | 287 | 图片保存名称 288 | 289 | 290 | 291 | 292 | 293 | 294 | -------------------------------------------------------------------------------- /standard.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LiquidAmmonia/BigAssignment-AHotelSystem/44e47d03d49cef23b6910438d47ad3a4ffcc01d9/standard.jpg -------------------------------------------------------------------------------- /timg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LiquidAmmonia/BigAssignment-AHotelSystem/44e47d03d49cef23b6910438d47ad3a4ffcc01d9/timg.jpg -------------------------------------------------------------------------------- /wcomment.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | /******************************************************************** 4 | 文件名:wcomment.cpp 5 | 功能模块和目的:实现添加评分 6 | 开发者:程晔安 7 | 日期:8.2 8 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 9 | 更改记录: 10 | **********************************************************************/ 11 | 12 | #include "wcomment.h" 13 | #include "ui_wcomment.h" 14 | 15 | #include "qmessagebox.h" 16 | #include "mydatabase.h" 17 | 18 | #include "mainwindow.h" 19 | #include "order.h" 20 | #include "hotel.h" 21 | #include "room.h" 22 | 23 | extern QVectorRawRoomlist; 24 | 25 | 26 | WComment::WComment(MainWindow *newparent, Order* newpOrder) : 27 | parent(newparent),pOrder(newpOrder), 28 | ui(new Ui::WComment) 29 | { 30 | ui->setupUi(this); 31 | 32 | connect(ui->btnOk, SIGNAL(clicked(bool)), this, SLOT(Comment())); 33 | 34 | connect(ui->btnCancel, SIGNAL(clicked(bool)), 35 | this, SLOT(close())); 36 | connect(ui->btnCancel, SIGNAL(clicked(bool)), 37 | parent, SLOT(show())); 38 | } 39 | 40 | WComment::~WComment() 41 | { 42 | delete ui; 43 | } 44 | 45 | void WComment::Comment() 46 | { 47 | //获取评分等级 48 | int Star; 49 | if(ui->radioButton->isChecked()) 50 | Star = 1; 51 | else if(ui->radioButton_2->isChecked()) 52 | Star = 2; 53 | else if(ui->radioButton_3->isChecked()) 54 | Star = 3; 55 | else if(ui->radioButton_4->isChecked()) 56 | Star = 4; 57 | else 58 | Star = 5; 59 | 60 | //将评分等级放入相应的房间中 61 | for(int i=0;iGetpRoom()->GetRoomId() == RawRoomlist[i].GetRoomId()) 64 | { 65 | pOrder->GetpRoom()->SetStar(Star); 66 | } 67 | } 68 | 69 | QMessageBox::information(this, "ERROR", 70 | "评价成功,欢迎您下次光临!", QMessageBox::Ok); 71 | 72 | //返回主窗口 73 | pOrder->SetType(5); 74 | this->close(); 75 | parent->show(); 76 | 77 | } 78 | -------------------------------------------------------------------------------- /wcomment.h: -------------------------------------------------------------------------------- 1 | 2 | /************************************************************************** 3 | 文件名:wcomment.h 4 | 功能模块和目的:添加评论 5 | 开发者:程晔安 6 | 日期:8.3 7 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 8 | 更改记录: 9 | **************************************************************************/ 10 | 11 | #ifndef WCOMMENT_H 12 | #define WCOMMENT_H 13 | 14 | #include 15 | 16 | #include "order.h" 17 | 18 | 19 | /************************************************************************** 20 | 类名:wComment 21 | 功能:为已完成的订单添加评论 22 | 接口说明:有指向mainWindow的指针 23 | 开发者:程晔安 24 | 日期:8.3 25 | 更改记录: 26 | **************************************************************************/ 27 | 28 | namespace Ui { 29 | class WComment; 30 | } 31 | 32 | class MainWindow; 33 | 34 | class WComment : public QDialog 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | explicit WComment(MainWindow *parent, Order* pOrder); 40 | ~WComment(); 41 | 42 | public slots: 43 | //添加评论 44 | void Comment(); 45 | 46 | private: 47 | //记录相关信息 48 | Ui::WComment *ui; 49 | MainWindow*parent; 50 | Order *pOrder; 51 | 52 | }; 53 | 54 | #endif // WCOMMENT_H 55 | -------------------------------------------------------------------------------- /wcomment.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | WComment 4 | 5 | 6 | 7 | 0 8 | 0 9 | 499 10 | 419 11 | 12 | 13 | 14 | 15 | 微软雅黑 16 | 75 17 | true 18 | 19 | 20 | 21 | Dialog 22 | 23 | 24 | 25 | 26 | 200 27 | 30 28 | 81 29 | 31 30 | 31 | 32 | 33 | 34 | 微软雅黑 35 | 16 36 | 75 37 | true 38 | 39 | 40 | 41 | 请评价 42 | 43 | 44 | 45 | 46 | 47 | 80 48 | 90 49 | 351 50 | 221 51 | 52 | 53 | 54 | 55 | 56 | 57 | 服务很烂!差评没商量 58 | 59 | 60 | 61 | 62 | 63 | 64 | 勉强可以接受 65 | 66 | 67 | 68 | 69 | 70 | 71 | 不错哦 72 | 73 | 74 | 75 | 76 | 77 | 78 | 太赞了! 79 | 80 | 81 | 82 | 83 | 84 | 85 | 我准备搬家来这里啦 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 290 95 | 320 96 | 131 97 | 71 98 | 99 | 100 | 101 | 102 | 18 103 | 104 | 105 | 106 | 确定 107 | 108 | 109 | 110 | 111 | 112 | 80 113 | 320 114 | 141 115 | 71 116 | 117 | 118 | 119 | 120 | 18 121 | 75 122 | true 123 | 124 | 125 | 126 | 取消 127 | 128 | 129 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /whotel.cpp: -------------------------------------------------------------------------------- 1 | 2 | /******************************************************************** 3 | 文件名:whotel.cpp 4 | 功能模块和目的:实现酒店平台 5 | 开发者:程晔安 6 | 日期:8.1 7 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 8 | 更改记录: 9 | **********************************************************************/ 10 | 11 | #include "whotel.h" 12 | #include "ui_whotel.h" 13 | 14 | #include "QMessageBox" 15 | #include "qtablewidget.h" 16 | #include "QDate" 17 | #include "mydatabase.h" 18 | #include "QVector" 19 | 20 | #include "order.h" 21 | #include "hotel.h" 22 | #include "room.h" 23 | 24 | #include "enums.h" 25 | 26 | using namespace std ; 27 | 28 | extern QVectorg_HotelManagerlist; 29 | extern QVectorg_Hotellist; 30 | extern QVectorg_Orderlist; 31 | 32 | extern QVectorRawRoomlist; 33 | 34 | whotel::whotel(loginwindow1 *newParent, 35 | Hotel* new_pHotel) : 36 | parent(newParent), pHotel(new_pHotel), 37 | ui(new Ui::whotel) 38 | { 39 | ui->setupUi(this); 40 | 41 | //装饰 42 | this->setFixedSize(this->width(),this->height()); 43 | this->setWindowTitle("APlaceToStay__Hotel"); 44 | 45 | ui->table->setSelectionBehavior(QAbstractItemView::SelectRows); 46 | ui->table->setSelectionMode(QAbstractItemView::SingleSelection); 47 | ui->table2->setSelectionBehavior(QAbstractItemView::SelectRows); 48 | ui->table2->setSelectionMode(QAbstractItemView::SingleSelection); 49 | //初始显示 50 | ShowRoomInfo(); 51 | ShowOrderInfo(); 52 | //接口 53 | 54 | //保存并推出 55 | connect(ui->btnExit, SIGNAL(clicked(bool)), this, SLOT(SaveAndLogout())); 56 | 57 | //显示所属房间信息 58 | connect(ui->btnRefresh, SIGNAL(clicked(bool)), this, SLOT(ShowRoomInfo())); 59 | 60 | //更改房间信息 61 | connect(ui->btnChange, SIGNAL(clicked(bool)), this, SLOT(ChangeRoom())); 62 | 63 | //更改订单状态:入住 64 | connect(ui->btnCheckIn, SIGNAL(clicked(bool)), this, SLOT(CheckIn())); 65 | 66 | //更改订单状态:确认退房 67 | connect(ui->btnCheckOut, SIGNAL(clicked(bool)), this, SLOT(CheckOut())); 68 | 69 | //刷新 70 | connect(ui->btnRefresh_2, SIGNAL(clicked(bool)), this, SLOT(ShowOrderInfo())); 71 | 72 | //新建房间 73 | connect(ui->btnNew, SIGNAL(clicked(bool)), this, SLOT(NewARoom())); 74 | } 75 | 76 | whotel::~whotel() 77 | { 78 | delete ui; 79 | } 80 | 81 | //保存并退出 82 | void whotel::SaveAndLogout() 83 | { 84 | //链接数据库 85 | myDatabase Database; 86 | Database.Memory(); 87 | //返回登录窗口 88 | this->close(); 89 | parent->show(); 90 | //密码清空 91 | parent->ClearPassword(); 92 | return ; 93 | } 94 | 95 | //显示房间信息 96 | void whotel::ShowRoomInfo() 97 | { 98 | 99 | //初始化表头 100 | InitialRoomHeader(); 101 | 102 | //开始显示 103 | QVector tempRoomlist = pHotel->Roomlist; 104 | for(int i=0;itable->setRowCount(i+1); 107 | //类型转换 108 | QString temp_enter; 109 | if(tempRoomlist[i].IsApproved()) 110 | temp_enter = "已过审"; 111 | else 112 | temp_enter = "未过审"; 113 | 114 | //显示价格和数量 115 | ui->table->setItem(i, 0, 116 | new QTableWidgetItem(temp_enter)); 117 | ui->table->setItem(i, 1, 118 | new QTableWidgetItem( 119 | QString::number(tempRoomlist[i].GetPrice()))); 120 | ui->table->setItem(i, 2, 121 | new QTableWidgetItem( 122 | QString::number(tempRoomlist[i].GetNumber()))); 123 | //房间种类 124 | //转换类型 125 | QString str_type[5] = {"钟点房", "大床房", "双人房", "奢华房", "总统套房"}; 126 | 127 | ui->table->setItem(i, 3, 128 | new QTableWidgetItem( 129 | str_type[tempRoomlist[i].GetType()])); 130 | //折扣 131 | ui->table->setItem(i, 4, 132 | new QTableWidgetItem( 133 | QString::number(tempRoomlist[i].GetDiscount(), 'f', 2))); 134 | //图片 135 | QLabel *label = new QLabel(""); 136 | 137 | qDebug()<setPixmap(QPixmap(tempRoomlist[i].GetImages()).scaled(125,150)); 139 | 140 | ui->table->setCellWidget(i, 5, label); 141 | //商家描述 142 | ui->table->setItem(i, 6, 143 | new QTableWidgetItem( 144 | tempRoomlist[i].GetDiscription())); 145 | } 146 | 147 | 148 | 149 | } 150 | 151 | //创建基础房间表头 152 | void whotel::InitialRoomHeader() 153 | { 154 | ui->table->clear(); 155 | ui->table->setColumnCount(7); 156 | ui->table->setHorizontalHeaderItem(0, new QTableWidgetItem 157 | (QStringLiteral("是否通过审核"))); 158 | ui->table->setHorizontalHeaderItem(1, new QTableWidgetItem 159 | (QStringLiteral("价格"))); 160 | ui->table->setHorizontalHeaderItem(2, new QTableWidgetItem 161 | (QStringLiteral("数量"))); 162 | //房间种类不可更改 163 | ui->table->setHorizontalHeaderItem(3, new QTableWidgetItem 164 | (QStringLiteral("房间种类"))); 165 | ui->table->setHorizontalHeaderItem(4, new QTableWidgetItem 166 | (QStringLiteral("折扣"))); 167 | ui->table->setHorizontalHeaderItem(5, new QTableWidgetItem 168 | (QStringLiteral("图片"))); 169 | ui->table->setHorizontalHeaderItem(6, new QTableWidgetItem 170 | (QStringLiteral("商家描述"))); 171 | 172 | } 173 | 174 | //改变房间信息 175 | void whotel::ChangeRoom() 176 | { 177 | int row = ui->table->currentRow(); 178 | 179 | //判断是否选中房间 180 | if(row == -1) 181 | { 182 | QMessageBox::information(this, "ERROR", "未选中房间!", QMessageBox::Ok); 183 | return ; 184 | } 185 | //传入对应房间指针,进入RoomChange界面 186 | Room* pRoom = &pHotel->Roomlist[row]; 187 | pRoomChange = new RoomChange(this, pRoom); 188 | pRoomChange->show(); 189 | } 190 | 191 | //初始化订单表头 192 | void whotel::InitialOrder() 193 | { 194 | ui->table2->clear(); 195 | ui->table2->setColumnCount(5); 196 | ui->table2->setHorizontalHeaderItem(0, new QTableWidgetItem 197 | (QStringLiteral("卖家账号"))); 198 | ui->table2->setHorizontalHeaderItem(1, new QTableWidgetItem 199 | (QStringLiteral("卖家电话"))); 200 | ui->table2->setHorizontalHeaderItem(2, new QTableWidgetItem 201 | (QStringLiteral("订购房型"))); 202 | ui->table2->setHorizontalHeaderItem(3, new QTableWidgetItem 203 | (QStringLiteral("订单状态"))); 204 | ui->table2->setHorizontalHeaderItem(4, new QTableWidgetItem 205 | (QStringLiteral("预计入住时间"))); 206 | ui->table2->setHorizontalHeaderItem(0, new QTableWidgetItem 207 | (QStringLiteral("住房时间"))); 208 | } 209 | 210 | //显示订单表 211 | void whotel::ShowOrderInfo() 212 | { 213 | InitialOrder(); 214 | temppOrderlist.clear(); 215 | //开始显示 216 | 217 | //选择酒店对应的订单并放入暂时的订单列表中 218 | for(int i=0;i< g_Orderlist.size();i++) 219 | { 220 | if(g_Orderlist[i].GetpRoom()->GetHotelName() == 221 | pHotel->GetHotelName()) 222 | { 223 | temppOrderlist.push_back(&g_Orderlist[i]); 224 | } 225 | } 226 | 227 | //显示 228 | for(int i=0;i< temppOrderlist.size();i++) 229 | { 230 | ui->table2->setRowCount(i+1); 231 | 232 | //显示用户账号和手机号 233 | ui->table2->setItem(i, 0, 234 | new QTableWidgetItem( 235 | temppOrderlist[i]->GetpCustomer()->GetAccount())); 236 | ui->table2->setItem(i, 1, 237 | new QTableWidgetItem( 238 | temppOrderlist[i]->GetpCustomer()->GetPhone())); 239 | //转换类型 240 | QString str_RoomType[5] = {"钟点房", "大床房", "双人房", "奢华房", "总统套房"}; 241 | 242 | //显示房间型号 243 | ui->table2->setItem(i, 2, 244 | new QTableWidgetItem( 245 | str_RoomType[temppOrderlist[i]->GetpRoom()->GetType()])); 246 | //转换类型 247 | //显示订单状态 248 | QString str_OrderType[6] = {"已预订", "已交款", "退款", "已入住", "已退房", "已评论"}; 249 | ui->table2->setItem(i, 3, 250 | new QTableWidgetItem( 251 | str_OrderType[temppOrderlist[i]->GetType()])); 252 | //显示订单的起始日期 253 | ui->table2->setItem(i, 4, 254 | new QTableWidgetItem( 255 | temppOrderlist[i]->GetDate().toString("dd.MM.yyyy"))); 256 | //先对应天数 257 | ui->table2->setItem(i, 5, 258 | new QTableWidgetItem( 259 | QString::number(temppOrderlist[i]->GetDays()))); 260 | 261 | } 262 | 263 | } 264 | 265 | //更改订单状态:确认入住 266 | void whotel::CheckIn() 267 | { 268 | int row = ui->table2->currentRow(); 269 | 270 | //判断是否选中订单 271 | if(row == -1) 272 | { 273 | QMessageBox::information(this, "ERROR", "未选中订单!", QMessageBox::Ok); 274 | return ; 275 | } 276 | 277 | //判断订单的状态是否为已缴费 278 | if(temppOrderlist[row]->GetType() == 1) 279 | { 280 | for(int i=0;iGetRoomId() == 284 | temppOrderlist[row]->GetpRoom()->GetRoomId())&& 285 | (g_Orderlist[i].GetpCustomer()->GetAccount() == 286 | temppOrderlist[row]->GetpCustomer()->GetAccount())) 287 | { 288 | g_Orderlist[i].SetType(3); 289 | QMessageBox::information(this, "SUCCESS", "更改成功", 290 | QMessageBox::Ok); 291 | } 292 | } 293 | } 294 | else 295 | { 296 | QMessageBox::information(this, "FAILED", "订单状态有误!", 297 | QMessageBox::Ok); 298 | 299 | } 300 | } 301 | 302 | //更改订单状态:确定退房 303 | void whotel::CheckOut() 304 | { 305 | int row = ui->table2->currentRow(); 306 | //判断是否选中了订单 307 | if(row == -1) 308 | { 309 | QMessageBox::information(this, "ERROR", "未选中订单!", QMessageBox::Ok); 310 | return ; 311 | } 312 | 313 | //判断选中订单状态 314 | if(temppOrderlist[row]->GetType() == 3) 315 | { 316 | for(int i=0;iGetRoomId() == 320 | temppOrderlist[row]->GetpRoom()->GetRoomId())&& 321 | (g_Orderlist[i].GetpCustomer()->GetAccount() == 322 | temppOrderlist[row]->GetpCustomer()->GetAccount())) 323 | { 324 | g_Orderlist[i].SetType(4); 325 | QMessageBox::information(this, "SUCCESS", "更改成功", 326 | QMessageBox::Ok); 327 | } 328 | } 329 | } 330 | else 331 | { 332 | //订单状态不符 333 | QMessageBox::information(this, "FAILED", "订单状态有误!", 334 | QMessageBox::Ok); 335 | } 336 | 337 | 338 | } 339 | 340 | //创建新房间 341 | void whotel::NewARoom() 342 | { 343 | this->hide(); 344 | //转向创建新房间界面 345 | pNewRoom = new NewRoom(this, pHotel); 346 | pNewRoom->show(); 347 | } 348 | 349 | -------------------------------------------------------------------------------- /whotel.h: -------------------------------------------------------------------------------- 1 | /* 2 | 文件名:whotel.h 3 | 功能模块和目的:创建酒店管理员的界面 4 | 开发者:程晔安 5 | 日期:8.2 6 | 版权信息:Copyright 2018 by Yean Cheng .All rights reserved. 7 | 更改记录: 8 | */ 9 | #ifndef WHOTEL_H 10 | #define WHOTEL_H 11 | 12 | #include 13 | #include "QVector" 14 | #include "QtWidgets" 15 | 16 | #include "roomchange.h" 17 | #include "loginwindow1.h" 18 | #include "newroom.h" 19 | 20 | #include "hotelmanager.h" 21 | #include "hotel.h" 22 | #include "room.h" 23 | #include "order.h" 24 | 25 | /************************************************************************** 26 | 类名:whotel 27 | 28 | 功能:创建酒店管理员界面 29 | 接口说明:有指向loginwindow,newroom,roomchange的指针 30 | 开发者:程晔安 31 | 日期:8.2 32 | 更改记录: 33 | **************************************************************************/ 34 | 35 | namespace Ui { 36 | class whotel; 37 | } 38 | 39 | class loginwindow1; 40 | class RoomChange; 41 | class NewRoom; 42 | 43 | class whotel : public QWidget 44 | { 45 | Q_OBJECT 46 | 47 | public: 48 | explicit whotel(loginwindow1*parent, Hotel*pHotel); 49 | ~whotel(); 50 | 51 | private: 52 | Ui::whotel *ui; 53 | 54 | //可以返回到登陆界面 55 | loginwindow1*parent; 56 | //记录当前酒店的信息 57 | Hotel*pHotel; 58 | //通向其他界面 59 | RoomChange*pRoomChange; 60 | NewRoom*pNewRoom; 61 | 62 | //记录与此酒店相关的订单列表 63 | QVectortemppOrderlist ; 64 | public slots: 65 | //保存退出 66 | void SaveAndLogout(); 67 | 68 | //显示房间信息 69 | void ShowRoomInfo(); 70 | 71 | //初始化房间信息列表标题 72 | void InitialRoomHeader(); 73 | 74 | //修改房间信息 75 | void ChangeRoom(); 76 | 77 | //更改订单状态:确定入住 78 | void CheckIn(); 79 | 80 | //更改订单状态:确定退房 81 | void CheckOut(); 82 | 83 | //显示订单信息 84 | void ShowOrderInfo(); 85 | 86 | //初始化订单列表标题 87 | void InitialOrder(); 88 | 89 | //创建一个新房间 90 | void NewARoom(); 91 | }; 92 | 93 | #endif // WHOTEL_H 94 | -------------------------------------------------------------------------------- /whotel.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | whotel 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1053 10 | 624 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 0 20 | 0 21 | 1061 22 | 631 23 | 24 | 25 | 26 | 27 | 微软雅黑 28 | 75 29 | true 30 | 31 | 32 | 33 | 0 34 | 35 | 36 | 37 | 房间列表 38 | 39 | 40 | 41 | 42 | 0 43 | 170 44 | 1051 45 | 421 46 | 47 | 48 | 49 | 100 50 | 51 | 52 | 53 | 54 | 55 | 300 56 | 40 57 | 161 58 | 101 59 | 60 | 61 | 62 | 63 | 20 64 | 75 65 | true 66 | 67 | 68 | 69 | 更改信息 70 | 71 | 72 | 73 | 74 | 75 | 790 76 | 40 77 | 161 78 | 101 79 | 80 | 81 | 82 | 83 | 20 84 | 75 85 | true 86 | 87 | 88 | 89 | 保存退出 90 | 91 | 92 | 93 | 94 | 95 | 550 96 | 40 97 | 161 98 | 101 99 | 100 | 101 | 102 | 103 | 20 104 | 75 105 | true 106 | 107 | 108 | 109 | 刷新列表 110 | 111 | 112 | 113 | 114 | 115 | 70 116 | 40 117 | 151 118 | 101 119 | 120 | 121 | 122 | 123 | 微软雅黑 124 | 20 125 | 75 126 | true 127 | 128 | 129 | 130 | 新建房间 131 | 132 | 133 | 134 | 135 | 136 | 订单列表 137 | 138 | 139 | 140 | 141 | 420 142 | 40 143 | 171 144 | 111 145 | 146 | 147 | 148 | 149 | 20 150 | 151 | 152 | 153 | 确认入住 154 | 155 | 156 | 157 | 158 | 159 | 710 160 | 40 161 | 171 162 | 111 163 | 164 | 165 | 166 | 167 | 20 168 | 169 | 170 | 171 | 确认退房 172 | 173 | 174 | 175 | 176 | 177 | 0 178 | 190 179 | 1051 180 | 401 181 | 182 | 183 | 184 | 185 | 186 | 187 | 120 188 | 40 189 | 171 190 | 111 191 | 192 | 193 | 194 | 195 | 20 196 | 197 | 198 | 199 | 刷新列表 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | -------------------------------------------------------------------------------- /大作业报告.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LiquidAmmonia/BigAssignment-AHotelSystem/44e47d03d49cef23b6910438d47ad3a4ffcc01d9/大作业报告.pdf --------------------------------------------------------------------------------