📄 searchcustomerdlg.cpp
字号:
// SearchCustomerDLG.cpp : implementation file
//
#include "stdafx.h"
#include "trade_mis.h"
#include "SearchCustomerDLG.h"
#include "Trade_MISView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSearchCustomerDLG dialog
CSearchCustomerDLG::CSearchCustomerDLG(CWnd* pParent /*=NULL*/)
: CDialog(CSearchCustomerDLG::IDD, pParent)
{
//{{AFX_DATA_INIT(CSearchCustomerDLG)
m_sCity = _T("");
m_bCity = FALSE;
m_sCompany = _T("");
m_bCompany = FALSE;
m_sPerson = _T("");
m_bPerson = FALSE;
//}}AFX_DATA_INIT
}
void CSearchCustomerDLG::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSearchCustomerDLG)
DDX_CBString(pDX, IDD_SEARCHCUSTOMER_CITY, m_sCity);
DDX_Check(pDX, IDD_SEARCHCUSTOMER_CITYCHECK, m_bCity);
DDX_Text(pDX, IDD_SEARCHCUSTOMER_COMPANY, m_sCompany);
DDX_Check(pDX, IDD_SEARCHCUSTOMER_COMPANYCHECK, m_bCompany);
DDX_Text(pDX, IDD_SEARCHCUSTOMER_PERSON, m_sPerson);
DDX_Check(pDX, IDD_SEARCHCUSTOMER_PERSONCHECK, m_bPerson);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSearchCustomerDLG, CDialog)
//{{AFX_MSG_MAP(CSearchCustomerDLG)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSearchCustomerDLG message handlers
void CSearchCustomerDLG::OnOK()
{
// TODO: Add extra validation here
UpdateData(true);
m_sCompany.TrimRight(" ");
m_sPerson.TrimRight(" ");
if ( !(m_bCompany||m_bPerson||m_bCity) )
{
AfxMessageBox(_T("请选择查询条件!"), MB_ICONEXCLAMATION);
return;
}
if ( m_bCompany && ""==m_sCompany )
{
AfxMessageBox(_T("公司名称不能为空"), MB_ICONEXCLAMATION);
return;
}
if ( m_bPerson && ""==m_sPerson )
{
AfxMessageBox(_T("联系人姓名不能为空"), MB_ICONEXCLAMATION);
return;
}
if (!m_bCompany) m_sCompany = "%";
if (!m_bPerson) m_sPerson = "%";
if (!m_bCity) m_sCity = "%";
_variant_t strQuery;
strQuery = "select * from customers where CompanyName like '"+m_sCompany+"' and ContactName like '"+m_sPerson+"' and City like '"+m_sCity+"'";
CTrade_MISView* p = (CTrade_MISView*)(((CMainFrame*)AfxGetMainWnd())->GetActiveView());
p->RefreshCustomer(strQuery);
//CDialog::OnOK();
}
BOOL CSearchCustomerDLG::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// Init Combobox
_variant_t strQuery, Holder;
strQuery = "select DISTINCT City from customers";
theApp.ADOExecute(theApp.m_pADOSet, strQuery);
int iCount = theApp.m_pADOSet->GetRecordCount();
theApp.m_pADOSet->MoveFirst();
for (int i=0; i<iCount; i++)
{
Holder = theApp.m_pADOSet->GetCollect("City");
((CComboBox*)GetDlgItem(IDD_SEARCHCUSTOMER_CITY))->InsertString(i, Holder.vt==VT_NULL?"":(char*)(_bstr_t)Holder);
theApp.m_pADOSet->MoveNext();
}
((CComboBox*)GetDlgItem(IDD_SEARCHCUSTOMER_CITY))->SetCurSel(0);
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 + -