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

下载本文档

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

文档简介

宾馆管理系统一程序界面1主界面2入住与订房界面3结帐界面二程序源代码主界面源代码//hotelDlg.cpp:implementationfile//#include"stdafx.h"#include"hotel.h"#include"hotelDlg.h"#include"fstream.h"#include"rzdj.h"#include"gkjz.h"#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endif///////////////////////////////////////////////////////////////////////////////CAboutDlgdialogusedforAppAboutclassCAboutDlg:publicCDialog{public: CAboutDlg();//DialogData //{{AFX_DATA(CAboutDlg) enum{IDD=IDD_ABOUTBOX}; //}}AFX_DATA //ClassWizardgeneratedvirtualfunctionoverrides //{{AFX_VIRTUAL(CAboutDlg) protected: virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport //}}AFX_VIRTUAL//Implementationprotected: //{{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_MAPEND_MESSAGE_MAP()///////////////////////////////////////////////////////////////////////////////CHotelDlgdialogCHotelDlg::CHotelDlg(CWnd*pParent/*=NULL*/) :CDialog(CHotelDlg::IDD,pParent){ //{{AFX_DATA_INIT(CHotelDlg) m_name=_T(""); m_password=_T(""); //}}AFX_DATA_INIT //NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32 m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);}CHotelDlg::~CHotelDlg(){ fstreamq; q.open("guest.txt",ios::out|ios::binary); guest*p,*t; p=Head.next; while(p) { q.write((char*)p,sizeof(guest)); p=p->next; } q.close(); p=&Head; t=p->next; while(!t) { deletep; p=t; t=t->next; } deletep;}voidCHotelDlg::DoDataExchange(CDataExchange*pDX){ CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CHotelDlg) DDX_Control(pDX,IDC_COMBO1,m_com); DDX_Control(pDX,IDC_LIST2,m_list); DDX_Control(pDX,IDC_BUTTON14,m_zt); DDX_Control(pDX,IDC_BUTTON13,m_qd); DDX_Control(pDX,IDC_BUTTON1,m_zx); DDX_Control(pDX,IDC_STATICnh,m_nh); DDX_Control(pDX,IDC_STATICmm,m_mm); DDX_Control(pDX,IDC_STATICgiy,m_gly); DDX_Control(pDX,IDC_BUTTON9,m_yd); DDX_Control(pDX,IDC_BUTTON8,m_jz); DDX_Control(pDX,IDC_BUTTON7,m_dj); DDX_Control(pDX,IDC_EDIT2,m_pwd); DDX_Control(pDX,IDC_EDIT1,m_user); DDX_Text(pDX,IDC_EDIT1,m_name); DDX_Text(pDX,IDC_EDIT2,m_password); //}}AFX_DATA_MAP Head.next=NULL; totle=10; fstreamp; p.open("guest.txt",ios::in|ios::binary); guest*temp; temp=newguest; p.read((char*)temp,sizeof(guest)); while(!p.eof()) { temp->next=Head.next; Head.next=temp; totle--; temp=newguest; p.read((char*)temp,sizeof(guest)); } deletetemp; p.close(); TCHARrgtsz[4][10]={_T("房号"),_T("姓名"),_T("身份证号"),_T("入住日期")}; LV_COLUMNlvcolumn; CRectrect; m_list.GetWindowRect(&rect); m_list.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP/*|LVS_EX_GRIDLINES*/); for(inti=1;i<5;i++) { lvcolumn.mask=LVCF_FMT|LVCF_SUBITEM|LVCF_TEXT|LVCF_WIDTH|LVCF_ORDER; lvcolumn.fmt=LVCFMT_CENTER; lvcolumn.pszText=rgtsz[i-1]; lvcolumn.iSubItem=i; lvcolumn.iOrder=i; lvcolumn.cx=(rect.Width())/4; m_list.InsertColumn(i,&lvcolumn); } inputCtrlList();}BEGIN_MESSAGE_MAP(CHotelDlg,CDialog) //{{AFX_MSG_MAP(CHotelDlg) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_BUTTON14,OnButton14) ON_BN_CLICKED(IDC_BUTTON13,OnButton13) ON_BN_CLICKED(IDC_BUTTON1,OnButton1) ON_BN_CLICKED(IDC_BUTTON7,OnButton7) ON_BN_CLICKED(IDC_BUTTON8,OnButton8) ON_BN_CLICKED(IDC_BUTTON9,OnButton9) ON_BN_CLICKED(IDC_BUTTON10,OnButton10) ON_CBN_SELCHANGE(IDC_COMBO1,OnSelchangeCombo1) //}}AFX_MSG_MAPEND_MESSAGE_MAP()///////////////////////////////////////////////////////////////////////////////CHotelDlgmessagehandlersBOOLCHotelDlg::OnInitDialog(){ CDialog::OnInitDialog(); //Add"About..."menuitemtosystemmenu. //IDM_ABOUTBOXmustbeinthesystemcommandrange. ASSERT((IDM_ABOUTBOX&0xFFF0)==IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX<0xF000); CMenu*pSysMenu=GetSystemMenu(FALSE); if(pSysMenu!=NULL) { CStringstrAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); if(!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu); } } //Settheiconforthisdialog.Theframeworkdoesthisautomatically //whentheapplication'smainwindowisnotadialog SetIcon(m_hIcon,TRUE); //Setbigicon SetIcon(m_hIcon,FALSE); //Setsmallicon //TODO:Addextrainitializationhere returnTRUE;//returnTRUEunlessyousetthefocustoacontrol}voidCHotelDlg::OnSysCommand(UINTnID,LPARAMlParam){ if((nID&0xFFF0)==IDM_ABOUTBOX) { CAboutDlgdlgAbout; dlgAbout.DoModal(); } else { CDialog::OnSysCommand(nID,lParam); }}//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,//thisisautomaticallydoneforyoubytheframework.voidCHotelDlg::OnPaint(){ if(IsIconic()) { CPaintDCdc(this);//devicecontextforpainting SendMessage(WM_ICONERASEBKGND,(WPARAM)dc.GetSafeHdc(),0); //Centericoninclientrectangle intcxIcon=GetSystemMetrics(SM_CXICON); intcyIcon=GetSystemMetrics(SM_CYICON); CRectrect; GetClientRect(&rect); intx=(rect.Width()-cxIcon+1)/2; inty=(rect.Height()-cyIcon+1)/2; //Drawtheicon dc.DrawIcon(x,y,m_hIcon); } else { CDialog::OnPaint(); }}//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags//theminimizedwindow.HCURSORCHotelDlg::OnQueryDragIcon(){ return(HCURSOR)m_hIcon;}voidCHotelDlg::OnButton14(){ //TODO:Addyourcontrolnotificationhandlercodehere m_user.SetWindowText(""); m_pwd.SetWindowText("");}voidCHotelDlg::OnButton13(){ //TODO:Addyourcontrolnotificationhandlercodehere intc=1; m_user.GetWindowText(m_name); m_pwd.GetWindowText(m_password); fstreamfile; file.open("master.txt",ios::in); charname[81]; charpassword[81]; file.getline(name,80,'\n'); file.getline(password,80,'\n'); while(!file.eof()) { if(strcmp(m_name,name)==0&&strcmp(m_password,password)==0) { c=1; break; } file.getline(name,80,'\n'); file.getline(password,80,'\n'); } if(c==0) { MessageBox("用户名或密码错误","wrong",MB_ICONWARNING); } else { m_gly.ShowWindow(FALSE); m_mm.ShowWindow(FALSE); m_user.ShowWindow(FALSE); m_pwd.ShowWindow(FALSE); m_qd.ShowWindow(FALSE); m_zt.ShowWindow(FALSE); m_dj.EndModalState(); m_jz.EndModalState(); m_yd.EndModalState(); m_nh.ShowWindow(TRUE); m_zx.ShowWindow(TRUE); }}voidCHotelDlg::OnButton1(){ //TODO:Addyourcontrolnotificationhandlercodehere m_gly.ShowWindow(TRUE); m_mm.ShowWindow(TRUE); m_user.ShowWindow(TRUE); m_pwd.ShowWindow(TRUE); 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::OnButton7(){ //TODO:Addyourcontrolnotificationhandlercodehere if(totle>0) { rzdjf; f.DoModal(); if(f.m_name!=""&&f.m_sfzh!=""&&f.m_fh!=""&&f.m_rq!="") { chara[11],b[19],c[5],d[11]; strcpy(a,f.m_name.GetBuffer(0)); strcpy(b,f.m_sfzh.GetBuffer(0)); strcpy(c,f.m_fh.GetBuffer(0)); strcpy(d,f.m_rq.GetBuffer(0)); guest*x; x=newguest(a,b,c,d); x->next=Head.next; Head.next=x; totle--; } } else { MessageBox("无空客房","wrong",MB_ICONWARNING); } inputCtrlList();}voidCHotelDlg::OnButton8(){ //TODO:Addyourcontrolnotificationhandlercodehere gkjzg; g.setList(Head); g.DoModal(); totle++;}voidCHotelDlg::OnButton9(){ //TODO:Addyourcontrolnotificationhandlercodehere if(totle>0) { rzdjf; f.DoModal(); if(f.m_name!=""&&f.m_sfzh!=""&&f.m_fh!=""&&f.m_rq!="") { chara[11],b[19],c[5],d[11]; strcpy(a,f.m_name.GetBuffer(0)); strcpy(b,f.m_sfzh.GetBuffer(0)); strcpy(c,f.m_fh.GetBuffer(0)); strcpy(d,f.m_rq.GetBuffer(0)); guest*x; x=newguest(a,b,c,d); x->next=Head.next; Head.next=x; totle--; } } else { MessageBox("无空客房","wrong",MB_ICONWARNING); }}voidCHotelDlg::OnButton10(){ //TODO:Addyourcontrolnotificationhandlercodehere ShellExecute(NULL,"open","hotel.doc",NULL,NULL,SW_SHOWNORMAL);}voidCHotelDlg::OnSelchangeCombo1(){ //TODO:Addyourcontrolnotificationhandlercodehere intnIndex=m_com.GetCurSel(); reput(nIndex);}voidCHotelDlg::inputCtrlList(){ guest*p; intk=0; m_list.DeleteAllItems(); for(inti=0;i<100;i++) { m_list.InsertItem(k,LPSTR_TEXTCALLBACK); chartemp[20]; itoa(i+1,temp,10); m_list.SetItemText(k,0,temp); p=Head.next; while(p) { if(atoi(p->getNum())==i+1) { break; } p=p->next; } if(p) { m_list.SetItemText(k,1,p->getName()); m_list.SetItemText(k,2,p->getId()); m_list.SetItemText(k,3,p->getDate()); } k++; }}voidCHotelDlg::reput(intx){ guest*p; intk=0; inti; m_list.DeleteAllItems(); switch(x) { case0: for(i=0;i<50;i+=2) { m_list.InsertItem(k,LPSTR_TEXTCALLBACK); chartemp[20]; itoa(i+1,temp,10); m_list.SetItemText(k,0,temp); p=Head.next; while(p) { if(atoi(p->getNum())==i+1) { break; } p=p->next; } if(p) { m_list.SetItemText(k,1,p->getName()); m_list.SetItemText(k,2,p->getId()); m_list.SetItemText(k,3,p->getDate()); } k++; } break; case1: for(i=50;i<100;i++) { m_list.InsertItem(k,LPSTR_TEXTCALLBACK); chartemp[20]; itoa(i+1,temp,10); m_list.SetItemText(k,0,temp); p=Head.next; while(p) { if(atoi(p->getNum())==i+1) { break; } p=p->next; } if(p) { m_list.SetItemText(k,1,p->getName()); m_list.SetItemText(k,2,p->getId()); m_list.SetItemText(k,3,p->getDate()); } k++; } break; case2: for(i=1;i<50;i+=2) { m_list.InsertItem(k,LPSTR_TEXTCALLBACK); chartemp[20]; itoa(i+1,temp,10); m_list.SetItemText(k,0,temp); p=Head.next; while(p) { if(atoi(p->getNum())==i+1) { break; } p=p->next; } if(p) { m_list.SetItemText(k,1,p->getName()); m_list.SetItemText(k,2,p->getId()); m_list.SetItemText(k,3,p->getDate()); } k++; } break; }}2入住与订房界面代码//rzdj.cpp:implementationfile//#include"stdafx.h"#include"hotel.h"#include"rzdj.h"#ifdef_DEBUG#definenewDEBUG_NEW#undefTHIS_FILEstaticcharTHIS_FILE[]=__FILE__;#endif///////////////////////////////////////////////////////////////////////////////rzdjdialogrzdj::rzdj(CWnd*pParent/*=NULL*/) :CDialog(rzdj::IDD,pParent){ //{{AFX_DATA_INIT(rzdj) m_name=_T(""); m_sfzh=_T(""); 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_sfzh,18); DDX_Text(pDX,IDC_EDIT3,m_fh); DDV_MaxChars(pDX,m_fh,4); DDX_Text(pDX,IDC_EDIT4,m_rq); DDV_MaxChars(pDX,m_rq,10); //}}AFX_DATA_MAP}BEGIN_MESSAGE_MAP(rzdj,CDialog) //{{AFX_MSG_MAP(rzdj) //}}AFX_MSG_MAPEND_MESSAGE_MAP()///////////////////////////////////////////////////////////////////////////////rzdjmessagehandlersvoidrzdj::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_FILEstaticcharTHIS_FILE[]=__FILE__;#endif///////////////////////////////////////////////////////////////////////////////gkjzdialoggkjz::gkjz(CWnd*pParent/*=NULL*/) :CDialog(gkjz::IDD,pParent){ //{{AFX_DATA_INIT(gkjz) m_fh=_T(""); m_ts=0; m_jg=0.0f; //}}AFX_DATA_INIT}voidgkjz::DoData

温馨提示

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

评论

0/150

提交评论