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

📄 searchclientreserve.cpp

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

#include "stdafx.h"
#include "ClientRelationship.h"
#include "SearchClientReserve.h"
#include "ClientReserveForm.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSearchClientReserve dialog


CSearchClientReserve::CSearchClientReserve(CWnd* pParent /*=NULL*/)
	: CDialog(CSearchClientReserve::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSearchClientReserve)
	m_reserveStyle = _T("");
	m_attendStaff = _T("");
	m_clientName = _T("");
	m_clientStaff = _T("");
	m_subject = _T("");
	m_address = _T("");
	//}}AFX_DATA_INIT
}


void CSearchClientReserve::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSearchClientReserve)
	DDX_Control(pDX, IDC_address, m_addressCombo);
	DDX_Control(pDX, IDC_subject, m_subjectCombo);
	DDX_Control(pDX, IDC_clientStaff, m_clientStaffCombo);
	DDX_Control(pDX, IDC_clientName, m_clientNameCombo);
	DDX_Control(pDX, IDC_attendStaff, m_attendStaffCombo);
	DDX_Control(pDX, IDC_reserveStyle, m_reserveStyleCombo);
	DDX_Control(pDX, IDC_LIST1, m_list);
	DDX_CBString(pDX, IDC_reserveStyle, m_reserveStyle);
	DDX_CBString(pDX, IDC_attendStaff, m_attendStaff);
	DDX_CBString(pDX, IDC_clientName, m_clientName);
	DDX_CBString(pDX, IDC_clientStaff, m_clientStaff);
	DDX_CBString(pDX, IDC_subject, m_subject);
	DDX_CBString(pDX, IDC_address, m_address);
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////////
// CSearchClientReserve message handlers

void CSearchClientReserve::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);
	}
	CClientReserveForm dlg;
	dlg.m_clientReserveID=str;
	dlg.is_search=1;
	dlg.DoModal();
	
	*pResult = 0;
}

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

	strSQL="select * from clientReserve";
	
	int flag=0;
	if(m_reserveStyle!="")
	{
		strSQL+=" where reserveStyle='"+m_reserveStyle+"' ";
		flag=1;
	}
	if(m_attendStaff!=""&&flag==1)
	{
		strSQL+=" and attendStaff='"+m_attendStaff+"' ";
	}
	else if(m_attendStaff!=""&&flag==0)
	{
		strSQL+=" where attendStaff='"+m_attendStaff+"' ";
		flag=1;
	}
	if(m_clientName!=""&&flag==1)
	{
		strSQL+=" and clientName='"+m_clientName+"' ";
	}
	else if(m_clientName!=""&&flag==0)
	{
		strSQL+=" where clientName='"+m_clientName+"' ";
		flag=1;
	}
	if(m_clientStaff!=""&&flag==1)
	{
		strSQL+=" and clientStaff='"+m_clientStaff+"' ";
	}
	else if(m_clientStaff!=""&&flag==0)
	{
		strSQL+=" where clientStaff='"+m_clientStaff+"' ";
		flag=1;
	}
	if(m_subject!=""&&flag==1)
	{
		strSQL+=" and subject='"+m_subject+"' ";
	}
	else if(m_subject!=""&&flag==0)
	{
		strSQL+=" where subject='"+m_subject+"' ";
		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;
	}
//	AfxMessageBox(strSQL);
				
	hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
	int i=0;
	m_list.DeleteAllItems();
	CString str;
	while(!(m_pRecordset->adoEOF))
	{
		m_list.InsertItem(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("clientReserveID")));
		COleDateTime reserveTime= m_pRecordset->GetCollect("reserveTime");
		str.Format("%d-%d-%d",reserveTime.GetYear(),reserveTime.GetMonth(),reserveTime.GetDay);
		m_list.SetItemText(i,1,str);
		m_list.SetItemText(i,2, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("reserveStyle")));
		m_list.SetItemText(i,3, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("attendStaff")));
		m_list.SetItemText(i,4, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("clientName")));
		m_list.SetItemText(i,5, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("clientStaff")));
		m_list.SetItemText(i,6, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("telephone")));
		m_list.SetItemText(i,7, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("subject")));
		m_list.SetItemText(i,8, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("address")));
		m_list.SetItemText(i,9, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("content")));		
		m_list.SetItemText(i,10, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("remindNum")));
	//	is_everyDay= ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("isEveryDay"));
		
		m_pRecordset->MoveNext();
		i++;
	}
	m_pRecordset->Close();
	
}

BOOL CSearchClientReserve::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);
	
	CString strSQL;
	_RecordsetPtr m_pRecordset;
	HRESULT hTRes;
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));	

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

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

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

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

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

	strSQL="select distinct address from clientReserve";	
				
	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();
	
	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 + -