?? clientplanexecute.cpp
字號:
// ClientPlanExecute.cpp : implementation file
//
#include "stdafx.h"
#include "Sale.h"
#include "ClientPlanExecute.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CClientPlanExecute dialog
CClientPlanExecute::CClientPlanExecute(CWnd* pParent /*=NULL*/)
: CDialog(CClientPlanExecute::IDD, pParent)
{
//{{AFX_DATA_INIT(CClientPlanExecute)
m_year = _T("");
m_monthBegin = _T("");
m_monthEnd = _T("");
m_clientID = _T("");
//}}AFX_DATA_INIT
}
void CClientPlanExecute::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CClientPlanExecute)
DDX_Control(pDX, IDC_LIST1, m_clientPlanExecuteList);
DDX_Control(pDX, IDC_COMBO4, m_clientIDCombo);
DDX_CBString(pDX, IDC_COMBO1, m_year);
DDX_CBString(pDX, IDC_COMBO2, m_monthBegin);
DDX_CBString(pDX, IDC_COMBO3, m_monthEnd);
DDX_CBString(pDX, IDC_COMBO4, m_clientID);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CClientPlanExecute, CDialog)
//{{AFX_MSG_MAP(CClientPlanExecute)
ON_BN_CLICKED(IDC_BUTTON1, OnSearch)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CClientPlanExecute message handlers
BOOL CClientPlanExecute::OnInitDialog()
{
CDialog::OnInitDialog();
DWORD style;
style=m_clientPlanExecuteList.GetExStyle();
style=(style|LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT)&(~LVS_EX_CHECKBOXES) ;
m_clientPlanExecuteList.SetExtendedStyle(style);
m_clientPlanExecuteList.InsertColumn(0,"客戶編號",LVCFMT_LEFT,100);
m_clientPlanExecuteList.InsertColumn(1,"客戶名稱",LVCFMT_LEFT,100);
m_clientPlanExecuteList.InsertColumn(2,"計劃金額",LVCFMT_LEFT,100);
m_clientPlanExecuteList.InsertColumn(3,"銷售定額",LVCFMT_LEFT,100);
m_clientPlanExecuteList.InsertColumn(4,"銷售額",LVCFMT_LEFT,100);
m_clientPlanExecuteList.InsertColumn(5,"較計劃金額",LVCFMT_LEFT,100);
m_clientPlanExecuteList.InsertColumn(6,"較銷售定額",LVCFMT_LEFT,100);
m_clientPlanExecuteList.InsertColumn(7,"計劃金額完成率",LVCFMT_LEFT,100);
m_clientPlanExecuteList.InsertColumn(8,"銷售定額完成率",LVCFMT_LEFT,100);
CString strSQL;
HRESULT hTRes;
strSQL="select * from client";
_RecordsetPtr m_pClientRecordset;
hTRes = m_pClientRecordset.CreateInstance(_T("ADODB.Recordset"));
if (SUCCEEDED(hTRes))
{
hTRes = m_pClientRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
TRACE(_T("連接成功!\n"));
while(!(m_pClientRecordset->adoEOF))
{
m_clientIDCombo.AddString((LPCTSTR)(_bstr_t)(m_pClientRecordset->GetCollect("clientID")));
m_pClientRecordset->MoveNext();
}
}
}
m_pClientRecordset->Close();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CClientPlanExecute::OnSearch()
{
UpdateData(true);
CString strSQL;
HRESULT hTRes;
strSQL="select * from clientSalePlanView where clientID='";
strSQL=strSQL+m_clientID+"'";
strSQL=strSQL+" and planYear='";
strSQL=strSQL+m_year+"'";
_RecordsetPtr m_pClientSalePlanRecordset;
float totalPlan=0;
float totalRatio=0;
totalPlan=0;
totalRatio=0;
hTRes = m_pClientSalePlanRecordset.CreateInstance(_T("ADODB.Recordset"));
if (SUCCEEDED(hTRes))
{
hTRes = m_pClientSalePlanRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
TRACE(_T("連接成功!\n"));
int monthBegin,monthEnd;
m_clientPlanExecuteList.DeleteAllItems();
monthBegin=atoi(m_monthBegin);
monthEnd=atoi(m_monthEnd);
int j=0;
if(!(m_pClientSalePlanRecordset->adoEOF))
{
m_clientPlanExecuteList.InsertItem(j,(LPCTSTR)(_bstr_t)(m_pClientSalePlanRecordset->GetCollect("clientID")));
m_clientPlanExecuteList.SetItemText(j,1,(LPCTSTR)(_bstr_t)(m_pClientSalePlanRecordset->GetCollect("company")));
while(!(m_pClientSalePlanRecordset->adoEOF))
{
_variant_t index;
for(int i=monthBegin;i<monthEnd;i++)
{
index=(long)(i*2+4-2);
totalPlan=totalPlan+atof((_bstr_t)m_pClientSalePlanRecordset->GetCollect(index));
index=(long)(i*2+4-1);
totalRatio=totalRatio+atof((_bstr_t)m_pClientSalePlanRecordset->GetCollect(index));
}
m_pClientSalePlanRecordset->MoveNext();
}
CString str;
str.Format("%f",totalPlan);
m_clientPlanExecuteList.SetItemText(j,2,(LPCTSTR)str);
str.Format("%f",totalRatio);
m_clientPlanExecuteList.SetItemText(j,3,(LPCTSTR)str);
}
}
}
m_pClientSalePlanRecordset->Close();
strSQL="select * from saleAllView where clientName='";
strSQL=strSQL+m_clientID+"'";
strSQL=strSQL+" and formDate>='";
strSQL=strSQL+m_year+"-";
strSQL=strSQL+m_monthBegin+"-1' and formDate<='";
strSQL=strSQL+m_year+"-";
strSQL=strSQL+m_monthEnd+"-1'";
_RecordsetPtr m_pConsignmentFormCommidityRecordset;
float total;
total=0;
hTRes = m_pConsignmentFormCommidityRecordset.CreateInstance(_T("ADODB.Recordset"));
if (SUCCEEDED(hTRes))
{
hTRes = m_pConsignmentFormCommidityRecordset->Open((LPTSTR)strSQL.GetBuffer(130),
((CSaleApp*)AfxGetApp())->m_pConn.GetInterfacePtr(),
adOpenDynamic,adLockPessimistic,adCmdText);
if(SUCCEEDED(hTRes))
{
TRACE(_T("連接成功!\n"));
if(!(m_pConsignmentFormCommidityRecordset->adoEOF))
{
while(!(m_pConsignmentFormCommidityRecordset->adoEOF))
{
total=total+(atoi(_bstr_t(m_pConsignmentFormCommidityRecordset->GetCollect("num"))))*
(atof((_bstr_t)(m_pConsignmentFormCommidityRecordset->GetCollect("price"))));
m_pConsignmentFormCommidityRecordset->MoveNext();
}
}
CString str;
str.Format("%f",total);
m_clientPlanExecuteList.SetItemText(0,4,(LPCTSTR)str);
str.Format("%f",total-totalPlan);
m_clientPlanExecuteList.SetItemText(0,5,(LPCTSTR)str);
str.Format("%f",total-totalRatio);
m_clientPlanExecuteList.SetItemText(0,6,(LPCTSTR)str);
str.Format("%f",(total-totalPlan)/totalPlan);
m_clientPlanExecuteList.SetItemText(0,7,(LPCTSTR)str);
str.Format("%f",(total-totalRatio)/totalRatio);
m_clientPlanExecuteList.SetItemText(0,8,(LPCTSTR)str);
}
}
UpdateData(false);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -