⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 searchmarketinvestigate.cpp

📁 关于客户关系管理系统的源码
💻 CPP
字号:
// SearchMarketInvestigate.cpp : implementation file
//

#include "stdafx.h"
#include "ClientRelationship.h"
#include "SearchMarketInvestigate.h"
#include "MarketInvestigateForm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSearchMarketInvestigate dialog


CSearchMarketInvestigate::CSearchMarketInvestigate(CWnd* pParent /*=NULL*/)
	: CDialog(CSearchMarketInvestigate::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSearchMarketInvestigate)
	m_investigateDateBegin = COleDateTime::GetCurrentTime();
	m_investigateDateEnd = COleDateTime::GetCurrentTime();
	m_investigatePerson = _T("");
	m_object = _T("");
	//}}AFX_DATA_INIT
}


void CSearchMarketInvestigate::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSearchMarketInvestigate)
	DDX_Control(pDX, IDC_investigatePerson, m_investigatePersonCombo);
	DDX_Control(pDX, IDC_object, m_objectCombo);
	DDX_Control(pDX, IDC_LIST1, m_list);
	DDX_DateTimeCtrl(pDX, IDC_investigateDateBegin, m_investigateDateBegin);
	DDX_DateTimeCtrl(pDX, IDC_investigateDateEnd, m_investigateDateEnd);
	DDX_CBString(pDX, IDC_investigatePerson, m_investigatePerson);
	DDX_CBString(pDX, IDC_object, m_object);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSearchMarketInvestigate, CDialog)
	//{{AFX_MSG_MAP(CSearchMarketInvestigate)
	ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
	ON_BN_CLICKED(IDC_search, OnSearch)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSearchMarketInvestigate message handlers

void CSearchMarketInvestigate::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	CString str;
	int flag=0;
	POSITION pos = m_list.GetFirstSelectedItemPosition();
	if(pos)
	{
		int nFirstSelItem = m_list.GetNextSelectedItem(pos);		
		str=m_list.GetItemText(nFirstSelItem,0);
	}
	CMarketInvestigateForm dlg;
	dlg.m_marketInvestigateID=str;
	dlg.is_search=1;
	dlg.DoModal();
	
	*pResult = 0;
}

BOOL CSearchMarketInvestigate::OnInitDialog() 
{
	CDialog::OnInitDialog();

	DWORD style;
	style=m_list.GetExStyle();
	style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
	m_list.SetExtendedStyle(style);
	
	m_list.InsertColumn(0,"新闻编号",LVCFMT_LEFT,100);
	m_list.InsertColumn(1,"发布日期",LVCFMT_LEFT,100);
	m_list.InsertColumn(2,"发布人员",LVCFMT_LEFT,100);
	m_list.InsertColumn(3,"新闻主题",LVCFMT_LEFT,100);
	m_list.InsertColumn(4,"新闻内容",LVCFMT_LEFT,100);
	
	CString strSQL;
	_RecordsetPtr m_pRecordset;
	HRESULT hTRes;
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));	

	strSQL="select distinct investigatePerson from marketInvestigate";	
				
	hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
	int i=0;
	while(!(m_pRecordset->adoEOF))
	{
		m_investigatePersonCombo.InsertString(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("investigatePerson")));
		m_pRecordset->MoveNext();
		i++;
	}
	m_pRecordset->Close();

	strSQL="select distinct object from marketInvestigate";	
				
	hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
	i=0;
	while(!(m_pRecordset->adoEOF))
	{
		m_objectCombo.InsertString(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("object")));
		m_pRecordset->MoveNext();
		i++;
	}
	m_pRecordset->Close();
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSearchMarketInvestigate::OnSearch() 
{
	UpdateData(true);

	CString strSQL;
	_RecordsetPtr m_pRecordset;
	HRESULT hTRes;
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));	

	strSQL="select * from marketInvestigate";
	CString str;
	str.Format("%d-%d-%d",m_investigateDateBegin.GetYear(),m_investigateDateBegin.GetMonth(),m_investigateDateBegin.GetDay());
	strSQL+=" where investigateDate>'"+str+"' ";
	str.Format("%d-%d-%d",m_investigateDateEnd.GetYear(),m_investigateDateEnd.GetMonth(),m_investigateDateEnd.GetDay());
	strSQL+=" and investigateDate<'"+str+"' ";

	if(m_investigatePerson!="")
	{
		strSQL+=" and investigatePerson='"+m_investigatePerson+"' "; 
	}
	if(m_object!="")
	{
		strSQL+=" and object='"+m_object+"' ";
	}
//	AfxMessageBox(strSQL);
	
	hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
	int i=0;
	m_list.DeleteAllItems();
	while(!(m_pRecordset->adoEOF))
	{
		m_list.InsertItem(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("marketInvestigateID")));
		COleDateTime investigateDate= m_pRecordset->GetCollect("investigateDate");
		str.Format("%d-%d-%d",investigateDate.GetYear(),investigateDate.GetMonth(),investigateDate.GetDay());
		m_list.SetItemText(i,1,str);
		m_list.SetItemText(i,2, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("investigatePerson")));
		m_list.SetItemText(i,3, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("object")));
		m_list.SetItemText(i,4, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("summary")));		
	
		m_pRecordset->MoveNext();
		i++;
	}
	m_pRecordset->Close();
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -