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

📄 searchopponent.cpp

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

#include "stdafx.h"
#include "ClientRelationship.h"
#include "SearchOpponent.h"
#include "OpponentContactForm.h"
#include "OpponentProductForm.h"
#include "OpponentStaffForm.h"
#include "OpponentInfoForm.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSearchOpponent dialog


CSearchOpponent::CSearchOpponent(CWnd* pParent /*=NULL*/)
	: CDialog(CSearchOpponent::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSearchOpponent)
	m_opponentID = _T("");
	m_legalPerson = _T("");
	m_opponentName = _T("");
	m_address = _T("");
	m_industryCharacter = _T("");
	m_scale = _T("");
	m_opponentLevel = _T("");
	//}}AFX_DATA_INIT
}


void CSearchOpponent::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSearchOpponent)
	DDX_Control(pDX, IDC_LIST1, m_list);
	DDX_Control(pDX, IDC_opponentLevel, m_opponentLevelCombo);
	DDX_Control(pDX, IDC_scale, m_scaleCombo);
	DDX_Control(pDX, IDC_industryCharacter, m_industryCharacterCombo);
	DDX_Control(pDX, IDC_address, m_addressCombo);
	DDX_Control(pDX, IDC_opponentName, m_opponentNameCombo);
	DDX_Control(pDX, IDC_legalPerson, m_legalPersonCombo);
	DDX_Control(pDX, IDC_opponentID, m_opponentIDCombo);
	DDX_CBString(pDX, IDC_opponentID, m_opponentID);
	DDX_CBString(pDX, IDC_legalPerson, m_legalPerson);
	DDX_CBString(pDX, IDC_opponentName, m_opponentName);
	DDX_CBString(pDX, IDC_address, m_address);
	DDX_CBString(pDX, IDC_industryCharacter, m_industryCharacter);
	DDX_CBString(pDX, IDC_scale, m_scale);
	DDX_CBString(pDX, IDC_opponentLevel, m_opponentLevel);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSearchOpponent, CDialog)
	//{{AFX_MSG_MAP(CSearchOpponent)
	ON_BN_CLICKED(IDC_opponentStaff, OnOpponentStaff)
	ON_BN_CLICKED(IDC_opponentProduct, OnOpponentProduct)
	ON_BN_CLICKED(IDC_opponentContact, OnOpponentContact)
	ON_BN_CLICKED(IDC_search, OnSearch)
	ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
	ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSearchOpponent message handlers

void CSearchOpponent::OnOpponentStaff() 
{
	COpponentStaffForm dlg;
	if(dlg.DoModal()==IDOK)
	{
	}	
}

void CSearchOpponent::OnOpponentProduct() 
{
	COpponentProductForm dlg;
	if(dlg.DoModal()==IDOK)
	{
	}	
}

void CSearchOpponent::OnOpponentContact() 
{
	COpponentContactForm dlg;
	if(dlg.DoModal()==IDOK)
	{
	}	
}

void CSearchOpponent::OnSearch() 
{
	UpdateData(true);
	CString strSQL;
	_RecordsetPtr m_pRecordset;
	HRESULT hTRes;
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));	

	int flag=0;
	strSQL="select * from opponent ";
	if(m_opponentID!="")
	{
		strSQL+="where opponentID='"+m_opponentID+"' ";
		flag=1;
	}

	if(m_legalPerson!=""&&flag==1)
	{
		strSQL+=" and legalPerson='"+m_legalPerson+"' ";
	}
	else if(m_legalPerson!=""&&flag==0)
	{
		strSQL+="where legalPerson='"+m_legalPerson+"'";
		flag=1;
	}

	if(m_opponentName!=""&&flag==1)
	{
		strSQL+=" and opponentName='"+m_opponentName+"' ";
	}
	else if(m_opponentName!=""&&flag==0)
	{
		strSQL+="where opponentName='"+m_opponentName+"' ";
		flag=1;
	}

	if(m_address!=""&&flag==1)
	{
		strSQL+=" and address='"+m_address+"' ";
	}
	else if(m_address!=""&&flag==0)
	{
		strSQL+="where address='"+m_address+"' ";
		flag=1;
	}

	if(m_industryCharacter!=""&&flag==1)
	{
		strSQL+=" and industryCharacter='"+m_industryCharacter+"' ";
	}
	else if(m_industryCharacter!=""&&flag==0)
	{
		strSQL+="where industryCharacter='"+m_industryCharacter+"' ";
		flag=1;
	}

	if(m_scale!=""&&flag==1)
	{
		strSQL+=" and scale='"+m_scale+"' ";
	}
	else if(m_scale!=""&&flag==0)
	{
		strSQL+="where scale='"+m_scale+"'";
		flag=1;
	}

	if(m_opponentLevel!=""&&flag==1)
	{
		strSQL+=" and opponentLevel='"+m_opponentLevel+"'";
	}
	else if(m_legalPerson!=""&&flag==0)
	{
		strSQL+="where opponentLevel='"+m_opponentLevel+"' ";
		flag=1;
	}
		
//	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))
	{
		CString str;
		m_list.InsertItem(i, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("opponentID")));
		COleDateTime bookinDate= m_pRecordset->GetCollect("bookinDate");
		str.Format("%d-%d-%d",bookinDate.GetYear(),bookinDate.GetMonth(),bookinDate.GetDay());
		m_list.SetItemText(i,3, str);
		m_list.SetItemText(i,4, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("opponentLevel")));
		m_list.SetItemText(i,2, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("opponentName")));
		m_list.SetItemText(i,1, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("legalPerson")));
		m_list.SetItemText(i,5, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("industryCharacter")));
		m_list.SetItemText(i,6, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("address")));
		float allFunds= m_pRecordset->GetCollect("allFunds");
		str.Format("%f",allFunds);
		m_list.SetItemText(i,7,str);
		m_list.SetItemText(i,8, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("scale")));
		m_list.SetItemText(i,9, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("webSite")));
		m_list.SetItemText(i,10, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("fax")));
		m_list.SetItemText(i,11, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("telephone")));
		m_list.SetItemText(i,12, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("postCode")));
//		m_list.SetItemText(i,13, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("account")));
		m_list.SetItemText(i,13, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("address")));
		m_list.SetItemText(i,14, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("manageRange")));
		m_list.SetItemText(i,15, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("managePolicy")));
		m_list.SetItemText(i,16, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("goalMarket")));
		m_list.SetItemText(i,17, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("resourceCondition")));
		m_list.SetItemText(i,18, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("developeTend")));
		m_list.SetItemText(i,19, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("assess")));


		m_pRecordset->MoveNext();
		i++;
	}
	m_pRecordset->Close();
	
}

void CSearchOpponent::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	
	*pResult = 0;
}

BOOL CSearchOpponent::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);
	m_list.InsertColumn(5,"行业性质",LVCFMT_LEFT,100);
	m_list.InsertColumn(6,"总资产",LVCFMT_LEFT,100);
	m_list.InsertColumn(7,"规模",LVCFMT_LEFT,100);
	m_list.InsertColumn(8,"网站",LVCFMT_LEFT,100);
	m_list.InsertColumn(9,"传真",LVCFMT_LEFT,100);
	m_list.InsertColumn(10,"电话",LVCFMT_LEFT,100);
	m_list.InsertColumn(11,"邮编",LVCFMT_LEFT,100);
	m_list.InsertColumn(12,"帐号",LVCFMT_LEFT,100);
	m_list.InsertColumn(13,"地址",LVCFMT_LEFT,100);
	m_list.InsertColumn(14,"经营范围",LVCFMT_LEFT,100);
	m_list.InsertColumn(15,"经营策略",LVCFMT_LEFT,100);
	m_list.InsertColumn(16,"目标市场",LVCFMT_LEFT,100);
	m_list.InsertColumn(17,"资源情况",LVCFMT_LEFT,100);
	m_list.InsertColumn(18,"发展趋势",LVCFMT_LEFT,100);
	m_list.InsertColumn(19,"评价分析",LVCFMT_LEFT,100);

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

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

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

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

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

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

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

	strSQL="select distinct opponentLevel from opponent";	
				
	hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
	i=0;
	while(!(m_pRecordset->adoEOF))
	{
		m_opponentLevelCombo.InsertString(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("opponentLevel")));
		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 CSearchOpponent::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);
	}
	COpponentInfoForm dlg;
	dlg.m_opponentID=str;
	dlg.is_search=1;
	dlg.DoModal();
	
	*pResult = 0;
}

⌨️ 快捷键说明

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