jobsempviewdlg.cpp

来自「A HR database application.」· C++ 代码 · 共 73 行

CPP
73
字号
// JobsEmpViewDlg.cpp : implementation file
//

#include "stdafx.h"
#include "HRDB.h"
#include "JobsEmpViewDlg.h"

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

//引入全局变量userName,passWord
extern CString   userName;
extern CString   passWord;

/////////////////////////////////////////////////////////////////////////////
// CJobsEmpViewDlg dialog


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


void CJobsEmpViewDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CJobsEmpViewDlg)
	DDX_Control(pDX, IDC_ADODC1, m_Adodc);
	DDX_Control(pDX, IDC_DATAGRID1, m_DataGrid);
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////////
// CJobsEmpViewDlg message handlers

BOOL CJobsEmpViewDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	try
	{
		//初始化ADODC数据源
		m_Adodc.SetConnectionString("Provider=MSDASQL.1; Password=" + passWord +
			"; Persist Security Info=True; User ID=" + userName + "; Data Source=hr; Initial Catalog=hr");
		m_Adodc.SetRecordSource("select * from job_emp_details_view");
		m_Adodc.Refresh(); //important

		//将DATAGRID绑定到ADODC控件
		LPUNKNOWN pcursor = m_Adodc.GetDSCCursor();
		m_DataGrid.SetRefDataSource(pcursor);
	}
	catch (...) //捕获任何类型的异常
	{
		AfxMessageBox("无权查询!");
	}
	
	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 + =
减小字号Ctrl + -
显示快捷键?