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

📄 clientcontactform.cpp

📁 关于客户关系管理系统的源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	
}

void CClientContactForm::OnExit() 
{
	this->OnCancel();
}

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

	DWORD style;
	style=m_clientList.GetExStyle();
	style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
	m_clientList.SetExtendedStyle(style);
	
	m_clientList.InsertColumn(0,"客户编码",LVCFMT_LEFT,100);
	m_clientList.InsertColumn(1,"单位名称",LVCFMT_LEFT,100);
	m_clientList.InsertColumn(2,"联系人",LVCFMT_LEFT,100);
	m_clientList.InsertColumn(3,"登记日期",LVCFMT_LEFT,100);
	m_clientList.InsertColumn(4,"客户级别",LVCFMT_LEFT,100);
	m_clientList.InsertColumn(5,"地区",LVCFMT_LEFT,100);
	m_clientList.InsertColumn(6,"地址",LVCFMT_LEFT,100);
	m_clientList.InsertColumn(7,"邮编",LVCFMT_LEFT,100);
	m_clientList.InsertColumn(8,"电话",LVCFMT_LEFT,100);
	m_clientList.InsertColumn(9,"传真",LVCFMT_LEFT,100);
	m_clientList.InsertColumn(10,"网站",LVCFMT_LEFT,100);
	m_clientList.InsertColumn(11,"eMail",LVCFMT_LEFT,100);
	m_clientList.InsertColumn(12,"备注",LVCFMT_LEFT,100);


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

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

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

	i=0;
	_RecordsetPtr m_pClientRecordset;
	strSQL="select * from client";
	hTRes = m_pClientRecordset.CreateInstance(_T("ADODB.Recordset"));
	if (SUCCEEDED(hTRes))
	{
		hTRes = m_pClientRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
		while(!(m_pClientRecordset->adoEOF))
		{
			m_clientList.InsertItem(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("clientID")));
			m_clientList.SetItemText(i,1,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("clientName")));
			m_clientList.SetItemText(i,2,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("contactPerson")));
			m_clientList.SetItemText(i,3,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("bookinDate")));
			m_clientList.SetItemText(i,4,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("clientLevel")));
			m_clientList.SetItemText(i,5,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("areaID")));
			m_clientList.SetItemText(i,6,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("address")));
			m_clientList.SetItemText(i,7,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("postcode")));
			m_clientList.SetItemText(i,8,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("telephone")));
			m_clientList.SetItemText(i,9,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("fax")));
			m_clientList.SetItemText(i,10,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("webSite")));
			m_clientList.SetItemText(i,11,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("eMail")));
			m_clientList.SetItemText(i,12,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pClientRecordset->GetCollect("remark")));

			
			i++;
			m_pClientRecordset->MoveNext();
		}
	}

	style=m_contactList.GetExStyle();
	style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
	m_contactList.SetExtendedStyle(style);
	
	m_contactList.InsertColumn(0,"记录编号",LVCFMT_LEFT,100);
	m_contactList.InsertColumn(1,"交往日期",LVCFMT_LEFT,100);
	m_contactList.InsertColumn(2,"我方代表",LVCFMT_LEFT,100);
	m_contactList.InsertColumn(3,"客户代表",LVCFMT_LEFT,100);
	m_contactList.InsertColumn(4,"交往主题",LVCFMT_LEFT,100);
	m_contactList.InsertColumn(5,"交往情况",LVCFMT_LEFT,100);
	m_contactList.InsertColumn(6,"交往总结",LVCFMT_LEFT,100);
	m_contactList.InsertColumn(7,"交往结果",LVCFMT_LEFT,100);
	

	tx_contactSubject=GetDlgItem(IDC_contactSubject);
	tx_contactCondition=GetDlgItem(IDC_contactCondition);
	tx_contactSummary=GetDlgItem(IDC_contactSummary);
	tx_contactResult=GetDlgItem(IDC_contactResult);
	tx_clientStaff=GetDlgItem(IDC_clientStaff);
	tx_ourStaff=GetDlgItem(IDC_ourStaff);
	tx_contactDate=GetDlgItem(IDC_contactDate);
	tx_recordID=GetDlgItem(IDC_recordID);

	bt_add=GetDlgItem(IDC_add);
	bt_cancelation=GetDlgItem(IDC_cancelation);
	bt_delete=GetDlgItem(IDC_delete);
	bt_save=GetDlgItem(IDC_save);
	bt_modify=GetDlgItem(IDC_modify);
	
	tx_contactSubject->EnableWindow(false);
	tx_contactCondition->EnableWindow(false);
	tx_contactSummary->EnableWindow(false);
	tx_contactResult->EnableWindow(false);
	tx_clientStaff->EnableWindow(false);
	tx_ourStaff->EnableWindow(false);
	tx_contactDate->EnableWindow(false);
	tx_recordID->EnableWindow(false);

	bt_add->EnableWindow(true);
	bt_cancelation->EnableWindow(false);
	bt_delete->EnableWindow(false);
	bt_save->EnableWindow(false);
	bt_modify->EnableWindow(false);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CClientContactForm::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult) 
{
	UpdateData(true);
	POSITION pos = m_contactList.GetFirstSelectedItemPosition();
	if(pos)
	{
		int nFirstSelItem = m_contactList.GetNextSelectedItem(pos);
		m_recordID=m_contactList.GetItemText(nFirstSelItem,0);
	}

	CClientContact clientContact;
	clientContact.GetData(m_clientID,m_recordID);

	m_contactSubject = clientContact.GetContactSubject();
	m_contactCondition = clientContact.GetContactCondition();
	m_contactSummary = clientContact.GetContactSummary();
	m_contactResult = clientContact.GetContactResult();
	m_clientStaff = clientContact.GetClientStaff();
	m_ourStaff = clientContact.GetOurStaff();
	m_contactDate = clientContact.GetContactDate();


	tx_contactSubject->EnableWindow(false);
	tx_contactCondition->EnableWindow(false);
	tx_contactSummary->EnableWindow(false);
	tx_contactResult->EnableWindow(false);
	tx_clientStaff->EnableWindow(false);
	tx_ourStaff->EnableWindow(false);
	tx_contactDate->EnableWindow(false);
	tx_recordID->EnableWindow(false);

	bt_add->EnableWindow(true);
	bt_cancelation->EnableWindow(false);
	bt_delete->EnableWindow(true);
	bt_save->EnableWindow(false);
	bt_modify->EnableWindow(true);

	UpdateData(false);

	
	*pResult = 0;
}

void CClientContactForm::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	UpdateData(true);
	POSITION pos = m_clientList.GetFirstSelectedItemPosition();
	if(pos)
	{
		int nFirstSelItem = m_clientList.GetNextSelectedItem(pos);
		m_clientID=m_clientList.GetItemText(nFirstSelItem,0);
	}

	m_contactList.DeleteAllItems();

	CString strSQL;

	strSQL="select * from clientContact where clientID='";
	strSQL=strSQL+m_clientID+"'";
	_RecordsetPtr m_pRecordset;
	HRESULT hTRes;
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));				
	hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
	int i=0;
	while(!(m_pRecordset->adoEOF))
	{
		CString str;
	
		m_contactList.InsertItem(i, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("contactID")));
		COleDateTime contactDate= m_pRecordset->GetCollect("contactDate");
		str.Format("%d-%d-%d",contactDate.GetYear(),contactDate.GetMonth(),contactDate.GetDay());
		m_contactList.SetItemText(i,1, str);
		m_contactList.SetItemText(i,2, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("ourStaff")));
		m_contactList.SetItemText(i,3, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("clientStaff")));
		m_contactList.SetItemText(i,4, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("contactSubject")));
		m_contactList.SetItemText(i,5, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("contactCondition")));
		m_contactList.SetItemText(i,6, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("contactSummary")));
		m_contactList.SetItemText(i,7, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("contactResult")));
	
		m_pRecordset->MoveNext();
		i++;
	}

	
	*pResult = 0;
}


void CClientContactForm::Refresh()
{
	m_contactList.DeleteAllItems();

	CString strSQL;

	strSQL="select * from clientContact where clientID='";
	strSQL=strSQL+m_clientID+"'";
	_RecordsetPtr m_pRecordset;
	HRESULT hTRes;
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));				
	hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
	int i=0;
	while(!(m_pRecordset->adoEOF))
	{
		CString str;
	
		m_contactList.InsertItem(i, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("contactID")));
		COleDateTime contactDate= m_pRecordset->GetCollect("contactDate");
		str.Format("%d-%d-%d",contactDate.GetYear(),contactDate.GetMonth(),contactDate.GetDay());
		m_contactList.SetItemText(i,1, str);
		m_contactList.SetItemText(i,2, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("ourStaff")));
		m_contactList.SetItemText(i,3, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("clientStaff")));
		m_contactList.SetItemText(i,4, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("contactSubject")));
		m_contactList.SetItemText(i,5, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("contactCondition")));
		m_contactList.SetItemText(i,6, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("contactSummary")));
		m_contactList.SetItemText(i,7, ((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("contactResult")));
	
		m_pRecordset->MoveNext();
		i++;
	}

}

⌨️ 快捷键说明

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