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

📄 tablelookupperdlg.cpp

📁 evc环境下的数据库查看器。可以查看表格和表格内的数据。
💻 CPP
字号:
// TableLookUpperDlg.cpp : implementation file
//

#include "stdafx.h"
#include "TableLookUpper.h"
#include "TableLookUpperDlg.h"

#include "./DBFiles/VOConnection.h"
#include "./DBFiles/VORecordSet.h"

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

CVOConnection _gConnection;

/////////////////////////////////////////////////////////////////////////////
// CTableLookUpperDlg dialog

CTableLookUpperDlg::CTableLookUpperDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTableLookUpperDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTableLookUpperDlg)
	m_Table = _T("");
	m_NumberOfRecord = 0;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CTableLookUpperDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTableLookUpperDlg)
	DDX_Control(pDX, IDC_LIST1, m_DataList);
	DDX_CBString(pDX, IDC_COMBO1, m_Table);
	DDX_Text(pDX, IDC_EDIT1, m_NumberOfRecord);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CTableLookUpperDlg, CDialog)
	//{{AFX_MSG_MAP(CTableLookUpperDlg)
	ON_BN_CLICKED(IDC_BUTTON1, OnConnect)
	ON_BN_CLICKED(IDC_BUTTON2, OnRefresh)
	ON_BN_CLICKED(IDC_BUTTON3, OnCheckNUmberofRecords)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTableLookUpperDlg message handlers

CString AppFolderPath;

BOOL CTableLookUpperDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	CenterWindow(GetDesktopWindow());	// center to the hpc screen

	// TODO: Add extra initialization here


	{
		CString strFilePath;
		TCHAR lpFileName[MAX_PATH+1];
		GetModuleFileName(NULL, lpFileName, MAX_PATH);
		strFilePath = lpFileName;
		
		int nLastIndex = strFilePath.ReverseFind('\\');
		if (nLastIndex!=-1) 
		{
			AppFolderPath = strFilePath.Left(nLastIndex);
		} 
		else 
		{
			AppFolderPath = _T("\\");
		}
	}

	_gConnection.SetConnectDB(AppFolderPath + _T("\\main.cdb"));

	for(int i=0; i<20; i++)
		m_DataList.InsertColumn(i, _T("data"), LVCFMT_LEFT, 40);
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}



void CTableLookUpperDlg::OnConnect() 
{
	// TODO: Add your control notification handler code here
	_gConnection.SetConnectDB(AppFolderPath + _T("\\main.cdb"));
}

void CTableLookUpperDlg::OnRefresh() 
{
	// TODO: Add your control notification handler code here
	UpdateData();

	if (m_Table.IsEmpty())
	{
		AfxMessageBox(_T("请选择一个数据表格"));
		return;
	}

	CVORecordSet rs(_gConnection);

	CString SQL;
	SQL.Format(_T("select * from %s"), m_Table);

	rs.Open(SQL);

	m_DataList.DeleteAllItems();

	int fcount = rs.GetFieldCount();
	
	for(int i=0; i<fcount; i++)
	{
		LVCOLUMN col;
		col.mask = LVCF_TEXT;
		CString fname = rs.GetFieldName(i);
		col.pszText = fname.GetBuffer(0);
		m_DataList.SetColumn(i, &col);
	}

	int rcount;
	
	rcount = rs.GetRecordCount();

	for(i=0; i<rcount; i++)
	{
		m_DataList.InsertItem(i, rs.GetFieldValueString(0));

		for(int j=1; j<fcount; j++)
		{
			m_DataList.SetItemText(i, j, rs.GetFieldValueString(j));
		}

		rs.MoveNext();
	}
	
	
}

void CTableLookUpperDlg::OnCheckNUmberofRecords() 
{
	// TODO: Add your control notification handler code here
	UpdateData();

	if (m_Table.IsEmpty())
	{
		AfxMessageBox(_T("请选择一个数据表格"));
		return;
	}

	CVORecordSet rs(_gConnection);

	CString SQL;
	SQL.Format(_T("select * from %s"), m_Table);

	rs.Open(SQL);

	m_NumberOfRecord = rs.GetRecordCount();

	UpdateData(FALSE);
}

⌨️ 快捷键说明

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