📄 searchs.cpp
字号:
// SearchS.cpp : implementation file
//
#include "stdafx.h"
#include "aomanage.h"
#include "SearchS.h"
#include "MainFrm.h"
#include "SupplyS.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSearchS dialog
CSearchS::CSearchS(CWnd* pParent /*=NULL*/)
: CParentDlg(CSearchS::IDD, pParent)
{
//{{AFX_DATA_INIT(CSearchS)
m_strContact = _T("");
m_strTele = _T("");
m_strSCode = _T("");
m_strSName = _T("");
//}}AFX_DATA_INIT
m_pSupply=new CDaoRecordset(&((CMainFrame*)AfxGetMainWnd())->m_db);
}
void CSearchS::DoDataExchange(CDataExchange* pDX)
{
CParentDlg::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSearchS)
DDX_Control(pDX, IDC_LIST1, m_ctlList);
DDX_Text(pDX, IDC_EDIT10, m_strContact);
DDX_Text(pDX, IDC_EDIT3, m_strTele);
DDX_Text(pDX, IDC_EDIT2, m_strSCode);
DDX_Text(pDX, IDC_EDIT1, m_strSName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSearchS, CParentDlg)
//{{AFX_MSG_MAP(CSearchS)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_WM_CLOSE()
ON_MESSAGE(WM_LIST2DBLCLICK,OnList2DblClick)
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSearchS message handlers
BOOL CSearchS::OnInitDialog()
{
CParentDlg::OnInitDialog();
m_pSupply->Open(AFX_DAO_USE_DEFAULT_TYPE,"select * from supply");
FIELD2 fdValue[5]={{"厂代码","scode"},{"厂名","sname"},\
{"联系人","contact"},\
{"电话","tele"},{"地址","address"}
};
m_ctlList.SetField(5,fdValue,m_pSupply);
m_ctlList.Init();
double nWidth[5]={1.5,1,1,1,2};
m_ctlList.SetWidth(nWidth);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSearchS::OnButton1()
{
UpdateData(TRUE);
CString strFltr;
if (m_strSCode.GetLength())
strFltr+=" and scode='"+m_strSCode+"'";
if (m_strSName.GetLength())
strFltr+=" and sname='"+m_strSName+"'";
if (m_strContact.GetLength())
strFltr+=" and contact='"+m_strContact+"'";
if (m_strTele.GetLength())
strFltr+=" and tele='"+m_strTele+"'";
if (!strcmp(strFltr.Left(5)," and "))
strFltr=strFltr.Right(strFltr.GetLength()-5);
m_pSupply->m_strFilter=strFltr;
m_ctlList.Refresh();
}
void CSearchS::OnButton2()
{
OnCancel();
}
void CSearchS::OnClose()
{
if (m_pSupply->IsOpen())
m_pSupply->Close();
CParentDlg::OnClose();
}
void CSearchS::OnList2DblClick(WPARAM wParam,LPARAM)
{
CSupplyS dlg;
dlg.m_strSCode.Format("%07d",wParam);
if (dlg.DoModal()==IDOK)
m_ctlList.Refresh();
}
void CSearchS::OnButton5()
{
POSITION pos=m_ctlList.GetFirstSelectedItemPosition();
if (pos)
{
int nItem=m_ctlList.GetNextSelectedItem(pos);
CSupplyS dlg;
dlg.m_strSCode=m_ctlList.GetItemText(nItem,0);
if (dlg.DoModal()==IDOK)
m_ctlList.Refresh();
}
else
MessageBox("请选中该记录");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -