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

📄 clientsaletotal.cpp

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

#include "stdafx.h"
#include "ClientRelationship.h"
#include "ClientSaleTotal.h"

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

/////////////////////////////////////////////////////////////////////////////
// CClientSaleTotal dialog


CClientSaleTotal::CClientSaleTotal(CWnd* pParent /*=NULL*/)
	: CDialog(CClientSaleTotal::IDD, pParent)
{
	//{{AFX_DATA_INIT(CClientSaleTotal)
	m_dateBegin = COleDateTime::GetCurrentTime();
	m_dateEnd = COleDateTime::GetCurrentTime();
	m_clientName = _T("");
	m_summary = _T("");
	//}}AFX_DATA_INIT
}


void CClientSaleTotal::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CClientSaleTotal)
	DDX_Control(pDX, IDC_clientName, m_clientNameCombo);
	DDX_DateTimeCtrl(pDX, IDC_dateBegin, m_dateBegin);
	DDX_DateTimeCtrl(pDX, IDC_dateEnd, m_dateEnd);
	DDX_CBString(pDX, IDC_clientName, m_clientName);
	DDX_Text(pDX, IDC_EDIT1, m_summary);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CClientSaleTotal, CDialog)
	//{{AFX_MSG_MAP(CClientSaleTotal)
	ON_BN_CLICKED(IDC_BUTTON1, OnAnalysis)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CClientSaleTotal message handlers

void CClientSaleTotal::OnAnalysis() 
{
	UpdateData(true);
	CString strSQL;
	CString str;
	strSQL="exec clientSaleTotal '";//构造执行存储过程的sql语句
	str.Format("%d-%d-%d",m_dateBegin.GetYear(),m_dateBegin.GetMonth(),m_dateBegin.GetDay());
	strSQL+=str+"','";
	str.Format("%d-%d-%d",m_dateEnd.GetYear(),m_dateEnd.GetMonth(),m_dateEnd.GetDay());
	strSQL+=str+"','"+m_clientName+"'";

	_RecordsetPtr m_pRecordset;
	HRESULT hTRes;
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));
	//执行存储过程
	m_pRecordset=(((CClientRelationshipApp*)AfxGetApp())->m_pConn)->Execute((_bstr_t)strSQL,NULL,adCmdText);
	//取出存储过程的执行结果
	str=((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("totalMoney"));
	//显示执行结果
	m_summary="销售额为:"+str;
	UpdateData(false);//将数据更新到对话框
}

BOOL CClientSaleTotal::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	CString strSQL;
	_RecordsetPtr m_pRecordset;
	HRESULT hTRes;
	hTRes = m_pRecordset.CreateInstance(_T("ADODB.Recordset"));	

	strSQL="select distinct clientName from client";	
				
	hTRes = m_pRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
			((CClientRelationshipApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
			adOpenDynamic,adLockPessimistic,adCmdText);
	int i=0;
	while(!(m_pRecordset->adoEOF))
	{
		m_clientNameCombo.InsertString(i,((CClientRelationshipApp*)AfxGetApp())->GetStringFromVariant(m_pRecordset->GetCollect("clientName")));
		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 + -