www.pudn.com > BUS(end).rar > BusEditDlg.cpp
// BusEditDlg.cpp : implementation file
//
#include "stdafx.h"
#include "bus.h"
#include "BusEditDlg.h"
# include "BusAddDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBusEditDlg dialog
CBusEditDlg::CBusEditDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBusEditDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CBusEditDlg)
m_busnum = 0;
m_bussta = _T("");
//}}AFX_DATA_INIT
}
void CBusEditDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBusEditDlg)
DDX_Control(pDX, IDC_EDID_DIALOG_COMBO, m_num);
DDX_Text(pDX, IDC_BUSNUM_EDIT, m_busnum);
DDX_Text(pDX, IDC_BUSTA_EDIT, m_bussta);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBusEditDlg, CDialog)
//{{AFX_MSG_MAP(CBusEditDlg)
ON_BN_CLICKED(IDC_FIND_BUTTON, OnFindButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBusEditDlg message handlers
//DEL BOOL CBusEditDlg::OnInitDialog()
//DEL {
//DEL
//DEL }
BOOL CBusEditDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
if(!m_database.Open(NULL,FALSE,FALSE,"ODBC;DSN=test1"))//对COMBO的DATA即下拉选项初始化
{
AfxMessageBox("Failed to open database");// 把数据库中含有的车次列如DATA;
}
m_set.Open();
CString str;
m_set.MoveFirst();
while(!m_set.IsEOF())
{
str.Format("%ld",m_set.m_bus_number);
m_num.AddString(str);
m_set.MoveNext();
}
m_set.Close();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CBusEditDlg::OnFindButton()
{
// TODO: Add your control notification handler code here
//CString str;
int i=m_num.GetCurSel();
m_set.m_strFilter="[bus_station]";// WHERE子句
if(m_set.IsOpen()){
m_set.Close();
}
m_set.Open();
m_set.MoveFirst();
for (int j=0;j