www.pudn.com > BUS(end).rar > BusDelDlg.cpp
// BusDelDlg.cpp : implementation file
//
#include "stdafx.h"
#include "bus.h"
#include "BusDelDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBusDelDlg dialog
CBusDelDlg::CBusDelDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBusDelDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CBusDelDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CBusDelDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBusDelDlg)
DDX_Control(pDX, IDC_DEL_DIALOG_COMBO, m_num);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBusDelDlg, CDialog)
//{{AFX_MSG_MAP(CBusDelDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBusDelDlg message handlers
BOOL CBusDelDlg::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 CBusDelDlg::OnOK()
{
// TODO: Add extra validation here
int i=m_num.GetCurSel();// 查找要删除 的记录
m_set.m_strFilter="[bus_station]";
if(m_set.IsOpen())
m_set.Close();
m_set.Open();
m_set.MoveFirst();
for(int j=0;j