📄 queryempdlg.cpp
字号:
// QueryEmpDlg.cpp : implementation file
//
#include "stdafx.h"
#include "PersonelManage.h"
#include "QueryEmpDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CQueryEmpDlg dialog
CQueryEmpDlg::CQueryEmpDlg(CWnd* pParent /*=NULL*/)
: CDialog(CQueryEmpDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CQueryEmpDlg)
m_strDeptName = _T("");
m_strEmail = _T("");
m_strName = _T("");
//}}AFX_DATA_INIT
m_nSelDeptID = -1;
}
void CQueryEmpDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CQueryEmpDlg)
DDX_Control(pDX, IDC_COMBO_DEPTNAME, m_cmbDeptName);
DDX_CBString(pDX, IDC_COMBO_DEPTNAME, m_strDeptName);
DDX_Text(pDX, IDC_EDIT_EMAIL, m_strEmail);
DDX_Text(pDX, IDC_EDIT_NAME, m_strName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CQueryEmpDlg, CDialog)
//{{AFX_MSG_MAP(CQueryEmpDlg)
ON_CBN_DROPDOWN(IDC_COMBO_DEPTNAME, OnDropdownComboDeptname)
ON_CBN_SELCHANGE(IDC_COMBO_DEPTNAME, OnSelchangeComboDeptname)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CQueryEmpDlg message handlers
void CQueryEmpDlg::OnDropdownComboDeptname()
{
// TODO: Add your control notification handler code here
CString strQuery = _T("SELECT [DeptID], [DeptName] FROM [tblDepartment]");
CString deptValue;
long nDeptID;
CADODatabase *pDb = new CADODatabase;
try
{
if(pDb->Open())
{
CADORecordset *pRs = new CADORecordset(pDb);
if(pRs->Open(strQuery, CADORecordset::openQuery))
{
m_cmbDeptName.ResetContent();
int cur = 0;
while(!pRs->IsEOF())
{
pRs->GetFieldValue("DeptID", nDeptID);
pRs->GetFieldValue("DeptName", deptValue);
m_cmbDeptName.InsertString(cur, deptValue);
m_cmbDeptName.SetItemData(cur, nDeptID);
cur++;
pRs->MoveNext();
}
pRs->Close();
}
delete pRs;
pDb->Close();
}
delete pDb;
}
catch(CADOException)
{
}
}
void CQueryEmpDlg::OnSelchangeComboDeptname()
{
// TODO: Add your control notification handler code here
int nItem = m_cmbDeptName.GetCurSel();
if(nItem == -1)
m_nSelDeptID = -1;
else
m_nSelDeptID = m_cmbDeptName.GetItemData(nItem);
}
void CQueryEmpDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
if(m_strName.GetLength() == 0 && m_strEmail.GetLength() == 0 && m_nSelDeptID == -1)
{
AfxMessageBox("请至少选择一个条件!");
return;
}
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -