⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 page1.cpp

📁 vc编译的酒店管理系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// 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"//消息显示对话框
/////////////////////////////////////////////////////////////////////////////
// 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;//初始状态为不搜索状态
}


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
	//初始化数据成员
	m_CoolProgress.SetRange(0,100);
	m_CoolProgress.SetColor(RGB(64,0,0));
	m_CoolProgress.SetStep(1);
	m_CoolProgress.SetPos(0);
	//初始化静态数据成员
	InitDate();//初始化数据成员
	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))
	{//检查输入的语法的正确性
		AfxMessageBox("你输入的字符不合法!");
	}
}

void CPage1::OnRadio() 
{
	// TODO: Add your control notification handler code here
	this->UpdateData(TRUE);//更新数据
}

void CPage1::OnSearch() 
{//按照制定的设置查询数据库
	// TODO: Add your control notification handler code here
/*
	    CQQView* pView=CQQView::GetView();
		CDC* pDC=pView->GetDC();//得到视图类DC*/
	//获得搜索类型,根据类型进行不同的搜索
	this->UpdateData(TRUE);//数据更新
	this->InitDate();//数据初始化,清除上次保留的数据 
	bSearch=true;
	m_CoolProgress.SetPos(0);//初始位置
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
                       一些特殊情况的处理
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
	CString strSearchText;
	m_SearchText.GetWindowText(strSearchText);
	if(strSearchText=="")
	{//查询文本为空
		AfxMessageBox("请输入查询文本!");
		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)
	{//没有选择一种输出项目
		AfxMessageBox("你应该至少选择一种输出项目");
		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;
	 }
 
/*************************相似查询模块结束*************************/

////////////////////////////////////////////////////////////////////
	   CInfoLookDialog m_InfoLookDialog;
	   m_InfoLookDialog.DoModal();//显示查询得到的结果

}

void CPage1::InitDate()
{//初始化静态数据成员
	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]="";//初始化字符数组 
			}
		}
	}
	for(i=0;i<nTables;i++)
	{
		nTablesItems[i]=0;//每张表的项目的数目设置为0
	}
}

void CPage1::OnDestroy() 
{
	CDialog::OnDestroy();
	
	// TODO: Add your message handler code here
//	InitDate();
}

void CPage1::SearchGuestInfoSet(CString strSearchText)
{//搜索GuestInfoSet数据库表
    this->UpdateData(TRUE);//数据更新
    int nTablesItemNum=nTablesItems[0];//表搜索到的项目数目
//	CString strTempText[100];
//	for(int i=0;i<100;i++)
//	{
//		strTempText[i]="";
//	}
//     int strTempTextItems=0;//记录保存到临时记录数组中的个数
	if(!m_GuestInfoSet.Open())
	{
		AfxMessageBox("打开数据库失败!");
		return;
	}
	m_GuestInfoSet.MoveFirst();//移动到第一条记录
	while (!m_GuestInfoSet.IsEOF())
	{
		bool bhas=true;
		if(bhas)
		{
	       if(m_SearchMethod.MatchingString(m_GuestInfoSet.m_HandCode,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_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))
			{//与客人证件号码匹配
				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))
			{//与客人是否团队成员匹配
				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))
			{//与客人是否团队主客匹配
				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))
			{//与客人证件号码匹配
			   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))
			{//与客人数目匹配
				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))
			{//与房间数目号码匹配
				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))
			{//与房间号码匹配
				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,",");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -