?? qqview.cpp
字號:
// QQView.cpp : implementation of the CQQView class
//
#include "stdafx.h"
#include "QQ.h"
#include "QQDoc.h"
#include "QQView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//////////////////////////////////////////////////////////////////////////
#include "RoomRegister.h" //登記頭文件
#include "ChooseRoom.h" //選房頭文件
#include "ChooseFood.h" //選食物頭文件
#include "ChooseServer.h" //服務(wù)點單頭文件
#include "MoneyPay.h" //支付帳單頭文件
#include "Checkout.h" //結(jié)帳走人頭文件
#include "GuestInfoLookup.h" //客人信息查詢對話框頭文件
#include "RoomInfoLookup.h" //房間信息查詢對話框頭文件
#include "BillInfoLookup.h" //帳單信息查詢對話框頭文件
#include "EmployerInfoLookup.h"//職員信息查詢對話框頭文件
#include "Tools.h"
#include "page3.h"
#include "MainFrm.h"
#include "HotelInfoShow.h"//酒店概況顯示對話框
#include "RoomDestine.h" //房間預(yù)定頭文件
/////////////////////////////////////////////////////////////////////////////
// CQQView
IMPLEMENT_DYNCREATE(CQQView, CView)
BEGIN_MESSAGE_MAP(CQQView, CView)
//{{AFX_MSG_MAP(CQQView)
ON_COMMAND(ID_ROOM_REGISTER, OnRoomRegister)
ON_COMMAND(ID_ROOM_CHOOSE, OnRoomChoose)
ON_COMMAND(ID_FOOD_ORDER, OnFoodOrder)
ON_COMMAND(ID_SERVER_ORDER, OnServerOrder)
ON_COMMAND(ID_MONEY_CHECKOUT, OnMoneyCheckout)
ON_COMMAND(ID_MONEY_STOCK, OnMoneyStock)
ON_COMMAND(ID_MONEY_REPORTFORM, OnMoneyReportform)
ON_COMMAND(ID_INFOLOOK_GUEST, OnInfolookGuest)
ON_COMMAND(ID_INFOLOOK_BILL, OnInfolookBill)
ON_COMMAND(ID_INFOLOOK_EMPLOYER, OnInfolookEmployer)
ON_COMMAND(ID_INFOLOOK_FOOD, OnInfolookFood)
ON_COMMAND(ID_INFOLOOK_ROOM, OnInfolookRoom)
ON_COMMAND(ID_INFOLOOK_SERVER, OnInfolookServer)
ON_COMMAND(ID_INFOLOOK_CONSUME, OnInfolookConsume)
ON_WM_TIMER()
ON_WM_ERASEBKGND()
ON_COMMAND(ID_MONEY_PAY, OnMoneyPay)
ON_WM_CREATE()
ON_WM_LBUTTONDOWN()
ON_COMMAND(ID_ROOM_DESTINE, OnRoomDestine)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CQQView construction/destruction
HBITMAP CQQView::m_CurScreenBitmap=NULL;
BOOL CQQView::bFirstRun=TRUE;
int CQQView::nImgTypeInView=-1;//普通圖像類型
CPoint CQQView::pnt=CPoint(0,0);
CQQView::CQQView()
{
// TODO: add construction code here
//賦初值
strShowText="";
bFinish=false;
bFirst=true;
InitStructData();
}
CQQView::~CQQView()
{
m_List.RemoveAll();
}
CQQView * CQQView::GetView()
{//靜態(tài)成員函數(shù)
CFrameWnd * pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd);
CView * pView = pFrame->GetActiveView();
if ( !pView )
return NULL;
// Fail if view is of wrong kind
// (this could occur with splitter windows, or additional
// views on a single document
if ( ! pView->IsKindOf( RUNTIME_CLASS(CQQView) ) )
return NULL;
return (CQQView*) pView;
}
BOOL CQQView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CQQView drawing
void CQQView::OnDraw(CDC* pDC)
{
CQQDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
LoadbgroundBitmap(pDC);//畫背景
if(bFirstRun)
{
nImgTypeInView=0;
LoadWelocmeBmp(pDC);
bFirstRun=FALSE;
}
if(page3.bDrawTreeImage)
{
page3.DrawTreeImage(pDC,CPoint(50,0));
page3.bDrawTreeImage=FALSE;
}
if(page3.bDrawFrameImage)
{
page3.DrawFrameImg(pDC,CRect(page3.xStart,page3.yStart,page3.xStart+350,page3.yStart+200));
page3.bDrawFrameImage=FALSE;
}
}
/////////////////////////////////////////////////////////////////////////////
// CQQView printing
BOOL CQQView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CQQView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CQQView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CQQView diagnostics
#ifdef _DEBUG
void CQQView::AssertValid() const
{
CView::AssertValid();
}
void CQQView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CQQDoc* CQQView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CQQDoc)));
return (CQQDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CQQView message handlers
//加載背景圖
void CQQView::LoadbgroundBitmap(CDC *pDC)
{//加載視的背景圖
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BKBMP);
CDC m;
m.CreateCompatibleDC(pDC);//創(chuàng)建一個于pDC兼容的DC
m.SelectObject(&bitmap);
CRect rect;
this->GetClientRect(&rect);
pDC->BitBlt(0,0,rect.Width(),rect.Height(),&m,0,0,SRCCOPY);
m.DeleteDC();
}
void CQQView::LoadWelocmeBmp(CDC* pDC)
{//加載啟動時的歡迎圖像
CBitmap bitmap;
bitmap.LoadBitmap(IDB_HOTELTEXT);
CDC m;
m.CreateCompatibleDC(pDC);//創(chuàng)建一個于pDC兼容的DC
m.SelectObject(&bitmap);
CRect rect;
this->GetClientRect(&rect);
//// long nStartX=rect.left;
// long nStartY=rect.bottom-280;
long nStartX=rect.left+rect.Width()/10;
long nStartY=rect.top+rect.Height()/10;
BITMAP m_bitmap;//定義位圖結(jié)構(gòu)體來保存位圖信息
bitmap.GetBitmap(&m_bitmap);//得到位圖結(jié)構(gòu)體,記錄了位圖的信息
long nWidth=m_bitmap.bmWidth;//位圖寬度
long nHeight=m_bitmap.bmHeight;//位圖高度
pDC->BitBlt(nStartX,nStartY,nWidth,nHeight,&m,0,0,SRCCOPY);
m.DeleteDC();
}
void CQQView::SetBitmapText(CPoint pnt,CDC*pDC, CString strText)
{//顯示帶有圖像和文字的字符串
CBitmap bitmap;
bitmap.LoadBitmap(IDB_TEXT);
CDC m;
m.CreateCompatibleDC(pDC);
m.SelectObject(&bitmap);
pDC->SetBkMode(TRANSPARENT);//設(shè)置背景模式
pDC->BitBlt(pnt.x,pnt.y,9,9,&m,0,0,SRCCOPY);//拷貝圖像
pDC->TextOut(pnt.x+15,pnt.y-5,strText);//輸出文本
}
//###################################################################
/////////////////////信息管理模塊
/////////////////////////////////////////////////////////////////////
void CQQView::OnRoomRegister()
{
// TODO: Add your command handler code here
nImgTypeInView=-1;//背景圖
bFirstRun=FALSE;
CGuestRegister guestreg;
guestreg.DoModal();//登記對話框
}
void CQQView::OnRoomChoose()
{
// TODO: Add your command handler code here
nImgTypeInView=-1;//背景圖
bFirstRun=FALSE;
CChooseRoom chooseroom;
chooseroom.DoModal();
}
void CQQView::OnRoomDestine()
{//房間預(yù)定
// TODO: Add your command handler code here
bFirstRun=FALSE;
CRoomDestine RoomDestine;
RoomDestine.DoModal();
}
void CQQView::OnFoodOrder()
{
// TODO: Add your command handler code here
nImgTypeInView=-1;//背景圖
bFirstRun=FALSE;
CChooseFood choosefood;
choosefood.DoModal();
}
void CQQView::OnServerOrder()
{
// TODO: Add your command handler code here
nImgTypeInView=-1;//背景圖
bFirstRun=FALSE;
CChooseServer chooseserver;
chooseserver.DoModal();
}
void CQQView::OnMoneyCheckout()
{//結(jié)帳走人
// TODO: Add your command handler code here
nImgTypeInView=-1;//背景圖
bFirstRun=FALSE;
CCheckOut checkout;
checkout.DoModal();
}
void CQQView::OnMoneyStock()
{
// TODO: Add your command handler code here
nImgTypeInView=-1;//背景圖
bFirstRun=FALSE;
}
void CQQView::OnMoneyReportform()
{
// TODO: Add your command handler code here
nImgTypeInView=-1;//背景圖
bFirstRun=FALSE;
}
void CQQView::OnMoneyPay()
{//支付某個帳單的款項
// TODO: Add your command handler code here
nImgTypeInView=-1;//背景圖
bFirstRun=FALSE;
CMoneyPay moneypay;
moneypay.DoModal();
}
/////////////////////////////////////////////////////////////////////
//###################################################################
////////////////////////////信息查詢模塊
//////////////////////////////////////////////////////////////////////
void CQQView::OnInfolookGuest()
{
// TODO: Add your command handler code her
bFirstRun=FALSE;
this->Invalidate();
this->UpdateData(TRUE);
CDC*pDC=GetDC();
CRect rect;
GetClientRect(&rect);
pDC->FillSolidRect(rect,pDC->GetBkColor());
LoadbgroundBitmap(pDC);//畫背景
guestinfolookup.DoModal();//模態(tài)顯示對話框
//////////////////////////////////////////////////////////////////////
//////設(shè)置每行要顯示的文本
CString strlineText[12];//行文本對象
strlineText[0]="客人的手牌號碼(HandCode)是: ";
strlineText[0]=strlineText[0]+guestinfolookup.HandCode;//設(shè)置顯示文本
strlineText[1]="客人的名字是(Name): ";
strlineText[1]=strlineText[1]+guestinfolookup.Name;//name
strlineText[2]="客人的類型(GuestType): ";
strlineText[2]=strlineText[2]+guestinfolookup.GuestType+" ";//gueatype
strlineText[3]="客人性別(Sex): ";
strlineText[3]=strlineText[3]+guestinfolookup.Sex;//sex
strlineText[4]="客人登記時使用的證件類型(Cerificate): ";
strlineText[4]=strlineText[4]+guestinfolookup.Certificate;//Certificate
strlineText[5]="客人登記的證件號碼是(CertifyCode): ";
strlineText[5]=strlineText[5]+guestinfolookup.CertifyCode;//CertifyCode
strlineText[6]="客人是否為團隊成員(IsMember): ";
if(guestinfolookup.IsMember){strlineText[6]=strlineText[6]+"是";}
else{strlineText[6]=strlineText[6]+"否";}//ismember
strlineText[7]="客人是否為團隊客人的主客(IsMaster): ";
if(guestinfolookup.IsMaster){strlineText[7]=strlineText[7]+"是";}
else{strlineText[7]=strlineText[7]+"否";}//ismaster
strlineText[8]="客人所在團隊編號(GroupID): ";
strlineText[8]=strlineText[8]+guestinfolookup.GroupID;
strlineText[9]="客人所在團隊的客人數(shù)目(GuestNum): ";CString str;str.Format("%d",guestinfolookup.GuestNum);
strlineText[9]=strlineText[9]+str;
strlineText[10]="團隊的房間數(shù)目(RoomNum): ";
strlineText[10]=strlineText[10]+guestinfolookup.RoomNum;
strlineText[11]="客人所在房間的號碼(RoomCode): ";
strlineText[11]=strlineText[11]+guestinfolookup.RoomCode;
int nWidth=rect.Width();
int nHeight=rect.Height();
CPoint potstart;
potstart.x=rect.left+nWidth/10;
potstart.y=rect.top+nHeight/10;
if(guestinfolookup.bSuccess)//查詢數(shù)據(jù)庫成功則進行操作
{
pDC->SetBkMode(TRANSPARENT);//設(shè)置背景模式
for(int i=0;i<12;i++)
{
pDC->SetBkMode(TRANSPARENT);
SetBitmapText(potstart.x,potstart.y+20*i,pDC,strlineText[i]);
}
}
//////////////////////////////////////////////////////////////////////
ClientToScreen(&rect);//將客戶區(qū)域轉(zhuǎn)變成屏幕坐標(biāo)
m_CurScreenBitmap=::GetScreenBitmap(&rect);
nImgTypeInView=0;//文字背景圖
}
void CQQView::OnInfolookBill()
{
// TODO: Add your command handler code here
bFirstRun=FALSE;
this->Invalidate();
this->UpdateData(TRUE);
CDC*pDC=GetDC();
CRect rect;
GetClientRect(&rect);//得到客戶區(qū)域
pDC->FillSolidRect(rect,pDC->GetBkColor());
LoadbgroundBitmap(pDC);//畫背景
CBillInfoLookup billinfolookup;
billinfolookup.DoModal();
///////////////////////////////////////////////////////////////
/////////////////顯示查詢文本
///////////////////////////////////////////////////////////////
CString line[6];
line[0]="帳單號: ";
line[0]=line[0]+billinfolookup.BillCode;
line[1]="客人手牌號碼: ";
line[1]=line[1]+billinfolookup.HandCode;
line[2]="應(yīng)付總金額: ";CString str;str.Format("%d",billinfolookup.Sum);
line[2]=line[2]+str;
line[3]="實付金額: ";str.Format("%d",billinfolookup.Paid);
line[3]=line[3]+str;
line[4]="折扣率: ";
line[4]=line[4]+billinfolookup.Rebate;
line[5]="是/否已經(jīng)付款: ";
if(billinfolookup.Striked)
{
line[5]=line[5]+"是";
}
else{ line[5]=line[5]+"否";}
////////////showtext////////////////////
int nWidth=rect.Width();
int nHeight=rect.Height();
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -