本系统实现的功能具体如下:
酒店客房管理系统的数据需求包括如下几点:
客户表
字段 | 中文解释 | 类型 | 约束 | 备注 |
---|---|---|---|---|
cno | 客户编号 | Char(20) | Not null | Primary key |
cname | 客户姓名 | Char(10) | Not null | |
csex | 客户性别 | Char(2) | Not null | |
cid | 客户手机号 | Char(20) | Not null |
客房表
字段 | 中文解释 | 类型 | 约束 | 备注 |
---|---|---|---|---|
Rno | 客房编号 | Char(20) | Not null | Primary key |
Rstyle | 客房类型 | Char(10) | Not null | |
Rprice | 客房价格 | Int | Not null | |
Rstate | 客房状态 | Char(10) | Not null |
Living表
字段 | 中文解释 | 类型 | 约束 | 备注 |
---|---|---|---|---|
Cno | 客户编号 | Char(20) | Not null | Primary key |
Ccomedate | 入住日期 | Datetime | Not null | |
Cleftdate | 离开日期 | Datetime | Not null | |
Rno | 客房编号 | Int | Not null | |
Ctime | 入住时间 | Int | Not null | |
Camount | 费用 | Int | Not null |
管理员表
字段 | 中文解释 | 类型 | 约束 | 备注 |
---|---|---|---|---|
Ano | 管理员编号 | Char(10) | Not null | Primary key |
Aname | 管理员姓名 | Char(10) | Not null | |
Asex | 管理员性别 | Char(2) | Not null | |
Apassword | 登录密码 | Char(20) | Not null |
物品表
字段 | 中文解释 | 类型 | 约束 | 备注 |
---|---|---|---|---|
Rno | 客房号 | Char(20) | Not null | |
Ritemno | 物品号 | Int | Not null | Primary key |
Ritemstate | 物品状态 | Char(10) | Not null | |
Ritemname | 物品名称 | Char(20) | Not null |
E-R图(实体-关系图)提供了表示实体、属性和联系的方法。 (1) 实体型 :用矩形表示,矩形框内写明实体名 (2) 属性:用椭圆型表示,并用无向边与其相应实体连接起来 (3) 联系:用菱形表示,菱形框内写明联系名,并用无向边与其有关实体连接。
本系统采用E-R图的方法进行数据库概念结构设计,系统E-R图如下所示:
客户实体图
客房实体图
管理员实体图
物品实体图
全局E-R图
将E-R图转换成关系模式:
客房(客房号,客房类型,客房状态,客房单价) 客户(客户编号,姓名,性别,手机号) 管理员(员工号,姓名,性别,密码) 物品(客房号,物品名称,物品状态) 入住(客房号,入住时间,退房时间,住宿费用)
创建数据库各表
此处数据是自己创建execl填入的,数据项不是很多。
(1)查询客户(customers)信息的视图定义如下。
Create view view_ customers (客户编号,客户姓名,客户性别,客户手机号)
As select cno,cname,csex,cid
From customers
(2)查询客房(rooms)信息的视图定义如下。
Create view view_rooms (客房号,客房类型,客房价格,客房状态)
As select rno, rstyle, rprice, rstate
From rooms
(3)查询客户住宿(living)信息的视图如下。
Create view view_living (客户编号,客房号,入住日期,离开日期,入住时间,费用)
As select cno,rno,ccomedate,cleftdate,ctime,camount
From living
(4)查询客房物品(roomitem)信息的视图定义如下。
Create view view_roomitem(客房号,客房物品编号,客房物品名称,物品状态)
As select rno,,ritemno,ritemname,ritemstate
From roomitem
创建索引
创建触发器
当在客房表中加入一条信息后显示“已占”表示有客户入住,当在客房表中删除一条信息后显示“已退”表示客户离开。
USE [hotel]
GO
Trigger [dbo].[roomsstatus_update]
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER trigger [dbo].[roomsstatus_update]
on [dbo].[rooms]
for update
as
declare @rno varchar(20),
@istf varchar(20)
select @istf=istf from ccomedate
where rno=@rno;
if @istf<>'已退'
begin
update rooms
set rstate='已占'
where rno=@rno
end;
if @istf='已退'
begin
update rooms
set rstate='空闲'
where rno=@rno
end;
创建客户表的触发器,当增加或删除一条信息时显示所有此表中信息。
存储过程
create procedure [dbo].[Query_totalruzhushijian_feiyong]
@ccomedate datetime,
@cleftdate datetime,
@rstyle varchar(10)
as
select sum(datediff(S,addtime,cleftdate)) as ctime,sum(rprice) as 费用合计 from living
where addtime>= ltrim(@ccomedate) and cleftdate<=ltrim(@ctime) and rstyle=@rstyle
group by rstyle;
--drop procedure Query_totalruzhushijian_feiyong;
GO
此处只是利用VBNET语言进行简单的模块搭建,并没有实现前端设计。
页面展示:
可以看见能直接对住房人员的需求进行操作:
(1)添加新住户
(2)预定房间
代码:(此处代码繁多,只截取主代码,剩下的都是粘贴这个管理系统的图片)
(此处为链接数据库代码)
好了今日分享到此结束,大家需要源码的话可以后台call我哟!也请各位佬指出不足!