?? page1.cpp
字號(hào):
// Page1.cpp : implementation file
//
#include "stdafx.h"
#include "qq.h"
#include "Page1.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//#define WM_SETPOS WM_USER+2//自定義消息
#include "QQView.h"
#include "InfoLookDialog.h"//消息顯示對(duì)話框
/////////////////////////////////////////////////////////////////////////////
// CPage1 dialog
IMPLEMENT_DYNCREATE(CPage1, CDialog)
int CPage1::nTablesItems[nTables]={0,0,0,0,0,0};
CString CPage1::pszText[nTables][nLines][nCols]=
{
""
};
CPage1::CPage1(CWnd* pParent /*=NULL*/)
: CDialog(CPage1::IDD, pParent)
{
//{{AFX_DATA_INIT(CPage1)
m_bBill = FALSE;
m_bEmployer = FALSE;
m_bFood = FALSE;
m_bGuest = FALSE;
m_bRoom = FALSE;
m_bServer = FALSE;
m_SearchType = 1;
//}}AFX_DATA_INIT
bSearch=false;//初始狀態(tài)為不搜索狀態(tài)
}
void CPage1::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPage1)
DDX_Control(pDX, IDC_SEARCHTEXT, m_SearchText);
DDX_Control(pDX, IDC_COOLPROGRESS, m_CoolProgress);
DDX_Check(pDX, IDC_CHECK_BILL, m_bBill);
DDX_Check(pDX, IDC_CHECK_EMPLOYER, m_bEmployer);
DDX_Check(pDX, IDC_CHECK_FOOD, m_bFood);
DDX_Check(pDX, IDC_CHECK_GUEST, m_bGuest);
DDX_Check(pDX, IDC_CHECK_ROOM, m_bRoom);
DDX_Check(pDX, IDC_CHECK_SERVER, m_bServer);
DDX_Radio(pDX, IDC_RADIO1, m_SearchType);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPage1, CDialog)
//{{AFX_MSG_MAP(CPage1)
ON_BN_CLICKED(IDC_CHECK_BILL, OnCheckBill)
ON_BN_CLICKED(IDC_CHECK_EMPLOYER, OnCheckEmployer)
ON_BN_CLICKED(IDC_CHECK_FOOD, OnCheckFood)
ON_BN_CLICKED(IDC_CHECK_GUEST, OnCheckGuest)
ON_BN_CLICKED(IDC_CHECK_ROOM, OnCheckRoom)
ON_BN_CLICKED(IDC_CHECK_SERVER, OnCheckServer)
ON_EN_CHANGE(IDC_SEARCHTEXT, OnChangeSearchtext)
ON_BN_CLICKED(IDC_RADIO1, OnRadio)
ON_BN_CLICKED(IDOK, OnSearch)
ON_WM_DESTROY()
ON_COMMAND(WM_SETPOS,OnSetCoolProcessPos)
ON_BN_CLICKED(IDC_RADIO2, OnRadio)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPage1 message handlers
BOOL CPage1::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
//初始化數(shù)據(jù)成員
m_CoolProgress.SetRange(0,100);
m_CoolProgress.SetColor(RGB(64,0,0));
m_CoolProgress.SetStep(1);
m_CoolProgress.SetPos(0);
//初始化靜態(tài)數(shù)據(jù)成員
InitDate();//初始化數(shù)據(jù)成員
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPage1::OnCheckBill()
{
// TODO: Add your control notification handler code here
this->UpdateData(true);
if(m_bBill==TRUE)
{
m_bBill=FALSE;
}
else{m_bBill=TRUE;}
}
void CPage1::OnCheckEmployer()
{
// TODO: Add your control notification handler code here
this->UpdateData(TRUE);
if(m_bEmployer==TRUE)
{
m_bEmployer=FALSE;
}
else{m_bEmployer=TRUE;}
}
void CPage1::OnCheckFood()
{
// TODO: Add your control notification handler code here
this->UpdateData(TRUE);
if(m_bFood==TRUE){m_bFood=FALSE;}
else{m_bFood=TRUE;}
}
void CPage1::OnCheckGuest()
{
// TODO: Add your control notification handler code here
this->UpdateData(TRUE);
if(m_bGuest==TRUE){m_bGuest=FALSE;}
else{m_bGuest=TRUE;}
}
void CPage1::OnCheckRoom()
{
// TODO: Add your control notification handler code here
this->UpdateData(TRUE);
if(m_bRoom==TRUE){m_bRoom=FALSE;}
else{m_bRoom=TRUE;}
}
void CPage1::OnCheckServer()
{
// TODO: Add your control notification handler code here
this->UpdateData(TRUE);
if(m_bServer==TRUE){m_bServer=FALSE;}
else{m_bServer=TRUE;}
}
void CPage1::OnChangeSearchtext()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
CString strSearchText;
m_SearchText.GetWindowText(strSearchText);
if(!m_SearchMethod.CheckString(strSearchText))
{//檢查輸入的語(yǔ)法的正確性
AfxMessageBox("你輸入的字符不合法!");
}
}
void CPage1::OnRadio()
{
// TODO: Add your control notification handler code here
this->UpdateData(TRUE);//更新數(shù)據(jù)
}
void CPage1::OnSearch()
{//按照制定的設(shè)置查詢數(shù)據(jù)庫(kù)
// TODO: Add your control notification handler code here
/*
CQQView* pView=CQQView::GetView();
CDC* pDC=pView->GetDC();//得到視圖類DC*/
//獲得搜索類型,根據(jù)類型進(jìn)行不同的搜索
this->UpdateData(TRUE);//數(shù)據(jù)更新
this->InitDate();//數(shù)據(jù)初始化,清除上次保留的數(shù)據(jù)
bSearch=true;
m_CoolProgress.SetPos(0);//初始位置
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
一些特殊情況的處理
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
CString strSearchText;
m_SearchText.GetWindowText(strSearchText);
if(strSearchText=="")
{//查詢文本為空
AfxMessageBox("請(qǐng)輸入查詢文本!");
return;
}
bool bunusualchar=false;//是否含有"?"或者"*"字符
int i=0;
while (i<strSearchText.GetLength()&&strSearchText[i]!=NULL)
{
if(strSearchText[i]=='?'||strSearchText[i]=='*')
{
bunusualchar=true;
break;
}
i++;
}
if(bunusualchar&&m_SearchType==0)
{//含有特殊的查詢文本但是選擇的是"完全匹配”查詢模式
AfxMessageBox("你輸入的查詢文本中含有通配符\n但是你選的是'完全匹配'模式!Error!");
return;
}
if(m_bGuest==FALSE&&m_bRoom==FALSE&&m_bBill==FALSE&&m_bServer==FALSE
&&m_bFood==FALSE&&m_bEmployer==FALSE)
{//沒(méi)有選擇一種輸出項(xiàng)目
AfxMessageBox("你應(yīng)該至少選擇一種輸出項(xiàng)目");
return;
}
/* 特殊處理完畢!!!! */
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
完全匹配查詢模塊
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
if(m_bGuest)
{
SearchGuestInfoSet(strSearchText);
}
if(m_bRoom)
{
SearchRoomInfoSet(strSearchText);
}
if(m_bBill)
{
SearchBillInfoSet(strSearchText);
}
if(m_bServer)
{
SearchServerInfoSet(strSearchText);
}
if(m_bFood)
{
SearchFoodInfoSet(strSearchText);
}
if(m_bEmployer)
{
SearchEmployerInfoSet(strSearchText);
}
if(bSearch)
{
for(i=0;i<100;i++)
{
m_CoolProgress.SetPos(i);
}
bSearch=false;
}
/*************************相似查詢模塊結(jié)束*************************/
////////////////////////////////////////////////////////////////////
CInfoLookDialog m_InfoLookDialog;
m_InfoLookDialog.DoModal();//顯示查詢得到的結(jié)果
}
void CPage1::InitDate()
{//初始化靜態(tài)數(shù)據(jù)成員
for(int i=0;i<nTables;i++)
{
for(int j=0;j<nLines;j++)
{
for(int k=0;k<nCols;k++)
{
pszText[i][j][k]="";//初始化字符數(shù)組
}
}
}
for(i=0;i<nTables;i++)
{
nTablesItems[i]=0;//每張表的項(xiàng)目的數(shù)目設(shè)置為0
}
}
void CPage1::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
// InitDate();
}
void CPage1::SearchGuestInfoSet(CString strSearchText)
{//搜索GuestInfoSet數(shù)據(jù)庫(kù)表
this->UpdateData(TRUE);//數(shù)據(jù)更新
int nTablesItemNum=nTablesItems[0];//表搜索到的項(xiàng)目數(shù)目
// CString strTempText[100];
// for(int i=0;i<100;i++)
// {
// strTempText[i]="";
// }
// int strTempTextItems=0;//記錄保存到臨時(shí)記錄數(shù)組中的個(gè)數(shù)
if(!m_GuestInfoSet.Open())
{
AfxMessageBox("打開(kāi)數(shù)據(jù)庫(kù)失敗!");
return;
}
m_GuestInfoSet.MoveFirst();//移動(dòng)到第一條記錄
while (!m_GuestInfoSet.IsEOF())
{
bool bhas=true;
if(bhas)
{
if(m_SearchMethod.MatchingString(m_GuestInfoSet.m_HandCode,strSearchText))
{//與手牌號(hào)碼匹配
FillGuestInfo(nTablesItemNum);//填充記錄
nTablesItemNum++;//記錄加1
// if(m_bBill)
// {
// strTempText[strTempTextItems]=m_GuestInfoSet.m_HandCode;
// strTempTextItems++;//Add 1
// }
bhas=false;
}
}
if(bhas)//若前面已經(jīng)找到了這個(gè)記錄
{
if(m_SearchMethod.MatchingString(m_GuestInfoSet.m_Name,strSearchText))
{//與名字匹配
FillGuestInfo(nTablesItemNum);//填充記錄
nTablesItemNum++;//記錄加1
// if(m_bBill)
// {
// strTempText[strTempTextItems]=m_GuestInfoSet.m_HandCode;
// strTempTextItems++;//Add 1
// }
bhas=false;
}
}
if(bhas)
{
if(m_SearchMethod.MatchingString(m_GuestInfoSet.m_GuestType,strSearchText))
{//與客人類型匹配
FillGuestInfo(nTablesItemNum);//填充記錄
nTablesItemNum++;//記錄加1
// if(m_bBill)
// {
// strTempText[strTempTextItems]=m_GuestInfoSet.m_HandCode;
// strTempTextItems++;//Add 1
// }
bhas=false;
}
}
if(bhas)
{
if(m_SearchMethod.MatchingString(m_GuestInfoSet.m_Sex,strSearchText))
{//與客人性別匹配
FillGuestInfo(nTablesItemNum);//填充記錄
nTablesItemNum++;//記錄加1
// if(m_bBill)
// {
// strTempText[strTempTextItems]=m_GuestInfoSet.m_HandCode;
// strTempTextItems++;//Add 1
// }
bhas=false;
}
}
if(bhas)
{
if(m_SearchMethod.MatchingString(m_GuestInfoSet.m_Certificate,strSearchText))
{//與客人證件類型匹配
FillGuestInfo(nTablesItemNum);//填充記錄
nTablesItemNum++;//記錄加1
// if(m_bBill)
// {
// strTempText[strTempTextItems]=m_GuestInfoSet.m_HandCode;
// strTempTextItems++;//Add 1
// }
bhas=false;
}
}
if(bhas)
{
if(m_SearchMethod.MatchingString(m_GuestInfoSet.m_CertifyCode,strSearchText))
{//與客人證件號(hào)碼匹配
FillGuestInfo(nTablesItemNum);//填充記錄
nTablesItemNum++;//記錄加1
// if(m_bBill)
// {
// strTempText[strTempTextItems]=m_GuestInfoSet.m_HandCode;
// strTempTextItems++;//Add 1
// }
bhas=false;
}
}
CString str;
if(m_GuestInfoSet.m_IsMember){str="是";}
else{str="否";}
if(bhas)
{
if(m_SearchMethod.MatchingString(str,strSearchText))
{//與客人是否團(tuán)隊(duì)成員匹配
FillGuestInfo(nTablesItemNum);//填充記錄
nTablesItemNum++;//記錄加1
// if(m_bBill)
// {
// strTempText[strTempTextItems]=m_GuestInfoSet.m_HandCode;
// strTempTextItems++;//Add 1
// }
bhas=false;
}
}
if(m_GuestInfoSet.m_IsMaster){str="是";}
else{str="否";}
if(bhas)
{
if(m_SearchMethod.MatchingString(str,strSearchText))
{//與客人是否團(tuán)隊(duì)主客匹配
FillGuestInfo(nTablesItemNum);//填充記錄
nTablesItemNum++;//記錄加1
// if(m_bBill)
// {
// strTempText[strTempTextItems]=m_GuestInfoSet.m_HandCode;
// strTempTextItems++;//Add 1
// }
bhas=false;
}
}
if(bhas)
{
if(m_SearchMethod.MatchingString(m_GuestInfoSet.m_GroupID,strSearchText))
{//與客人證件號(hào)碼匹配
FillGuestInfo(nTablesItemNum);//填充記錄
nTablesItemNum++;//記錄加1
// if(m_bBill)
// {
// strTempText[strTempTextItems]=m_GuestInfoSet.m_HandCode;
// strTempTextItems++;//Add 1
// }
bhas=false;
}
}
str.Format("%ld",m_GuestInfoSet.m_GuestNum);
if(bhas)
{
if(m_SearchMethod.MatchingString(str,strSearchText))
{//與客人數(shù)目匹配
FillGuestInfo(nTablesItemNum);//填充記錄
nTablesItemNum++;//記錄加1
// if(m_bBill)
// {
// strTempText[strTempTextItems]=m_GuestInfoSet.m_HandCode;
// strTempTextItems++;//Add 1
// }
bhas=false;
}
}
if(bhas)
{
if(m_SearchMethod.MatchingString(m_GuestInfoSet.m_RoomNum,strSearchText))
{//與房間數(shù)目號(hào)碼匹配
FillGuestInfo(nTablesItemNum);//填充記錄
nTablesItemNum++;//記錄加1
// if(m_bBill)
// {
// strTempText[strTempTextItems]=m_GuestInfoSet.m_HandCode;
// strTempTextItems++;//Add 1
// }
bhas=false;
}
}
if(bhas)
{
if(m_SearchMethod.MatchingString(m_GuestInfoSet.m_RoomCode,strSearchText))
{//與房間號(hào)碼匹配
FillGuestInfo(nTablesItemNum);//填充記錄
nTablesItemNum++;//記錄加1
// if(m_bRoom)
// {
// char* s=m_GuestInfoSet.m_RoomCode.GetBuffer(m_GuestInfoSet.m_RoomCode.GetLength());
// char* strtake=strtok(s,",");
// while (strtake!=NULL)
// {
// strTempText[strTempTextItems]=strtake;
// strTempTextItems++;
// strtake=strtok(NULL,",");
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -