📄 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<i;j++)
m_set.MoveNext();
if(MessageBox("是否要删除?","删除确认",MB_YESNO |MB_ICONQUESTION)==IDYES)
{
m_set.Delete();// 删除记录
AfxMessageBox("成功删除!");
}
if(m_set.IsOpen())
m_set.Close();
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -