数据库课程设计酒店客房管理系统的设计与实现.docx
《数据库课程设计酒店客房管理系统的设计与实现.docx》由会员分享,可在线阅读,更多相关《数据库课程设计酒店客房管理系统的设计与实现.docx(44页珍藏版)》请在冰豆网上搜索。
![数据库课程设计酒店客房管理系统的设计与实现.docx](https://file1.bdocx.com/fileroot1/2023-4/28/4a90714e-de23-4a95-a1b4-c4edee8837d3/4a90714e-de23-4a95-a1b4-c4edee8837d31.gif)
数据库课程设计酒店客房管理系统的设计与实现
.需求分析
1.系统需求:
根据宾馆管理系统的理念,宾馆管理系统必须满足一下需要:
(1)具有方便的登记、结帐功能和预订客房的功能,能够支持团体登记和团体结帐;
(2)能快速、准确地了解宾馆内的客房状态,以便管理者决策;
(3)提供多种手段查询客人的信息;
(4)具备一定的维护手段,有一定权利的操作员在密码的支持下才可以更改房价、房间类型、增减客房;
(5)完善的结帐报表系统;
(6)系统维护:
如数据安全管理(含备份与恢复)、操作员管理、权限设置等。
2.功能需求:
根据系统的需求分析,得到本系统的功能要求如下:
1.系统管理:
管理登陆系统的用户
2.订房信息的管理:
管理订房信息,对订房信息进行查询和添加新的订房信息。
3.基础数据库管理:
设置房的基本属性,如等级,价格等。
4.顾客信息管理:
管理顾客的信息,查询居住记录等。
3.性能需求:
(1)硬件环境:
处理器:
IntelPentium4或更高
内存:
256M或更高
硬盘:
40G或更高
(2)软件环境
操作系统:
Windows2000/XP/Vista;
支持软件:
MicrosoftSQLSever2000,VisualC++6.0。
.总体设计
1.系统概述;
有需求分析,要完成本系统的运行,需要的是客户机/服务器的运行方式。
采用的是VisualC++6.0作为开发工具,采用了SQLSever2000作为后台数据库,就可以满足一般的宾馆的客房管理的需求.
2.系统模块:
三.详细设计
(I)数据库设计
1.结构设计
(1)客房标准信息的E-R图
2)订房信息的E-R图
3)实体之间关系的E-R图
系统E-R图:
2.
数据库表的设计
1)登陆需要的数据有:
登陆ID密码pwd,pas2.建立表格user:
(2)房子的属性种类:
建立表格roomtype:
3)预定房子的时候用的表格:
4)客房表
5
5)结算信息表
利用查询分析器实现他们
1.建立表格user
6
2.Bookin表
3.roomtype表
4.rooms表
5.oucall表
1.
II)
输入数据即可。
程序设计程序运行数据流程图:
登陆
7
四.程序代码
#define
AFX_ROOMTYPEDLG_H__487EF091_29D9_404B_B081_0DAC2C2E1223__INCLUDE_
#if_MSC_VER>1000
#pragmaonce
#endif//_MSC_VER>1000
//RoomTypeDLG.h:
headerfile
classCRoomTypeDLG:
publicCDialog
{
//Construction
public:
boolm_bAirCon;
boolm_bTel;
boolm_bTV;
boolm_bToilet;
boolm_bAppend;
CRoomTypeDLG(CWnd*pParent=NULL);protected:
DECLARE_MESSAGE_MAP()
};
#include"stdafx.h"
#include"hotel_mis.h"
#include"RoomTypeDLG.h"
#include"Hotel_MISView.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
//CRoomTypeDLGdialog
CRoomTypeDLG:
:
CRoomTypeDLG(CWnd*pParent/*=NULL*/)
:
CDialog(CRoomTypeDLG:
:
IDD,pParent)
{
//{{AFX_DATA_INIT(CRoomTypeDLG)
m_sArea=_T("");
m_sBedNo=_T("");
m_sTypeID=_T("");
m_sTypeName=_T("");
m_sPrice=_T("");
//}}AFX_DATA_INIT
}
voidCRoomTypeDLG:
:
DoDataExchange(CDataExchange*pDX)
{
CDialog:
:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRoomTypeDLG)
}
BEGIN_MESSAGE_MAP(CRoomTypeDLG,CDialog)
9
//{{AFX_MSG_MAP(CRoomTypeDLG)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//CRoomTypeDLGmessagehandlers
BOOLCRoomTypeDLG:
:
OnInitDialog()
{
CDialog:
:
OnInitDialog();
//TODO:
Addextrainitializationhere
//InitEditTextlimit
if(m_bAppend)
{
//UpdateDialogCaption
SetWindowText(_T("添加客房标准"));
//InitCombobox
((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISAIRCON))->SetCurSel
(1);((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTEL))->SetCurSel
(1);((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTV))->SetCurSel
(1);
((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTOILET))->SetCurSel
(1);
}
else
{
//UpdateDialogCaption
SetWindowText(_T("修改客房标准"));
//DisableIDandNameEdit
GetDlgItem(IDC_ROOMTYPE_ID)->EnableWindow(false);
GetDlgItem(IDC_ROOMTYPE_NAME)->EnableWindow(false);
//InitCombobox
if(m_bAirCon)
((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISAIRCON))->SetCurSel
(1);
else
((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISAIRCON))->SetCurSel(0);
if(m_bTel)
((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTEL))->SetCurSel
(1);
else((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTEL))->SetCurSel(0);
if(m_bTV)
((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTV))->SetCurSel
(1);
10else((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTV))->SetCurSel(0);
if(m_bToilet)((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTOILET))->SetCurSel
(1);
else
((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTOILET))->SetCurSel(0);
}
returnTRUE;//returnTRUEunlessyousetthefocustoacontrol
//EXCEPTION:
OCXPropertyPagesshouldreturnFALSE
}
voidCRoomTypeDLG:
:
OnOK()
{
//TODO:
Addextravalidationhere
UpdateData(true);
m_sTypeID.TrimRight("");
m_sTypeName.TrimRight("");
m_sArea.TrimRight("");
m_sBedNo.TrimRight("");
m_sPrice.TrimRight("");
//Makesureallneededinfoisavailable
CStringsWarning="";
if(""==m_sTypeID)sWarning=_T("标准编号");
elseif(""==m_sTypeName)sWarning=_T("标准名称");
elseif(""==m_sArea)sWarning=_T("客房面积");
elseif(""==m_sBedNo)sWarning=_T("床位数量");
elseif(""==m_sPrice)sWarning=_T("住房单价");
if(""!
=sWarning)
{
sWarning+=_T("不能为空");
AfxMessageBox(sWarning,MB_ICONEXCLAMATION);
return;
}
//MakesuretheNumberinfoisvalid
floatfArea=atof(m_sArea);
if(0==fArea)
11
AfxMessageBox(_T("客房面积:
请输入非零数字"),MB_ICONEXCLAMATION);
return;
}
m_sArea.Format("%.2f",fArea);
floatfPrice=atof(m_sPrice);
if(0==fPrice)
{
AfxMessageBox(_T("住房单价:
请输入非零数字"),MB_ICONEXCLAMATION);
return;
}
m_sPrice.Format("%.2f",fPrice);
if(atof(m_sPrice)>99999999.99){
AfxMessageBox(_T("住房单价溢出,请不要超过99999999.99"),MB_ICONEXCLAMATION);
return;
}
_variant_tstrQuery;
if(m_bAppend)
{
//JudgeRoomTypeisUnique
strQuery="select*fromroomtypewheretypeid='"+m_sTypeID+"'";
theApp.ADOExecute(theApp.m_pADOSet,strQuery);
intiCount=theApp.m_pADOSet->GetRecordCount();
if(0!
=iCount)
{
AfxMessageBox(_T("已经存在此标准编号的记录!
"),MB_ICONEXCLAMATION);
return;
}
//JudgeRoomNameisUnique
strQuery="select*fromroomtypewheretypeid!
='"+m_sTypeID+"'andtypename='"+m_sTypeName+"'";
12theApp.ADOExecute(theApp.m_pADOSet,strQuery);
iCount=theApp.m_pADOSet->GetRecordCount();
if(0!
=iCount)
{
AfxMessageBox(_T("已经存相同客房标准的记录!
"),MB_ICONEXCLAMATION);
return;
}
}
//Getotherinfo
CStringsAir("0"),sTel("0"),sTV("0"),sToilet("0");
if(((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISAIRCON))->GetCurSel())sAir="1";
if(((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTEL))->GetCurSel())
sTel="1";
if(((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTV))->GetCurSel())
sTV="1";
if(((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTOILET))->GetCurSel())sToilet="1";
if(m_bAppend)//AppendRecord
{
strQuery="insertroomtype(typeid,typename,area,bednum,price,haircondition,htelephone,htelevision,htoilet)\values('"+m_sTypeID+"','"+m_sTypeName+"',"+m_sArea+","+m_sBedNo+","+m_sPrice+","+sAir+","+sTel+","+sTV+","+sToilet+")";
if(theApp.ADOExecute(theApp.m_pADOSet,strQuery))
{
AfxMessageBox(_T("添加记录成功!
"),MB_ICONINFORMATION);
//Clearallinputm_sTypeID=m_sTypeName=m_sArea=m_sBedNo=m_sPrice="";
((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISAIRCON))->SetCurSel
(1);((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTEL))->SetCurSel
(1);((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTV))->SetCurSel
(1);
((CComboBox*)GetDlgItem(IDC_ROOMTYPE_ISTOILET))->SetCurSel
(1);
UpdateData(false);
13
}
elseAfxMessageBox(_T("添加记录失败!
"),MB_ICONEXCLAMATION);
}
else//AlterRecord
{
strQuery="Updateroomtypesetarea="+m_sArea+",bednum="+m_sBedNo+",price="+m_sPrice+",haircondition="+sAir+",\htelephone="+sTel+",htelevision="+sTV+",htoilet="+sToilet+"wheretypeid='"+m_sTypeID+"'";
if(theApp.ADOExecute(theApp.m_pADOSet,strQuery))AfxMessageBox(_T("修改记录成功!
"),MB_ICONINFORMATION);
elseAfxMessageBox(_T("修改记录失败!
"),MB_ICONEXCLAMATION);
}
//RefreshRoomTypeList
CHotel_MISView*p=(CHotel_MISView*)(((CMainFrame*)AfxGetMainWnd())->GetActiveView());
p->RefreshRoomType();
if(!
m_bAppend)CDialog:
:
OnOK();
}
//Hotel_MISView.cpp:
implementationoftheCHotel_MISViewclass
#include"stdafx.h"
#include"Hotel_MIS.h"
#include"Hotel_MISDoc.h"
#include"Hotel_MISView.h"
#include"RoomTypeDLG.h"
#include"RoomDLG.h"
#include"CheckRoomDLG.h"
#include"CheckRemainDLG.h"
#include"BookInDLG.h"
#include"SearchBookInDLG.h"
#include"CheckOutDLG.h"
#include"SearchCheckOutDLG.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
//CHotel_MISView
14
IMPLEMENT_DYNCREATE(CHotel_MISView,CView)BEGIN_MESSAGE_MAP(CHotel_MISView,CView)//{{AFX_MSG_MAP(CHotel_MISView)ON_WM_SIZE()
ON_WM_CONTEXTMENU()ON_COMMAND(ID_MENU_ADDROOMTYPE,OnAddRoomType)ON_COMMAND(ID_MENU_ALTERROOMTYPE,OnAlterRoomType)ON_COMMAND(ID_MENU_DELROOMTYPE,OnDelRoomType)ON_COMMAND(ID_MENU_ADDROOM,OnAddRoom)ON_COMMAND(ID_MENU_ALTERROOM,OnAlterRoom)ON_COMMAND(ID_MENU_DELROOM,OnDelRoom)ON_COMMAND(ID_MENU_CHECKROOM,OnCheckRoom)ON_COMMAND(ID_MENU_CHECKREMAIN,OnCheckRemain)ON_COMMAND(ID_MENU_ADDBOOKIN,OnAddBookIn)ON_COMMAND(ID_MENU_ALTERBOOKIN,OnAlterBookIn)ON_COMMAND(ID_MENU_SEARCHBOOKIN,OnSearchBookIn)ON_COMMAND(ID_MENU_ADDCHECKOUT,OnAddCheckOut)ON_COMMAND(ID_MENU_ALTERCHECKOUT,OnAlterCheckOut)ON_COMMAND(ID_MENU_SEARCHCHECKOUT,OnSearchCheckOut)//}}AFX_MSG_MAP
END_MESSAGE_MAP()
//CHotel_MISViewconstruction/destructionCHotel_MISView:
:
CHotel_MISView()
{
//TODO:
addconstructioncodehere
m_sCurrentList="";
}
CHotel_MISView:
:
~CHotel_MISView(){}
BOOLCHotel_MISView:
:
PreCreateWindow(CREATESTRUCT&cs)
{
//TODO:
ModifytheWindowclassorstylesherebymodifying
//theCREATESTRUCTcs
returnCView:
:
PreCreateWindow(cs);
}
//CHotel_MISViewdrawing
voidCHotel_MISView:
:
OnDraw(CDC*pDC)
{
CHotel_MISDoc*pDoc=GetDocument();
ASSERT_VALID(pDoc);
//TODO:
adddrawcodefornativedatahere
15
}
//CHotel_MISViewdiagnostics
#ifdef_DEBUG
voidCHotel_MISView:
:
AssertValid()const
{
CView:
:
AssertValid();
}
voidCHotel_MISView:
:
Dump(CDumpContext&dc)const
{
CView:
:
Dump(dc);
}
CHotel_MISDoc*CHotel_MISView:
:
GetDocument()//non-debugversionisinline{
ASSERT(m_pDocument->IsKindOf(RUNTIME