MFC-宾馆管理系统_第1页
MFC-宾馆管理系统_第2页
MFC-宾馆管理系统_第3页
MFC-宾馆管理系统_第4页
MFC-宾馆管理系统_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

宾馆管理系统

一程序界面

1主界面

2入住与订房界面

3结帐界面

二程序源代码

主界面源代码

//hotelDIg.cpp:implementationfile

//

include"stdafx.h"

ttinclude"hotel.h"

#include"hotelDIg.h"

//include"fstream.h"

ttinclude"rzdj.h"

#include"gkjz.h"

tfifdef_DEBUG

ttdefinenewDEBUG_NEW

#undefTHIS_FILE

staticcharTHIS_FILE[]=__FILE;

ttendif

lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll

11CAboutDIgdialogusedforAppAbout

classCAboutDIg:publicCDalog

(

public:

CAboutDIgO;

//DialogData

//{{AFX_DATA(CAboutDlg)

enum{IDD=IDD_ABOUTBOX};

//}}AFX_DATA

//ClassWizardgeneratedvirtualfunctionoverrides

//{{AFX_VIRTUAL(CAboutDlg)

protected:

virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport

//}}AFX_VIRTUAL

//Implementation

protected:

//{{AFX_MSG(CAboutDlg)

//}}AFX_MSG

DECLARE_MESSAGE_MAP()

CAboutDlg::CAboutDlg():CDialog(CAboutDlg::IDD)

(

//{{AFX_DATA_INIT(CAboutDlg)

//}}AFX_DATA_INIT

)

voidCAboutDlg::DoDataExchange(CDataExchange*pDX)

(

CDialog::DoDataExchange(pDX);

//{{AFX_DATA_MAP(CAboutDlg)

//}}AFX_DATA_MAP

)

BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)

//{{AFX_MSG_MAP(CAboutDlg)

〃Nomessagehandlers

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll

11CHotelDIgdialog

CHotelDlg::CHotelDlg(CWnd*pParent/*=NULL*/)

:CDialog(CHotelDlg::IDD,pParent)

(

//{{AFX_DATA_INIT(CHotelDig)

m_name=_T("");

m_password=_T("");

//}}AFX_DATA_INIT

//NotethatLoadicondoesnotrequireasubsequentDestroylconinWin32

m_hlcon=AfxGetApp()->Loadlcon(IDR_MAINFKAME);

)

CHotelDlg::-CHotelDlg()

