QQView.cpp
上传用户:czfddz
上传日期:2013-03-20
资源大小:1517k
文件大小:24k
源码类别:

酒店行业

开发平台:

C/C++

  1. // QQView.cpp : implementation of the CQQView class
  2. //
  3. #include "stdafx.h"
  4. #include "QQ.h"
  5. #include "QQDoc.h"
  6. #include "QQView.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. //////////////////////////////////////////////////////////////////////////
  13. #include "RoomRegister.h"      //登记头文件 
  14. #include "ChooseRoom.h"        //选房头文件
  15. #include "ChooseFood.h"        //选食物头文件
  16. #include "ChooseServer.h"      //服务点单头文件
  17. #include "MoneyPay.h"          //支付帐单头文件
  18. #include "Checkout.h"          //结帐走人头文件
  19. #include "GuestInfoLookup.h"   //客人信息查询对话框头文件
  20. #include "RoomInfoLookup.h"    //房间信息查询对话框头文件
  21. #include "BillInfoLookup.h"    //帐单信息查询对话框头文件
  22. #include "EmployerInfoLookup.h"//职员信息查询对话框头文件
  23. #include "Tools.h"
  24. #include "page3.h"
  25. #include "MainFrm.h"
  26. #include "HotelInfoShow.h"//酒店概况显示对话框 
  27. #include "RoomDestine.h"  //房间预定头文件
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CQQView
  30. IMPLEMENT_DYNCREATE(CQQView, CView)
  31. BEGIN_MESSAGE_MAP(CQQView, CView)
  32. //{{AFX_MSG_MAP(CQQView)
  33. ON_COMMAND(ID_ROOM_REGISTER, OnRoomRegister)
  34. ON_COMMAND(ID_ROOM_CHOOSE, OnRoomChoose)
  35. ON_COMMAND(ID_FOOD_ORDER, OnFoodOrder)
  36. ON_COMMAND(ID_SERVER_ORDER, OnServerOrder)
  37. ON_COMMAND(ID_MONEY_CHECKOUT, OnMoneyCheckout)
  38. ON_COMMAND(ID_MONEY_STOCK, OnMoneyStock)
  39. ON_COMMAND(ID_MONEY_REPORTFORM, OnMoneyReportform)
  40. ON_COMMAND(ID_INFOLOOK_GUEST, OnInfolookGuest)
  41. ON_COMMAND(ID_INFOLOOK_BILL, OnInfolookBill)
  42. ON_COMMAND(ID_INFOLOOK_EMPLOYER, OnInfolookEmployer)
  43. ON_COMMAND(ID_INFOLOOK_FOOD, OnInfolookFood)
  44. ON_COMMAND(ID_INFOLOOK_ROOM, OnInfolookRoom)
  45. ON_COMMAND(ID_INFOLOOK_SERVER, OnInfolookServer)
  46. ON_COMMAND(ID_INFOLOOK_CONSUME, OnInfolookConsume)
  47. ON_WM_TIMER()
  48. ON_WM_ERASEBKGND()
  49. ON_COMMAND(ID_MONEY_PAY, OnMoneyPay)
  50. ON_WM_CREATE()
  51. ON_WM_LBUTTONDOWN()
  52. ON_COMMAND(ID_ROOM_DESTINE, OnRoomDestine)
  53. //}}AFX_MSG_MAP
  54. // Standard printing commands
  55. ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
  56. ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
  57. ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
  58. END_MESSAGE_MAP()
  59. /////////////////////////////////////////////////////////////////////////////
  60. // CQQView construction/destruction
  61. HBITMAP CQQView::m_CurScreenBitmap=NULL;
  62. BOOL CQQView::bFirstRun=TRUE;
  63. int CQQView::nImgTypeInView=-1;//普通图像类型
  64. CPoint CQQView::pnt=CPoint(0,0);
  65. CQQView::CQQView()
  66. {
  67. // TODO: add construction code here
  68. //赋初值
  69.      strShowText="";
  70.  bFinish=false;
  71.  bFirst=true;
  72.  InitStructData();
  73. }
  74. CQQView::~CQQView()
  75. {
  76.     m_List.RemoveAll();
  77. }
  78. CQQView * CQQView::GetView()
  79. {//静态成员函数
  80. CFrameWnd * pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd);
  81. CView * pView = pFrame->GetActiveView();
  82. if ( !pView )
  83. return NULL;
  84. // Fail if view is of wrong kind
  85. // (this could occur with splitter windows, or additional
  86. // views on a single document
  87. if ( ! pView->IsKindOf( RUNTIME_CLASS(CQQView) ) )
  88. return NULL;
  89. return (CQQView*) pView;
  90. }
  91. BOOL CQQView::PreCreateWindow(CREATESTRUCT& cs)
  92. {
  93. // TODO: Modify the Window class or styles here by modifying
  94. //  the CREATESTRUCT cs
  95. return CView::PreCreateWindow(cs);
  96. }
  97. /////////////////////////////////////////////////////////////////////////////
  98. // CQQView drawing
  99. void CQQView::OnDraw(CDC* pDC)
  100. {
  101. CQQDoc* pDoc = GetDocument();
  102. ASSERT_VALID(pDoc);
  103. // TODO: add draw code for native data here
  104. LoadbgroundBitmap(pDC);//画背景
  105. if(bFirstRun)
  106. {
  107. nImgTypeInView=0;
  108.         LoadWelocmeBmp(pDC);
  109. bFirstRun=FALSE;
  110. }
  111. if(page3.bDrawTreeImage)
  112. {
  113. page3.DrawTreeImage(pDC,CPoint(50,0));
  114. page3.bDrawTreeImage=FALSE;
  115. }
  116. if(page3.bDrawFrameImage)
  117. {
  118. page3.DrawFrameImg(pDC,CRect(page3.xStart,page3.yStart,page3.xStart+350,page3.yStart+200));
  119.     page3.bDrawFrameImage=FALSE;
  120. }
  121. }
  122. /////////////////////////////////////////////////////////////////////////////
  123. // CQQView printing
  124. BOOL CQQView::OnPreparePrinting(CPrintInfo* pInfo)
  125. {
  126. // default preparation
  127. return DoPreparePrinting(pInfo);
  128. }
  129. void CQQView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  130. {
  131. // TODO: add extra initialization before printing
  132. }
  133. void CQQView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
  134. {
  135. // TODO: add cleanup after printing
  136. }
  137. /////////////////////////////////////////////////////////////////////////////
  138. // CQQView diagnostics
  139. #ifdef _DEBUG
  140. void CQQView::AssertValid() const
  141. {
  142. CView::AssertValid();
  143. }
  144. void CQQView::Dump(CDumpContext& dc) const
  145. {
  146. CView::Dump(dc);
  147. }
  148. CQQDoc* CQQView::GetDocument() // non-debug version is inline
  149. {
  150. ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CQQDoc)));
  151. return (CQQDoc*)m_pDocument;
  152. }
  153. #endif //_DEBUG
  154. /////////////////////////////////////////////////////////////////////////////
  155. // CQQView message handlers
  156. //加载背景图
  157. void CQQView::LoadbgroundBitmap(CDC *pDC)
  158. {//加载视的背景图 
  159.     CBitmap bitmap;
  160.     bitmap.LoadBitmap(IDB_BKBMP);
  161. CDC m;
  162. m.CreateCompatibleDC(pDC);//创建一个于pDC兼容的DC
  163. m.SelectObject(&bitmap);
  164. CRect rect;
  165. this->GetClientRect(&rect);
  166. pDC->BitBlt(0,0,rect.Width(),rect.Height(),&m,0,0,SRCCOPY);
  167.     m.DeleteDC();  
  168. }
  169. void CQQView::LoadWelocmeBmp(CDC* pDC)
  170. {//加载启动时的欢迎图像 
  171. CBitmap bitmap;
  172.     bitmap.LoadBitmap(IDB_HOTELTEXT);
  173. CDC m;
  174. m.CreateCompatibleDC(pDC);//创建一个于pDC兼容的DC
  175. m.SelectObject(&bitmap);
  176. CRect rect;
  177. this->GetClientRect(&rect);
  178. //// long nStartX=rect.left;
  179. // long nStartY=rect.bottom-280;
  180.     long nStartX=rect.left+rect.Width()/10;
  181. long nStartY=rect.top+rect.Height()/10;
  182. BITMAP m_bitmap;//定义位图结构体来保存位图信息
  183. bitmap.GetBitmap(&m_bitmap);//得到位图结构体,记录了位图的信息
  184. long nWidth=m_bitmap.bmWidth;//位图宽度
  185. long nHeight=m_bitmap.bmHeight;//位图高度
  186. pDC->BitBlt(nStartX,nStartY,nWidth,nHeight,&m,0,0,SRCCOPY);
  187.     m.DeleteDC(); 
  188. }
  189. void CQQView::SetBitmapText(CPoint pnt,CDC*pDC, CString strText)
  190. {//显示带有图像和文字的字符串
  191.     CBitmap bitmap;
  192. bitmap.LoadBitmap(IDB_TEXT);
  193. CDC m;
  194. m.CreateCompatibleDC(pDC);
  195. m.SelectObject(&bitmap);
  196. pDC->SetBkMode(TRANSPARENT);//设置背景模式
  197. pDC->BitBlt(pnt.x,pnt.y,9,9,&m,0,0,SRCCOPY);//拷贝图像
  198. pDC->TextOut(pnt.x+15,pnt.y-5,strText);//输出文本
  199. }
  200. //###################################################################
  201. /////////////////////信息管理模块
  202. /////////////////////////////////////////////////////////////////////
  203. void CQQView::OnRoomRegister() 
  204. {
  205. // TODO: Add your command handler code here
  206. nImgTypeInView=-1;//背景图
  207. bFirstRun=FALSE;
  208. CGuestRegister guestreg;
  209. guestreg.DoModal();//登记对话框
  210. }
  211. void CQQView::OnRoomChoose() 
  212. {
  213. // TODO: Add your command handler code here
  214. nImgTypeInView=-1;//背景图
  215. bFirstRun=FALSE;
  216. CChooseRoom chooseroom;
  217. chooseroom.DoModal();
  218. }
  219. void CQQView::OnRoomDestine() 
  220. {//房间预定
  221. // TODO: Add your command handler code here
  222. bFirstRun=FALSE;
  223.     CRoomDestine RoomDestine;
  224. RoomDestine.DoModal();
  225. }
  226. void CQQView::OnFoodOrder() 
  227. {
  228. // TODO: Add your command handler code here
  229. nImgTypeInView=-1;//背景图
  230. bFirstRun=FALSE;
  231. CChooseFood choosefood;
  232. choosefood.DoModal();
  233. }
  234. void CQQView::OnServerOrder() 
  235. {
  236. // TODO: Add your command handler code here
  237. nImgTypeInView=-1;//背景图
  238. bFirstRun=FALSE;
  239. CChooseServer chooseserver;
  240. chooseserver.DoModal();
  241. }
  242. void CQQView::OnMoneyCheckout() 
  243. {//结帐走人
  244. // TODO: Add your command handler code here
  245. nImgTypeInView=-1;//背景图
  246. bFirstRun=FALSE;
  247. CCheckOut checkout;
  248.     checkout.DoModal();
  249. }
  250. void CQQView::OnMoneyStock() 
  251. {
  252. // TODO: Add your command handler code here
  253. nImgTypeInView=-1;//背景图
  254. bFirstRun=FALSE;
  255. }
  256. void CQQView::OnMoneyReportform() 
  257. {
  258. // TODO: Add your command handler code here
  259. nImgTypeInView=-1;//背景图
  260. bFirstRun=FALSE;
  261. }
  262. void CQQView::OnMoneyPay() 
  263. {//支付某个帐单的款项
  264. // TODO: Add your command handler code here
  265. nImgTypeInView=-1;//背景图
  266. bFirstRun=FALSE;
  267. CMoneyPay  moneypay;
  268. moneypay.DoModal();
  269. }
  270. /////////////////////////////////////////////////////////////////////
  271. //###################################################################
  272. ////////////////////////////信息查询模块
  273. //////////////////////////////////////////////////////////////////////
  274. void CQQView::OnInfolookGuest() 
  275. {
  276. // TODO: Add your command handler code her
  277. bFirstRun=FALSE;
  278.     this->Invalidate();
  279. this->UpdateData(TRUE);
  280. CDC*pDC=GetDC();
  281. CRect rect;
  282. GetClientRect(&rect);
  283. pDC->FillSolidRect(rect,pDC->GetBkColor());
  284. LoadbgroundBitmap(pDC);//画背景
  285.     guestinfolookup.DoModal();//模态显示对话框
  286. //////////////////////////////////////////////////////////////////////
  287. //////设置每行要显示的文本
  288. CString strlineText[12];//行文本对象
  289.     strlineText[0]="客人的手牌号码(HandCode)是: ";
  290. strlineText[0]=strlineText[0]+guestinfolookup.HandCode;//设置显示文本 
  291.     strlineText[1]="客人的名字是(Name): ";
  292.     strlineText[1]=strlineText[1]+guestinfolookup.Name;//name
  293.     strlineText[2]="客人的类型(GuestType): ";
  294.     strlineText[2]=strlineText[2]+guestinfolookup.GuestType+" ";//gueatype
  295.     strlineText[3]="客人性别(Sex): ";
  296.     strlineText[3]=strlineText[3]+guestinfolookup.Sex;//sex
  297.     strlineText[4]="客人登记时使用的证件类型(Cerificate): ";
  298.     strlineText[4]=strlineText[4]+guestinfolookup.Certificate;//Certificate
  299. strlineText[5]="客人登记的证件号码是(CertifyCode): ";
  300.     strlineText[5]=strlineText[5]+guestinfolookup.CertifyCode;//CertifyCode
  301.     strlineText[6]="客人是否为团队成员(IsMember): ";
  302. if(guestinfolookup.IsMember){strlineText[6]=strlineText[6]+"是";}
  303. else{strlineText[6]=strlineText[6]+"否";}//ismember
  304.     strlineText[7]="客人是否为团队客人的主客(IsMaster): ";
  305. if(guestinfolookup.IsMaster){strlineText[7]=strlineText[7]+"是";}
  306. else{strlineText[7]=strlineText[7]+"否";}//ismaster
  307.     strlineText[8]="客人所在团队编号(GroupID): ";
  308.     strlineText[8]=strlineText[8]+guestinfolookup.GroupID;
  309.     strlineText[9]="客人所在团队的客人数目(GuestNum): ";CString str;str.Format("%d",guestinfolookup.GuestNum);
  310.     strlineText[9]=strlineText[9]+str;
  311.     strlineText[10]="团队的房间数目(RoomNum): ";
  312.     strlineText[10]=strlineText[10]+guestinfolookup.RoomNum;
  313.     strlineText[11]="客人所在房间的号码(RoomCode): ";
  314.     strlineText[11]=strlineText[11]+guestinfolookup.RoomCode;
  315. int nWidth=rect.Width();
  316. int nHeight=rect.Height();
  317. CPoint potstart;
  318. potstart.x=rect.left+nWidth/10;
  319. potstart.y=rect.top+nHeight/10;
  320.     if(guestinfolookup.bSuccess)//查询数据库成功则进行操作
  321. {
  322.         pDC->SetBkMode(TRANSPARENT);//设置背景模式
  323.     for(int i=0;i<12;i++)
  324. {
  325. pDC->SetBkMode(TRANSPARENT);
  326. SetBitmapText(potstart.x,potstart.y+20*i,pDC,strlineText[i]);
  327. }
  328. }
  329. //////////////////////////////////////////////////////////////////////
  330.     ClientToScreen(&rect);//将客户区域转变成屏幕坐标
  331. m_CurScreenBitmap=::GetScreenBitmap(&rect);
  332. nImgTypeInView=0;//文字背景图
  333. }
  334. void CQQView::OnInfolookBill() 
  335. {
  336. // TODO: Add your command handler code here
  337. bFirstRun=FALSE;
  338. this->Invalidate();
  339. this->UpdateData(TRUE);
  340. CDC*pDC=GetDC();
  341. CRect rect;
  342. GetClientRect(&rect);//得到客户区域
  343. pDC->FillSolidRect(rect,pDC->GetBkColor());
  344. LoadbgroundBitmap(pDC);//画背景
  345.     CBillInfoLookup billinfolookup;
  346.     billinfolookup.DoModal();
  347. ///////////////////////////////////////////////////////////////
  348. /////////////////显示查询文本
  349. ///////////////////////////////////////////////////////////////
  350. CString line[6];
  351. line[0]="帐单号: ";
  352.     line[0]=line[0]+billinfolookup.BillCode;
  353. line[1]="客人手牌号码: ";
  354. line[1]=line[1]+billinfolookup.HandCode;
  355. line[2]="应付总金额: ";CString str;str.Format("%d",billinfolookup.Sum);
  356.     line[2]=line[2]+str;
  357. line[3]="实付金额: ";str.Format("%d",billinfolookup.Paid);
  358.     line[3]=line[3]+str;
  359. line[4]="折扣率: ";
  360. line[4]=line[4]+billinfolookup.Rebate;
  361. line[5]="是/否已经付款: ";
  362. if(billinfolookup.Striked)
  363. {
  364.        line[5]=line[5]+"是";
  365. }
  366. else{ line[5]=line[5]+"否";}
  367. ////////////showtext////////////////////
  368. int nWidth=rect.Width();
  369. int nHeight=rect.Height();
  370. CPoint potstart;
  371. potstart.x=rect.left+nWidth/10;
  372. potstart.y=rect.top+nHeight/10;
  373.     if(billinfolookup.bSuccess)//查询数据库成功则进行操作
  374. {
  375.         pDC->SetBkMode(TRANSPARENT);//设置背景模式
  376.     for(int i=0;i<6;i++)
  377. {
  378. SetBitmapText(potstart.x,potstart.y+20*i,pDC,line[i]);
  379. }
  380. }
  381. ///////////////////////////over/////////////////////////
  382. ClientToScreen(&rect);//将客户区域转变成屏幕坐标
  383. m_CurScreenBitmap=::GetScreenBitmap(&rect);
  384. nImgTypeInView=0;//文字背景图
  385. }
  386. void CQQView::OnInfolookEmployer() 
  387. {
  388. // TODO: Add your command handler code here
  389. bFirstRun=FALSE;
  390. this->Invalidate();
  391. this->UpdateData(TRUE);
  392. CDC*pDC=GetDC();
  393. CRect rect;
  394. GetClientRect(&rect);
  395. pDC->FillSolidRect(rect,pDC->GetBkColor());
  396. LoadbgroundBitmap(pDC);//画背景
  397.     CEmployerInfoLookup employerinfolookup;
  398.     employerinfolookup.DoModal();
  399. ///////////////////show text/////////////////////
  400. CString line[3];
  401. line[0]="员工编号: ";
  402. line[0]=line[0]+employerinfolookup.EmployerCode;
  403. line[1]="名字: ";
  404. line[1]=line[1]+employerinfolookup.Name;
  405.     line[2]="所属部门: ";
  406.     line[2]=line[2]+employerinfolookup.Depart;
  407. //////show text
  408. int nWidth=rect.Width();
  409. int nHeight=rect.Height();
  410. CPoint potstart;
  411. potstart.x=rect.left+nWidth/10;
  412. potstart.y=rect.top+nHeight/10;
  413. if(employerinfolookup.bSuccess)//查询数据库成功则进行操作
  414. {
  415.         pDC->SetBkMode(TRANSPARENT);//设置背景模式
  416.     for(int i=0;i<3;i++)
  417. {
  418. SetBitmapText(potstart.x,potstart.y+20*i,pDC,line[i]);
  419. }
  420. }//over
  421. //////////////////////////////////////////////////////////////////////////
  422. ClientToScreen(&rect);//将客户区域转变成屏幕坐标
  423. m_CurScreenBitmap=::GetScreenBitmap(&rect);//抓取当前客户区图像,为改变
  424.                                //改变主框架大小时调用
  425. nImgTypeInView=0;//文字背景图
  426. }
  427. void CQQView::OnInfolookFood() 
  428. {
  429. // TODO: Add your command handler code here
  430. bFirstRun=FALSE;
  431.     this->UpdateData(TRUE);
  432. CDC*pDC=GetDC();
  433. CRect rect;
  434. GetClientRect(&rect);
  435. pDC->FillSolidRect(rect,pDC->GetBkColor());
  436. //  pDC->SetBkMode(TRANSPARENT);
  437. LoadbgroundBitmap(pDC);//画背景
  438. int nWidth=rect.Width();
  439. int nHeight=rect.Height();
  440. CPoint potstart;
  441. potstart.x=rect.left+nWidth/10;
  442. potstart.y=rect.top+nHeight/10;
  443. //////////////////////////////////////////////
  444. CFoodInfoSet m_FoodInfoSet;
  445.     if(!m_FoodInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE))
  446. {
  447. MessageBox("连接数据库失败或数据库为空!","数据库错误",MB_OK);
  448. return ;
  449. }
  450.     m_FoodInfoSet.MoveFirst();//to the first
  451. int i=0;
  452. while(!m_FoodInfoSet.IsEOF())
  453. {
  454.         CString foodname,foodprice,strShowText;
  455. foodname=m_FoodInfoSet.m_FoodName;
  456. foodprice.Format("%5.0f",m_FoodInfoSet.m_FoodPrice);
  457.         strShowText=foodname+": "+ foodprice;
  458. pDC->SetBkMode(TRANSPARENT);//设置背景模式
  459. SetBitmapText(potstart.x,potstart.y+20*i,pDC,strShowText);
  460.         m_FoodInfoSet.MoveNext();//next
  461. i++;
  462. }
  463.     m_FoodInfoSet.Close();
  464. ClientToScreen(&rect);//将客户区域转变成屏幕坐标
  465. m_CurScreenBitmap=::GetScreenBitmap(&rect);
  466. nImgTypeInView=0;//文字背景图
  467. }
  468. void CQQView::OnInfolookRoom() 
  469. {
  470. // TODO: Add your command handler code here
  471. bFirstRun=FALSE;
  472.     this->Invalidate();
  473. this->UpdateData(TRUE);
  474. CDC*pDC=GetDC();
  475. CRect rect;
  476. GetClientRect(&rect);
  477. pDC->FillSolidRect(rect,pDC->GetBkColor());
  478. LoadbgroundBitmap(pDC);//画背景
  479. CRoomInfoLookup roominfolookup;
  480. roominfolookup.DoModal();
  481. ///////////////////////////////////////////////////////////////
  482. CString line[7];
  483. line[0]="房间号: ";
  484.     line[0]=line[0]+roominfolookup.RoomCode;
  485. line[1]="房间类型: ";
  486. line[1]=line[1]+roominfolookup.RoomType;
  487. line[2]="房间所在楼层: ";
  488. CString str;str.Format("%d",roominfolookup.Floor);
  489. line[2]=line[2]+str;
  490. line[3]="房间电话号码: ";
  491.     line[3]=line[3]+roominfolookup.Phone;
  492. line[4]="房间状态: ";
  493. line[4]=line[4]+roominfolookup.RoomStatus;
  494. line[5]="是/否团队客人成员: ";
  495.     if(roominfolookup.PriceType)
  496. {
  497. line[5]=line[5]+"是";
  498. }
  499. else{ line[5]=line[5]+"否";}
  500. line[6]="房间单位时间价格: ";
  501. str.Format("%5.00f",roominfolookup.Price);
  502. line[6]=line[6]+str;
  503. ///////showtext
  504. int nWidth=rect.Width();
  505. int nHeight=rect.Height();
  506. CPoint potstart;
  507. potstart.x=rect.left+nWidth/10;
  508. potstart.y=rect.top+nHeight/10;
  509.     if(roominfolookup.bSuccess)//查询数据库成功则进行操作
  510. {
  511.         pDC->SetBkMode(TRANSPARENT);//设置背景模式
  512.     for(int i=0;i<7;i++)
  513. {
  514. SetBitmapText(potstart.x,potstart.y+20*i,pDC,line[i]);
  515. }
  516. }//over
  517. ClientToScreen(&rect);//将客户区域转变成屏幕坐标
  518. m_CurScreenBitmap=::GetScreenBitmap(&rect);
  519. nImgTypeInView=0;//文字背景图
  520. }
  521. void CQQView::OnInfolookServer() 
  522. {
  523. // TODO: Add your command handler code here
  524. bFirstRun=FALSE;
  525. this->UpdateData(TRUE);
  526. CDC*pDC=GetDC();
  527. CRect rect;
  528. GetClientRect(&rect);
  529. pDC->FillSolidRect(rect,pDC->GetBkColor());
  530. LoadbgroundBitmap(pDC);//画背景
  531. int nWidth=rect.Width();
  532. int nHeight=rect.Height();
  533. CPoint potstart;
  534. potstart.x=rect.left+nWidth/10;
  535. potstart.y=rect.top+nHeight/10;
  536. //////////////////////////////////////////////
  537. CServerInfoSet m_ServerInfoSet;
  538.     if(!m_ServerInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE))
  539. {
  540. MessageBox("连接数据库失败或数据库为空!","数据库错误",MB_OK);
  541. return ;
  542. }
  543.     m_ServerInfoSet.MoveFirst();//to the first
  544. int i=0;
  545. while(!m_ServerInfoSet.IsEOF())
  546. {
  547.         CString servername,serverprice,strShowText;
  548. servername=m_ServerInfoSet.m_ServerName;
  549. serverprice.Format("%5.0f",m_ServerInfoSet.m_ServerPrice);
  550.         strShowText=servername+": "+ serverprice;
  551. pDC->SetBkMode(TRANSPARENT);//设置背景模式
  552. SetBitmapText(potstart.x,potstart.y+20*i,pDC,strShowText);
  553. m_ServerInfoSet.MoveNext();//next
  554. i++;
  555. }
  556.     m_ServerInfoSet.Close();
  557. ClientToScreen(&rect);//将客户区域转变成屏幕坐标
  558. m_CurScreenBitmap=::GetScreenBitmap(&rect);
  559. nImgTypeInView=0;//文字背景图
  560. }
  561. void CQQView::OnInfolookConsume() 
  562. {
  563. // TODO: Add your command handler code here
  564. bFirstRun=FALSE;
  565. }
  566. //#####################################################################
  567. void CQQView::OnTimer(UINT nIDEvent) 
  568. {
  569. // TODO: Add your message handler code here and/or call default
  570. // CGuestInfoLookup guestinfolookup;
  571. // CDC* pDC=GetDC();//得到DC
  572. ////////////////////主要处理消息查询的显示 
  573. //////////////////////////////////////////////////////////////////////
  574. /*********************************************************************
  575.                          客人消息查询显示
  576. *********************************************************************/
  577. /////////////////////////////////////////////////////////////////////
  578. CView::OnTimer(nIDEvent);
  579. }
  580. BOOL CQQView::OnEraseBkgnd(CDC* pDC) 
  581. {
  582. // TODO: Add your message handler code here and/or call default
  583. return CView::OnEraseBkgnd(pDC);
  584. }
  585. int CQQView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
  586. {
  587. if (CView::OnCreate(lpCreateStruct) == -1)
  588. return -1;
  589. // TODO: Add your specialized creation code here
  590.     return 0;
  591. }
  592. /*
  593.  * 初始化结构体数据,保存数据到结构体中供其他的地方调用 
  594.  */
  595. static LPTSTR strText[]=
  596. {
  597. "本酒店全名:华天大酒店,属于国家五星级大酒店n是湖南地区最大的酒店",
  598. "客房部主要负责酒店的房间管理n已经和房间有关的工作",
  599. "这是客房部的一个分枝,接待客人的职能",
  600. "管理楼层",
  601. "清洗衣物",
  602. "餐饮部主要负责客人的食物服务n可进行:点菜,加/换、退菜的工作n还可以订送餐等服务",
  603. "对餐厅进行管理服务",
  604. "酒吧是餐饮部的分支,为客人提供酒服务",
  605. "康乐部主要负责各种娱乐活动,添加客人在酒店的乐趣",
  606. "洗浴区为用户提供上乘的服务n这里可以为客人提供洗澡的场所n还可以泡温水,能让客人得到充分的享受",
  607. "休闲娱乐中心,有舞厅,歌厅,卡拉OK包厢,设施齐全,服务一流",
  608. "财务部主要负责财务的管理,包括:结帐,库存,汇总报表等",
  609. "负责酒店的各种物品的购买",
  610. "存放各种酒店的物品等",
  611. "接收钱物,为客人进行钱物结帐",
  612.     NULL
  613. };
  614. void CQQView::InitStructData()
  615. {
  616.     RANGLEITEMSINFO* pInfo=new RANGLEITEMSINFO;
  617. pInfo->nIndex=0;
  618. pInfo->x1=126;pInfo->y1=8;
  619. pInfo->x2=206;pInfo->y2=45;
  620. pInfo->strContentText=strText[0];
  621. m_List.AddTail(pInfo);
  622.     pInfo=new RANGLEITEMSINFO;
  623. pInfo->nIndex=1;
  624. pInfo->x1=29;pInfo->y1=57;
  625. pInfo->x2=99;pInfo->y2=88;
  626. pInfo->strContentText=strText[1];
  627. m_List.AddTail(pInfo);
  628. pInfo=new RANGLEITEMSINFO;
  629. pInfo->nIndex=2;
  630. pInfo->x1=106;pInfo->y1=57;
  631. pInfo->x2=170;pInfo->y2=88;
  632. pInfo->strContentText=strText[5];
  633. m_List.AddTail(pInfo);
  634. pInfo=new RANGLEITEMSINFO;
  635. pInfo->nIndex=3;
  636. pInfo->x1=176;pInfo->y1=57;
  637. pInfo->x2=240;pInfo->y2=88;
  638. pInfo->strContentText=strText[8];
  639. m_List.AddTail(pInfo);
  640. pInfo=new RANGLEITEMSINFO;
  641. pInfo->nIndex=4;
  642. pInfo->x1=245;pInfo->y1=57;
  643. pInfo->x2=315;pInfo->y2=88;
  644. pInfo->strContentText=strText[11];
  645. m_List.AddTail(pInfo);
  646. pInfo=new RANGLEITEMSINFO;
  647. pInfo->nIndex=5;
  648. pInfo->x1=17;pInfo->y1=107;
  649. pInfo->x2=42;pInfo->y2=170;
  650. pInfo->strContentText=strText[2];
  651. m_List.AddTail(pInfo);
  652. pInfo=new RANGLEITEMSINFO;
  653. pInfo->nIndex=6;
  654. pInfo->x1=47;pInfo->y1=107;
  655. pInfo->x2=77;pInfo->y2=171;
  656. pInfo->strContentText=strText[3];
  657. m_List.AddTail(pInfo);
  658. pInfo=new RANGLEITEMSINFO;
  659. pInfo->nIndex=7;
  660. pInfo->x1=83;pInfo->y1=110;
  661. pInfo->x2=108;pInfo->y2=172;
  662. pInfo->strContentText=strText[4];
  663. m_List.AddTail(pInfo);
  664. pInfo=new RANGLEITEMSINFO;
  665. pInfo->nIndex=8;
  666. pInfo->x1=113;pInfo->y1=112;
  667. pInfo->x2=137;pInfo->y2=173;
  668. pInfo->strContentText=strText[6];
  669. m_List.AddTail(pInfo);
  670. pInfo=new RANGLEITEMSINFO;
  671. pInfo->nIndex=9;
  672. pInfo->x1=142;pInfo->y1=112;
  673. pInfo->x2=168;pInfo->y2=173;
  674. pInfo->strContentText=strText[7];
  675. m_List.AddTail(pInfo);
  676. pInfo=new RANGLEITEMSINFO;
  677. pInfo->nIndex=10;
  678. pInfo->x1=172;pInfo->y1=112;
  679. pInfo->x2=201;pInfo->y2=173;
  680. pInfo->strContentText=strText[9];
  681. m_List.AddTail(pInfo);
  682. pInfo=new RANGLEITEMSINFO;
  683. pInfo->nIndex=11;
  684. pInfo->x1=210;pInfo->y1=112;
  685. pInfo->x2=232;pInfo->y2=173;
  686. pInfo->strContentText=strText[10];
  687. m_List.AddTail(pInfo);
  688. pInfo=new RANGLEITEMSINFO;
  689. pInfo->nIndex=12;
  690. pInfo->x1=240;pInfo->y1=112;
  691. pInfo->x2=263;pInfo->y2=174;
  692. pInfo->strContentText=strText[12];
  693. m_List.AddTail(pInfo);
  694. pInfo=new RANGLEITEMSINFO;
  695. pInfo->nIndex=13;
  696. pInfo->x1=269;pInfo->y1=112;
  697. pInfo->x2=294;pInfo->y2=173;
  698. pInfo->strContentText=strText[13];
  699. m_List.AddTail(pInfo);
  700. pInfo=new RANGLEITEMSINFO;
  701. pInfo->nIndex=14;
  702. pInfo->x1=300;pInfo->y1=111;
  703. pInfo->x2=327;pInfo->y2=174;
  704. pInfo->strContentText=strText[14];
  705. m_List.AddTail(pInfo);
  706. }
  707. void CQQView::OnLButtonDown(UINT nFlags, CPoint point) 
  708. {
  709. // TODO: Add your message handler code here and/or call default
  710. if(nImgTypeInView==12)
  711. {
  712. for(int i=0;i<15;i++)
  713. {
  714. CRect rect(page3.pntArray[i*2],page3.pntArray[2*i+1]);
  715. if(rect.PtInRect(point))
  716. {   //若采用CHotoelInfoShow的方法来显示信息,总算存在背景的擦除问题
  717. //当采用动画的形式显示信息,退出对话框后,这个对话框的背景被重画
  718. //背景被擦除,不能保持图像的一致
  719. //  [6/29/2003-9:59]
  720. // CHotelInfoShow pHotelInfo;
  721. // pHotelInfo.lpszShowText=strText[i];
  722. // pHotelInfo.DoModal(); 
  723.                 MessageBox(strText[i],"酒店信息介绍",MB_OK);
  724. }
  725. }
  726. }
  727. if(nImgTypeInView==13)
  728. {//当前视图区显示的是“酒店概况”图像
  729. CRect rect;
  730. GetClientRect(&rect);
  731. pnt=point;
  732. CPoint pnt=page3.GetImgOrgPoint();//得到当前的图像原点
  733. int n=m_List.GetCount();
  734. for(int i=0;i<n;i++)
  735. {
  736.             RANGLEITEMSINFO* pRangleInfo;
  737. POSITION pos=m_List.FindIndex(i);
  738. pRangleInfo=m_List.GetAt(pos);
  739. CRect rect(pRangleInfo->x1+pnt.x,pRangleInfo->y1+pnt.y,pRangleInfo->x2+pnt.x,pRangleInfo->y2+pnt.y);
  740. if(rect.PtInRect(point))
  741. {
  742. //弹出消息,提示给用户关于酒店的情况
  743. MessageBox(pRangleInfo->strContentText,"酒店情况介绍",MB_OK);
  744. //  CHotelInfoShow pHotelInfo;
  745. //      pHotelInfo.lpszShowText=pRangleInfo->strContentText;
  746. // pHotelInfo.pntCenter=point;
  747. //  pHotelInfo.DoModal(); 
  748. }
  749. }
  750. }
  751. CView::OnLButtonDown(nFlags, point);
  752. }