📄 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 + -