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

📄 deptcurrentjobsviewdlg.cpp

📁 A HR database application.
💻 CPP
字号:
// DeptCurrentJobsViewDlg.cpp : implementation file
//

#include "stdafx.h"
#include "HRDB.h"
#include "DeptCurrentJobsViewDlg.h"

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

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

/////////////////////////////////////////////////////////////////////////////
// CDeptCurrentJobsViewDlg dialog


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


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


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

/////////////////////////////////////////////////////////////////////////////
// CDeptCurrentJobsViewDlg message handlers

BOOL CDeptCurrentJobsViewDlg::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 \
									DISTINCT j.job_title current_job, \
									d.department_name \
								 FROM \
									employees e, \
									departments d, \
									jobs j \
								 WHERE d.department_id = e.department_id \
							       AND e.job_id = j.job_id \
							     ORDER BY d.department_name");
		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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -