?? contentdlg.cpp
字號:
// ContentDlg.cpp : implementation file
//
#include "stdafx.h"
#include "NameGis.h"
#include "ContentDlg.h"
#include "MainFrm.h"
#include "AppApi.h"
#include "Crack.h"
// CContentDlg dialog
IMPLEMENT_DYNAMIC(CContentDlg, CDialog)
CContentDlg::CContentDlg(CWnd* pParent /*=NULL*/)
: CDialog(CContentDlg::IDD, pParent)
{
m_szName = "";
}
CContentDlg::~CContentDlg()
{
}
void CContentDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_CONTENT_RESULTLIST, m_ResultList);
}
BEGIN_MESSAGE_MAP(CContentDlg, CDialog)
END_MESSAGE_MAP()
// CContentDlg message handlers
//-----------------------------------------------------------------------------------------
BOOL CContentDlg::OnInitDialog()
{
CDialog::OnInitDialog();
if ("" == m_szName)
return TRUE;
CMainFrame* pMainWnd = (CMainFrame*)AfxGetMainWnd();
CString szTableName = pMainWnd->m_environment.GetTableName(
m_szName,"地名索引");
if ("" == szTableName)
{
AfxMessageBox("屬性庫中無此地名!");
return TRUE;
}
m_ResultList.ResetContent();
CDaoDatabase* tmpDB = new CDaoDatabase;
try
{
tmpDB->Open(pMainWnd->m_environment.m_szDBName);
}
catch (CDaoException* e)
{
DisplayDaoException(e);
delete tmpDB;
e->Delete();
return TRUE;
}
CDaoRecordset rs(tmpDB);
try
{
CString szSQL;
CString szFieldName;
szFieldName = pMainWnd->m_environment.GetFieldName(m_szName);
if (szFieldName == "")
szFieldName = "單位名稱";
szSQL = "Select * From [" + szTableName + "] Where "
+ szFieldName + " ='" + m_szName + "'";
rs.Open(dbOpenDynaset,szSQL);
if (0 == rs.GetRecordCount())
return TRUE;
COleVariant var;
for(int i=0; i<rs.GetFieldCount(); i ++)
{
CDaoFieldInfo fieldinfo;
rs.GetFieldInfo(i, fieldinfo);
var = rs.GetFieldValue(i);
CString szValue = fieldinfo.m_strName + ":"
+ CCrack::strVARIANT(var);
m_ResultList.AddString(szValue);
}
}
catch (CDaoException* e)
{
DisplayDaoException(e);
delete tmpDB;
e->Delete();
return TRUE;
}
if(tmpDB)
{
if(tmpDB->IsOpen())
{
tmpDB->Close();
}
delete tmpDB;
tmpDB = NULL;
}
return TRUE;
}
//-----------------------------------------------------------------------------------------
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -