?? roominfolookup.cpp
字號:
// RoomInfoLookup.cpp : implementation file
//
#include "stdafx.h"
#include "qq.h"
#include "RoomInfoLookup.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CRoomInfoLookup dialog
CString CRoomInfoLookup::STRINGS[100]={""};
CRoomInfoLookup::CRoomInfoLookup(CWnd* pParent /*=NULL*/)
: CDialog(CRoomInfoLookup::IDD, pParent)
{
//{{AFX_DATA_INIT(CRoomInfoLookup)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
RoomCode = _T("");
RoomType = _T("");
Floor = 0;
Phone = _T("");
RoomStatus = _T("");
PriceType = FALSE;
Price = 0.0f;
bSuccess=false;
}
void CRoomInfoLookup::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRoomInfoLookup)
DDX_Control(pDX, IDC_COMBO1, m_InfoLookup_RoomCode);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRoomInfoLookup, CDialog)
//{{AFX_MSG_MAP(CRoomInfoLookup)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRoomInfoLookup message handlers
BOOL CRoomInfoLookup::OnInitDialog()
{
CDialog::OnInitDialog();
HICON m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME2);
this->SetIcon(m_hIcon,true);//設(shè)置對話框圖標(biāo)
// TODO: Add extra initialization here
m_acCombo.Init(GetDlgItem(IDC_COMBO1));
if(!m_RoomInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE))
{
MessageBox("打開數(shù)據(jù)庫失敗!","數(shù)據(jù)庫錯誤",MB_OK);
return false;
}
InitDate();
m_RoomInfoSet.MoveFirst();//move to the first record
int i=0;
while(!m_RoomInfoSet.IsEOF())
{
STRINGS[i]=m_RoomInfoSet.m_RoomCode;
m_RoomInfoSet.MoveNext();
i++;
}
m_RoomInfoSet.Close();//關(guān)閉數(shù)據(jù)庫
for (int j=0;(!STRINGS[j].IsEmpty()); j++)
{
m_acCombo.GetStringList().Add(STRINGS[j].GetBuffer(STRINGS[j].GetLength()));
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CRoomInfoLookup::OnOK()
{
// TODO: Add extra validation here
CString str;
m_InfoLookup_RoomCode.GetWindowText(str);
if(str=="")
{
MessageBox("請輸入房間號碼!","數(shù)據(jù)為空錯誤",MB_OK);
return ;
}
if(!m_RoomInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE))
{
MessageBox("打開數(shù)據(jù)庫失敗!","數(shù)據(jù)庫錯誤",MB_OK);
bSuccess=false;
return ;
}
bool bInSQL=false;//是否存在這個數(shù)據(jù)記錄
m_RoomInfoSet.MoveFirst();
while(!m_RoomInfoSet.IsEOF())
{
if(m_RoomInfoSet.m_RoomCode==str)
{
bInSQL=true;
break;
}
else bInSQL=false;
m_RoomInfoSet.MoveNext();
}
///////////////////////////////////////////////////////////
// 查詢成功的話保存得到的數(shù)據(jù)
if(bInSQL)
{
RoomCode=m_RoomInfoSet.m_RoomCode;
RoomType=m_RoomInfoSet.m_RoomType;
Floor=m_RoomInfoSet.m_Floor;
Phone=m_RoomInfoSet.m_Phone;
RoomStatus=m_RoomInfoSet.m_RoomStatus;
PriceType=m_RoomInfoSet.m_PriceType;
Price=m_RoomInfoSet.m_Price;
bSuccess=true;
}
else
{
MessageBox("該記錄不存在!","記錄錯誤",MB_OK);
bSuccess=false;
////保存數(shù)據(jù)完成關(guān)閉數(shù)據(jù)庫
m_RoomInfoSet.Close();
return ;
}
////保存數(shù)據(jù)完成關(guān)閉數(shù)據(jù)庫
m_RoomInfoSet.Close();
CDialog::OnOK();
}
void CRoomInfoLookup::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void CRoomInfoLookup::InitDate()
{
for(int i=0;i<100;i++)
{
STRINGS[i]="";
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -