📄 deviceeditdlg.cpp
字号:
// DeviceEditDlg.cpp : implementation file
//
#include "stdafx.h"
#include "sjsys.h"
#include "DeviceEditDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDeviceEditDlg dialog
CDeviceEditDlg::CDeviceEditDlg(CWnd* pParent /*=NULL*/)
: CDialog(CDeviceEditDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CDeviceEditDlg)
m_DeviceName = _T("");
m_EmployeeName = _T("");
m_Config = _T("");
m_StartDate = _T("");
m_SubDepartment = _T("");
m_Type = _T("");
//}}AFX_DATA_INIT
pEmployeeRecordset=NULL;
pDepartmentRecordset=NULL;
}
void CDeviceEditDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDeviceEditDlg)
DDX_Control(pDX, IDC_SubDepartmentEdit, m_DepartmentControl);
DDX_Control(pDX, IDC_EmployeeNameEdit, m_EmployeeControl);
DDX_Text(pDX, IDC_DeviceNameEdit, m_DeviceName);
DDX_CBString(pDX, IDC_EmployeeNameEdit, m_EmployeeName);
DDX_Text(pDX, IDC_ConfigEdit, m_Config);
DDX_Text(pDX, IDC_StartDateEdit, m_StartDate);
DDX_CBString(pDX, IDC_SubDepartmentEdit, m_SubDepartment);
DDX_Text(pDX, IDC_TypeEdit, m_Type);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDeviceEditDlg, CDialog)
//{{AFX_MSG_MAP(CDeviceEditDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDeviceEditDlg message handlers
BOOL CDeviceEditDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString SQLStr;
_variant_t var;
//m_EmployeeControl.AddString("123");
//m_EmployeeControl.AddString("123");
//m_EmployeeControl.AddString("123");
pEmployeeRecordset.CreateInstance(__uuidof(Recordset));
pDepartmentRecordset.CreateInstance(__uuidof(Recordset));
//获取所有雇员姓名,添入EmployeeControl编辑框
try
{
SQLStr.Format("select * from Employee");
pEmployeeRecordset->Open(_bstr_t(SQLStr),
((CSjsysApp*)AfxGetApp())->pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
while(!pEmployeeRecordset->adoEOF)
{
var = pEmployeeRecordset->GetCollect("CName");
if(var.vt != VT_NULL)
{
//(LPCSTR)_bstr_t(var)
m_EmployeeControl.AddString((LPCSTR)_bstr_t(var));
//MessageBox("here!");
}
pEmployeeRecordset->MoveNext();
}
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
pEmployeeRecordset->Close();
//获取所有部室名,添入DepartmentControl编辑框
try
{
SQLStr.Format("select * from Department where Upnodeid in(select ID from Department where Upnodeid in(select ID from Department where Upnodeid=0))");
pDepartmentRecordset->Open(_bstr_t(SQLStr),
((CSjsysApp*)AfxGetApp())->pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
while(!pDepartmentRecordset->adoEOF)
{
var = pDepartmentRecordset->GetCollect("CName");
if(var.vt != VT_NULL)
{
//(LPCSTR)_bstr_t(var)
m_DepartmentControl.AddString((LPCSTR)_bstr_t(var));
//MessageBox("here!");
}
pDepartmentRecordset->MoveNext();
}
}
catch(_com_error *e)
{
AfxMessageBox(e->ErrorMessage());
}
pDepartmentRecordset->Close();
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 + -