📄 searchdg.cpp
字号:
// SearchDg.cpp : implementation file
//
#include "stdafx.h"
#include "Employ.h"
#include "SearchDg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSearchDg dialog
CSearchDg::CSearchDg(CWnd* pParent /*=NULL*/)
: CDialog(CSearchDg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSearchDg)
m_sAddressIn = _T("");
m_sAddressOut = _T("");
m_sBirthOut = _T("");
m_sDutyIn = _T("");
m_sDutyOut = _T("");
m_sEduIn = _T("");
m_sEduOut = _T("");
m_sMemoIn = _T("");
m_sMemoOut = _T("");
m_sNameIn = _T("");
m_sNameOut = _T("");
m_sPhoneIn = _T("");
m_sPhoneOut = _T("");
m_sSexOut = _T("");
m_sWorkOut = _T("");
m_iTotalNum = 0;
m_iSexIn = 0;
//}}AFX_DATA_INIT
}
void CSearchDg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSearchDg)
DDX_Control(pDX, IDC_DELETE, m_DelCtrl);
DDX_Control(pDX, IDC_SPRECORD, m_SprecordCtrl);
DDX_Text(pDX, IDC_ADDRESS_IN, m_sAddressIn);
DDX_Text(pDX, IDC_ADDRESS_OUT, m_sAddressOut);
DDX_Text(pDX, IDC_BIRTH_OUT, m_sBirthOut);
DDX_Text(pDX, IDC_DUTY_IN, m_sDutyIn);
DDX_Text(pDX, IDC_DUTY_OUT, m_sDutyOut);
DDX_Text(pDX, IDC_EDU_IN, m_sEduIn);
DDX_Text(pDX, IDC_EDU_OUT, m_sEduOut);
DDX_Text(pDX, IDC_MEMO_IN, m_sMemoIn);
DDX_Text(pDX, IDC_MEMO_OUT, m_sMemoOut);
DDX_Text(pDX, IDC_NAME_IN, m_sNameIn);
DDX_Text(pDX, IDC_NAME_OUT, m_sNameOut);
DDX_Text(pDX, IDC_PHONE_IN, m_sPhoneIn);
DDX_Text(pDX, IDC_PHONE_OUT, m_sPhoneOut);
DDX_Text(pDX, IDC_SEX_OUT, m_sSexOut);
DDX_Text(pDX, IDC_WORK_OUT, m_sWorkOut);
DDX_Text(pDX, IDC_TOTALNUM, m_iTotalNum);
DDX_CBIndex(pDX, IDC_SEXCOB_IN, m_iSexIn);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSearchDg, CDialog)
//{{AFX_MSG_MAP(CSearchDg)
ON_BN_CLICKED(IDC_START, OnStart)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPRECORD, OnDeltaposSprecord)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSearchDg message handlers
void CSearchDg::OnStart()
{
// TODO: Add your control notification handler code here
UpdateData();
CEmploy temp;
temp.m_iSex=m_iSexIn;
temp.m_sAddress=m_sAddressIn;
temp.m_sDuty=m_sDutyIn;
temp.m_sEducate=m_sEduIn;
temp.m_sMemo=m_sMemoIn;
temp.m_sName=m_sNameIn;
temp.m_sPhone=m_sPhoneIn;
CMainFrame * pt=(CMainFrame *)AfxGetMainWnd();
CEmployDoc * pDoc=(CEmployDoc *)pt->GetActiveDocument();
pDoc->m_Sys.SearchEmploy(temp,ResultList);
m_iTotalNum=ResultList.GetCount();
if(m_iTotalNum==0)
{
m_sAddressOut=_T("");
m_sBirthOut=_T("");
m_sDutyOut=_T("");
m_sEduOut=_T("");
m_sMemoOut=_T("");
m_sNameOut=_T("");
m_sPhoneOut=_T("");
m_sWorkOut=_T("");
m_sSexOut=_T("");
m_DelCtrl.EnableWindow(FALSE);
m_SprecordCtrl.EnableWindow(FALSE);
}
else
{
m_DelCtrl.EnableWindow(TRUE);
if(m_iTotalNum!=1)
{
m_SprecordCtrl.EnableWindow(TRUE);
m_SprecordCtrl.SetPos(0);
m_SprecordCtrl.SetRange(0,m_iTotalNum-1);
}
else
{
m_SprecordCtrl.EnableWindow(FALSE);
}
CEmploy temp;
temp=ResultList.GetHead();
SetToPrint(temp);
}
UpdateData(FALSE);
}
void CSearchDg::OnDeltaposSprecord(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
// TODO: Add your control notification handler code here
UpdateData();
CEmploy temp;
CMainFrame * pMainFrm=(CMainFrame *)AfxGetMainWnd();
CEmployDoc * pDoc=(CEmployDoc *)pMainFrm->GetActiveDocument();
pDoc->SetModifiedFlag();
POSITION pos1=ResultList.GetHeadPosition();
for(int i=0;i<pNMUpDown->iPos;i++)
ResultList.GetNext(pos1);
CEmploy & tpList=ResultList.GetAt(pos1);
CEmploy & tpSource=(pDoc->m_Sys).Get(tpList);
tpList.m_sAddress=m_sAddressOut;
tpList.m_sDuty=m_sDutyOut;
tpList.m_sEducate=m_sEduOut;
tpList.m_sPhone=m_sPhoneOut;
tpList.m_sMemo=m_sMemoOut;
tpSource.m_sAddress=m_sAddressOut;
tpSource.m_sDuty=m_sDutyOut;
tpSource.m_sEducate=m_sEduOut;
tpSource.m_sPhone=m_sPhoneOut;
tpSource.m_sMemo=m_sMemoOut;
if(pNMUpDown->iDelta==0x00000001)
{
if(pNMUpDown->iPos<(ResultList.GetCount()-1))
{
POSITION pos=ResultList.GetHeadPosition();
for(int i=0;i<pNMUpDown->iPos+1;i++)
ResultList.GetNext(pos);
temp=ResultList.GetAt(pos);
SetToPrint(temp);
}
}
else
{
if(pNMUpDown->iPos>0)
{
POSITION pos=ResultList.GetHeadPosition();
for(int i=0;i<pNMUpDown->iPos-1;i++)
ResultList.GetNext(pos);
temp=ResultList.GetAt(pos);
SetToPrint(temp);
}
}
pDoc->UpdateAllViews(NULL);
UpdateData(FALSE);
*pResult = 0;
}
void CSearchDg::SetToPrint(const CEmploy &temp)
{
m_sAddressOut=temp.m_sAddress;
m_sBirthOut=temp.m_tBirth.Format("%Y-%m-%d");
m_sDutyOut=temp.m_sDuty;
m_sEduOut=temp.m_sEducate;
m_sMemoOut=temp.m_sMemo;
m_sNameOut=temp.m_sName;
m_sPhoneOut=temp.m_sPhone;
m_sWorkOut=temp.m_tWork.Format("%Y-%m-%d");
if(temp.m_iSex==0)
m_sSexOut="巢";
else if(temp.m_iSex==1)
m_sSexOut="咯";
else
m_sSexOut="";
}
void CSearchDg::OnDelete()
{
// TODO: Add your control notification handler code here
int iPos=(m_SprecordCtrl.GetPos())&0x11101111;
POSITION pos=ResultList.GetHeadPosition();
for(int i=0;i<iPos;i++)
ResultList.GetNext(pos);
CEmploy temp=ResultList.GetAt(pos);
CMainFrame * pMainFrm=(CMainFrame *)AfxGetMainWnd();
CEmployDoc * pDoc=(CEmployDoc *)pMainFrm->GetActiveDocument();
pDoc->m_Sys.DelEmploy(temp);
pDoc->SetModifiedFlag();
ResultList.RemoveAt(pos);
if(ResultList.GetCount()==1)
{
m_SprecordCtrl.EnableWindow(FALSE);
temp=ResultList.GetHead();
SetToPrint(temp);
}
else if(ResultList.GetCount()==0)
{
m_DelCtrl.EnableWindow(FALSE);
temp.m_iSex=2;
temp.m_sAddress=_T("");
temp.m_sDuty=_T("");
temp.m_sEducate=_T("");
temp.m_sMemo=_T("");
temp.m_sName=_T("");
temp.m_sPhone=_T("");
SetToPrint(temp);
m_sBirthOut=_T("");
m_sWorkOut=_T("");
}
else
{
m_SprecordCtrl.SetRange(0,ResultList.GetCount()-1);
if((m_SprecordCtrl.GetPos()&0x11101111)>0)
m_SprecordCtrl.SetPos((m_SprecordCtrl.GetPos()&0x11101111)-1);
else
m_SprecordCtrl.SetPos(0);
POSITION recordpos=ResultList.GetHeadPosition();
int tip=(m_SprecordCtrl.GetPos())&0x11101111;
for(int i=0;i<tip;i++)
ResultList.GetNext(recordpos);
temp=ResultList.GetAt(recordpos);
SetToPrint(temp);
}
pDoc->UpdateAllViews(NULL);
UpdateData(FALSE);
}
BOOL CSearchDg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_DelCtrl.EnableWindow(FALSE);
m_SprecordCtrl.EnableWindow(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSearchDg::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -