⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contentdlg.cpp

📁 公交查询系统源代码 是武汉的 提供简单的查询和乘车方案 vc++
💻 CPP
字号:
// ContentDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Public_TGIS.h"
#include "ContentDlg.h"
#include "MainFrm.h"
#include "AppApi.h"
#include "Crack.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CContentDlg dialog


CContentDlg::CContentDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CContentDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CContentDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	m_szName = "";
}


void CContentDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CContentDlg)
	DDX_Control(pDX, IDC_CONTENT_RESULTLIST, m_ResultList);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CContentDlg, CDialog)
	//{{AFX_MSG_MAP(CContentDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CContentDlg message handlers

BOOL CContentDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	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;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -