客房管理系统-源代码(可用)

合集下载

酒店管理系统代码(C语言版)

酒店管理系统代码(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]。

宾馆客房管理系统源程序

宾馆客房管理系统源程序
void disp()
{
cout <<"顾客编号:"<<NO<<endl<<"顾客姓名:"<<name<<endl<<"顾客身份ID:"<<ID<<endl<<"入住时间:"<<intime<<endl<<"离开时间:"<<outtime<<endl;
cout<<"所住房间:"<<borroom<<endl;
borroom=roomID;
return;
}
int retroom(int roomID)
{
if(borroom==roomID)
{
borroom=0;
return 1;
}
return 0;
}
{
strcpy(ID,i);
}
void setborroom(char bor)
{
borroom=bor;
}
void setintime(char in)
{
intime=in;
cout<<"已退出";
break;
case 1:
cout << "输入新的姓名:";
cin>>pname;
r->setname(pname);
break;
case 2:

C语言程序设计客房管理系统源码和报告

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语言程序设计源码和报告,实现了基本的客房管理功能,能够实现客房的预订、入住、退房等操作。

客房管理系统C语言实现

客房管理系统C语言实现

客房管理系统包括⽤户登记、客房查询、客户查询、数据统计等功能。

查询功能要实现按房间号、价格、房间标记、⽤户姓名、居⺠身份证等查询。

会员的级别、打折等。

数据统计包括统计某时间段整个酒店的⼊住率、房客信息,分析规律等。

采⽤⽂件进⾏客房信息、客户信息的存储。

#include <stdio.h>#include <string.h>#define MAX_ROOMS 100#define MAX_CUSTOMERS 100struct room {int room_no;int price;char label[20];char status;};struct customer {char name[20];char id[20];char membership[20];float discount;int room_no;char check_in[20];char check_out[20];};struct room rooms[MAX_ROOMS];struct customer customers[MAX_CUSTOMERS];int num_rooms = 0;int num_customers = 0;void add_customer() {printf("请输⼊客户姓名:");scanf("%s", customers[num_customers].name);printf("请输⼊客户身份证号码:");scanf("%s", customers[num_customers].id);printf("请输⼊客户折扣(0-1):");scanf("%f", &customers[num_customers].discount);num_customers++;printf("客户信息已添加。

C语言宾馆管理系统源代码

C语言宾馆管理系统源代码
}
else
{
printf("要删除的话就按1:");
scanf("%d",&i);
if(i==1)
{
q=head;
while(q!=NULL&&q->next!=p)
q=q->next;
q->next=p->next;
}
while(b--)
{
p=(listnode *)malloc(sizeof(listnode));
printf("姓名 性别 证件 入住 天数 房号 标准 价格 预收 押金 离开 备注\n");
printf("**********************************************************************\n");
printf("*******************************************\n");
printf("姓名查找,按1表示查找:");
p=head->next;
scanf("%d",&i);
if(i==1)
{
printf("请输入要查询的姓名:");
scanf("%s",&come);
while(p&&strcmp(p->e,come)<0)
p=p->next;
if(p==NULL||strcmp(p->e,come)>0)

数据库客房管理系统代码

数据库客房管理系统代码

酒店客房管理系统设计一、 需求分析1.1 系统需求分析“客房管理信息系统”以实现宾馆客房各种信息的系统化、规范化、自动化为目标,具 体要达到以下几个基本要求:(一)客户入住管理通过该管理功能,系统可以通过计算机对客户的一些基本信息进行录入,成为客房管理信息系统查询的数据资料。

(1)新客人信息的录入。

(2)客人信息的修改。

(3)客人信息的查询。

(4)客人信息的删除。

(5)客人信息的保存。

(6)客房信息的查询。

(二)结算管理(1)退房结算:输入客户房号,查找该客户信息、住房信息以及费用情况。

(2)收银处理:确认客户总费用,并自动登记总费用帐。

同时,自动将房间用房标志(占)改为(空);并将客户信息保存。

1.2数据分析通过进行系统调查,了解用户需求、分析应用软件系统的功能需求。

总结出了系统逻辑模型,即系统业务流程图、数据流图、应用软件功能结构图和数据字典等。

各流程图如下面的图所示:客房管理系统操作员客房客户操作查询返回信息1.2.1 客房管理系统业务流程图客户操作员返回结果交钱结账结账费用入住登记返回信息返回结果查询要求核对账单返回账单信息入住 管理结算 处理结算账单入住信息客房信息P1P2 D1D2D3要求客房管理系统入住管理 结算管理信息查询客户登记退房结算收银处理1.2.3 客房管理系统功能模块客户查询客房查询1.2.2 客房管理系统数据流图二、数据库概念结构设计经考察和分析,本案例客房管理系统包括以下实体:客户实体、客房实体、操作员实体、退房实体,它们的E-R 图如以下所示。

客户 客户编号 客户姓名年龄性别 身份证号户籍客房号客房类型客房价格 住宿日期住宿时间 离宿日期 离宿时间押金 账单编号 退房 入住登记客房号 客房类型 客房价格客房状态客房 返回退房登记客户编号 客户姓名 身份证号 客房号客房类型客房价格住宿日期住宿时间住宿天数宿费水费电费总额三、数据库逻辑结构设计根据E-R图,将图转换为关系模型即:将实体、实体的属性和实体之间的联系转换为关系模式,然后对数据模型进行优化得到如下关系数据表。

CC客房管理系统含源代码

CC客房管理系统含源代码

C C客房管理系统含源代码The latest revision on November 22, 2020课程设计(论文)说明书题目:简易客房管理系统学院:计算机科学与工程学院专业:计算机科学与技术姓名:学号:指导教师:2014年09月30日目录引言随着我国经济的迅速发展,人们的生活水平有了显着的提高,宾馆酒店业的竞争也愈来愈激烈。

如何在激烈的竞争中生从发展,是每一个宾馆酒店必须面临的问题。

因此,采用全新的计算机网络和宾馆管理系统,已成为提高宾馆的管理效率,改善服务的水准备的重要手段之一。

在某种意义上,宾馆客房管理方面的信息话已成为现代化宾馆的重要标志。

是国家发展必要的软件管理基础。

所以,本着这样的需求。

此次C++语言课程设计我选择的是简易客房管理系统设计,系统设计采用c++语言在microsoftvisualc++下编译而成。

通过本课程设计,使我能更加系统地理解和掌握数据结构的基本概念;能自如地根据实际要求,设计相应的数据结构,并运用C++语言实现所设计的算法,能够利用所学的基本知识和技能,分析和解决简单的程序设计问题,为后续其它课程的学习和应用打下良好基础。

1系统概述客房管理系统具有1.建立数据文件(客房信息文件、住客信息文件)功能;2.具有数据输入功能;3.具有数据修改功能;4.具有数据删除功能;5.能查询(查找)一些基本信息(如按房号查询、按姓名查询、空余客房查询等);6.具有多种统计功能(如、某住客应付多少费用等)本系统开发由分析、设计、实施、调试和测试等阶段组成。

通过一个菜单界面,提示用户进行信息输入输出,提供客房信息录入,客户入住登记,客房信息修改,客房信息删除,退房结算,查询空房,已住房相关信息的功能,并在最后具有通过文件的形式保存客房信息、住客信息的功能。

由此构成一个简单的,供客房工作人员进行客房管理、住客登记、查询一体化的客房管理系统。

2需求分析系统需求根据题目要求,要求对客户信息进行输入、输出等操作;在程序中需要浏览客户的信息,应提供显示、统计、查询、修改等操作;另外还应提供键盘式选择菜单实现功能选择。

宾馆客房系统代码

宾馆客房系统代码

宾馆客房系统代码第一页面中标签控件属性如下: 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('结算费用')。

数据库课程设计程序代码(宾馆客房管理系统)

数据库课程设计程序代码(宾馆客房管理系统)

create database hotelmanager /*创建数据库hotelmanager*/ gouse hotelmanagergocreate table cusinfo /*创建数据表cusinfo*/ (dingname varchar(10) not null,cname varchar(10),cid char(18),vip char(2))gocreate table ordform /*创建数据表ordform*/(ono varchar(36) not null,cname varchar(10) not null,csex char(2),cid char(18),rid char(6) not null,rstyle varchar(10),arrivetime datetime,cno char(10) not null,dingname varchar(10),livetime char(10),dingph char(15) not null,ozt char(4))gocreate table roominfo /*创建数据表roominfo*/(rid char(6) not null,rstyle varchar(10),kfzt char(2) not null)gocreate table liveorder /*创建数据表liveorder*/(lno varchar(36) not null,rid char(6) not null,rstyle varchar(10),btime datetime not null,cno char(10),cname varchar(10) not null,etime datetime,ono varchar(36),lzt char(4) )gocreate table bill /*创建数据表bill*/(bno varchar(36) not null,rid char(6) not null,cname varchar(10),cust money,btime datetime,etime datetime,remarks varchar(40))gocreate table roomsp /*创建数据表roomsp*/(rstyle varchar(10) not null,rprice money)gocreate table hordform /*创建数据表hordform*/(ono varchar(36) not null,cname varchar(10) not null,csex char(2),cid char(18),rid char(6) not null,rstyle varchar(10),arrivetime datetime,cno char(10) not null,dingname varchar(10),livetime char(10),dingph char(15) not null,ozt char(4))gocreate table hliveorder /*创建数据表hliveorder*/(lno varchar(36) not null,rid char(6) not null,rstyle varchar(10),btime datetime not null,cno char(10),cname varchar(10) not null,etime datetime,ono varchar(36),lzt char(4) )goinsert into cusinfo values('mao','zcl','330227************','n') insert into cusinfo values('qxb','zyy','330227************','n') goinsert into roominfo values('2010','s','n')insert into roominfo values('2201','s','n')insert into roominfo values('2301','s','n')insert into roominfo values('3010','s','y')insert into roominfo values('3012','s','n')insert into roominfo values('3015','s','n')insert into roominfo values('4210','d','n')insert into roominfo values('4110','d','n')insert into roominfo values('4010','d','n')insert into roominfo values('5220','d','n')insert into roominfo values('5210','d','n')insert into roominfo values('5201','d','n')goinsert into roomsp values('s',200)insert into roomsp values('d',300)goinsert into ordform values('o0201001','zcl','f','330227************','2301','s','2010-01-02','1','mao','1','883060089','n')goinsert into liveorder values('l2010001','2301','s','2010-01-02','1','zcl','2010-01-03','o0201001','n') insert into liveorder values('l2010002','3010','s','2010-01-03','1','qxb','2010-01-04','o0201002','y') insert into liveorder(lno,rid,rstyle,btime,cno,cname,ono,lzt)values('l2010003','5220','d','2010-01-09','1','myy','o0201003','y')insert into liveorder(lno,rid,rstyle,btime,cno,cname,ono,lzt)values('l2010004','5201','d','2010-01-02','2','zxx',null,'y')goinsert into bill(bno,rid,cname,cust,btime) values('b2010003','5220','myy',0,'2010-01-10')insert into bill(bno,rid,cname,cust,btime) values('b2010004','5201','zxx',0,'2010-01-02')goalter table cusinfo add primary key(dingname)alter table ordform add primary key(ono)alter table roominfo add primary key(rid)alter table liveorder add primary key(lno)alter table bill add primary key(bno)alter table roomsp add primary key(rstyle)gocreate proc ordformproc @lno varchar(36) /*保存入住单*/asbegin tranupdate roominfo set kfzt='y' from roominfo,liveorder where liveorder.rid=roominfo.rid and liveorder.lno=@lno /*修改客房信息*/update ordform set ozt='y' from ordform,liveorder where liveorder.ono=ordform.ono and liveorder.lno=@lno /*修改预订单信息*/insert into hordform select * from ordform where ozt='y' /*将已入住的预订单放入历史*/ delete from ordform where ozt='y' /*清除已入住预订单*/commitgoselect * from roominfoselect * from ordformgoexec ordformproc 'l2010001'exec ordformproc 'l2010004'select * from roominfoselect * from ordformgocreate proc liveorderproc @lno varchar(36) /*收银退房*/asbegin tranupdate liveorder set etime=getdate(),lzt='n' where lno=@lnoupdate roominfo set kfzt='n' from roominfo,liveorder where roominfo.rid=liveorder.rid and liveorder.lno=@lno /*修改客房状态*/insert into hliveorder select * from liveorder where lno=@lno /*导入历史*/delete from liveorder where lno=@lno /*清除入住单*/commitgoselect * from liveorderselect * from hliveordergoexec liveorderproc 'l2010004'goselect * from liveorderselect * from hliveorderselect *from roominfo where rid='5201'gocreate proc billproc @lno varchar(36) /*计算应收款*/asbegin trandeclare @total moneydeclare @datecount intupdate liveorder set etime=getdate() where lno=@lno /*设置离店时间*/select @datecount=datediff(dd,btime,getdate()) from liveorder where lno=@lno /*计算住店天数*/ select @total=0select @total=@datecount*(isnull(rprice,0)) from liveorder,bill,roomspwhere bill.rid=liveorder.rid and liveorder.rstyle=roomsp.rstyle and lno=@lno /*计算住店金额*/ update bill set etime=getdate(),cust=@total from bill,liveorder where bill.rid=liveorder.rid and lno=@lno /*修改账单*/commitgoselect * from liveorderselect * from billgoexec billproc 'l2010004'goselect * from liveorderselect * from bill。

酒店管理系统实现代码

酒店管理系统实现代码

//入住import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.Border;import javax.swing.text.*;public class A1 extends JFrame implements WindowListener {//定义各个组件JFrame frame = new JFrame ("入住系统");JLabel nameLabel = new JLabel("客户姓名");JLabel idtifyLabel = new JLabel("身份证号");JLabel roomLabel = new JLabel("入住房号");JLabel moneyLabel = new JLabel("应付金额");JTextField nameField = new JTextField();JTextField idtifyField= new JTextField();JTextField roomField= new JTextField();JTextField moneyField= new JTextField();JButton button1,button2;/*public static void main(String args[]){A1 a1 = new A1();a1.go();}*/public void go(){UpperCaseDocument ucDocument = new UpperCaseDocument();nameField.setDocument(ucDocument);nameField.setForeground(Color.black);//frame.addWindowListener(this);nameField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String username = nameField.getText();}});JComboBox jcb1;//组合框String[] itemList = { "现金", "刷卡" };jcb1 = new JComboBox(itemList);jcb1.setSelectedIndex(0);button1=new JButton("确认支付");button2=new JButton("取消支付");final JPanel p1 = new JPanel();p1.add(jcb1);p1.add(button1);p1.add(button2);p1.setLayout(new GridLayout(3,1));Border etched = BorderFactory.createEtchedBorder();Border border = BorderFactory.createTitledBorder(etched, "付款方式");p1.setBorder(border);button1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="确认支付"){ JOptionPane.showMessageDialog(p1,"支付成功","success",RMA TION_MESSAGE);}}});button2.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="取消支付"){ JOptionPane.showMessageDialog(p1,"支付失败","failure",RMA TION_MESSAGE);}}});idtifyField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String idtify= idtifyField.getText();String idtifyword= new String(idtify);}});roomField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String room= roomField.getText();String roomword= new String(room);}});moneyField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String money= moneyField.getText();String idtifyword= new String(money);}});//面板labelPanel放标签JPanel labelPanel = new JPanel();labelPanel.setLayout(new GridLayout(4,1));labelPanel.add(nameLabel);labelPanel.add(idtifyLabel);labelPanel.add(roomLabel);labelPanel.add(moneyLabel);//面板fieldPanel放文本框JPanel fieldPanel = new JPanel();fieldPanel.setLayout(new GridLayout(4,1));fieldPanel.add(nameField);fieldPanel.add(idtifyField);fieldPanel.add(roomField);fieldPanel.add( moneyField);//面板northPanel放面板lanelPanel和面板fieldPanelJPanel northPanel = new JPanel();northPanel.setLayout(new GridLayout(1,2));northPanel.add(labelPanel);northPanel.add(fieldPanel);Container cp = frame.getContentPane();cp.add(northPanel,BorderLayout.NORTH);//northPanel放在northcp.add(p1,BorderLayout.SOUTH);frame.setSize(200,250);frame.setVisible(true);}public void windowClosing(WindowEvent e1){System.exit(0);}public void windowOpened(WindowEvent e2){}public void windowIconified(WindowEvent e3){}public void windowDeiconified(WindowEvent e4){}public void windowClosed(WindowEvent e5){}public void windowActivated(WindowEvent e6){}public void windowDeactivated(WindowEvent e7){ }}class UpperCaseDocument extends PlainDocument { public void insertString(int offset,String string, AttributeSet attributeSet)throws BadLocationException{ string = string.toUpperCase();super.insertString(offset,string, attributeSet);}}第二个://退房import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.Border;import javax.swing.text.*;public class A2 extends JFrame {//定义各个组件JFrame frame = new JFrame ("退房系统");JLabel nameLabel = new JLabel("客户姓名");JLabel idtifyLabel = new JLabel("身份证号");JLabel roomLabel = new JLabel("退房号");JLabel timeLabel = new JLabel("退房时间");JTextField nameField = new JTextField();JTextField idtifyField= new JTextField();JTextField roomField= new JTextField();JTextField timeField= new JTextField();JButton button1,button2;//JTextArea ta = new JTextArea(5,20);/*public static void main(String args[]){A2 a2 = new A2();a2.go();}*/public void go(){UpperCaseDocument ucDocument = new UpperCaseDocument();nameField.setDocument(ucDocument);nameField.setForeground(Color.black);nameField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String username = nameField.getText();}});button1=new JButton("是");button2=new JButton("否");final JPanel p1 = new JPanel();p1.add(button1);p1.add(button2);p1.setLayout(new GridLayout(2,1));Border etched = BorderFactory.createEtchedBorder();Border border = BorderFactory.createTitledBorder(etched, "是否结清消费账单");p1.setBorder(border);button1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="是"){ JOptionPane.showMessageDialog(p1,"谢谢您的大力支持!","success",RMA TION_MESSAGE);}}});button2.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="否"){ JOptionPane.showMessageDialog(p1,"请结清消费账单","failure",RMA TION_MESSAGE);}}});idtifyField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String idtify= idtifyField.getText();String idtifyword= new String(idtify);}});roomField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ String room= roomField.getText();String roomword= new String(room);}});timeField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e){ String time= timeField.getText();String timeword= new String(time);}});//面板labelPanel放标签JPanel labelPanel = new JPanel();labelPanel.setLayout(new GridLayout(4,1)); labelPanel.add(nameLabel);labelPanel.add(idtifyLabel);labelPanel.add(roomLabel);labelPanel.add(timeLabel);//面板fieldPanel放文本框JPanel fieldPanel = new JPanel();fieldPanel.setLayout(new GridLayout(4,1)); fieldPanel.add(nameField);fieldPanel.add(idtifyField);fieldPanel.add(roomField);fieldPanel.add( timeField);//面板northPanel放面板lanelPanel和面板fieldPanel JPanel northPanel = new JPanel();northPanel.setLayout(new GridLayout(1,2)); northPanel.add(labelPanel);northPanel.add(fieldPanel);Container cp = frame.getContentPane();cp.add(northPanel,BorderLayout.NORTH);//northPanel放在northcp.add(p1,BorderLayout.SOUTH);// frame.pack();frame.setSize(200,230);frame.setVisible(true);}}class UpperCaseDocument extends PlainDocument{ public void insertString(int offset,String string, AttributeSet attributeSet)throws BadLocationException{ string = string.toUpperCase();super.insertString(offset,string, attributeSet);}}第三个://客房预订import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.Border;import javax.swing.text.*;public class A3 extends JFrame {//定义各个组件JFrame frame = new JFrame ("客房预订");JLabel nameLabel = new JLabel("预订人姓名");JLabel numberLabel = new JLabel("手机号");JTextField nameField = new JTextField();JTextField numberField= new JTextField();JRadioButton rb1 = new JRadioButton("来电预订");JRadioButton rb2 = new JRadioButton("电话预订");JRadioButton rb3 = new JRadioButton("电传预订");JRadioButton rb4 = new JRadioButton("传真预订");JRadioButton rb5 = new JRadioButton("信函预订");JButton button1,button2;/** public static void main(String args[]){A3 a3 = new A3();a3.go();}*/public void go(){UpperCaseDocument ucDocument = new UpperCaseDocument();nameField.setDocument(ucDocument);nameField.setForeground(Color.black);nameField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String username = nameField.getText();}});JComboBox jcb1;//组合框String[] itemList = { "总统套房", "双人间","单人间" };jcb1 = new JComboBox(itemList);jcb1.setSelectedIndex(0);button1=new JButton("是");button2=new JButton("否");final JPanel p1 = new JPanel();p1.add(button1);p1.add(button2);p1.setLayout(new GridLayout(3,1));Border etched = BorderFactory.createEtchedBorder();Border border = BorderFactory.createTitledBorder(etched, "预订房类型"); p1.setBorder(border);button1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="是"){ JOptionPane.showMessageDialog(p1,"客人预订成功","success",RMA TION_MESSAGE);}}});button2.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="否"){ JOptionPane.showMessageDialog(p1,"客人预订失败","failure",RMA TION_MESSAGE);}}});JPanel p2 = new JPanel();p2.add(rb1);p2.add(rb3);p2.add(rb4);p2.add(rb5);p2.setLayout(new FlowLayout());border = BorderFactory.createTitledBorder(etched, "预订方式"); p2.setBorder(border);//创建ButtonGroup按钮组,并在组中添加按钮ButtonGroup group1 = new ButtonGroup();group1.add(rb1);group1.add(rb2);group1.add(rb3);group1.add(rb4);group1.add(rb5);numberField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String number= numberField.getText();String numberword= new String(number);}});//面板labelPanel放标签JPanel labelPanel = new JPanel();labelPanel.setLayout(new GridLayout(2,1));labelPanel.add(nameLabel);labelPanel.add(numberLabel);//面板fieldPanel放文本框JPanel fieldPanel = new JPanel();fieldPanel.setLayout(new GridLayout(2,1));fieldPanel.add(nameField);fieldPanel.add(numberField);//面板northPanel放面板lanelPanel和面板fieldPanelJPanel northPanel = new JPanel();northPanel.setLayout(new GridLayout(1,2));northPanel.add(labelPanel);northPanel.add(fieldPanel);Container cp = frame.getContentPane();cp.add(northPanel,BorderLayout.NORTH);//northPanel放在northcp.add(p2,BorderLayout.CENTER);cp.add(p1,BorderLayout.SOUTH);frame.setSize(200,330);frame.setVisible(true);}}class UpperCaseDocument extends PlainDocument{ public void insertString(int offset,String string, AttributeSet attributeSet)throws BadLocationException{ string = string.toUpperCase();super.insertString(offset,string, attributeSet);}}第四个//餐饮预订import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.Border;import javax.swing.text.*;public class A4 extends JFrame {//定义各个组件JFrame frame = new JFrame ("餐饮预订");JLabel nameLabel = new JLabel("预订人姓名");JLabel timeLabel = new JLabel("预订消费时间");JTextField nameField = new JTextField();JTextField timeField= new JTextField();JCheckBox cb1 = new JCheckBox("中餐");JCheckBox cb2 = new JCheckBox("西餐");JCheckBox cb3 = new JCheckBox("红酒");JCheckBox cb4 = new JCheckBox("饮料");JCheckBox cb5 = new JCheckBox("甜点");JCheckBox cb6 = new JCheckBox("水果");JButton button1,button2;/*public static void main(String args[]){A4 a4 = new A4();a4.go();}*/public void go(){UpperCaseDocument ucDocument = new UpperCaseDocument();nameField.setDocument(ucDocument);nameField.setForeground(Color.black);nameField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String username = nameField.getText();//ta.append("\nUser Name : "+username);}});button1=new JButton("是");button2=new JButton("否");final JPanel p1 = new JPanel();p1.add(button1);p1.add(button2);p1.setLayout(new GridLayout(3,1));Border etched = BorderFactory.createEtchedBorder();Border border = BorderFactory.createTitledBorder(etched, "确认订餐"); p1.setBorder(border);button1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="是"){ JOptionPane.showMessageDialog(p1,"订餐成功","success",RMA TION_MESSAGE);}}});button2.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="否"){ JOptionPane.showMessageDialog(p1,"订餐失败","failure",RMA TION_MESSAGE);}}});timeField.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String time= timeField.getText();String timeword= new String(time);}});JPanel p2 = new JPanel();p2.add(cb1);p2.add(cb2);p2.add(cb3);p2.add(cb4);p2.add(cb5);p2.add(cb6);Border etched1 = BorderFactory.createEtchedBorder();Border border1 = BorderFactory.createTitledBorder(etched1, "预订内容"); p2.setBorder(border1);//面板labelPanel放标签JPanel labelPanel = new JPanel();labelPanel.setLayout(new GridLayout(4,1));labelPanel.add(nameLabel);labelPanel.add(timeLabel);//面板fieldPanel放文本框JPanel fieldPanel = new JPanel();fieldPanel.setLayout(new GridLayout(4,1));fieldPanel.add(nameField);fieldPanel.add(timeField);//面板northPanel放面板lanelPanel和面板fieldPanelJPanel northPanel = new JPanel();northPanel.setLayout(new GridLayout(1,2));northPanel.add(labelPanel);northPanel.add(fieldPanel);Container cp = frame.getContentPane();cp.add(northPanel,BorderLayout.NORTH);//northPanel放在northcp.add(p2,BorderLayout.CENTER);cp.add(p1,BorderLayout.SOUTH);frame.setSize(200,350);frame.setVisible(true);}}class UpperCaseDocument extends PlainDocument{ public void insertString(int offset,String string, AttributeSet attributeSet)throws BadLocationException{ string = string.toUpperCase();super.insertString(offset,string, attributeSet);}}第五个:import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.border.Border;import javax.swing.text.*;public class A5 extends JFrame {//定义各个组件JFrame frame = new JFrame ("订单管理");JLabel a1 = new JLabel("订单号");JLabel a2 = new JLabel("订货名称");JLabel a3 = new JLabel("收货地址");JLabel a4 = new JLabel("应收金额");JLabel a5 = new JLabel("客户名称");JLabel a6 = new JLabel("结算方式");JLabel a7 = new JLabel("经办人");JTextField b1 = new JTextField();JTextField b2= new JTextField();JTextField b3= new JTextField();JTextField b4= new JTextField();JTextField b5 = new JTextField();JTextField b6 = new JTextField();JTextField b7 = new JTextField();JButton button1,button2;public static void main(String args[]){A5 a1 = new A5();a1.go();}public void go(){UpperCaseDocument ucDocument = new UpperCaseDocument();b1.setDocument(ucDocument);b1.setForeground(Color.black);b1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ String username = b1.getText();}});JComboBox jcb1;//组合框String[] itemList = { "现金", "刷卡" };jcb1 = new JComboBox(itemList);jcb1.setSelectedIndex(0);button1=new JButton("确认收款");button2=new JButton("取消收款");final JPanel p1 = new JPanel();p1.add(jcb1);p1.add(button1);p1.add(button2);p1.setLayout(new GridLayout(3,1));Border etched = BorderFactory.createEtchedBorder();Border border = BorderFactory.createTitledBorder(etched, "收款方式"); p1.setBorder(border);button1.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="确认收款"){ JOptionPane.showMessageDialog(p1,"收款成功","success",RMA TION_MESSAGE);}}});button2.addActionListener(new ActionListener(){public void actionPerformed(ActionEvent e){if (e.getActionCommand()=="取消收款"){ JOptionPane.showMessageDialog(p1,"收款失败","failure",RMA TION_MESSAGE);}}});b1.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String idtify= a1.getText();String idtifyword= new String(idtify);}});b2.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String room= a2.getText();String roomword= new String(room);}});b3.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String money= a3.getText();String idtifyword= new String(money);}});b4.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String money= a4.getText();String idtifyword= new String(money);}});b5.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { String money= a5.getText();String idtifyword= new String(money);}});//面板labelPanel放标签JPanel labelPanel = new JPanel();labelPanel.setLayout(new GridLayout(7,1));labelPanel.add(a1);labelPanel.add(a2);labelPanel.add(a3);labelPanel.add(a4);labelPanel.add(a5);labelPanel.add(a6);labelPanel.add(a7);//面板fieldPanel放文本框JPanel fieldPanel = new JPanel();fieldPanel.setLayout(new GridLayout(7,1));fieldPanel.add(b1);fieldPanel.add(b2);fieldPanel.add(b3);fieldPanel.add( b4);fieldPanel.add( b5);fieldPanel.add( b6);fieldPanel.add( b7);//面板northPanel放面板lanelPanel和面板fieldPanel JPanel northPanel = new JPanel();northPanel.setLayout(new GridLayout(1,2));northPanel.add(labelPanel);northPanel.add(fieldPanel);Container cp = frame.getContentPane();cp.add(northPanel,BorderLayout.NORTH);//northPanel放在northcp.add(p1,BorderLayout.SOUTH);frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);frame.setSize(200,250);frame.setVisible(true);}}class UpperCaseDocument extends PlainDocument{ public void insertString(int offset,String string, AttributeSet attributeSet)throws BadLocationException{ string = string.toUpperCase();super.insertString(offset,string, attributeSet);}}第六个:import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.text.*;import javax.swing.border.*;public class F{private JFrame frame;private JButton b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13;JTextArea ta = new JTextArea(20,20);JTextArea tb = new JTextArea(20,20);public static void main(String args[]){F that=new F();that.go();}void go(){frame=new JFrame("客房检查");Container contentPane=frame.getContentPane();JPanel P1=new JPanel();P1.setLayout(new GridLayout());b1=new JButton("101 \n单人间");b2=new JButton("102 \n单人间");b3=new JButton("103 \n单人间");b4=new JButton("104 \n单人间");b5=new JButton("105 \n单人间");b6=new JButton("201 \n双人间");b7=new JButton("202 \n双人间");b8=new JButton("203 \n双人间");b9=new JButton("204 \n双人间");b10=new JButton("205 \n双人间");b11=new JButton("301 \n总统套房");b12=new JButton("302 \n总统套房");b13=new JButton("303 \n总统套房");b1.setBackground(Color.cyan);b2.setBackground(Color.cyan);b3.setBackground(Color.cyan);b4.setBackground(Color.cyan);b5.setBackground(Color.cyan);b6.setBackground(Color.magenta);b7.setBackground(Color.magenta);b8.setBackground(Color.magenta);b9.setBackground(Color.magenta);b10.setBackground(Color.magenta);b11.setBackground(Color.pink);b12.setBackground(Color.pink);b13.setBackground(Color.pink);P1.add(b1);P1.add(b2);P1.add(b3);P1.add(b4);P1.add(b5);P1.add(b6);P1.add(b7);P1.add(b8);P1.add(b9);P1.add(b10);P1.add(b11);P1.add(b12);P1.add(b13);tb.append("房间总数:13");tb.append("\n当前占用:");tb.append("\n当前可供:");P1.add(tb);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="101 \n单人间"){ta.setText("");JFrame frame=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n101房间是否打扫:");ta.append("\n101房间里是否有家具损坏:");ta.append("\n101房间是否交足余额:");JButton a=new JButton("提交");p2.add(a);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="提交"){JOptionPane.showMessageDialog(ta,"提交成功",null,RMA TION_MESSAGE);}}};a.addActionListener(al);p2.add(ta);p2.setBackground(Color.yellow);frame.setContentPane(p2);frame.pack();frame.setVisible(true);}else if(e.getActionCommand()=="102 \n单人间"){ta.setText("");JFrame frame=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n102房间是否打扫:");ta.append("\n102房间里是否有家具损坏:");ta.append("\n102房间是否交足余额:");JButton a=new JButton("提交");p2.add(a);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="提交"){JOptionPane.showMessageDialog(ta,"提交成功",null,RMA TION_MESSAGE);}}};a.addActionListener(al);p2.add(ta);p2.setBackground(Color.yellow);frame.setContentPane(p2);frame.pack();frame.setVisible(true);}else if(e.getActionCommand()=="103 \n单人间"){ta.setText("");JFrame frame=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n103房间是否打扫:");ta.append("\n103房间里是否有家具损坏:");ta.append("\n103房间是否交足余额:");JButton a=new JButton("提交");p2.add(a);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="提交"){JOptionPane.showMessageDialog(ta,"提交成功",null,RMA TION_MESSAGE);}}};a.addActionListener(al);p2.add(ta);p2.setBackground(Color.yellow);frame.setContentPane(p2);frame.pack();frame.setVisible(true);}else if(e.getActionCommand()=="104 \n单人间"){ta.setText("");JFrame frame=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n104房间是否打扫:");ta.append("\n104房间里是否有家具损坏:");ta.append("\n104房间是否交足余额:");JButton a=new JButton("提交");p2.add(a);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="提交"){JOptionPane.showMessageDialog(ta,"提交成功",null,RMA TION_MESSAGE);}}};a.addActionListener(al);p2.add(ta);p2.setBackground(Color.yellow);frame.setContentPane(p2);frame.pack();frame.setVisible(true);}else if(e.getActionCommand()=="105 \n单人间"){ta.setText("");JFrame frame=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n105房间是否打扫:");ta.append("\n105房间里是否有家具损坏:");ta.append("\n105房间是否交足余额:");JButton a=new JButton("提交");p2.add(a);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="提交"){JOptionPane.showMessageDialog(ta,"提交成功",null,RMA TION_MESSAGE);}}};a.addActionListener(al);p2.add(ta);p2.setBackground(Color.yellow);frame.setContentPane(p2);frame.pack();frame.setVisible(true);}else if(e.getActionCommand()=="201 \n双人间"){ta.setText("");JFrame frame1=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n201房间是否打扫:");ta.append("\n201房间里是否有家具损坏:");ta.append("\n201房间是否交足余额:");JButton a=new JButton("提交");p2.add(a);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="提交"){JOptionPane.showMessageDialog(ta,"提交成功",null,RMA TION_MESSAGE);}}};a.addActionListener(al);p2.add(ta);p2.setBackground(Color.cyan);frame1.setContentPane(p2);frame1.pack();frame1.setVisible(true);}else if(e.getActionCommand()=="202 \n双人间"){ta.setText("");JFrame frame2=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n202房间是否打扫:");ta.append("\n202房间里是否有家具损坏:");ta.append("\n202房间是否交足余额:");JButton a=new JButton("提交");p2.add(a);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="提交"){JOptionPane.showMessageDialog(ta,"提交成功",null,RMA TION_MESSAGE);}}};a.addActionListener(al);p2.add(ta);p2.setBackground(Color.cyan);frame2.setContentPane(p2);frame2.pack();frame2.setVisible(true);}else if(e.getActionCommand()=="203 \n双人间"){ta.setText("");JFrame frame=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n203房间是否打扫:");ta.append("\n203房间里是否有家具损坏:");ta.append("\n203房间是否交足余额:");JButton a=new JButton("提交");p2.add(a);ActionListener al=new ActionListener(){public void actionPerformed(ActionEvent e){if(e.getActionCommand()=="提交"){JOptionPane.showMessageDialog(ta,"提交成功",null,RMA TION_MESSAGE);}}};a.addActionListener(al);p2.add(ta);p2.setBackground(Color.cyan);frame.setContentPane(p2);frame.pack();frame.setVisible(true);}else if(e.getActionCommand()=="204 \n双人间"){ta.setText("");JFrame frame=new JFrame("检查信息");JPanel p2=new JPanel();Container cp=frame.getContentPane();ta.append("\n204房间是否打扫:");ta.append("\n204房间里是否有家具损坏:");。

C语言程序设计客房管理系统源码和报告精编版

C语言程序设计客房管理系统源码和报告精编版

C语言程序设计客房管理系统源码和报告公司内部编号:(GOOD-TMMT-MMUT-UUPTY-UUYY-DTTI-《C语言程序设计》综合实验报告一、需求分析编写一个客房管理系统,提供键盘式菜单实现功能选择,功能包括:用户登记、统计、查询和用户信息修改。

软件平台:CODEBLOCKS二、整体设计整个客房管理系统被设计为用户登记模块、统计模块、查询模块和修改模块。

数据以TXT格式存储,支持保存信息。

三、详细设计(1通过函数添加信息到txt。

是(2)统计模块读取txt信息到结构体数组room,提示用户选择统计方式,设置计数器,顺序遍历Room数组,1、计数器记录数组数,即总客房数2、判断每一个数组中的结构体的时间是否和需要查询的日期相同,若相同,计数器加一(3)查询模块调用readfile 函数,将信息读入room结构体数组中,提示用户选择查询方式,通过基本查找算法查找Room 数组。

可以按房间号、价格、房间标记、用户姓名、居民身份证查询。

(4)修改模块调用readfile 函数,读取信息到room 结构体数组,提示用户输入需要修改的房间号,采用基本查找算法在数组中找到要修改的数据,提示用户重新更改房间信息,最后将结构体数组重新写入文件保存。

四、源代码#include <stdio.h>#include <stdlib.h>#include <string.h>选择统计方式 2、按时间统计 1、统计总客房数 遍历每一个结构判断是否和要调用打印函数,是 遍历每一个结构调用readfile (读取文件函判断是否是用户输入需要查询的房修改结构体j 调用saveall 函调用readfile 函数,读读取信息#define M 80//客户结构体typedef struct client{char name[12]; //姓名int sex; //性别int age; //年龄char id[20]; //身份证号int year; //入住时间int month;int date;}CLIENT;//客房结构体struct Hotel{int roomid;int tel; //用户的话int price; //价格int sign; //默认标记为空房间 CLIENT client_list; //客户信息}room[M];void Menu(); //目录界面void dengji(struct Hotel room[]);void savefile(struct Hotel room[],int i);int readfile(struct Hotel room[]);void tongji(struct Hotel room[]);void chaxun(struct Hotel room[]);void printmessage(struct Hotel room[],int n); void xiugai(struct Hotel room[]);//主函数int main(){int n;char reply;Menu();do{printf("请输入选项对应的数字:\n");scanf("%d",&n);while(n!=1&&n!=2&&n!=3&&n!=4){printf("请输入各选项对应的数字!\n"); scanf("%d",&n);}switch (n){case 1:dengji(room);break;case 2:tongji(room);break;case 3:chaxun(room);break;case 4:xiugai(room);break;}printf("是否还要进入其它选项(回复Y或y继续)\n"); scanf(" %c",&reply);}while (reply=='y'||reply=='Y');return 0;}//系统目录void Menu(){printf("************************客房管理系统***************************\n");printf( "\t\t\t 1————登记\n" );printf( "\t\t\t 2————统计\n" );printf( "\t\t\t 3————查询\n" );printf( "\t\t\t 4————修改\n" );printf("******************************************************* ********\n");}//登记客户信息void dengji(struct Hotel room[]){int x,j,i,flag;char answer;do{i=readfile(room);do{flag=0;printf("输入您想入住的房间号:(三位数)\n"); scanf("%3d",&x);for(j=0;j<i;j++){if(room[j].roomid==x){printf("该房间已经被占用!\n");flag=1;}}}while(flag>0);room[i+1].roomid=x;printf("请输入您的电话:(仅支持六位数号码~)\n"); scanf("%d",&room[i+1].tel);printf("入住价格\n");scanf("%d",&room[i+1].price);printf("请输入您的名字\n");scanf("%s",room[i+1].client_);printf("性别:(1表示女,0表示男)\n");scanf("%d",&room[i+1].client_list.sex);printf("您的年龄:\n");scanf("%d",&room[i+1].client_list.age);printf("您的id:\n");scanf("%s",room[i+1].client_list.id);printf( "请输入入住年月日(格式:2015 11 11)\n");scanf("%4d%2d%2d",&room[i+1].client_list.year,&room[i+1].client _list.month,&room[i+1].client_list.date);savefile(room,i+1);printf("是否还要继续登记(回复Y或y继续)\n");scanf(" %c",&answer);}while(answer=='Y'||answer=='y');}//读取txt中的信息int readfile(struct Hotel room[]){FILE *fp;int i;if((fp=fopen("room.txt","r"))==NULL){printf("Failure to open score.txt!\n");exit(0);}for (i=0;!feof(fp);i++){fscanf(fp,"%5d",&room[i].roomid);fscanf(fp,"%6d",&room[i].price);fscanf(fp,"%15d",&room[i].tel);fscanf(fp,"%12s",room[i].client_); fscanf(fp,"%4d",&room[i].client_list.sex); fscanf(fp,"%6d",&room[i].client_list.age); fscanf(fp,"%20s",room[i].client_list.id);fscanf(fp,"%7d",&room[i].client_list.year); fscanf(fp,"%5d",&room[i].client_list.month); fscanf(fp,"%5d",&room[i].client_list.date); }fclose(fp);return i;}//保存结构体数组信息到文件void savefile(struct Hotel room[],int i){FILE *fp;if((fp = fopen("room.txt","a"))==NULL){printf("Failure to open score.txt!\n");exit(0);}fprintf(fp,"%5d%6d%15d%12s%4d%6d%20s%7d%5d%5d",room[i].roomid,room[i].price,room[i].tel,room[i].client_,room[i].client_list.sex,room[i].client_list.age,room[i].client_list.id,room[i].client_list.year,room[i].client_list.month,room[i].client_list.date);fclose(fp);}//统计模块void tongji(struct Hotel room[]){int n,x;int year,month,day,j,count=0;x=readfile(room);printf("请选择统计方式:1>统计房客数,2>统计某一天的房客数\n");scanf("%d",&n);switch (n){case 1:printf("客房总数为:%d\n",x);break;case 2:printf("请输入具体时间:\n");scanf("%d%d%d",&year,&month,&day);for(j=0;j<x;j++){if(room[j].client_list.year==year&&room[j].client_list.month==m onth&&room[j].client_list.date==day){count++;}}printf("%d年%d月%d号的房客数为%d",year,month,day,count);}}//查询模块void chaxun(struct Hotel room[]){int n,x,roomid,price,j;char name[12],id[20];x=readfile(room);printf("按房间号查询请按1;按价格查询请按2;按用户姓名查询请按3;按身份证号码查询请按4\n");scanf("%d",&n);switch(n){case 1:printf("请输入房间号:\n");scanf("%d",&roomid);for(j=0;j<x;j++){if(room[j].roomid==roomid){print(room,j);}}break;case 2:printf("请输入价格:\n");scanf("%d",&price);for(j=0;j<x;j++){if(room[j].price==price){print(room,j);}}break;case 3:printf("请输入客户姓名:\n");scanf("%s",name);for(j=0;j<x;j++){if(strcmp(room[j].client_,name)==0) {print(room,j);}}break;case 4:printf("请输入身份证号码:\n");scanf("%s",id);for(j=0;j<x;j++){if(strcmp(room[j].client_list.id,id)==0) {print(room,j);}}}}//打印void print(struct Hotel room[],int j){printf("%5d%6d%15d%12s%4d%6d%20s%7d%5d%5d\n",room[j].roomid,room[j].price,room[j].tel,room[j].client_,room[j].client_list.sex,room[j].client_list.age,room[j].client_list.id,room[j].client_list.year,room[j].client_list.month,room[j].client_list.date);}void printmessage(struct Hotel room[],int n){int j;for(j=0;j<n;j++){printf("%5d%6d%15d%12s%4d%6d%20s%7d%5d%5d\n", room[j].roomid,room[j].price,room[j].tel,room[j].client_,room[j].client_list.sex,room[j].client_list.age,room[j].client_list.id,room[j].client_list.year,room[j].client_list.month,room[j].client_list.date);}}//修改模块void xiugai(struct Hotel room[]){int i, m, roomid;m = readfile(room);printf("请选择房间号:\n");scanf("%d",&roomid);for(i=0;i<m;i++){if(room[i].roomid==roomid){printf("请输入您的电话:\n");scanf("%d",&room[i].tel);printf("入住价格\n");scanf("%d",&room[i].price);printf("请输入您的名字\n");scanf("%s",room[i].client_);printf("性别:\n");scanf("%d",&room[i].client_list.sex);printf("您的年龄:\n");scanf("%d",&room[i].client_list.age);printf("您的id:\n");scanf("%s",room[i].client_list.id);scanf("%4d%2d%2d",&room[i].client_list.year,&room[i].client_lis t.month,&room[i].client_list.date);}}saveall(room,m);}//保存所有信息到txt文件void saveall(struct Hotel room[],int m){int j;FILE *fp;if((fp = fopen("room.txt","w"))==NULL){printf("Failure to open score.txt!\n");exit(0);}for(j=0;j<m;j++){fprintf(fp,"%5d%6d%15d%12s%4d%6d%20s%7d%5d%5d",room[j].roomid,room[j].price,room[j].tel,room[j].client_,Room[j].client_list.sex,room[j].client_list.age,room[j].client_list.id,room[j].client_list.year,room[j].client_list.month,room[j].client_list.date);}fclose(fp);}五、调试与测试主界面:1、登记功能测试:情况1:客户需要入住的房间号被占用,提示已经被占用,重新选择情况2:选择的房间没有被占用,提示用户输入登记信息,登记完成后系统后台执行保存,弹出窗口询问是否继续登记下一个顾客2、统计功能测试:情况1:选择统计客房总数,系统返回总客房数情况2:选择按日期统计,系统返回具体某天的客房总数3、查询功能测试:情况1:按房间号查询情况2:按价格查询情况3:按用户名查询情况4:按身份证号查询4、修改功能测试:输入需要修改的房间后,系统提示用户重新写入房间信息六、总结本程序可通过键盘选择目录对应的功能,提供登记、查询、统计、修改四大功能。

酒店管理系统代码

酒店管理系统代码

结 构 定 义typedef struct Checkininformation// -------------------------------------- 枚举类型 ---------------------------------enum{MainUI, HotellnfoUI, CheckinUI, CheckinResultUI, OrderUI, CheckOutUI, Exit};//GUI enum {Single, Double, Big};//Room Typeenum {Hour, Day);//countType#include <windows.h> ^include <dos ・ h> #include<stdio. h> #include<stdlib ・ h> #include<time ・ h>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 *checkinlnfo; long date; Room * room; }Order;typedef struct Hotelinfomation {int checkinAmount; int singleRemainAmount; int doubleRemainAmount: int bigRemainAmount; /Hotelinfo;//房型 〃房号 //入住情况//房价//入住信息//入住时间//房间信息//已入住房数//单人房剩余房数 //双人房剩余房数 //大床房剩余房数全局变量int GUI = MainUI;Order* orderList [lOOj ; //订单数组Room* roomList E100]; //房间数组Hot el Info * hotel Info 二NULL;//酒店房间信息/ ———————————————I j jij j—————void initiallizeRoomList();void insertToOrderList(Order * order);Room* getRoomB^^Type (int roomType);Order* getOrderByRoomNum(int roomNum);void showMainUI0;void showHotellnfoUI0 ;void shou€heckinUI0;void shou€heckinResultUI0 :void showOrderUI0;void shou€heckOutUI0;-Main函数-----------void mainO//主函数//初始化酒店房间信息hotelinfo = (Hotelinfo *)malloc(sizeof(Hotelinfo));hotelinfo -> singleRemainAmount = 20; hotelinfo -> doubleRemainAmount=40;hotelinfo -> bigRemainAmount=40; hotelinfo -> checkinAmount^O;〃初始化房间列表initiallizeRoomList 0;//界而显示while(GUI != Exit){switch(GUI){case MainUI: showMainUI0; break;case HotellnfoUI: showHotellnfoUI0; break;case CheckinUI: showCheckinUI(); break;case CheckinResultUI: showCheckinResultUI0; break;case OrderUI: showOrderUI0; break;case CheckOutUI: showCheckOutUI0; break;default: break;}}}MMV MM W W 丿» MHK «■■■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+l;roomLi st[i]->roomType=S ingle;}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; roomLi st[i]->roomType=Double;}for(i=60;i<100;i++) //大床房房间信息初始化{newRoom = ( Room* )malloc(sizeof(Room));roomList[i] = newRoom;roomList[i]->checked=O;roomList[i]->price=180;roomList[i]->roomNum= i+1;roomLi s t[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=l;hotelInfo->singleRemainAmount — ;hotelInfo->checkinAmount++;return roomList[i];}}break;case Double:for(i=20;i<60;i++){if ( roomList[i]->checked == 0){roomList[i]->checked=l;hotelInfo->doubleRemainAmount — ; hotelInfo->checkinAmount++;return roomList[i];}break;case Big:for (i=60;i<100;i++){if ( roomList[i]->checked == 0){roomList[i]->checked=l; hot e11nfo->b i gRema i nAmount --;hotelInfo->checkinAmount++; return roomList[i];}}break;}}//将订单放入订单列表}void insertToOrderList(Order * order){int i;for( i = 0;i<100;i++){if( orderListEi] =NULL ){orderList"i] = order; break;}}}〃通过房号查询订单Order* getOrderByRoomNum(int roomNum){int i;for(i=0;i<100;i++)if( orderListli]->room->roomNum = roomNum)}return orderListLi ]; void showMainUI0 {//显示主界而,并接受输入 int chooseNum;system(〃cls");printf("\n\n 二============酒店房间登记与计费管理管理系统 二=========\t\n\n\n");入住登记 \t\t\t\t*\n"); 査询入住情况\t\t\t*\n ?,); 査询当前费用\t\t\t*\n"); 结账退房 \t\t\t\t*\n z ,);退出程序 \t\t\t\t*\n\n\n zz );printf C\n\n 二=============酒店房间登记与计费管理管理系统 二=========\t\n\n\n");printf C 请输入相应编号进入菜单\T);//接受输入scanf (〃%d : &chooseNum); switch(chooseNum) { case 1:GUI = HotelInfoUI; break; case 2:GUI = HotellnfoUI; break; case 3:GUI = OrderUI; break; case 4:GUI = OrderUI; break; case 5:Sleep(3000); GUI = Exit; break;printf (“*\t\t\t\tl. printf (,z *\t\t\t\t2.printf (,z *\t\t\t\t3. printf (“*\t\t\t\t4. printf (“*\t\t\t\t5.default:break;}} void showHotellnfoUI0int chooseNum;systemC'cls'7);printf("\n\n二============洒店入住情况査询菜单============\t\n\n\n\n");printf (,z*\t\t\t 入住房间数:%d\t\t\t\t*\n z\ hotel Inf o->checkinAmount);printf (”*\t\t\t 剩余房间数:\t");printf C单人房:%d\t\t*\n v, hotel Inf o->singleRemainAmount);printf (,z*\t\t\t\t\t 双人房:%d\t\t*\n?z, hote 1 Info->doub 1 eRemainAmount);printf 大床房:%d\t\t*\n\n/z, hotel Inf o->bigRema inAmount);printf ("\n\n二============洒店入住情况査询菜单=====================\t\n\n\n/z);printf C按0 :返回\n");printf (,z按1 :登记入住\n");scanf&chooseNum);switch(chooseNum){case 0:GUI = MainUI;break;case 1:GUI = CheckinUI;break;default:GUI = HotellnfoUI; break;}}void showCheckinUI(){Order * newOrder;Room* newRoom = NULL;〃填写一个新的入住信息Checkininfo * newCheckinlnfo = NULL;int roomTypeNum; int countTypeNum;system(,/cls/,);printf("\n\n 二=============酒店入住登记菜单newCheckinlnfo = ( Checkininfo * 〉malloc(sizeof(Checkininfo)); printfC*\t\t 请输入姓名:");scanf C?%s,z, &(newCheckinInfo->name));printf (”*\t\t请输入证件号:”);scanf (,z%d/z, &(newCheckinInfo->id));printf (”*\t\t请选择入住房型:\n");printfC\t\t\tl.单人房\n\t\t\t2.双人房\n\t\t\t3.大床房\n"); scanf&(roomTypeNum));switch (roomTyp eNum) //通过输入的数字对应房型{case 1:newCheckinInfo->roomType = Single;break;case 2:newCheckinInfo->roomType = Double;break;case 3:newCheckinInfo->roomType = Big;break;default:newCheckinInfo->roomType = Single;break;}printf (**\t\t请选择计费方式:\n");printf ("\t\t\tl.按小时计费;\n\t\t\t2.按天数计费\n"); //通过输入的数字对应计费方式scanf (,z%d,z, &countTy^peNum);switch(countTypeNum){case 1:newCheckinInfo->countType = Hour;break;case 2:newCheckinlnfo^countT^e = Day; break;}printf (〃\n\n 二============二二酒店二=============\t\n\n\n");〃生成一个新的订单newOrder = ( Order* )malloc(sizeof(Order)); newOrder ->checkininfo = neu^heckinlnfo; newOrder -> date = time(O);switch (newCheckinlnfo-^oomT^e){case Single:newRoom = getRoomByType(Single): break;case Double:newRoom=getRoomByType (Double); break;case Big :newRoom=getRoomByType(Big);break;}newOrder->room = newRoom; insertToOrderList(newOrder);printf ("房间号为:%d\n", newOrder->roonr->roomNum); GUI = CheckinResultUI;} void shou€heckinResultUI0{int chooseNum;printf (〃\n\n 二============ 洒店入=============\t\n\n\n");printf (z/\t\t\t************\t\t\t\t\n,z);printf (/z\t\t\t* 登记成功*\t\t\t\t\n*);printf (z/\t\t\t************\t\t\t\t\n\n,');printf (〃\n\n 二============ 洒店入=========\t\n\n\n〃);printf C按0 :返回\n"); scanf(“%d: &chooseNum);switch(chooseNum){case 0:GUI = MainUI;break;default:GUI = CheckinResultUI; break; 入住登记菜单//通过房型获取房间住登记确认菜单住登记确认菜单}}void showOrderUI(){int roomNum;int chooseNum;int amount;Order * theOrder = NULL;system("cls");printf r\n\n===================洒店房间信息査询菜单=====================\t\n\n\n/z);printf ("请输入房间号:");scanf(〃%d: &roomNum);if (roomNum<0 roomNum>100){printf (/z\n输入有误谙重新输入”);GUI = OrderUI;}else{theOrder = getOrderByRoomNum(roomNum);printfC房型:”);switch(theOrder->room->roomType){case Single:printf 单人房\n");break;case Double:printf 双人房\n"); break:case Big:printf 大床房\n");break;}printf (/z计费方式:”);switch(theOrder->checkinInfo->countType ) case Hour:printf (*小时计费\n");amount = (time(O) - theOrder->date) / 3600 +1;printf C已入住时间:%d 小时amount); break;case Day:printf (* 天计费\n");amount = (time(0) - theOrder->date) / (3600*24) +1;printf C已入住时间:%d 天\(;amount); break;}printf ("房价:%d\n", the0rder->room->price);printf ("应支付:%d\n\n?,, amount * the0rder->room->price);printf r\n\n===================酒店房间信息查询菜单============\t\n\n\n");printf C按0:返回\n");printfC按]:结账退房\n");scanf("Ed", &chooseNum);switch(chooseNum){case 0:GUI = MainUI;break;case 1:GUI 二CheckOutUI;break;default:break;}}}void shou€heckOutUI (){int chooseNum;printf ("\n\n二============洒店结账退房确认菜单=============\t\n\n\n");printf(〃\t\t\t\t************\t\t\t\t\n");printf (z/\t\t\t\t* 结账成功*\t\t\t\t\n");printf(〃\t\t\t\t************\t\t\t\t\n\n");printf ("\n\n二============洒店结账退房确认菜单=========\t\n\n\n");printf C?按0:返回”); scanf (,z%d,z, &chooseNum);swi tch (chooseNum){case 0:GUI = MainUI;break;default:GUI = CheckOutUI;break;}}感谢您的支持与配合,我们会努力把内容做得更好!。

基于JAVA的客房管理系统设计(有源代码+数据库)

基于JAVA的客房管理系统设计(有源代码+数据库)

计算机软件学专业课程设计报告书课程名称SQL server 2000课程设计题目客房管理系统1概述1.1背景客房管理是旅店管理事务中的一项重要工作,在管理过程中涉及到大量的数据处理,传统的人工管理已经无法完成胜任。

相关数据的处理带来了更大的工作量。

本系统采用目前比较流行的JDBC-ODBC数据访问技术,成功地将面向对象的程序设计思想应用到数据库应用程序设计中。

1.2开发与运行环境本客房管理系统的开发与运行环境如下:开发环境:Eclipse 3.1开发工具:JAVA 1.5数据库管理系统:SQL Server 2000运行环境:Windows 2000/XP/2003/Vista使用说明:用户自己附加数据库,并且在控制面板下的数据工具中的数据源(ODBC),在用户DSN下添加名为“客房管理”,驱动程序为SQL-Server。

并且安装了JAVA虚拟机,该程序即可使用。

2需求分析客房资管理系统涉及到:客人信息、客房信息、入住信息、历史信息等多种数据信息。

客房管理系统的用户包括系统管理员。

系统管理员负责整理工作,如各种基本信息的添加、删除和简单的结账计算等操作。

本系统的主要功能包括:客人信息管理:客人信息数据的添加、删除、结账计算。

数据查询:查看客人信息数据,查看客房信息数据。

数据统计:统计一段时间的客房情况和月收入等基本统计。

3系统设计3.1系统模块设计根据系统功能分析和一些旅店客房管理的特点,经过模块化的分析得到如下图所示的系统功能模块结构图。

系统功能模块结构图3.2数据库设计3.2.1数据流图顶层数据流图第0层数据流图3.2.2数据字典根据系统功能模块结构图及典型旅店客房管理系统的需求,总结出来如下的数据字典:(1)数据项说明数据项名称含义说明类型长度记录编号惟一标识一条记录bigint 8客房编号惟一标识一间客房varchar 10离店时间标识离店时间datetime 8 金额标识所收金额money 8类别标识客房类别smallint 2(2)数据流说明(3)数据存储说明(4)处理过程说明处理过程名称:审核登陆输入:编号+密码输出:确认加工逻辑:根据编号和密码管理员,进入主窗体。

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

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

#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;}。

酒店客房管理系统设计VB程序源代码

酒店客房管理系统设计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 "请输入一个日期型数据。

客房管理系统源代码

客房管理系统源代码

#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<<"已取消添加。

酒店客房管理系统源程式

酒店客房管理系统源程式

酒店客房管理系统源程式酒店客房管理系统程式如下:(1)使用t—sql语句建立超市商品管理系统资料库。

create database 酒店客房管理系统on(name = 酒店客房管理系统,filename = ‘d:\10——丁小玲\酒店客房管理系统.mdf’,size = 10mb,maxsize = 100mb,filegrowth = 10%)log on(name = 酒店客房管理系统_log,filename = ‘d:\10——丁小玲\酒店客房管理系统.ldf’,size = 5mb,maxsize = 50mb,filegrowth = 1%);(2)使用t—sql语句建立库存表。

--1建立使用者资讯表use 酒店客房管理系统create table usersinfo( useid varchar(20) primary key,name varchar(20),upassword varchar(20),*** varchar(2),email varchar(20),uaddress varchar(20),telephone varchar(20),department varchar(20),utype int --1代表酒店管理员,代表前台服务员);--2建立客户资讯表use 酒店客房管理系统create table customersinfo( cidentityid varchar(30) primary key,**ame varchar(20),cphone varchar(20));--3建立客房型别表use 酒店客房管理系统create table roomcategory( rcategoryid varchar(20) primary key,name varchar(10),area real,bednum int,price numeric(7,2),aircondition varchar(10),tv varchar(10));--4建立客房资讯表use 酒店客房管理系统create table roomsinfo( roomid varchar(20)primary key,rcategoryid varchar(20)not null,rpostition varchar(50),eescription varchar(50));--5建立客房状态表use 酒店客房管理系统create table roomstatus( roomid varchar(20) primary key,rstatus int, --1有人,空房foreign key (roomid) references roomsinfo(roomid) );--6建立客房业务表,用于查询现在在酒店居住的客户 use 酒店客房管理系统create table roomservice( roomid varchar(20) primary key,cidentityid varchar(30) not null);--7建立业务记录表use 酒店客房管理系统create table history( begintime date,endtime date,roomid varchar(20),totalprice numeric(10,2),cidentityid varchar(30),**ame varchar(20),cphone varchar(20)primary key(begintime,roomid,cidentityid));(3)使用t—sql语句建立库存检视。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

// 酒店客房管理课设源代码#include<stdio.h>#include<string.h> //在使用中要用到的字符串都包含在本文件中#include<stdlib.h> //exit()函数就包含在此文件中#define M 81int z[81]={0}; //定义一个数组存放使用的房间的标记的信息,且初始化为0int j,s; //定义两个全局变量FILE *fp; //定义一个指向文件的指针变量struct date{int month;int day;int year;}final;struct hotel{int price;int room_ID;struct client{char name[20];int sex;int age;char ID_card[20];int count;struct date start;}personal;}room[M]; //定义全局结构体变量,且里面又调用两个结构体//int fflush( fp); //声明刷新函数fflush( fp),且指向指针变量指向的位置void save();void search_situ( ); //声明查看客房入住情况函数void regist_infor( ); //声明客房登记入住函数void modify_infor( ); //声明客房信息修改函数函数void modify_one( ); //声明修改客房信息函数中的修改个人函数void modify_hotel( ); //声明修改客房信息函数中的修改客房函数void disp_money( ); //声明显示入住费用函数int main(){int menu(); //声明主菜单函数void print_star();void print_message();printf("\n\n\n\n\n");print_star();printf("\n");print_message();printf("\n");print_star();menu(); //把主菜单用函数来实现save();return 0;}void print_star(){int i;for(i=1;i<30;i++)printf("\t*");}void print_message(){printf("\t\t\t\t欢迎使用客房管理系统\n");}int menu(){int n;do{printf("\n");printf("\t\t********************酒店客房管理系统*******************\n\n\n");printf("\t\t\t\t1:查看客房入住情况\n\n\n");printf("\t\t\t\t2:登记入住信息\n\n\n");printf("\t\t\t\t3:修改客房信息\n\n\n");printf("\t\t\t\t4:显示入住费用\n\n\n");printf("\t\t\t\t5:退出\n\n\n");printf("\t\t\t\t6:返回\n\n\n");printf("\t\t*********************菜单********************\n");printf("\n\n\t\t\t 请选择输入选项[1\\2\\3\\4\\5\\6]:\n");scanf("%d",&n);while(n<1||n>6){printf("请重新输入选项!");scanf("%d",&n);}switch(n){case 1:search_situ();break; //调用查看函数case 2:regist_infor();break; //调用登记函数case 3:modify_infor();break; //调用修改函数case 4:disp_money();break; //调用显示入住费用函数case 5:exit(0);case 6:break;}}while(n!=6);scanf("%d",&n);return 0;}void search_situ( ) //查看函数{int g,count=0;for(g=1;g<=80;g++){if(z[g]==0)++count;elseif(z[g]==1)printf("\n正在使用的房间号:%d",g);}printf("\n\n未使用的房间数:%d",count); //通过循环输出未使用的房间数printf("\n\n");printf("\n请输入需查询的房间号:\n"); //查询输入的房间号的信息,且输出该房间的相关信息scanf("%d",&s);if(z[s]==1){printf("姓名:%s",room[s]);printf("\n性别(其中:1表示男,2表示女!):%d",room[s].personal.sex);printf("\n年龄:%d",room[s].personal.age);printf("\n身份证号:%s",room[s].personal.ID_card);printf("\n入住年份:%d",room[s].personal.start.year);printf("月:%d",room[s].personal.start.month);printf("日:%d",room[s].personal.start.day);printf("\n房间号:%d",room[s].room_ID);printf("\n客房单价:%d",room[s].price);printf("\n入住人数:%d",room[s].personal.count);menu();}elseprintf("该房间未被使用!");save(); //调用保存函数}void regist_infor( ) // 登记函数{printf("请输入登记相关信息:\n");printf("\n房间号:");scanf("%d",&j);room[j].room_ID=j;printf("\n姓名:");scanf("%s",&room[j]);printf("\n性别(其中:1表示男,2表示女!):");scanf("%d",&room[j].personal.sex);printf("\n年龄:");scanf("%d",&room[j].personal.age);printf("\n身份证号:");scanf("%s",&room[j].personal.ID_card);printf("\n入住年份:");scanf("%d",&room[j].personal.start.year);printf("月:");scanf("%d",&room[j].personal.start.month);printf("日:");scanf("%d",&room[j].personal.start.day);printf("\n客房单价:");scanf("%d",&room[j].price);printf("请输入入住人数\n");scanf("%d",&room[j].personal.count);z[j]=1; //标记使用的房间为1save();}void modify_infor( ) //修改函数{int r,m;do{printf("\t\t\t *******************菜单******************\n\n\n");printf("\t\t\t\t\t 1:修改客户信息\n\n\n");printf("\t\t\t\t\t 2:修改客房信息\n\n\n");printf("\t\t\t\t\t 3:菜单\n\n\n");printf("\t\t\t\t\t4:退出\n\n\n");printf("\t\t\t *****************************************\n\n\n");printf("\t\t\t 请选择输入选项[1\\2\\3\\4]:\n");scanf("%d",&m);if(m<1||m>3){r=1;getchar();}else r=0;}while(r==1);switch(m){case 1:modify_one();break;case 2:modify_hotel();break;case 3:menu();case 4:exit(0);}save();}void modify_one() //修改个人信息函数{int q;char a[20];printf("\n请选择您要修改的个人选项\n");printf("1:姓名2:性别(其中:1表示男,2表示女!) 3:年龄4:身份证号5:入住年份6:入住月份7入住日8:入住人数\n");printf("\t请选择输入选项[1\\2\\3\\4\\5\\6\\7\\8]:\n\b\b");scanf("%d",&q);switch(q){int t,p;char k;case 1:printf("请输入新名字\n");for(t=0;t<20;t++)scanf("%s",&a[t]);strcpy(room[j],a);break;case 2:printf("请选择新性别(其中:1表示男,2表示女!)\n");scanf("%d",&k);room[j].personal.sex=k;break;case 3:printf("请输入新年龄\n");scanf("%d",&p);room[j].personal.age=p;break;case 4:printf("请输入新身份证号\n");scanf("%d",&p);room[j].personal.ID_card[20]=p;break;case 5:printf("请输入新年份\n");scanf("%d",&p);room[j].personal.start.year=p;break;case 6:printf("请输入新月份\n");scanf("%d",&p);room[j].personal.start.month=p;break;case 7:printf("请输入新日子\n");scanf("%d",&p);room[j].personal.start.day=p;break;case 8:printf("请输入新入住人数\n");scanf("%d",&p);room[j].personal.count=p;break;}menu();}void modify_hotel() //修改客房信息函数{int l;printf("\n\t\t\t\t请选择您要修改的客房信息\n\n");printf("\t\t\t\t1:房间号\n\n \t\t\t\t2:客房单价\n\n \t\t\t\t3:入住人数\n\n \t\t\t\t4:返回\n\n");printf("\t\t\t请选择输入选项[1\\2\\3\\4]:\n\b\b");scanf("%d",&l);switch(l){case 1:printf("请输入旧房号\n");scanf("%d",&j);printf("请输入新房号\n");scanf("%d",&s);strcpy(room[s],room[j]);room[s].personal.sex=room[j].personal.sex; room[j].personal.sex=0;room[s].personal.age=room[j].personal.age; room[j].personal.age=0;strcpy(room[s].personal.ID_card,room[j].personal.ID_card);room[s].personal.start.year=room[j].personal.start.year;room[j].personal.start.year=0;room[s].personal.start.month=room[j].personal.start.month;room[j].personal.start.month=0;room[s].personal.start.day=room[j].personal.start.day;room[j].personal.start.day=0;room[s].room_ID=s;room[s].price=room[j].price;room[s].personal.count=room[j].personal.count;z[s]=1; z[j]=0; break;case 2:printf("请输入房号\n");scanf("%d",&s);printf("请输入新单价\n");scanf("%d",&s);room[s].price=s;break;case 3:printf("请输入房号\n");scanf("%d",&s);printf("请输入新入住人数\n");scanf("%d",&s);room[s].personal.count=s;break;case 4:break;}save();menu();}void disp_money( ) //显示入住费用函数{int i,sum;printf("请输入房间号;\n");scanf("%d",&room[j].room_ID);printf("\n入住年份:%d",room[j].personal.start.year);printf("月:%d",room[j].personal.start.month);printf("日:%d",room[j].personal.start.day);printf("房间单价为:");printf("%d",room[j].price);printf("\n请输入退房时间:\n");printf("请输入年份:");scanf("%d",&final.year);printf("请输入月份:");scanf("%d",&final.month);printf("请输入日:");scanf("%d",&final.day);printf("\n请输入住房天数:\n");scanf("%d",&i);sum=room[j].price*i;printf("总费用sum=%d\n",sum);save();menu();}void save() //保存函数{FILE *fp;int i;if((fp=fopen("客房管理.txt","w+"))==NULL) //打开输出文件“客房管理.txt”{printf("cannot open file\n");exit(0);}for(i=0;i<M;i++){if(fwrite((&room[i]), sizeof(room[M]),1,fp)!=1) printf("file write error\n");fflush(fp);}fclose(fp); //关闭文件}。

相关文档
最新文档