📄 selectstaff.cpp
字号:
// SelectStaff.cpp : implementation file
//
#include "stdafx.h"
#include "Sale.h"
#include "SelectStaff.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSelectStaff dialog
CSelectStaff::CSelectStaff(CWnd* pParent /*=NULL*/)
: CDialog(CSelectStaff::IDD, pParent)
{
//{{AFX_DATA_INIT(CSelectStaff)
m_yearPlan = 0.0f;
m_yearRatio = 0.0f;
m_JanPlan = 0.0f;
m_JanRatio = 0.0f;
m_FebPlan = 0.0f;
m_FebRatio = 0.0f;
m_MarPlan = 0.0f;
m_MarRatio = 0.0f;
m_AprPlan = 0.0f;
m_AprRatio = 0.0f;
m_MayPlan = 0.0f;
m_MayRatio = 0.0f;
m_JunPlan = 0.0f;
m_JunRatio = 0.0f;
m_JulPlan = 0.0f;
m_JulRatio = 0.0f;
m_AugPlan = 0.0f;
m_AugRatio = 0.0f;
m_SepPlan = 0.0f;
m_SepRatio = 0.0f;
m_OctPlan = 0.0f;
m_OctRatio = 0.0f;
m_NovPlan = 0.0f;
m_NovRatio = 0.0f;
m_DecPlan = 0.0f;
m_DecRatio = 0.0f;
//}}AFX_DATA_INIT
}
void CSelectStaff::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSelectStaff)
DDX_Control(pDX, IDC_LIST1, m_staffList);
// DDX_Text(pDX, IDC_yearPlan, m_yearPlan);
// DDX_Text(pDX, IDC_yearRatio, m_yearRatio);
DDX_Text(pDX, IDC_JanPlan, m_JanPlan);
DDX_Text(pDX, IDC_JanRatio, m_JanRatio);
DDX_Text(pDX, IDC_FebPlan, m_FebPlan);
DDX_Text(pDX, IDC_FebRatio, m_FebRatio);
DDX_Text(pDX, IDC_MarPlan, m_MarPlan);
DDX_Text(pDX, IDC_MarRatio, m_MarRatio);
DDX_Text(pDX, IDC_AprPlan, m_AprPlan);
DDX_Text(pDX, IDC_AprRatio, m_AprRatio);
DDX_Text(pDX, IDC_MayPlan, m_MayPlan);
DDX_Text(pDX, IDC_MayRatio, m_MayRatio);
DDX_Text(pDX, IDC_JunPlan, m_JunPlan);
DDX_Text(pDX, IDC_JunRatio, m_JunRatio);
DDX_Text(pDX, IDC_JulPlan, m_JulPlan);
DDX_Text(pDX, IDC_JulRatio, m_JulRatio);
DDX_Text(pDX, IDC_AugPlan, m_AugPlan);
DDX_Text(pDX, IDC_AugRatio, m_AugRatio);
DDX_Text(pDX, IDC_SepPlan, m_SepPlan);
DDX_Text(pDX, IDC_SepRatio, m_SepRatio);
DDX_Text(pDX, IDC_OctPlan, m_OctPlan);
DDX_Text(pDX, IDC_OctRatio, m_OctRatio);
DDX_Text(pDX, IDC_NovPlan, m_NovPlan);
DDX_Text(pDX, IDC_NovRatio, m_NovRatio);
DDX_Text(pDX, IDC_DecPlan, m_DecPlan);
DDX_Text(pDX, IDC_DecRatio, m_DecRatio);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSelectStaff, CDialog)
//{{AFX_MSG_MAP(CSelectStaff)
ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickStaffList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSelectStaff message handlers
void CSelectStaff::OnClickStaffList(NMHDR* pNMHDR, LRESULT* pResult)
{
UpdateData(true);
POSITION pos = m_staffList.GetFirstSelectedItemPosition();
if(pos)
{
int nFirstSelItem = m_staffList.GetNextSelectedItem(pos);
staffID=m_staffList.GetItemText(nFirstSelItem,0);
staffName=m_staffList.GetItemText(nFirstSelItem,1);
}
*pResult=0;
}
BOOL CSelectStaff::OnInitDialog()
{
CDialog::OnInitDialog();
DWORD style;
style=m_staffList.GetExStyle();
style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
m_staffList.SetExtendedStyle(style);
m_staffList.InsertColumn(0,"员工编号",LVCFMT_LEFT,100);
m_staffList.InsertColumn(1,"姓名",LVCFMT_LEFT,100);
m_staffList.InsertColumn(2,"职务",LVCFMT_LEFT,100);
m_staffList.InsertColumn(3,"工作部门",LVCFMT_LEFT,100);
m_staffList.InsertColumn(4,"性别",LVCFMT_LEFT,100);
m_staffList.InsertColumn(5,"住址",LVCFMT_LEFT,100);
m_staffList.InsertColumn(6,"出生年月",LVCFMT_LEFT,100);
m_staffList.InsertColumn(7,"邮编",LVCFMT_LEFT,100);
m_staffList.InsertColumn(8,"婚姻状况",LVCFMT_LEFT,100);
m_staffList.InsertColumn(9,"电话",LVCFMT_LEFT,100);
m_staffList.InsertColumn(10,"民族",LVCFMT_LEFT,100);
m_staffList.InsertColumn(11,"邮箱",LVCFMT_LEFT,100);
m_staffList.InsertColumn(12,"文化程度",LVCFMT_LEFT,100);
m_staffList.InsertColumn(13,"QQ号码",LVCFMT_LEFT,100);
m_staffList.InsertColumn(14,"毕业学校",LVCFMT_LEFT,100);
m_staffList.InsertColumn(15,"专业",LVCFMT_LEFT,100);
m_staffList.InsertColumn(16,"身份证号",LVCFMT_LEFT,100);
m_staffList.InsertColumn(17,"手机",LVCFMT_LEFT,100);
m_staffList.InsertColumn(18,"工种",LVCFMT_LEFT,100);
m_staffList.InsertColumn(19,"备注",LVCFMT_LEFT,100);
_RecordsetPtr m_pTreeRecordset; //用于创建一个查询记录集
CString strSQL;
//-----------------------------------------------
strSQL="SELECT * FROM staff";
try
{
HRESULT hTRes;
hTRes = m_pTreeRecordset.CreateInstance(_T("ADODB.Recordset"));
if (SUCCEEDED(hTRes))
{
//----------------------------------------------------
hTRes = m_pTreeRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
TRACE(_T("连接成功!\n"));
//------------------------------------------
m_pTreeRecordset->MoveFirst();
if (!(m_pTreeRecordset->adoEOF))
{
int i=0;
// AfxMessageBox("Here!");
while(!m_pTreeRecordset->adoEOF)
{
//_variant_t vIndex=(long)0;
m_staffList.InsertItem(i,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("staffID")));
m_staffList.SetItemText(i,1,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("staffName")));
m_staffList.SetItemText(i,2,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("duty")));
m_staffList.SetItemText(i,3,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("department")));
m_staffList.SetItemText(i,4,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("sex")));
m_staffList.SetItemText(i,5,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("address")));
m_staffList.SetItemText(i,6,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("birthday")));
m_staffList.SetItemText(i,7,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("postcode")));
m_staffList.SetItemText(i,8,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("marriageCondition")));
m_staffList.SetItemText(i,9,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("telephone")));
m_staffList.SetItemText(i,10,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("nationality")));
m_staffList.SetItemText(i,11,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("eMail")));
m_staffList.SetItemText(i,12,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("educationLevel")));
m_staffList.SetItemText(i,13,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("QQ")));
m_staffList.SetItemText(i,14,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("graduateSchool")));
m_staffList.SetItemText(i,15,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("major")));
m_staffList.SetItemText(i,16,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("identityNO")));
m_staffList.SetItemText(i,17,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("mobile")));
m_staffList.SetItemText(i,18,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("workType")));
m_staffList.SetItemText(i,19,(LPCTSTR)(_bstr_t)(m_pTreeRecordset->GetCollect("remark")));
if (!(m_pTreeRecordset->adoEOF))
{
m_pTreeRecordset->MoveNext();
i++;
}
}
}
//---------------------------------------
}
}
}
catch(_com_error e)///捕捉异常
{
CString errormessage;
MessageBox("创建销售类型记录集失败!","错误");
}
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 + -