?? roomregister.cpp
字號(hào):
// RoomRegister.cpp : implementation file
//
#include "stdafx.h"
#include "qq.h"
#include "RoomRegister.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "InfoSet.h"
/////////////////////////////////////////////////////////////////////////////
// CRoomRegister dialog
CGuestRegister::CGuestRegister(CWnd* pParent /*=NULL*/)
: CDialog(CGuestRegister::IDD, pParent)
{
//{{AFX_DATA_INIT(CRoomRegister)
m_nCertificatType = 0;
m_nSex = -1;
m_nGuestType = -1;
Certificate="身份證";
GuestNum=0;
GuestType="個(gè)人";
IsMaster=false;
IsMember=false;
RoomCode="0";
Sex="男";
//}}AFX_DATA_INIT
year=0;
month=0;
day=0;
hour=0;
minute=0;
second=0;
}
void CGuestRegister::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRoomRegister)
DDX_Control(pDX, IDC_GROUPID, GroupID);
DDX_Control(pDX, IDC_STARTTIME, StartTime);
DDX_Control(pDX, IDC_CERTIFYCODE, CertifyCode);
DDX_Control(pDX, IDC_GUESTNAME, Name);
DDX_Control(pDX, IDC_HANDCODE, HandCode);
DDX_Radio(pDX, IDC_RADIO1, m_nCertificatType);
DDX_Radio(pDX, IDC_RADIO3, m_nSex);
DDX_Radio(pDX, IDC_RADIO5, m_nGuestType);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGuestRegister, CDialog)
//{{AFX_MSG_MAP(CRoomRegister)
ON_BN_CLICKED(IDC_RADIO1, OnCertificatType)
ON_BN_CLICKED(IDC_RADIO3, OnSex)
ON_BN_CLICKED(IDC_RADIO5, OnGuestType)
ON_BN_CLICKED(IDC_RADIO2, OnCertificatType)
ON_BN_CLICKED(IDC_RADIO4, OnSex)
ON_BN_CLICKED(IDC_RADIO6, OnGuestType)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CRoomRegister message handlers
void CGuestRegister::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
CString str;
HandCode.GetWindowText(str);
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
檢查數(shù)據(jù)庫中是否已經(jīng)存在這個(gè)手牌號(hào)碼
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
bool bhas=false;
if(!m_GuestInfoSet.Open())
{
MessageBox("打開數(shù)據(jù)庫失敗!","數(shù)據(jù)庫錯(cuò)誤",MB_OK);
return;
}
while (!m_GuestInfoSet.IsEOF())
{
if(str==m_GuestInfoSet.m_HandCode)
{
bhas=true;
}
m_GuestInfoSet.MoveNext();
}
m_GuestInfoSet.Close();
if(bhas)
{
MessageBox("已經(jīng)注冊(cè)了這個(gè)客人!","注冊(cè)錯(cuò)誤",MB_OK);
return;
}
//////////////////////////////////////////////////////////////////////////
/*
* 檢查身份證的號(hào)碼是否為15位或者為18位
*/
CString strCertifyCode;//證件號(hào)碼
CertifyCode.GetWindowText(strCertifyCode);//獲得證件號(hào)碼
int nCertifyCodeLength=strCertifyCode.GetLength();//獲得證件的長(zhǎng)度
if(nCertifyCodeLength!=15&&nCertifyCodeLength!=18)
{
if(m_nCertificatType==0)
{//若選擇的是身份證
MessageBox("你的身份證的號(hào)碼的位數(shù)不正確!\n應(yīng)該為15位或者18位!",
"身份證錯(cuò)誤",MB_OK);
return ;
}
}
if(str!="")
{
/*
* 判斷該客人是否預(yù)定了房間
*/
// [7/1/2003-11:28]
if(!m_RoomDestine.Open())
{
MessageBox("打開數(shù)據(jù)庫失敗!","數(shù)據(jù)庫錯(cuò)誤",MB_OK);
return;
}
m_RoomDestine.MoveFirst();
while (!m_RoomDestine.IsEOF())
{
if(strCertifyCode==m_RoomDestine.m_CeritifyCode)
{
//查找到該客人已經(jīng)預(yù)定了房間
MessageBox("該客人已經(jīng)預(yù)定了房間",NULL,MB_OK);
}
m_RoomDestine.MoveNext();
}
m_RoomDestine.Close();
//////////////////////////////////////////////////////////////////////////
if(!m_GuestInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE))
{//連接數(shù)據(jù)庫
MessageBox("打開數(shù)據(jù)庫失敗!","數(shù)據(jù)庫錯(cuò)誤",MB_OK);
return;
}
m_GuestInfoSet.AddNew();//添加一個(gè)新的空的記錄集
m_GuestInfoSet.m_Certificate=Certificate;
CertifyCode.GetWindowText(m_GuestInfoSet.m_CertifyCode);
GroupID.GetWindowText(m_GuestInfoSet.m_GroupID);
m_GuestInfoSet.m_GuestNum=GuestNum;
m_GuestInfoSet.m_GuestType=GuestType;
HandCode.GetWindowText(m_GuestInfoSet.m_HandCode);
m_GuestInfoSet.m_IsMaster=IsMaster;
m_GuestInfoSet.m_IsMember=IsMember;
Name.GetWindowText(m_GuestInfoSet.m_Name);
m_GuestInfoSet.m_RoomCode=RoomCode;
m_GuestInfoSet.m_RoomNum=RoomNum;
m_GuestInfoSet.m_Sex=Sex;
m_GuestInfoSet.Update();//數(shù)據(jù)更新
m_GuestInfoSet.Close(); //關(guān)閉數(shù)據(jù)庫
}
////將開始入住時(shí)間寫入數(shù)據(jù)庫中
if(!m_BillCheckoutInfoSet.Open())
{
MessageBox("打開數(shù)據(jù)庫失敗!","數(shù)據(jù)庫錯(cuò)誤",MB_OK);
return;
}
m_BillCheckoutInfoSet.AddNew();
CTime time(year,month,day,hour,minute,second,0);
m_BillCheckoutInfoSet.m_StartTime=time;//寫入開始時(shí)間
m_BillCheckoutInfoSet.m_HandCode=str;//寫入手牌號(hào)碼
m_BillCheckoutInfoSet.Update();
m_BillCheckoutInfoSet.Close();//close the DB
CDialog::OnOK();
}
void CGuestRegister::OnCertificatType()
{
// TODO: Add your control notification handler code here
UpdateData(true);
if(m_nCertificatType==0)
{
Certificate="身份證";//設(shè)置證件類型為"身份證"
}
if(m_nCertificatType==1)
{
Certificate="軍人證";//設(shè)置證件類型為"軍人證"
}
}
void CGuestRegister::OnSex()
{
// TODO: Add your control notification handler code here
this->UpdateData(true);
if(m_nSex==0)
{
Sex="男";
}
if(m_nSex==1)
{
Sex="女";
}
}
void CGuestRegister::OnGuestType()
{
// TODO: Add your control notification handler code here
this->UpdateData(true);
if(m_nGuestType==0)
{
GuestType="團(tuán)體成員";
IsMaster=false;
IsMember=true;
}
if(m_nGuestType==1)
{
GuestType="主客";
IsMember=false;
IsMaster=true;
}
}
BOOL CGuestRegister::OnInitDialog()
{
CDialog::OnInitDialog();
HICON m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME2);
this->SetIcon(m_hIcon,true);//設(shè)置對(duì)話框圖標(biāo)
// TODO: Add extra initialization here
/*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
將當(dāng)前的時(shí)間顯示在開始入住時(shí)間欄中
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/
CTime time=CTime::GetCurrentTime();//構(gòu)造時(shí)間對(duì)象
CTime tm(time);//構(gòu)造時(shí)間對(duì)象
year=tm.GetYear();
month=tm.GetMonth();
day=tm.GetDay();
hour=tm.GetHour();
minute=tm.GetMinute();
second=tm.GetSecond();
CString strYear,strMonth,strDay;
strYear.Format("%d",year);
strMonth.Format("%d",month);
strDay.Format("%d",day);
CString strShowText;
strShowText=strYear+"-"+strMonth+"-"+strDay;
CString strCurrentTime=time.Format("%H:%M:%S");
strShowText=strShowText+" "+strCurrentTime;
StartTime.SetWindowText(strShowText);//顯示當(dāng)前時(shí)間
//////////////////////////////////////////////////////////////////////////
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CGuestRegister::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -