第五组酒店客房预订管理系统的设计与实现源代码
酒店管理系统代码(C语言版)

#include <stdio.h〉#include 〈stdlib。
h>#include <string。
h>//房间信息结构体struct Node{int Count; //指示该房间有多少个房客char nameOne[20]; //房客1的名字char nameTwo[20]; //房客2的名字int sexOne;//房客1的性别—1代表女,0代表没有,1代表男int sexTwo; //房客2的性别int roomNumber;//房间号}roomArray[5];//初始化房间数组void InitArray(){int i;for(i=0;i<5;i++){roomArray[i].roomNumber = 301+i;memset(roomArray[i]。
nameOne,0,20);memset(roomArray[i]。
nameTwo,0,20);roomArray[i].sexOne = 0;roomArray[i].sexTwo = 0;roomArray[i].Count = 0;}}void fun1() //旅客入住的操作{char name[20];int sex;int i;printf(”\n输入入住旅客姓名和性别(空格隔开,1为男,—1为女):”);scanf(”%s %d",name,&sex);for(i=0;i<5;i++){if(roomArray[i]。
Count == 2){continue;}else if(roomArray[i].Count == 1){if(roomArray[i]。
sexOne != sex){continue;}strcpy(roomArray[i].nameTwo,name);roomArray[i].sexTwo = sex;roomArray[i]。
Count++;system("cls”);printf("客人已经成功入住,在房间%d”,roomArray[i].roomNumber);return;;}else{strcpy(roomArray[i]。
酒店客房管理系统的设计与实现

酒店客房管理系统的设计与实现1. 引言酒店客房管理系统是一种帮助酒店管理客房信息并提供相关服务的软件系统。
该系统能够方便酒店管理人员对客房进行预订管理、入住登记、客房状态跟踪等操作,提高客房的利用率和服务质量。
本文将介绍酒店客房管理系统的设计与实现。
2. 功能需求分析酒店客房管理系统的功能主要包括以下几点:1.客房信息管理:包括客房类型、客房价格、客房状态等信息的录入和查询。
2.客房预订管理:支持客户对客房进行预订操作,同时能够进行客房的冲突检测,避免重复预订。
3.客房入住管理:记录客户的入住信息,包括入住登记、客房分配、押金收取等。
4.客房状态跟踪:及时更新客房的状态信息,包括客房是否已打扫、客房是否已空净等。
5.客房费用管理:包括客房的消费记录、押金退还、费用结算等功能。
6.统计报表生成:能够根据需求生成各类统计报表,如客房利用率、客房收入等。
3. 系统设计3.1 数据库设计酒店客房管理系统的数据库设计是系统设计的关键部分。
系统需要设计以下几个主要的数据表:•客房表:存储客房的基本信息,包括客房ID、客房类型、价格、状态等字段。
•客户表:存储客户的基本信息,包括客户ID、姓名、联系方式等字段。
•预订表:存储客户的预订信息,包括客户ID、客房ID、预订时间、预订状态等字段。
•入住表:存储客户的入住信息,包括客户ID、客房ID、入住时间、退房时间、押金等字段。
•消费表:存储客户的消费记录,包括客户ID、客房ID、消费金额、消费时间等字段。
3.2 系统架构设计酒店客房管理系统的架构设计应该采用分层结构,主要包括表示层、业务逻辑层和数据存储层。
•表示层:负责与用户交互,展示界面并接收用户输入,使用HTML、CSS和JavaScript等前端技术完成。
•业务逻辑层:负责处理用户请求、业务逻辑判断、调用数据存储层从数据库中读取或写入数据等,使用Java或其他后端语言实现。
•数据存储层:负责与数据库进行交互,读取或写入数据,可以使用关系数据库(SQL Server、MySQL)或非关系数据库(MongoDB、Redis)等进行存储。
酒店客房管理系统设计VB程序源代码

酒店客房管理系统设计系统源代码酒店客房管理系统代码清单:frmAddlb窗体代码:Private Sub Command1_Click()Dim sql As StringDim conn As New adodb.ConnectionDim rs_fjstyle As New adodb.RecordsetIf Trim(Text1.Text) = "" ThenMsgBox "请输入房间类型", vbOKOnly + vbExclamation, ""Text1.SetFocusExit SubEnd IfIf Trim(Text2.Text) = "" ThenMsgBox "请输入类型代号", vbOKOnly + vbExclamation, ""Text2.SetFocusExit SubEnd IfIf Trim(Text3.Text) = "" ThenMsgBox "请输入房间数量", vbOKOnly + vbExclamation, ""Text3.SetFocusExit SubEnd Ifconn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\data\database.mdb"sql = "select * from 客房类别where 房间类型='" & Text1.Text & "'"rs_fjstyle.Open sql, conn, adOpenKeyset, adLockPessimisticIf rs_fjstyle.EOF Thenrs_fjstyle.AddNewrs_fjstyle.Fields(1) = Trim(Text1.Text)rs_fjstyle.Fields(2) = Trim(Text2.Text)rs_fjstyle.Fields(3) = Trim(Text3.Text)rs_fjstyle.UpdateMsgBox "添加成功", vbOKOnly + vbExclamation, ""Text1.Text = ""Text2.Text = ""Text3.Text = ""Text1.SetFocusrs_fjstyle.CloseElseMsgBox "你添加的类别已存在,请输入新类别", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = ""Text2.Text = ""rs_fjstyle.CloseExit SubEnd IfEnd SubPrivate Sub Command2_Click()Unload Mefrmlbinfo.ShowEnd SubfrmAdduser窗体代码:Private Sub Command1_Click()Dim sql As StringDim rs_add As New adodb.RecordsetDim conn As New adodb.Connectionconn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\data\database.mdb"If Trim(Text1.Text) = "" ThenMsgBox "用户名不能为空,请输入!", vbOKOnly + vbExclamation, ""Text1.SetFocusElsesql = "select * from 用户信息"rs_add.Open sql, conn, adOpenKeyset, adLockPessimisticWhile (rs_add.EOF = False)If Trim(rs_add.Fields(1)) = Trim(Text1.Text) ThenMsgBox "已有这个用户", vbOKOnly + vbExclamation, ""Text1.SetFocusText1.Text = ""Text2.Text = ""Text3.Text = ""Exit SubElsers_add.MoveNextEnd IfWendIf Trim(Text2.Text) <> Trim(Text3.Text) ThenMsgBox "两次密码不一致", vbOKOnly + vbExclamation, ""Text2.SetFocusText2.Text = ""Text3.Text = ""Exit SubElsers_add.AddNewrs_add.Fields(1) = Text1.Textrs_add.Fields(2) = Text2.Textrs_add.UpdateMsgBox "添加用户成功!", vbOKOnly + vbExclamation, ""'Me.HideEnd IfEnd IfEnd SubPrivate Sub Command2_Click()Unload MeEnd SubfrmdfAdd窗体代码:Private Sub Command1_Click()Dim sql As StringDim conn As New adodb.ConnectionDim rs_fjstyle As New adodb.RecordsetIf Trim(Text1.Text) = "" ThenMsgBox "请输入姓名!", vbOKOnly + vbExclamation, ""Text1.SetFocusExit SubEnd If'If Trim(Text2.Text) = "" Then'MsgBox "日期不能为空!", vbOKOnly + vbExclamation, ""'Text2.SetFocus'Exit Sub'Else'If Not IsDate(Text2.Text) Then' MsgBox "请按照2006-12-30格式输入登记日期!", vbOKOnly + vbExclamation, "" ' Text2.Text = ""' Text2.SetFocus'Exit Sub'End If'End IfIf Trim(Text3.Text) = "" ThenMsgBox "请输入房间编号!", vbOKOnly + vbExclamation, ""Text2.SetFocusExit SubEnd IfIf Trim(Text4.Text) = "" ThenMsgBox "请选择房间类型!", vbOKOnly + vbExclamation, ""Text4.SetFocusExit SubEnd IfIf Trim(Text5.Text) = "" ThenMsgBox "请交定金!", vbOKOnly + vbExclamation, ""Text5.SetFocusExit SubEnd Ifconn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\data\database.mdb"sql = "select * from 预订客房"rs_fjstyle.Open sql, conn, adOpenKeyset, adLockPessimistic'rs_fjstyle.EOFrs_fjstyle.AddNewrs_fjstyle.Fields(1) = Trim(Text1.Text)rs_fjstyle.Fields(4) = Trim(DTPicker1.Value)rs_fjstyle.Fields(5) = Trim(DTPicker2.Value)rs_fjstyle.Fields(2) = Trim(Text3.Text)rs_fjstyle.Fields(3) = Trim(Text4.Text)rs_fjstyle.Fields(6) = Val(Text5.Text)rs_fjstyle.UpdateMsgBox "添加成功", vbOKOnly + vbExclamation, ""rs_fjstyle.CloseCommand3.Enabled = TrueExit SubEnd SubPrivate Sub Command2_Click()Text1.Text = ""'Text2.Text = ""'Text3.Text = ""Text4.Text = ""Text5.Text = ""Text1.SetFocusEnd SubPrivate Sub Command3_Click()Dim conn As New adodb.ConnectionDim rs_fjstyle As New adodb.Recordsetconn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\data\database.mdb"sql = "select 客人姓名,房间编号,房间类型,订房日期,订房时间,预交订金from 预订客房" rs_fjstyle.CursorLocation = adUseClientrs_fjstyle.Open sql, conn, adOpenKeyset, adLockPessimisticDataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseSet DataGrid1.DataSource = rs_fjstyleMsgBox "数据已更新!", vbOKOnly + vbExclamation, ""Exit SubEnd SubPrivate Sub Command4_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim sql As StringDim conn As New adodb.ConnectionDim rs_fjstyle As New adodb.Recordsetconn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\data\database.mdb"sql = "select 客人姓名,房间编号,房间类型,订房日期,订房时间,预交订金from 预订客房" rs_fjstyle.CursorLocation = adUseClientrs_fjstyle.Open sql, conn, adOpenKeyset, adLockPessimisticDataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseSet DataGrid1.DataSource = rs_fjstyleExit SubSet DTPicker2.Value = TimeEnd SubfrmDfdy窗体代码:Private Sub Command1_Click()Dim conn As New adodb.ConnectionDim rs_dfdybb As New adodb.Recordsetconn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\data\database.mdb"sql = "select 房间编号,房间类别,日住宿费,周住宿费,月住宿费,预订,空房from 客房信息"rs_dfdybb.Open sql, conn, adOpenKeyset, adLockPessimisticSet DataReport1.DataSource = rs_dfdybb.DataSourceDataReport1.DataMember = rs_dfdybb.DataMemberDataReport1.Show' Unload MeEnd SubPrivate Sub Command2_Click()Unload MeEnd SubPrivate Sub Form_Load()Dim sql As StringDim rs_dfdy As New RecordsetDim conn As New adodb.ConnectionOn Error GoTo loaderrorconn.Open "provider=Microsoft.Jet.OLEDB.4.0; data source=" & App.Path & "\data\database.mdb"sql = "select 房间编号,房间类别,日住宿费,周住宿费,月住宿费,预订,空房from 客房信息" rs_dfdy.CursorLocation = adUseClientrs_dfdy.Open sql, conn, adOpenKeyset, adLockPessimisticDataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = FalseDataGrid1.AllowUpdate = FalseSet DataGrid1.DataSource = rs_dfdyExit Subloaderror:MsgBox Err.DescriptionEnd SubfrmdfEdit窗体代码:Option ExplicitDim rs_xgkfinfo As New adodb.RecordsetPrivate Sub cmddel_Click()Dim answer As Stringanswer = MsgBox("确定要删除吗?", vbYesNo, "")If answer = vbYes ThenDataGrid1.AllowDelete = TrueDataGrid1.AllowAddNew = FalseDataGrid1.AllowDelete = Falsers_xgkfinfo.Deleters_xgkfinfo.UpdateDataGrid1.RefreshElseExit SubEnd IfEnd SubPrivate Sub cmdEdit_Click()Dim answer As StringOn Error GoTo cmdEditcmddel.Enabled = FalsecmdEdit.Enabled = Falsecmdupdate.Enabled = TrueCommand4.Enabled = FalseDataGrid1.AllowUpdate = TrueExit SubcmdEdit:If Err.Number <> 0 ThenMsgBox Err.DescriptionEnd IfEnd Sub'-------------------------------------------------------Private Sub DataGrid1_BeforeColUpdate(ByVal ColIndex As Integer, OldValue As Variant, Cancel As Integer)If ColIndex = 3 ThenIf Not IsDate(DataGrid1.Columns(3).Value) ThenCancel = TrueMsgBox "请输入一个日期型数据。
C语言程序设计客房管理系统源码和报告

C语言程序设计客房管理系统源码和报告客房管理系统是一种常见的管理系统,它能够实现对酒店客房的预订、入住、退房等操作,有效地管理酒店的客房资源,提高管理效率。
本文将介绍一个简单的C语言程序设计,实现了基本的客房管理功能。
1.功能设计本客房管理系统主要包括以下功能:-显示房间列表:显示所有房间的编号、类型、价格等信息-入住房间:根据用户输入的房间号和入住人信息,将房间状态设置为“入住中”-退房:根据用户输入的房间号,将房间状态设置为“空闲”,并生成退房结算单-查询房间信息:根据用户输入的房间号,显示该房间的详细信息-按房间类型查询:根据用户输入的房间类型,显示该类型的所有房间信息2.数据结构设计为了实现上述功能,我们需要设计合适的数据结构。
-客房类型结构体:包括房间类型名称和价格等信息-客房结构体:包括房间号、类型、状态、入住人信息等信息具体的数据结构定义和全局变量声明如下:```c#define TYPE_NUM 3 // 客房类型数量typedef struct RoomTypechar typeName[20]; // 类型名称double price; // 价格} RoomType;typedef struct Roomint roomNum; // 房间号int type; // 房间类型,对应RoomType数组的下标int status; // 房间状态,0表示空闲,1表示入住中char name[20]; // 入住人姓名} Room;RoomType types[TYPE_NUM] = {{"单人间", 100.0}, {"标准间", 200.0}, {"豪华间", 300.0}}; // 房间类型数组,包含三种类型Room rooms[100]; // 客房数组,最多100个房间int roomNum = 0; // 当前客房数量```3.主程序设计主程序中包含下面几个函数:-显示房间列表:遍历客房数组,输出每个房间的编号、类型和状态-入住房间:根据用户输入的房间号和入住人信息,将房间状态设置为“入住中”-退房:根据用户输入的房间号,将房间状态设置为“空闲”,并生成退房结算单-查询房间信息:根据用户输入的房间号,显示该房间的详细信息-按房间类型查询:根据用户输入的房间类型,显示该类型的所有房间信息具体的主程序设计如下:```c#include <stdio.h>void showRoomLisprintf("房间号类型状态入住人姓名\n");for (int i = 0; i < roomNum; i++)printf("%-5d %-8s %-8s %s\n", rooms[i].roomNum,types[rooms[i].type].typeName,rooms[i].status == 0 ? "空闲" : "入住中", rooms[i].name);}void checkIint roomNum;printf("请输入房间号:");scanf("%d", &roomNum);//检查房间是否存在,并且是否空闲for (int i = 0; i < roomNum; i++)if (rooms[i].roomNum == roomNum)if (rooms[i].status == 0)printf("请输入入住人姓名:");scanf("%s", rooms[i].name);rooms[i].status = 1; // 设置房间状态为“入住中”printf("入住成功!\n");return;} elseprintf("该房间已被占用!\n");return;}}}printf("房间不存在!\n");void checkOuint roomNum;printf("请输入房间号:");scanf("%d", &roomNum);//检查房间是否存在,并且是否入住中for (int i = 0; i < roomNum; i++)if (rooms[i].roomNum == roomNum)if (rooms[i].status == 1)printf("请输入退房人姓名:");scanf("%s", rooms[i].name);rooms[i].status = 0; // 设置房间状态为“空闲”printf("退房成功!\n");//生成退房结算单printf("房间号:%d\n", rooms[i].roomNum);printf("入住人:%s\n", rooms[i].name);printf("房间类型:%s\n", types[rooms[i].type].typeName); printf("房费:%.2f元\n", types[rooms[i].type].price); return;} elseprintf("该房间未入住!\n");return;}}printf("房间不存在!\n");void queryRoomInfint roomNum;printf("请输入房间号:");scanf("%d", &roomNum);//检查房间是否存在for (int i = 0; i < roomNum; i++)if (rooms[i].roomNum == roomNum)printf("房间号:%d\n", rooms[i].roomNum);printf("房间类型:%s\n", types[rooms[i].type].typeName);printf("房费:%.2f元\n", types[rooms[i].type].price);printf("状态:%s\n", rooms[i].status == 0 ? "空闲" : "入住中");printf("入住人:%s\n", rooms[i].name);return;}printf("房间不存在!\n");void queryRoomByTypchar typeName[20];printf("请输入房间类型:");scanf("%s", typeName);int type;//获取房间类型对应的序号for (int i = 0; i < TYPE_NUM; i++)if (strcmp(types[i].typeName, typeName) == 0) type = i;break;}}//查找对应类型的房间int count = 0;for (int i = 0; i < roomNum; i++)if (rooms[i].type == type)count++;printf("房间号:%d\n", rooms[i].roomNum);printf("房间类型:%s\n", types[rooms[i].type].typeName);printf("房费:%.2f元\n", types[rooms[i].type].price);printf("状态:%s\n", rooms[i].status == 0 ? "空闲" : "入住中");printf("入住人:%s\n", rooms[i].name);}}if (count == 0)printf("该类型的房间不存在!\n");}int maiint choice;while (1)printf("\n--------欢迎使用客房管理系统--------\n");printf("1. 显示房间列表\n");printf("2. 入住房间\n");printf("3. 退房\n");printf("4. 查询房间信息\n");printf("5. 按房间类型查询\n"); printf("6. 退出\n");printf("请输入您的选择:"); scanf("%d", &choice);switch (choice)case 1:showRoomList(;break;case 2:checkIn(;break;case 3:checkOut(;break;case 4:queryRoomInfo(;break;case 5:queryRoomByType(;break;case 6:printf("感谢使用客房管理系统,再见!\n");return 0;default:printf("输入有误,请重新输入!\n");break;}}```以上就是一个简单的客房管理系统的C语言程序设计源码和报告,实现了基本的客房管理功能,能够实现客房的预订、入住、退房等操作。
(完整word版)酒店管理系统代码

#include 〈windows.h>#include <dos。
h〉#include〈stdio。
h〉#include〈stdlib.h〉#include<time.h〉//—-------—-—-—-——-———-——--—-—-—-——-———--—-—-—-----—结构定义———--—--—-——---———--—-———-——--——————--——-—typedef struct CheckinInformation{char name[10]; //姓名int id; //证件号int roomType; //房型int countType; //计费方式}CheckinInfo;typedef struct HotelRoom{int roomType;//房型int roomNum; //房号int checked; //入住情况int price;//房价}Room;typedef struct RoomOrder{CheckinInfo *checkinInfo; //入住信息long date;//入住时间Room * room;//房间信息}Order;typedef struct HotelInfomation{int checkinAmount;//已入住房数int singleRemainAmount;//单人房剩余房数int doubleRemainAmount;//双人房剩余房数int bigRemainAmount; //大床房剩余房数}HotelInfo;//--—--——--——-—--—--—---—-———--—-—枚举类型—--—--—-—--————-—-------—--enum {MainUI,HotelInfoUI,CheckinUI,CheckinResultUI,OrderUI,CheckOutUI,Exit};//GUI enum {Single,Double,Big};//Room Typeenum {Hour,Day};//countType//——--—---—--——-—---—---——-----—-—全局变量--——————————-—-—-——-———--—int GUI = MainUI;Order*orderList[100]; //订单数组Room*roomList[100]; //房间数组HotelInfo * hotelInfo = NULL;//酒店房间信息//—-—-—————-----—-———-—-———---———函数声明--—---—--------—-——---——-——-void initiallizeRoomList();void insertToOrderList(Order *order);Room*getRoomByType(int roomType);Order* getOrderByRoomNum(int roomNum);void showMainUI();void showHotelInfoUI();void showCheckinUI();void showCheckinResultUI();void showOrderUI();void showCheckOutUI();//—--——--———--——-—-—---——-————--—Main函数----—-————--—----———-————---void main() //主函数{//初始化酒店房间信息hotelInfo = (HotelInfo *)malloc(sizeof(HotelInfo));hotelInfo -> singleRemainAmount = 20;hotelInfo -〉doubleRemainAmount=40;hotelInfo —〉bigRemainAmount=40;hotelInfo —〉checkinAmount=0;//初始化房间列表initiallizeRoomList();//界面显示while(GUI != Exit){switch(GUI){case MainUI:showMainUI();break;case HotelInfoUI:showHotelInfoUI();break;case CheckinUI:showCheckinUI();break;case CheckinResultUI:showCheckinResultUI();break;case OrderUI:showOrderUI();break;case CheckOutUI:showCheckOutUI();break;default:break;}}}//----————-——-————---------—-——--函数定义—-----———-——————--—---——————void initiallizeRoomList(){//房间数组初始化,初始化的结果是让roomList的数组有100个room指针,而且设置了相应的值int i;Room*newRoom=NULL;for(i=0;i〈20;i++)//单人房房间信息初始化{newRoom = (Room* )malloc(sizeof(Room));roomList[i]= newRoom;roomList[i]->checked=0;roomList[i]—〉price=110;roomList[i]-〉roomNum=i+1;roomList[i]—〉roomType=Single;}for(i=20;i<60;i++)//双人房房间信息初始化{newRoom = ( Room*)malloc(sizeof(Room));roomList[i]= newRoom;roomList[i]—>checked=0;roomList[i]—>price=180;roomList[i]—〉roomNum=i+1;roomList[i]—>roomType=Double;}for(i=60;i〈100;i++) //大床房房间信息初始化{newRoom = ( Room*)malloc(sizeof(Room));roomList[i]= newRoom;roomList[i]—〉checked=0;roomList[i]—>price=180;roomList[i]—〉roomNum=i+1;roomList[i]->roomType=Big;}}//通过所选择的房型获取空房间,获取房间后将房间信息改为已入住,并减少相应房型的剩余房间数Room* getRoomByType(int roomType){int i;switch(roomType){case Single:for(i=0;i<20;i++){if( roomList[i]->checked == 0){roomList[i]->checked=1;hotelInfo-〉singleRemainAmount -- ;hotelInfo—〉checkinAmount++;return roomList[i];}}break;case Double:for(i=20;i<60;i++){if(roomList[i]-〉checked == 0){roomList[i]—>checked=1;hotelInfo—>doubleRemainAmount —— ;hotelInfo-〉checkinAmount++;return roomList[i];}}break;case Big:for(i=60;i<100;i++){if( roomList[i]->checked == 0){roomList[i]—〉checked=1;hotelInfo—〉bigRemainAmount -—;hotelInfo—>checkinAmount++;return roomList[i];}}break;}}//将订单放入订单列表void insertToOrderList(Order * order){int i;for( i = 0;i<100;i++){if( orderList[i]==NULL ){orderList[i]= order;break;}}}//通过房号查询订单Order*getOrderByRoomNum(int roomNum){int i;for(i=0;i〈100;i++){if( orderList[i]—>room-〉roomNum == roomNum){return orderList[i];}}}void showMainUI(){//显示主界面,并接受输入int chooseNum;system("cls");printf(”\n\n==========================酒店房间登记与计费管理管理系统=======================\t\n\n\n");printf(”*\t\t\t\t1. 入住登记\t\t\t\t*\n");printf("*\t\t\t\t2。
客房管理系统源代码

#include<iostream>#include<string>#include<fstream>using namespace std;/*问题描述:该系统能简单实现对客栈的住宿情况进行管理。
至少包括以下信息:房号、房型、单价(每床)、已住人数;住客姓名、性别、年龄、身份、身份证号码,房号,床号,入住日期、入住时间、离店日期、离店时间。
这些信息应存放在两个文件中,分别是客房信息文件、住客信息文件。
"房型"可取值1-3,分别表示单人间、双人间、通铺(可以住很多人的房间)功能要求:1.具有建立数据文件(客房信息文件、住客信息文件)功能;2.具有数据输入功能;3.具有数据修改功能;4.具有数据删除功能;5.能查询(查找)一些基本信息(如按房号查询、按姓名查询、空余客房查询等);6.具有多种统计功能(要求有一定的实用性)(如某客房当前有那些空床、某住客应付多少费用、某天住店总人数和总收入等)说明:(1)功能各方面越完善越好(2)自定义的数据结构可以使用数组,链表,树等,可以使用多种数据结构来存放数据,然后在其上使用不同的排序算法。
(3)若用数组,必须动态分配空间(文本文件中最好有一行来表示数组应该有多大,这样便于动态分配空间)*///*************************************************类定义class Customer //住客信息类{public:string name; //姓名string id; //身份证号string sex;//性别int age; //年龄int roomnum; //入住房号string ruzhum; //入住日期string ruzhut;//入住时间string lidianm;//离店日期string lidiant;//离店时间int staytime; //入住天数Customer(){name="无";id="0";sex="0";age= -1;roomnum=0;ruzhum="0";ruzhut="0";lidianm="0";lidiant="0";staytime=0;};~Customer(){};};class Room //客房类{public:int num;//房号int price; //价格string type; //类型int renshu; //入住人数int yajin; //客房押金Room(){num=0;price=0;type=50;renshu=0;yajin=0;};~Room(){};};//******************************************************************** ******************客房信息录入功能void room_luru(Room *room);void room_luru2(Room *room);void room_luru(Room *room)//无房,添房函数{if(room[0].num==0){int size;static int Number=300;cout<<"目前暂无房间信息,请添加!"<<endl<<endl;cout<<"请输入要添加的房间数:";cin>>size;for(int i=0;i<size;i++){room[i].num=Number++;cout<<"房间号码:"<<room[i].num;cout<<endl;cout<<"房间类型:";cin>>room[i].type;cout<<"房间价格:";cin>>room[i].price;cout<<endl<<endl;};cout<<"客房信息录入成功!"<<endl<<endl;}else{string P;cout<<"客房信息已有,是否还要添加房间?(Y/N)";cin>>P;if(P=="Y")room_luru2(room);else if(P=="N")cout<<"已取消房间添加."<<endl<<endl;else cout<<"此操作非法!"<<endl<<endl;};system("pause");system("cls");};//******************************************************************** ********void room_luru2(Room *room)//有房,添加房间函数{static int Number=300;string P;do{// int Number=300;for(int i=0;i<30;i++){if(room[i].num==0){room[i].num=Number++;cout<<"房间号码:"<<room[i].num;cout<<endl;cout<<"房间类型:";cin>>room[i].type;cout<<endl;cout<<"房间价格:";cin>>room[i].price;cout<<endl<<endl;cout<<"房间添加成功,是否继续添加?(Y/N):";cin>>P;break;}else Number++;};}while(P=="Y");if(P=="N")cout<<"已取消添加。
酒店管理系统的设计与实现(正文+部分源代码)_毕业设计

酒店管理系统的设计与实现(正文+部分源代码)目录摘要........................................................ I II Abstract ...................................................... I V 引言. (1)第一章绪论 (2)1.1 系统开发背景 (2)1.2 课题研究目的及意义 (2)1.3 国内外现状及发展动态 (3)1.4 系统开发工具及相关技术 (4)1.4.1 系统开发工具 (4)1.4.2 数据库开发工具 (4)1.4.3 C#开发语言介绍 (5)第二章系统分析 (8)2.1 需求分析 (8)2.1.1 系统的主要功能 (8)2.1.2 系统的实现目标 (8)2.1.3 系统的性能需求 (9)2.1.4 运行环境 (10)2.2 可行性分析 (11)2.3 数据需求分析 (12)2.4 数据字典 (14)2.5 数据流图 (15)第三章系统设计 (16)3.1 系统功能结构设计 (16)3.2 数据库设计 (17)3.3 系统流程图 (20)第四章系统详细设计与实现 (22)4.1 用户登录 (22)4.3客房管理 (25)4.3.1客房信息修改 (25)4.3.2 入住管理 (29)4.3.3 退租管理 (33)4.3.4 客房类型管理 (35)4.4 员工管理 (38)4.5财务管理 (44)4.6 酒店初始化 (46)4.7用户密码更改 (48)第五章系统测试 (52)5.1测试的作用和意义 (52)5.2测试方法 (52)5.3系统测试 (53)结束语 (57)参考文献 (58)致谢 (59)附录 (60)摘要该软件采用应用开发技术,具有一些客房查询、入住、退房等功能,尤其依靠的优点来为酒店更好的进行管理,稳定性,可扩展性,安全性,健壮性,都是该酒店管理的优势所在。
宾馆客房系统代码

宾馆客房系统代码第一页面中标签控件属性如下: Object Label1: Tlabel Left=57 Top=78Width=36Height=12Caption='房间号'Object Label1: Tlabel Left=57Top=110Width=48Height=12Caption='客户姓名'Object Label1: Tlabel Left=57Top=142Width=48Height=12Caption='身份证号码'Object Label1: Tlabel Left=57Top=174Width=48Height=12Caption='入住时间'Object Label1: Tlabel Left=57Top=214Width=48Height=12Caption='入住理由'Object Label1: Tlabel Left=312 Top=78Width=24Height=12Caption='房价'Object Label1: TlabelLeft=312Top=110Width=48Height=12Caption='住宿天数'Object Label1: TlabelLeft=312Top=142Width=48Height=12Caption='值班人员'Object Label1: TlabelLeft=312Top=174Width=48Height=12Caption='电话号码'Object Label1: TlabelLeft=312Top=214Width=48Height=12Caption='结算费用'Object Label1: TlabelLeft=224Top=24Width=120Height=20Caption='顾客入住登记'Font.Height=-20 ='宋体' 第一页面中数据编辑类控件属性如下: Object DBEdit1: TDBEditLeft=129Top=79Width=121Height=20DataField='房间号'DataSource=Datasource1Taborder=0Object DBEdit1: TDBEdit Left=129Top=111Width=121Height=20DataField='客户姓名' DataSource=Datasource1 Taborder=1Object DBEdit1: TDBEdit Left=129Top=143Width=121Height=20DataField='身份证号码' DataSource=Datasource1 Taborder=2Object DBEdit1: TDBEdit Left=129Top=175Width=121Height=20DataField='入住时间' DataSource=Datasource1 Taborder=3Object DBEdit1: TDBEdit Left=129Top=207Width=121Height=20DataField='入住理由' DataSource=Datasource1 Taborder=4Object DBEdit1: TDBEdit Left=129Top=79Width=121Height=20DataField='房价' DataSource=Datasource1 Taborder=5Object DBEdit1: TDBEdit Left=382Top=111Width=121Height=20DataField='入住天数' DataSource=Datasource1 Taborder=6Object DBEdit1: TDBEdit Left=382Top=143Width=121Height=20DataField='值班人员' DataSource=Datasource1 Taborder=7Object DBEdit1: TDBEdit Left=382Top=175Width=121Height=20DataField='电话号码' DataSource=Datasource1 Taborder=8Object DBEdit1: TDBEdit Left=382Top=207Width=121Height=20DataField='结算费用' DataSource=Datasource1 Taborder=9第一页面中数据连接类控件属性如下:Object Table1: TtableActive=TureTableName=宾馆住宿系统.dbLeft=488Top=64Object DataSource1: TdataSourceDataSet=Table1Object DBNavigator1: TDBNavigatorLeft=184Top=224Width=240Height=25DataSource=DataSource1Flat=TrueTabOrder=10Procedure TForm1.Edit1Click(Sender:TObject); BeginEdit2.Text:=' 'Edit3.Text:=' ';End;Procedure TForm1.Edit2Click(Sender:Tobject); BeginEdit1.Text:=' 'Edit3.Text:=' ';End;Procedure TForm1.Edit3Click(Sender:Tobject);BeginEdit2.Text:=' 'Edit1.Text:=' ';End;执行按钮的程序代码如下:Procedure TForm1.Button1Click(Sender:Tobject);BeginTable1.refresh;With table1 doTryDisablecontrols;Filtered:=false;If edit1.text<>' ' then memo1.text:='客户姓名'+' ' ' '+edit1.text+' ' ' ';If edit2.text<>' ' then memo1.text:='房间号'+' ' ' '+edit2.text;If edit3.text<>' ' then memo1.text:='入住时期'+' ' ' '+edit1.text+' ' ' ';Filter:=memo1.text;Filtered:=true;FinallyEnablecontrols;If dbedit1.text=' ' then begin Messagebeep(1);Showmessage(' 没有符合条件的记录,请确认条件或放弃查询~'); If messageDlg(' 是否继续查询,只有结束查询才能作其他操作~',mtinformation,[mbyes,mbno],0)=mrno then beginFiltered:=false;Table1.close;Table1.open;End;End else beginIf messageDlg('是否继续查询,只有结束查询才能作其他操作~',mtinformation,[mbyes,mbno],0)=mrno then beginFiltered:=false;Table1.close;Table1.open;End;End;End;End;第二页各个控件的属性描述如下:Object Tabsheet2: TtabsheetCaption=客房查询Object Labell2: TlabelLeft=215Top=10Width=114Height=19Caption=客户查询系统Font.Height=-19=宋体Object Labell3: Tlabel Left=24Top=200Width=60Height=12Caption=按姓名查询Object Labell4: Tlabel Left=24Top=224Width=60Height=19Caption=按房号查询Object Labell5: Tlabel Left=23Top=246Width=60Height=12Caption=按时期查询endObject DBFrid1: TDBGrid Left=8Top=40Width=553Height=140DataSource=DataSource1 TitleFont.Height=-12 =宋体Object Edit1:TeditLeft=93Top=197Width=102Hdight=20Text=Edit1Object Edit2:TeditLeft=93Top=218Width=103Hdight=20Text=Edit2Object Edit3:TeditLeft=93Top=241Width=103Hdight=20Text=Edit3Object Button1:TbuttonLeft=232Top=208Width=75Height=25Caption='执行查询'Object Memo1:TmemoLeft=372Top=189Width=185Height=61Visible=False第三页面命令控件代码:Procedure TForm1.Button2Click(Sender:Tobject); VarSum1:real;S:string;Bookmark1:tbookmark; BeginSum1=0.00;Bookmark1:=table1.getbookmark;Table1.disablecontrols; Table1.first;While not table1.eof do BeginSum1:=sum1+table1.fieldbyname('结算费用')。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
#include <iostream>#include <iomanip>#include <string>#include <fstream>#include"conio.h" //输入/输出文件流类using namespace std;const int Maxr=100; //最多的客户const int Maxb=100; //最多的客房const int Maxbor=10; //每位客户最多预订十间客房//person类class person{public:char name[20];char ID[18];char *getname() {return name;}//获取姓名char *getID() {return ID;} //获取身份证号void setID(char I[]) //设置身份证号{strcpy(ID,I);}void setname(char na[]) //设置姓名{strcpy(name,na);}};//客户类公有继承了person类,实现对客户的信息的描述class customer:public person{private:int num; //客户编号int tag; //删除标记1:已删0:未删int borbook[Maxbor]; //所订房间public:customer() {}int gettag() {return tag;} //获取删除标记void delbook(){ tag=1; } //设置删除标记1:已删0:未删int getnum() {return num;} //获取客户编号void addcustomer(int n,char *na,char *I) //增加客户{tag=0;num=n;strcpy(name,na);strcpy(ID,I);for(int i=0;i<Maxbor;i++)borbook[i]=0;}void borrowbook(int bookid) //预订操作{for(int i=0;i<Maxbor;i++){if (borbook[i]==0){borbook[i]=bookid;return;}}}int retbook(int bookid) //退订操作{for(int i=0;i<Maxbor;i++){if(borbook[i]==bookid){borbook[i]=0;return 1;}}return 0;}void display() //读出客户信息{cout <<"客户编号:" << num <<setw(15)<< "姓名:" << name <<setw(15)<< "身份证号:" << ID<<setw(15)<<"客房编号:[";for(int i=0;i<Maxbor;i++)if(borbook[i]!=0)cout <<"#"<< borbook[i]<<" ";cout << "]"<<endl;}};//客户库类,实现建立客户的个人资料class RDatabase{private:int top; //客户记录指针customer read[Maxr]; //客户记录public:RDatabase() //构造函数,将customer.txt读到read[]中{customer s;top=-1;fstream file("customer.txt",ios::in); //打开一个输入文件while (1){file.read((char *)&s,sizeof(s));if (!file)break;top++;read[top]=s;}file.close(); //关闭customer.txt}void clear() //删除所有客户信息{top=-1;}int addcustomer(int n,char *na,char *I) //添加客户时先查找是否存在{customer *p=query(n);if (p==NULL){top++;read[top].addcustomer(n,na,I);return 1;}return 0;}customer *query(int customerid) //按编号查找{for (int i=0;i<=top;i++)if (read[i].getnum()==customerid&&read[i].gettag()==0){return &read[i];}return NULL;}customer *query(string name) //按name查找{for (int i=0;i<=top;i++)if (read[i].getname()==name&&read[i].gettag()==0){return &read[i];}return NULL;}void display() //输出所有客户信息{for (int i=0;i<=top;i++)if(read[i].gettag()==0)read[i].display();}void customerdata(); //客户库维护~RDatabase() //析构函数,将read[]写到customer.txt文件中{fstream file("customer.txt",ios::out);for (int i=0;i<=top;i++)if (read[i].gettag()==0)file.write((char *)&read[i],sizeof(read[i]));file.close();}};void RDatabase::customerdata(){char choice;char rsex[10];char rname[20];int customerid;char rID[18];customer *r;system("cls");while (choice!='0'){cout<<endl<<setw(40)<<"客户信息"<<endl;cout<<endl<<setw(28)<<"1 "<<"新增"<<endl;cout<<endl<<setw(28)<<"2 "<<"更改"<<endl;cout<<endl<<setw(28)<<"3 "<<"删除"<<endl;cout<<endl<<setw(28)<<"4 "<<"查找"<<endl;cout<<endl<<setw(28)<<"5 "<<"显示"<<endl;cout<<endl<<setw(28)<<"6 "<<"全删"<<endl;cout<<endl<<setw(28)<<"0 "<<"返回"<<endl;cin>>choice;system("cls");switch (choice){case '1':cout <<"请输入客户信息:"<<endl;cout << "输入客户编号:";cin >> customerid;cout << "输入客户姓名:";cin >> rname;cout << "输入客户身份证号:";cin >> rID;addcustomer (customerid,rname,rID);break;case '2':cout << "输入客户编号:";cin >> customerid;r=query(customerid);if (r==NULL){cout << " 该客户不存在"<<endl;break;}cout << "输入新的客户姓名:";cin >> rname;r->setname(rname);cout<<"输入新的身份证号码:";cin>>rID;r->setID (rID);break;case '3':cout << "输入客户编号:";cin >> customerid;r=query(customerid);if (r==NULL){cout <<" 该客户不存在" << endl;break;}r->delbook();cout<<"删除成功!"<<endl;break;case '4':char cho;cout<<"请选择查找方式:"<<endl;cout<<"1.按客户编号查找,2.按客户姓名查找";cin>>cho;system("cls");switch (cho){case '1':cout << "输入客户编号:";cin >> customerid;r=query(customerid);if (r==NULL){cout <<" 该客户不存在"<< endl;break;}break;case'2':cout<<"输入客户名字:";cin >> rname;r=query(rname);if (r==NULL){cout<<"该客户不存在"<<endl;break;}}r->display();break;case '5':display();break;case '6':clear();cout<<"删除成功!"<<endl;break;default:cout<<"正在返回主界面...";system("cls");break;}}}//客房类,实现对客房的描述class Book{private:int tag; //删除标记1:已删0:未删int no; //客房编号char name[20]; //客房描述int onshelf; //是否预订1:空房2:已预订public:Book(){}char *getname() { return name; } //获取姓名int getno(){ return no; } //获取客房编号int gettag(){ return tag; } //获取删除标记void setname(char na[]) //设置客房描述{strcpy(name,na);}void delbook(){ tag=1;} //删除客房void addbook(int n,char *na) //增加客房{tag=0;no=n;strcpy(name,na);onshelf=1;}int borrowbook() //预订操作{if (onshelf==1){onshelf=0;return 1;}return 0;}void retbook() //退订操作{onshelf=1;}void disp() //输出客房{cout <<"客房编号:"<< no <<setw(15)<< "客房描述:"<< name <<setw(15)<<(onshelf==1? "空房":"已预订") <<endl;}};//客房库类,实现对客房的管理,如查找、删除等class BDatabase{private:int top; //客房记录指针Book book[Maxb]; //客房记录public:BDatabase() //构造函数,将book.txt读到book[]中{Book b;top=-1;fstream file("book.txt",ios::in);while (1){file.read((char *)&b,sizeof(b));if (!file) break;top++;book[top]=b;}file.close();}void clear() //全删{top=-1;}int addbook(int n,char *na) //增加客房{Book *p=query(n);if (NULL==p){top++;book[top].addbook(n,na);return 1;}return 0;}Book *query(int bookid) //查找客房{for (int i=0;i<=top;i++)if (book[i].getno()==bookid &&book[i].gettag()==0){return &book[i];}return NULL;}Book *query(string bname){for (int i=0;i<=top;i++)if (book[i].getname()==bname&&book[i].gettag()==0){return &book[i];}return NULL;}void bookdata(); //客房库维护void disp(){for (int i=0;i<=top;i++)if (book[i].gettag()==0)book[i].disp();}~BDatabase() //析构函数,将book[]写到book.txt文件中{fstream file("book.txt",ios::out);for (int i=0;i<=top;i++)if (book[i].gettag()==0)file.write((char *)&book[i],sizeof(book[i]));file.close();}};void BDatabase::bookdata(){char choice;char bname[40];int bookid;Book *b;system("cls");while (choice!='0'){cout<<endl<<setw(40)<<"客房信息"<<endl;cout<<endl<<setw(28)<<"1 "<<"新增"<<endl;cout<<endl<<setw(28)<<"2 "<<"更改"<<endl;cout<<endl<<setw(28)<<"3 "<<"删除"<<endl;cout<<endl<<setw(28)<<"4 "<<"查找"<<endl;cout<<endl<<setw(28)<<"5 "<<"显示"<<endl;cout<<endl<<setw(28)<<"6 "<<"全删"<<endl;cout<<endl<<setw(28)<<"0 "<<"返回"<<endl;cin >> choice;system("cls");switch (choice){case '1':cout <<"请输入客房信息:"<<endl;cout << "输入客房编号:";cin >> bookid;cout << "输入客房描述:";cin >> bname;addbook(bookid,bname);break;case '2':cout << "输入客房编号:";cin >> bookid;b=query(bookid);if (b==NULL){cout <<" 该客房不存在"<<endl;break;}cout << "输入新的客房描述:";cin >> bname;b->setname(bname);break;case '3':cout <<"输入客房编号:";cin >> bookid;b=query(bookid);if (b==NULL){cout <<" 该客房不存在" << endl;break;}b->delbook();cout<<"删除成功!"<<endl;break;case '4':char bb;cout << "请选择查找方式:1.按客房编号查找2.按客房描述查找";cin >> bb;switch(bb){case'1':cout<<"请输入客房编号:";cin>>bookid;b=query(bookid);if (b==NULL){cout <<" 该客房不存在"<< endl;break;}break;case'2':cout<<"请输入客房描述:";cin>>bname;b=query(bname);if (b==NULL){cout <<" 该客房不存在"<< endl;break;}}b->disp();break;case '5':disp();break;case '6':clear();cout<<"删除成功!"<<endl;break;default:cout<<"正在返回主界面...";system("cls");}}}int main(){char choice;int bookid,customerid;RDatabase customerDB;customer *r;BDatabase BookDB;Book *b;while(choice!='0'){cout <<setw(39)<<"欢迎使用"<<endl;cout <<endl<<setw(55)<<"酒店客房预订管理系统"<<endl<<endl;cout <<"のののののののののののののののののののののののののののののののののののの"<<endl;cout <<"I"<<setw(71)<<"I";cout <<endl<<"I"<<setw(25)<<"1"<<setw(15)<<"客户信息"<<setw(31)<<"I"<<endl;cout <<"I"<<setw(71)<<"I";cout <<endl<<"I"<<setw(25)<<"2"<<setw(15)<<"客房信息"<<setw(31)<<"I"<<endl;cout <<"I"<<setw(71)<<"I";cout <<endl<<"I"<<setw(25)<<"3"<<setw(15)<<"订房"<<setw(31)<<"I"<<endl;cout <<"I"<<setw(71)<<"I";cout <<endl<<"I"<<setw(25)<<"4"<<setw(15)<<"退房"<<setw(31)<<"I"<<endl;cout <<"I"<<setw(71)<<"I";cout <<endl<<"I"<<setw(25)<<"0"<<setw(15)<<"退出"<<setw(31)<<"I"<<endl;cout <<"のののののののののののののののののののののののののののののののののののの"<<endl;cin >> choice;switch (choice){case '1':customerDB.customerdata();break;case '2':BookDB.bookdata();break;case '3':cout <<"输入客户编号:";cin >>customerid;cout <<"输入客房编号:";cin >>bookid;r=customerDB.query(customerid);//按编号查找if (r==NULL){cout <<" 不存在的客户,不能预订"<< endl;break;}b=BookDB.query(bookid);if (b==NULL){cout <<" 不存在的客房,不能预订"<< endl;break;}if (b->borrowbook()==0){cout << " 该客房已预订,不能预订"<< endl;break;}r->borrowbook(b->getno());cout<<"预订成功!"<<endl;break;case '4':cout<<"输入客户编号:";cin >>customerid;cout << "输入客房编号:";cin >>bookid;r=customerDB.query(customerid);if (r==NULL){cout <<" 不存在的客户,不能退订" << endl;break;}b=BookDB.query(bookid);if (b==NULL){cout <<" 不存在的客房,不能退订" <<endl;break;}b->retbook();r->retbook(b->getno());cout<<"退订成功!"<<endl;break;default:cout<<"正在写入数据库......谢谢使用!";}}return 0;}。