GuestInfoLookup.cpp
上传用户:sunh8215
上传日期:2010-02-13
资源大小:1616k
文件大小:4k
- // GuestInfoLookup.cpp : implementation file
- //
- #include "stdafx.h"
- #include "qq.h"
- #include "GuestInfoLookup.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CGuestInfoLookup dialog
- CString CGuestInfoLookup::STRINGS[100]={""};
- CGuestInfoLookup::CGuestInfoLookup(CWnd* pParent /*=NULL*/)
- : CDialog(CGuestInfoLookup::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CGuestInfoLookup)
- //}}AFX_DATA_INIT
- HandCode = _T("");//初始化数据成员
- Name = _T("");
- GuestType = _T("");
- Sex = _T("");
- Certificate = _T("");
- CertifyCode = _T("");
- IsMember = FALSE;
- IsMaster = FALSE;
- GroupID = _T("");
- GuestNum = 0;
- RoomNum = _T("");
- RoomCode = _T("");
- bSuccess=false;
- }
- void CGuestInfoLookup::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CGuestInfoLookup)
- DDX_Control(pDX, IDC_COMBO1, m_InfoLookup_HandCode);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CGuestInfoLookup, CDialog)
- //{{AFX_MSG_MAP(CGuestInfoLookup)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CGuestInfoLookup message handlers
- void CGuestInfoLookup::OnOK()
- {
- // TODO: Add extra validation here
- CString str;
- m_InfoLookup_HandCode.GetWindowText(str);
- if(str=="")
- {
- MessageBox("请输入手牌号!","数据为空错误",MB_OK);
- return ;
- }
- //查询数据库,保存查询得到的结果用来显示
- /////连接数据库,SQLstr
- if(!m_GuestInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE))
- {
- MessageBox("打开数据库失败!","数据库错误",MB_OK);
- bSuccess=false;
- return ;
- }
- bool bInSQL=false;//是否存在这个数据记录
- m_GuestInfoSet.MoveFirst();
- while(!m_GuestInfoSet.IsEOF())
- {
- if(m_GuestInfoSet.m_HandCode==str)
- {
- bInSQL=true;
- break;
- }
- else bInSQL=false;
- m_GuestInfoSet.MoveNext();
- }
- ///////////////////////////////////////////////////////////
- // 查询成功的话保存得到的数据
- if(bInSQL)
- {
- HandCode=m_GuestInfoSet.m_HandCode;
- Name=m_GuestInfoSet.m_Name;
- GuestType=m_GuestInfoSet.m_GuestType;
- Sex=m_GuestInfoSet.m_Sex;
- Certificate=m_GuestInfoSet.m_Certificate;
- CertifyCode=m_GuestInfoSet.m_CertifyCode;
- IsMember=m_GuestInfoSet.m_IsMember;
- IsMaster=m_GuestInfoSet.m_IsMaster;
- GroupID=m_GuestInfoSet.m_GroupID;
- GuestNum=m_GuestInfoSet.m_GuestNum;
- RoomNum=m_GuestInfoSet.m_RoomNum;
- RoomCode=m_GuestInfoSet.m_RoomCode;
- bSuccess=true;
- }
- else
- {
- MessageBox("该记录不存在!","记录错误",MB_OK);
- bSuccess=false;
- m_GuestInfoSet.Close();
- return ;
- }
- ////保存数据完成关闭数据库
- m_GuestInfoSet.Close();
- CDialog::OnOK();
- }
- BOOL CGuestInfoLookup::OnInitDialog()
- {
- CDialog::OnInitDialog();
- HICON m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME2);
- this->SetIcon(m_hIcon,true);//设置对话框图标
- // TODO: Add extra initialization here
- m_acCombo.Init(GetDlgItem(IDC_COMBO1));
- if(!m_GuestInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE))
- {
- MessageBox("打开数据库失败!","数据库错误",MB_OK);
- return false;
- }
- InitDate();//初始化数组
- m_GuestInfoSet.MoveFirst();//move to the first record
- int i=0;
- while(!m_GuestInfoSet.IsEOF())
- {
- STRINGS[i]=m_GuestInfoSet.m_HandCode;
- m_GuestInfoSet.MoveNext();
- i++;
- }
- m_GuestInfoSet.Close();//关闭数据库
- 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 CGuestInfoLookup::InitDate()
- {
- for(int i=0;i<100;i++)
- {
- STRINGS[i]="";
- }
- }