(

fstreamq;

q.open("guest.txt",ios::out|ios::binary);

guest

p=Head.next;

while(p)

(

q.write((char*)p,sizeof(guest));

p=p->next;

)

q.close();

p=&Head;

t=p->next;

while(!t)

deletetemp;

P-closeO;

TCHARrgtsz[4][10]={_T("房号,_T("姓名)_T(“身份证号。,_T("入住日期

")};

LV_COLUMNIvcolumn;

CRectrect;

m_list.GetWindowRect(&rect);

m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP/*|LVS_EX_G

RIDLINES*/);

for(inti=1;i<5;i++)

(

Ivcolumn.mask=LVCF_FMT|LVCF_SUBITEM|LVCF_TEXT|

LVCF_WIDTH|LVCF_ORDER;

Ivcolumn.fmt=LVCFMT_CENTER;

Ivcolumn.pszText=rgtsz[i-l];

Ivcolumn.iSubltem=i;

Ivcolumn.iOrder=i;

Ivcolumn.cx=(rect.Width())/4;

m_list.lnsertColumn(i,&lvcolumn);

)

inputCtrIListO;

)

BEGIN_MESSAGE_MAP(CHotelDlg,CDialog)

//{{AFX_MSG_MAP(CHOtelDlg)

ON_WM_SYSCOMMAND()

ON_WM_PAINT()

ON_WM_QUERYDRAGICON()

ON_BN_CLICKED(IDC_BUTTON14,OnButtonl4)

ON_BN_CUCKED(IDC_BUTTON13ZOnButtonl3)

ON_BN_CLICKED(IDC_BUTTON1,OnButtonl)

ON_BN_CUCKED(IDC_BUTTON7,OnButton7)

ON_BN_CLICKED(IDC_BUTTON8,OnButton8)

ON_BN_CUCKED(IDC_BUTTON9,OnButton9)

ON_BN_CLICKED(IDC_BUTTON10ZOnButtonlO)

ON_CBN_SELCHANGE(IDC_COMBO1,OnSelchangeCombol)

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll

11CHotelDIgmessagehandlers

BOOLCHotelDlg::OnlnitDialog()

(

CDialog::OnlnitDialog(j;

//Add"About..."menuitemtosystemmenu.

11IDM_ABOUTBOXmustbeinthesystemcommandrange.

ASSERT((IDM_ABOUTBOX&OxFFFO)==IDM_ABOUTBOX);

ASSERT(IDM_ABOUTBOX<OxFOOO);

CMenu*pSysMenu=GetSystemMenu(FALSE);

if(pSysMenu!=NULL)

(

CStringstrAboutMenu;

strAboutMenu.LoadString(IDS_ABOUTBOX);

if(!strAboutMenu.lsEmpty())

(

pSysMenu->AppendMenu(MF_SCPARATOR);

pSysMenu->AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);

)

)

//Settheiconforthisdialog.Theframeworkdoesthisautomatically

//whentheapplication'smainwindowisnotadialog

Setlcon(m_hlcon,TRUE);//Setbigicon

Setlcon(m_hlcon,FALSE);//Setsmallicon

//TODO:Addextrainitializationhere

returnTRUE;//returnTRUEunlessyousetthefocustoacontrol

)

voidCHotelDlg::OnSysCommand(UINTnID,LPARAMIParam)

(

if((nID&OxFFFO)==IDM_ABOUTBOX)

(

CAboutDIgdlgAbout;

dlgAbout.DoModal();

)

else

CDialog::OnSysCommand(nlD,IParam);

)

//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow

//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,

//thisisautomaticallydoneforyoubytheframework.

voidCHotelDlg::OnPaint()

(

if(lslconic())

(

CPaintDCdc(this);//devicecontextforpainting

SendMessage(WM_ICONERASEBKGNDz(WPARAM)dc.GetSafeHdc(),0);

//Centericoninclientrectangle

intcxlcon=GetSystemMetrics(SM_CXICON);

intcylcon=GetSystemMetrics(SM_CYICON);

CRectrect;

GetClientRect(&rect);

intx=(rect.Width()-cxlcon+1)/2;

inty=(rect.Heightf)-cylcon+1)/2;

//Drawtheicon

dc.Drawlcon(x,y,m_hlcon);

)

else

(

CDialog::OnPaint();

)

)

//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags

//theminimizedwindow.

HCURSORCHotelDlg::OnQueryDraglcon()

(

return(HCURSOR)m_hlcon;

)

voidCHotelDlg::OnButtonl4()

(

//TODO:Addyourcontrolnotificationhandlercodehere

m_user.SetWindowText("");

m_pwd.SetWindowText("");

)

voidCHotelDlg::OnButtonl3()

(

//TODO:Addyourcontrolnotificationhandlercodehere

intc=l;

m_user.GetWindowText(m_name);

m_pwd.GetWindowText(m_password);

fstreamfile;

,,

file.open(master.txt"/ios::in);

charname[81];

charpassword[81];

file.getline(namez80/\n');

file.getline(password,80/\n');

while(!file.eof())

(

if(strcmp(m_name/name)==0&&strcmp(m_password/password)==0)

(

c=l;

break;

)

file.getlinelname3O/'Xn');

file.getline(password,80,'\n');

)

if(c==O)

(

MessageBox(”用户名或密码错误","wrong”,MBJCONWARNING);

)

else

(

m_gly.ShowWindow(FALSE);

m_mm.ShowWindowfFALSE);

m_user.ShowWindow(FALSE);

m_pwd.ShowWindow(FALSE);

m_qd.ShowWindDW(FALSE);

m_zt.ShowWindcw(FALSE);

m_dj.EndModalState();

mJz.EndModalState();

m_yd.EndModalState();

m_nh.ShowWindow(TRUE);

m_zx.ShowWindow(TRUE);

)

)

voidCHotelDlg::OnButtonl()

//TODO:Addyourcontrolnotificationhandlercodehere

m_gly.ShowWindow(TRUE);

m_mm.ShowWindow(TRUE);

m_user.ShowWindow(TRUE);

m_pwd.ShowWindowiTRUE);

m_qd.ShowWindow(TRUE);

m_zt.ShowWindow(TRUE);

m_dj.BeginModalState();

m_Jz.BeginModalState();

m_yd.BeginModalState();

m_nh.ShowWindow(FALSE);

m_zx.ShowWindow(FALSE);

m_pwd.SetWindowText("");

m_user.SetWindowText("");

)

voidCHotelDlg::OnButton7l)

(

//TODO:Addyourcontrolnotificationhandlercodehere

if(totle>0)

(

rzdjf;

f.DoModal();

if(f.m_name!=""&&f.m_sfzh!=""&&f.m_fh!=""&&f.m_rq!="")

(

chara[ll],b[19],c⑸,

strcpy(aJ.m_name.GetBuffer(O));

strcpy(b,f.m_sfzh.GetBuffer(O));

strcpy(c,f.m_fh.GetBuffer(O));

strcpy(d,f.m_rq.GetBuf能r(0));

guest*x;

x=newguest(a,b,c,d);

x->next=Head.next;

Head.next=x;

totle-;

)

)

else

(

MessageBox(“无空客房","wrong”,MB」CONWARNING);

)

inputCtrlList();

)

voidCHotelDlg::OnButton8i)

//TODO:Addyourcontrolnotificationhandlercodehere

gkjzg;

g.setList(Head);

g.DoModal();

totle++;

)

voidCHotelDlg::OnButton9i)

(

//TODO:Addyourcontrolnotificationhandlercodehere

if(totle>0)

(

rzdjf;

f.DoModal();

(

chara[ll]zb[19],c[5],d[ll];

strcpy(a,f.m_name.GetBuffer(O));

strcpy(b/f.m_sfzh.GetBuffer(O));

strcpy(c,f.m_fh.GetBuffer(O));

strcpy(d,f.m_rq.GetBuffer(O));

guest*x;

x=newguest(a,b,c,d);

x->next=Head.next;

Head.next=x;

totle-;

)

)

else

(

MessageBox("无空客房"「wrong",MB」CONWARNING);

)

)

voidCHotelDlg::OnButtonlO()

//TODO:Addyourcontrolnotificationhandlercodehere

ShellExecute(NULL,"open","hotel.doc",NULL,NULL,SW_SHOWNORMAL);

)

voidCHotelDlg::OnSelchangeCombol()

(

//TODO:Addyourcontrolnotificationhandlercodehere

intnlndex=m_com.GetCurSel();

reput(nlndex);

)

voidCHotelDlg::inputCtrlList(){

guest*p;

intk=0;

m_list.DeleteAllltems(i;

for(inti=0;i<100;i++)

(

m_list.lnsertltem|k,LPSTR_TEXTCALLBACK);

chartemp[20];

itoa(i+l,temp,10):

m_list.SetltemText(k,O,temp);

p=Uead.next;

while(p)

(

if(atoi(p->getNum())==i+l)

{

break;

)

p=p->next;

)

if(P)

(

m_list.SetltemText(k/l/p->getName());

m_list.SetltemText(kz2zp->getld());

m_list.SetltemText(kz3/P->getDateO);

}

k++;

)

)

voidCHotelDlg::reput(intx)

{

guest*p;

intk=0;

inti;

m_list.DeleteAllltems();

switch(x)

case0:

for(i=0;i<50;i+=2)

(

mJist.lnsertltemfKLPSTR-TEXTCALLBACK);

chartemp[20];

itoa(i+l,temp,10);

m_list.SetltemText(k/O/temp);

p=Head.next;

while(p)

(

if(atoi(p->getNum())==i+l)

(

break;

)

p=p->next;

)

if(P)

(

m_list.SetltemText(k,lzp->getName());

m_list.SetltemText(kz2,p->getld());

m」ist.SetltemText(k,3,p->getDate());

)

k++;

)

break;

case1:

for(i=50;i<100;i++)

(

m_list.lnsertltem(k,LPSTR_TEXTCALLBACK);

chartemp[20];

itoa(i+l,temp,10);

mJist.SetltemTextfKO.temp);

p=Head.next;

while(p)

(

if(atoi(p->getNum())==i+l)

(

break;

)

p=p->next;

)

if(P)

m_list.SetltemText(k,lzp->getName());

m_list.SetltemText(k,2,p->getld());

m_list.SetltemText(k,3/p->getDate());

)

k++;

)

break;

case2:

for(i=l;i<50;i+=2)

(

m_list.lnsertltem(k,LPSTR_TEXTCALLBACK);

chartemp[20];

itoa(i+l/temp,10);

mJist.SetltemTextfk^O^emp);

p=Head.next;

while(p)

(

if(atoi(p->getNum())==i+l)

(

break;

)

p=p->next;

)

if(P)

{

m」ist.SetltemText(k,l,p->getName());

m_list.SetltemText(k,2,p->getld());

m」ist.SetltemText(k,3,p->getDate());

)

k++;

)

break;

)

}

2入住与订房界面代码

//rzdj.cpp:implementationfile

//

#include"stdafx.h"

^include"hotel.h"

^include"rzdj.h"

#ifdef.DEBUG

#definenewDEBUG_NEW

#undefTHIS_FILE

staticcharTHIS_FILE[]=_FILEj

ttendif

lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll

11rzdjdialog

rzdj::rzdj(CWnd*pParent/*=NULL*/)

:CDialog(rzdj::IDD,pParent)

(

//{{AFX_DATA_INIT(rzdj)

m_name=_T("");

m-sfzh=

m_fh=_T("");

m_rq=_T("");

//}}AFX_DATA_INIT

)

voidrzdj::DoDataExchange(CDataExchange*pDX)

CDialog::DoDataExchange(pDX);

//{{AFX_DATA_MAP(rzdj)

DDX_Text(pDX,IDC_EDIT1,m_name);

DDV_MaxChars(pDX,m_name,10);

DDX_Text(pDX,IDC_EDIT2,m_sfzh);

DDV_MaxChars(pDX,m_sfzhz18);

DDX_Text(pDX,IDC_EDIT3,m_fh);

DDV_MaxChars(pDX,m_fh,4);

DDX_Text(pDXzIDC_EDIT4Zm_rq);

DDV_MaxChars(pDX/m_rq,10);

//}}AFX_DATA_MAP

)

BEGIN_MESSAGE_MAP(rzdj,CDialog)

//{{AFX_MSG_MAP(rzdj)

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll

〃rzdjmessagehandlers

voidrzdj::OnOK()

(

//TODO:Addextravalidationhere

UpdateData(TRUE);

CDialog::OnOK();

}

3结账界面代码

//gkjz.cpp:implementationfile

//

include"stdafx.h"

#include"hotel.h"

include"gkjz.h"

#ifdef_DEBUG

#definenewDEBUG_NEW

#undefTHIS_FILE

staticcharTHIS_FILE[]=_FILE_;

#endif

/////////////////////////////////////////////////////////////////////////////

//gkjzdialog

gkjz::gkjz(CWnd*pParent/*=NULL*/)

:CDialogfgkjzizIDD,pParent)

(

//{{AFX_DATA_INIT(gkjz)

m_fh=_T("");

m_ts=0;

mjg=O.Of;

//}}AFX_DATA_INIT

voidgkjz::DoDataExchange(CDataExchange*pDX)

(

CDialog::DoDataExchange(pDX);

//{{AFX_DATA_MAP(gkjz)

DDX.ControKpDX,IDC_EDIT3fm_p);

DDX_Control(pDX,IDC_EDIT2,m_d);

DDX_Text(pDX,IDC_EDIT1,m_fh);

DDV_MaxChars(pDX/m_fh,4);

DDX_Text(pDXzIDC_EDIT2,m_ts);

DDX_Text(pDX,IDJEDIT3,mjg);

//}}AFX_DATA_MAP

BEGIN_MESSAGE_MAP(gkjz,CDialog)

//{{AFX_MSG_MAP(gkjz)

ON_EN_KILLFOCUS(IDC_EDrri,OnKillfocusEditl)

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////

11gkjzmessagehandlers

voidgkjz::setList(guest&x)

(

List=&x;

voidgkjz::OnOK()

(

〃TODO:Addextravalidationhere

guest+t;

t=List;

if(P)

(

while(t->next!=p)

(

t=t->next;

}

t->next=p->next;

deletep;

)

CDialog::OnOK();

voidgkjz::OnKillfocusEditl()

//TODO:Addyourcontrolnotificationhandlercodehere

p=List->next;

UpdateData(TRUE);

while(p)

{

if(strcmp(p->getNum()/this->m_fh)==O)

(

break;

)

p=p->next;

)

if(p==NULL)

(

MessageBox("该客房未被预订"Jwrong^MB'CONWARNING);

}

else

(

chartemp[3];

intd;

forfinti=0;i<2;i++)

(

temp[i]=*(p->getDate()+8+i);

)

SYSTEMTIMEst={0};

GetLocalTime(&st);

d=st.wDay-atoi(temp);

m_ts=d;

mjg=(float)(d*50);

UpdateData(FALSE);

)

三程序运行结果

登陆界面

上客房管理系统x

查询面板

关键字

入住与懵订X:

确定I

取消

你好管理员

注楷

土客房管理系统X

查询面板

关键字HI

层号姓名身份证号入住日斯

1

2林12345678901234514-05-1C

3

4

5

6

7

8

9

1O

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论