SmsManager/DLG_YWY_Analyse.cpp
2025-01-14 10:46:18 +08:00

655 lines
41 KiB
C++
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// DLG_YWY_Analyse.cpp: 实现文件
//
#include "stdafx.h"
#include "SmsManager.h"
#include "DLG_YWY_Analyse.h"
#include "afxdialogex.h"
#include "MainFrm.h"
// DLG_YWY_Analyse 对话框
IMPLEMENT_DYNAMIC(DLG_YWY_Analyse, CDialogEx)
DLG_YWY_Analyse::DLG_YWY_Analyse(CWnd* pParent /*=nullptr*/)
: CDialogEx(IDD_YWY_ANALYSE, pParent)
, m_bShowValue(FALSE)
{
m_tBegin = COleDateTime::GetCurrentTime()-COleDateTimeSpan(60,0,0,0);
m_tEnd = COleDateTime::GetCurrentTime();
m_lAbility = 0;
m_lDataType = 0;
m_lGap = 0;
m_lGraph = 0;
m_lQueryAll = 0;
m_lYWYID = 0;
m_lType = 0; //0企业1代理商
m_lItem = 0;
m_strName=_T("");
m_pMainFrame = NULL;
m_pAnalyse = NULL;
m_pSmsData = NULL;
}
DLG_YWY_Analyse::~DLG_YWY_Analyse()
{
CloseData();
}
void DLG_YWY_Analyse::CloseData()
{
if (m_pAnalyse)
{
delete m_pAnalyse;
m_pAnalyse = NULL;
}
if (m_pSmsData)
{
delete m_pSmsData;
m_pSmsData = NULL;
}
}
void DLG_YWY_Analyse::SetParam(CMainFrame * pFrame, long lYWYID, long lType, long lItem, CString strName)
{
m_lYWYID = lYWYID;
m_lType = lType; //0企业1代理商
m_lItem = lItem;
m_strName2 = strName;
m_strName = strName;
m_pMainFrame = pFrame;
}
void DLG_YWY_Analyse::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_CORP_ANALYSE_CHART, m_Chart);
DDX_DateTimeCtrl(pDX, IDC_CORP_ANALYSE_TBEGIN, m_tBegin);
DDX_DateTimeCtrl(pDX, IDC_CORP_ANALYSE_TEND, m_tEnd);
DDX_CBIndex(pDX, IDC_CORP_ANALYSE_SMSTYPE, m_lAbility);
DDX_CBIndex(pDX, IDC_CORP_ANALYSE_DATATYPE, m_lDataType);
DDX_CBIndex(pDX, IDC_CORP_ANALYSE_GAP, m_lGap);
DDX_CBIndex(pDX, IDC_CORP_ANALYSE_GRAPH, m_lGraph);
DDX_CBIndex(pDX, IDC_CORP_ANALYSE_QUERYALL, m_lQueryAll);
DDX_Control(pDX, IDC_CORP_ANALYSE_QUERYALL, m_L_QueryAll);
DDX_Control(pDX, IDC_CORP_ANALYSE_SHOWVALUE, m_B_ShowValue);
DDX_Check(pDX, IDC_CORP_ANALYSE_SHOWVALUE, m_bShowValue);
}
BEGIN_MESSAGE_MAP(DLG_YWY_Analyse, CDialogEx)
ON_BN_CLICKED(IDC_C_PAY_QUERY, &DLG_YWY_Analyse::OnBnClickedCPayQuery)
ON_WM_SIZE()
ON_CBN_SELCHANGE(IDC_CORP_ANALYSE_GRAPH, &DLG_YWY_Analyse::OnCbnSelchangeCorpAnalyseGraph)
ON_CBN_SELCHANGE(IDC_CORP_ANALYSE_DATATYPE, &DLG_YWY_Analyse::OnCbnSelchangeCorpAnalyseDatatype)
ON_BN_CLICKED(IDC_CORP_ANALYSE_SHOWVALUE, &DLG_YWY_Analyse::OnClickedCorpAnalyseShowvalue)
END_MESSAGE_MAP()
// DLG_YWY_Analyse 消息处理程序
void DLG_YWY_Analyse::OnBnClickedCPayQuery()
{
UpdateData(true);
if (m_tEnd < m_tBegin)
{
MessageBox(_T("查询结束日期不能小于起始日期,请改正!"), _T("错误"), MB_ICONWARNING);
GetDlgItem(IDC_CORP_ANALYSE_TBEGIN)->SetFocus();
return;
}
REQ_YWY_Analyse * pAnalyse = new REQ_YWY_Analyse; memset(pAnalyse, 0, sizeof(REQ_YWY_Analyse));
m_tBegin.GetAsSystemTime(pAnalyse->tBegin); //起始时间
m_tEnd.GetAsSystemTime(pAnalyse->tEnd); //结束时间
pAnalyse->lItem = m_lItem; //列表记录位置
pAnalyse->lYWYID = m_lYWYID; //业务员
if (m_lQueryAll > 0) //选择了其它内容
{
switch (m_lQueryAll)
{
case 1: //查询所有
pAnalyse->lYWYID = -1;
break;
}
}
_tcscpy(pAnalyse->szName, m_strName); //企业名称或代理商名称
pAnalyse->lAbility = m_lAbility; //能力0-短信1-彩信
pAnalyse->lGap = m_lGap+1; //间隔0-日1-月2-年
pAnalyse->lDataType = m_lDataType; //数据类型0-充值金额1-短信量2-金额+短信量
pAnalyse->lAbility = m_lAbility;
//pAnalyse->lCorpID = -3;
m_pMainFrame->SendFrame(SMSFUNC_YWY_ANALYSE, (BYTE*)pAnalyse, sizeof(REQ_YWY_Analyse));
}
BOOL DLG_YWY_Analyse::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: 在此添加额外的初始化
if (m_pMainFrame->GetUserPurview(PURVIEW_MANAGER_ADD, false))
{
GetDlgItem(IDC_CORP_ANALYSE_QUERYALL)->ShowWindow(true);
}
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void DLG_YWY_Analyse::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
if (m_Chart.GetSafeHwnd())
{
m_Chart.MoveWindow(12, 150, cx - 12 - 12, cy - 150 - 12);
/*
RECT rect,rect2;
m_Chart.GetWindowRect(&rect);
m_Chart.GetClientRect(&rect2);
RECT rect3, rect4;
this->GetWindowRect(&rect3);
this->GetClientRect(&rect4);
m_Chart.MoveWindow((rect3.left - rect.left), (rect3.top - rect.top), cx-(rect3.right-rect.right), cy-(rect3.bottom - rect.bottom));
int b = 10;
*/
}
}
BOOL DLG_YWY_Analyse::ProcessSocket(Socket_Head_Add *pHead, BYTE *pFrame)
{
//查看支付记录
if (pHead->lFuncType == SMSFUNC_YWY_ANALYSE )
{
ANS_YWY_Analyse * pAnalyse = (ANS_YWY_Analyse *)pFrame;
ANS_YWY_Analyse_Data * pSmsData = (ANS_YWY_Analyse_Data *)(pFrame + sizeof(ANS_YWY_Analyse));
if (!pAnalyse->bOK) //权限不足,返回错误
{
//没数据返回,清空统计图
return true;
}
CloseData();
m_pAnalyse = new ANS_YWY_Analyse;
*m_pAnalyse = *pAnalyse;
if (m_pAnalyse->lCount > 0)
{
m_pSmsData = new ANS_YWY_Analyse_Data[m_pAnalyse->lCount];
memcpy((BYTE*)m_pSmsData, (BYTE*)pSmsData, sizeof(ANS_YWY_Analyse_Data)*m_pAnalyse->lCount);
}
ReDrawGraph();
}
return false;
}
void DLG_YWY_Analyse::ReDrawGraph()
{
if (m_lGraph == 0)
{
m_Chart.put_chartType(1 | 0); //2D柱状图
}
if (m_lGraph == 1)
{
m_Chart.put_chartType(1 | 2); //2D线条型
}
GetDlgItem(IDC_CORP_ANALYSE_SHOWDATE)->SetWindowText(_T(""));
CString strTitle;
m_Chart.put_Stacking(FALSE); //设置栈模式
m_Chart.put_ColumnCount(1); //清空数据
m_Chart.put_RowCount(1); //清空数据
if (m_lQueryAll > 0)
m_strName = _T("所有客户经理");
else
m_strName = m_strName2;
switch (m_lDataType)
{
case 0:
default:
m_Chart.put_ShowLegend(FALSE);
m_Chart.put_ColumnCount(1); //设置列数
m_Chart.put_Column(1);
m_Chart.put_ColumnLabel(_T("业绩金额"));
strTitle.Format(_T("%s 业绩金额对比图"), m_strName);
break;
case 1:
m_Chart.put_ShowLegend(FALSE);
m_Chart.put_ColumnCount(1); //设置列数
m_Chart.put_Column(1);
m_Chart.put_ColumnLabel(_T("收入金额"));
strTitle.Format(_T("%s 收入金额对比图"), m_strName);
break;
case 2:
m_Chart.put_ShowLegend(FALSE);
m_Chart.put_ColumnCount(1); //设置列数
m_Chart.put_Column(1);
m_Chart.put_ColumnLabel(_T("提成金额"));
strTitle.Format(_T("%s 提成金额对比图"), m_strName);
break;
case 3:
m_Chart.put_ShowLegend(FALSE);
m_Chart.put_ColumnCount(1); //设置列数
m_Chart.put_Column(1);
m_Chart.put_ColumnLabel(_T("工资金额"));
strTitle.Format(_T("%s 工资金额对比图"), m_strName);
break;
case 4:
m_Chart.put_ShowLegend(FALSE);
m_Chart.put_ColumnCount(1); //设置列数
m_Chart.put_Column(1);
m_Chart.put_ColumnLabel(_T("新增客户"));
strTitle.Format(_T("%s 新增客户对比图"), m_strName);
break;
case 5:
m_Chart.put_ShowLegend(FALSE);
m_Chart.put_ColumnCount(1); //设置列数
m_Chart.put_Column(1);
m_Chart.put_ColumnLabel(_T("流失客户"));
strTitle.Format(_T("%s 流失客户对比图"), m_strName);
break;
case 6:
m_Chart.put_ShowLegend(FALSE);
m_Chart.put_ColumnCount(1); //设置列数
m_Chart.put_Column(1);
m_Chart.put_ColumnLabel(_T("工资/业绩比"));
strTitle.Format(_T("%s 工资/业绩比对比图"), m_strName);
break;
case 7:
m_Chart.put_ShowLegend(TRUE);
m_Chart.put_ColumnCount(2); //设置列数
m_Chart.put_Column(1);
m_Chart.put_ColumnLabel(_T("业绩金额"));
m_Chart.put_Column(2);
m_Chart.put_ColumnLabel(_T("工资金额"));
strTitle.Format(_T("%s 业绩金额+工资金额对比图"), m_strName);
break;
}
m_Chart.put_TitleText(strTitle);
if (!m_pAnalyse) //没有数据,不画图
return;
VARIANT var;
//((CVcFill)((CVcBackdrop)m_Chart.get_Backdrop()).get_Fill()).put_Style(1);
//((CVcColor)((CVcBrush)((CVcFill)((CVcBackdrop)m_Chart.get_Backdrop()).get_Fill()).get_Brush()).get_FillColor()).Set(255, 255, 255);
//((CVcValueScale)((CVcAxis)((CVcPlot)m_Chart.get_Plot()).get_Axis(0, var)).get_ValueScale()).put_Auto(false);//不自动标注Y轴刻度
//((CVcValueScale)((CVcAxis)((CVcPlot)m_Chart.get_Plot()).get_Axis(0, var)).get_ValueScale()).put_Maximum(1000);// Y轴最大刻度
//((CVcValueScale)((CVcAxis)((CVcPlot)m_Chart.get_Plot()).get_Axis(0, var)).get_ValueScale()).put_Minimum(0);// Y轴最小刻度
//((CVcValueScale)((CVcAxis)((CVcPlot)m_Chart.get_Plot()).get_Axis(0, var)).get_ValueScale()).put_MajorDivision(0);//Y轴刻度5等分
//((CVcValueScale)((CVcAxis)((CVcPlot)m_Chart.get_Plot()).get_Axis(0, var)).get_ValueScale()).put_MinorDivision(0);//每刻度一个刻度线
//((CVcAxisTitle)((CVcAxis)((CVcPlot)m_Chart.get_Plot()).get_Axis(0, var)).get_AxisTitle()).put_Text(_T("短信量")); //Y轴名称
//不要与x轴垂直的表格线
((CVcPen)((CVcAxisGrid)((CVcAxis)((CVcPlot)m_Chart.get_Plot()).get_Axis(0, var)).get_AxisGrid()).get_MajorPen()).put_Style(0);
//((CVcPen)((CVcAxisGrid)((CVcAxis)((CVcPlot)m_Chart.get_Plot()).get_Axis(1, var)).get_AxisGrid()).get_MajorPen()).put_Style(0);
//隐藏第二y轴即右边的y轴
((CVcAxisScale)((CVcAxis)((CVcPlot)m_Chart.get_Plot()).get_Axis(2, var)).get_AxisScale()).put_Hide(TRUE);
//设置x轴及y轴的标题。xTitle和yTitle为CString型
//m_Chart.GetPlot().GetAxis(0, var).GetAxisTitle().SetText(xTitle); //x轴
//m_Chart.GetPlot().GetAxis(1, var).GetAxisTitle().SetText(yTitle); //y轴
//m_Chart.put_RowCount(iRow);//设置曲线点数(画曲线一定要设置)
//((CVcColor)((CVcPen)((CVcSeries)((CVcSeriesCollection)((CVcPlot)m_Chart.get_Plot()).get_SeriesCollection()).get_Item(1)).get_Pen()).get_VtColor()).Set(0, 0, 255);
// 线宽(对点线图有效)
//((CVcPen)((CVcSeries)((CVcSeriesCollection)((CVcPlot)m_Chart.get_Plot()).get_SeriesCollection()).get_Item(1)).get_Pen()).put_Width(50);
//m_Chart.GetPlot().GetSeriesCollection().GetItem(1).GetPen().SetWidth(50);
//m_Chart.GetPlot().GetSeriesCollection().GetItem(2).GetPen().SetWidth(100);
//m_Chart.GetPlot().GetSeriesCollection().GetItem(3).GetPen().SetWidth(2);
// 数据点类型显示数据值的模式(对柱柱状图和点线图有效)
// 0: 不显示 1: 显示在柱状图外
// 2: 显示在柱状图内上方 3: 显示在柱状图内中间 4: 显示在柱状图内下方
long lShowType = 0;
if (m_B_ShowValue.GetCheck())
lShowType = 1;
((CVcDataPointLabel)((CVcDataPoint)((CVcDataPoints)((CVcSeries)((CVcSeriesCollection)((CVcPlot)m_Chart.get_Plot()).get_SeriesCollection()).get_Item(1)).get_DataPoints()).get_Item(-1)).get_DataPointLabel()).put_LocationType(lShowType);
((CVcDataPointLabel)((CVcDataPoint)((CVcDataPoints)((CVcSeries)((CVcSeriesCollection)((CVcPlot)m_Chart.get_Plot()).get_SeriesCollection()).get_Item(1)).get_DataPoints()).get_Item(-1)).get_DataPointLabel()).put_ValueFormat(_T("0,0"));
if (m_Chart.get_ColumnCount() >= 2)
{
((CVcDataPointLabel)((CVcDataPoint)((CVcDataPoints)((CVcSeries)((CVcSeriesCollection)((CVcPlot)m_Chart.get_Plot()).get_SeriesCollection()).get_Item(2)).get_DataPoints()).get_Item(-1)).get_DataPointLabel()).put_LocationType(lShowType);
((CVcDataPointLabel)((CVcDataPoint)((CVcDataPoints)((CVcSeries)((CVcSeriesCollection)((CVcPlot)m_Chart.get_Plot()).get_SeriesCollection()).get_Item(2)).get_DataPoints()).get_Item(-1)).get_DataPointLabel()).put_ValueFormat(_T("0,0"));
}
//图形上数值的显示设置
//MSChart1.Plot.SeriesCollection(AIndex).DataPoints(-1).DataPointLabel.Component = 2 '1 普通数值 2 百分比
//MSChart1.Plot.SeriesCollection(AIndex).DataPoints(-1).DataPointLabel.PercentFormat = "0%" '百分比显示格式
//普通数值显示格式 为空时将以科学计数法显示 为0时按实际显示
//MSChart1.Plot.SeriesCollection(AIndex).DataPoints(-1).DataPointLabel.ValueFormat = "0"
int nRowCount = 1;
switch (m_pAnalyse->lGap)
{
case 0: //日
default:
nRowCount = (m_tEnd - m_tBegin).GetTotalDays()+1;
break;
case 1: //月
{
long lYear = m_tEnd.GetYear() - m_tBegin.GetYear();
long lMon = m_tEnd.GetMonth() - m_tBegin.GetMonth()+1;
if (lMon <= 0)
{
lMon = 12 + lMon;
lYear = lYear - 1;
}
nRowCount = lYear * 12 + lMon;
}
break;
case 2: //年
nRowCount = m_tEnd.GetYear() - m_tBegin.GetYear()+1;
break;
case 3: //半年
nRowCount = (m_tEnd.GetYear() - m_tBegin.GetYear() + 1)*2;
break;
case 4: //同比-上半年
case 5: //同比-下半年
case 6: //同比-1季度
case 7: //同比-2季度
case 8: //同比-3季度
case 9: //同比-4季度
case 10: //同比-1月份
case 11: //同比-2月份
case 12: //同比-3月份
case 13: //同比-4月份
case 14: //同比-5月份
case 15: //同比-6月份
case 16: //同比-7月份
case 17: //同比-8月份
case 18: //同比-9月份
case 19: //同比-10月份
case 20: //同比-11月份
case 21: //同比-12月份
nRowCount = m_tEnd.GetYear() - m_tBegin.GetYear() + 1;
break;
}
if (nRowCount < 1) nRowCount = 1;
if (nRowCount > 500) nRowCount = 500;
m_Chart.put_RowCount(nRowCount);
//VARIANT var;
//((CVcCategoryScale)((CVcAxis)((CVcPlot)m_Chart.get_Plot()).get_Axis(0, var)).get_CategoryScale()).put_Auto(FALSE);// 不自动标注X轴刻度
//((CVcCategoryScale)((CVcAxis)((CVcPlot)m_Chart.get_Plot()).get_Axis(0, var)).get_CategoryScale()).put_DivisionsPerLabel(0);//每刻度一个标注
//((CVcCategoryScale)((CVcAxis)((CVcPlot)m_Chart.get_Plot()).get_Axis(0, var)).get_CategoryScale()).put_DivisionsPerTick(0);//每刻度一个刻度线
//((CVcAxisTitle)((CVcAxis)((CVcPlot)m_Chart.get_Plot()).get_Axis(0, var)).get_AxisTitle()).put_Text(_T("日期")); // X轴名称
CString strRow;
srand((unsigned)time(NULL));
int iSmsDataIndex = 0;
COleDateTime tDrawDate = m_tBegin;
int iDarwYear = m_tBegin.GetYear();
int iDrawMon = m_tBegin.GetMonth();
for (int row = 1; row <= nRowCount; ++row)
{
CString strDate; //画日期
ANS_YWY_Analyse_Data smsData = { 0 };
switch (m_pAnalyse->lGap)
{
case 0: //日
default:
{
}
break;
case 1: //月
strDate.Format(_T("%04d.%02d"), iDarwYear, iDrawMon);
if (iSmsDataIndex < m_pAnalyse->lCount)
{
if (iDarwYear == m_pSmsData[iSmsDataIndex].tDate.wYear && //时间相同,取数据
iDrawMon == m_pSmsData[iSmsDataIndex].tDate.wMonth)
{
smsData = m_pSmsData[iSmsDataIndex];
iSmsDataIndex++;
}
}
iDrawMon = iDrawMon + 1; //月加1
if (iDrawMon > 12)
{
iDrawMon = 1;
iDarwYear += 1;
}
break;
case 2: //年
strDate.Format(_T("%04d年"), iDarwYear);
if (iSmsDataIndex < m_pAnalyse->lCount)
{
if (iDarwYear == m_pSmsData[iSmsDataIndex].tDate.wYear )
{
smsData = m_pSmsData[iSmsDataIndex];
iSmsDataIndex++;
}
}
iDarwYear = iDarwYear + 1; //月加1
break;
case 3: //半年
if (row % 2 == 1)
{
strDate.Format(_T("%04d年上半年"), iDarwYear);
for (int i=0; i<6 && iSmsDataIndex < m_pAnalyse->lCount; i++)
{
if (iDarwYear == m_pSmsData[iSmsDataIndex].tDate.wYear && m_pSmsData[iSmsDataIndex].tDate.wMonth<=6)
{
smsData.fYZ = smsData.fYZ + m_pSmsData[iSmsDataIndex].fYZ;
smsData.fSR = smsData.fSR + m_pSmsData[iSmsDataIndex].fSR;
smsData.fTC = smsData.fTC + m_pSmsData[iSmsDataIndex].fTC;
smsData.fGZ = smsData.fGZ + m_pSmsData[iSmsDataIndex].fGZ;
smsData.lNewKH = smsData.lNewKH + m_pSmsData[iSmsDataIndex].lNewKH;
smsData.lLSKH = smsData.lLSKH + m_pSmsData[iSmsDataIndex].lLSKH;
//smsData.fGZYZBL = smsData.fGZYZBL + m_pSmsData[iSmsDataIndex].fGZYZBL;
iSmsDataIndex++;
}
else
{
break;
}
}
}
else
{
strDate.Format(_T("%04d年下半年"), iDarwYear);
for (int i = 0; i < 6 && iSmsDataIndex < m_pAnalyse->lCount; i++)
{
if (iDarwYear == m_pSmsData[iSmsDataIndex].tDate.wYear && m_pSmsData[iSmsDataIndex].tDate.wMonth > 6)
{
smsData.fYZ = smsData.fYZ + m_pSmsData[iSmsDataIndex].fYZ;
smsData.fSR = smsData.fSR + m_pSmsData[iSmsDataIndex].fSR;
smsData.fTC = smsData.fTC + m_pSmsData[iSmsDataIndex].fTC;
smsData.fGZ = smsData.fGZ + m_pSmsData[iSmsDataIndex].fGZ;
smsData.lNewKH = smsData.lNewKH + m_pSmsData[iSmsDataIndex].lNewKH;
smsData.lLSKH = smsData.lLSKH + m_pSmsData[iSmsDataIndex].lLSKH;
iSmsDataIndex++;
}
else
{
break;
}
}
iDarwYear = iDarwYear + 1; //月加1
}
break;
case 4: //同比-上半年
case 5: //同比-下半年
case 6: //同比-1季度
case 7: //同比-2季度
case 8: //同比-3季度
case 9: //同比-4季度
case 10: //同比-1月份
case 11: //同比-2月份
case 12: //同比-3月份
case 13: //同比-4月份
case 14: //同比-5月份
case 15: //同比-6月份
case 16: //同比-7月份
case 17: //同比-8月份
case 18: //同比-9月份
case 19: //同比-10月份
case 20: //同比-11月份
case 21: //同比-12月份
if (m_pAnalyse->lGap==4) strDate.Format(_T("%04d年上半年"), iDarwYear);
if (m_pAnalyse->lGap == 5) strDate.Format(_T("%04d年下半年"), iDarwYear);
if (m_pAnalyse->lGap == 6) strDate.Format(_T("%04d年1季度"), iDarwYear);
if (m_pAnalyse->lGap == 7) strDate.Format(_T("%04d年2季度"), iDarwYear);
if (m_pAnalyse->lGap == 8) strDate.Format(_T("%04d年3季度"), iDarwYear);
if (m_pAnalyse->lGap == 9) strDate.Format(_T("%04d年4季度"), iDarwYear);
if (m_pAnalyse->lGap >= 10 && m_pAnalyse->lGap <= 21 ) strDate.Format(_T("%04d年%d月"), iDarwYear, m_pAnalyse->lGap-9);
for (int i = 0; i < 12 && iSmsDataIndex < m_pAnalyse->lCount; i++)
{
if (iDarwYear == m_pSmsData[iSmsDataIndex].tDate.wYear && m_pSmsData[iSmsDataIndex].tDate.wMonth <= 12)
{
BOOL bGetData = false;
if (m_pAnalyse->lGap == 4 && m_pSmsData[iSmsDataIndex].tDate.wMonth <= 6) //同比-上半年
bGetData = true;
if (m_pAnalyse->lGap == 5 && m_pSmsData[iSmsDataIndex].tDate.wMonth > 6 && m_pSmsData[iSmsDataIndex].tDate.wMonth<=12) //同比-下半年
bGetData = true;
if (m_pAnalyse->lGap == 6 && m_pSmsData[iSmsDataIndex].tDate.wMonth >=1 && m_pSmsData[iSmsDataIndex].tDate.wMonth <= 3) //同比-1季度
bGetData = true;
if (m_pAnalyse->lGap == 7 && m_pSmsData[iSmsDataIndex].tDate.wMonth >= 4 && m_pSmsData[iSmsDataIndex].tDate.wMonth <= 6) //同比-2季度
bGetData = true;
if (m_pAnalyse->lGap == 8 && m_pSmsData[iSmsDataIndex].tDate.wMonth >= 7 && m_pSmsData[iSmsDataIndex].tDate.wMonth <= 9) //同比-3季度
bGetData = true;
if (m_pAnalyse->lGap == 9 && m_pSmsData[iSmsDataIndex].tDate.wMonth >= 10 && m_pSmsData[iSmsDataIndex].tDate.wMonth <= 12) //同比-4季度
bGetData = true;
if (m_pAnalyse->lGap >= 10 && m_pAnalyse->lGap <= 21 && m_pSmsData[iSmsDataIndex].tDate.wMonth == m_pAnalyse->lGap - 9) //同比-月份
bGetData = true;
if (bGetData)
{
smsData.fYZ = smsData.fYZ + m_pSmsData[iSmsDataIndex].fYZ;
smsData.fSR = smsData.fSR + m_pSmsData[iSmsDataIndex].fSR;
smsData.fTC = smsData.fTC + m_pSmsData[iSmsDataIndex].fTC;
smsData.fGZ = smsData.fGZ + m_pSmsData[iSmsDataIndex].fGZ;
smsData.lNewKH = smsData.lNewKH + m_pSmsData[iSmsDataIndex].lNewKH;
smsData.lLSKH = smsData.lLSKH + m_pSmsData[iSmsDataIndex].lLSKH;
//smsData.fGZYZBL = smsData.fGZYZBL + m_pSmsData[iSmsDataIndex].fGZYZBL;
}
iSmsDataIndex++;
}
else
{
break;
}
}
iDarwYear = iDarwYear + 1; //月加1
break;
}
m_Chart.put_Row(row);
m_Chart.put_RowLabel(strDate);
switch (m_lDataType)
{
case 0: //业绩
default:
((CVcDataGrid)m_Chart.get_DataGrid()).SetData(row, 1, smsData.fYZ, 0); //业绩
break;
case 1: //收入
((CVcDataGrid)m_Chart.get_DataGrid()).SetData(row, 1, smsData.fSR, 0); //收入
break;
case 2: //提成
((CVcDataGrid)m_Chart.get_DataGrid()).SetData(row, 1, smsData.fTC, 0); //提成
break;
case 3: //工资
((CVcDataGrid)m_Chart.get_DataGrid()).SetData(row, 1, smsData.fGZ, 0); //工资
break;
case 4: //新增客户
((CVcDataGrid)m_Chart.get_DataGrid()).SetData(row, 1, smsData.lNewKH, 0); //新增客户
break;
case 5: //流失客户
((CVcDataGrid)m_Chart.get_DataGrid()).SetData(row, 1, smsData.lLSKH, 0); //流失客户
break;
case 6: //工资/业绩比
((CVcDataGrid)m_Chart.get_DataGrid()).SetData(row, 1, smsData.fGZYZBL*10, 0); //工资/业绩比
break;
case 7: //业绩 + 工资
((CVcDataGrid)m_Chart.get_DataGrid()).SetData(row, 1, smsData.fYZ/10.0f, 0); //业绩
((CVcDataGrid)m_Chart.get_DataGrid()).SetData(row, 2, smsData.fGZ, 0); //工资
break;
}
}
m_Chart.Refresh();
}BEGIN_EVENTSINK_MAP(DLG_YWY_Analyse, CDialogEx)
ON_EVENT(DLG_YWY_Analyse, IDC_CORP_ANALYSE_CHART, 9, DLG_YWY_Analyse::PointSelectedCorpAnalyseChart, VTS_PI2 VTS_PI2 VTS_PI2 VTS_PI2)
END_EVENTSINK_MAP()
void DLG_YWY_Analyse::PointSelectedCorpAnalyseChart(short* Series, short* DataPoint, short* MouseFlags, short* Cancel)
{
CString strOut;
long lCol = *Series;
long lRow = *DataPoint;
double dData=0;
short sr = 0;
((CVcDataGrid)m_Chart.get_DataGrid()).GetData(lRow, lCol, &dData, &sr);
CString strRowLable = ((CVcDataGrid)m_Chart.get_DataGrid()).get_RowLabel(lRow, 1);
CString strColLable = ((CVcDataGrid)m_Chart.get_DataGrid()).get_ColumnLabel(lCol, 1);
long sData = (long)dData;
strOut.Format(_T("数据:%s,%s : %d"), strRowLable, strColLable, sData);
//AfxMessageBox(strOut);
GetDlgItem(IDC_CORP_ANALYSE_SHOWDATE)->SetWindowText(strOut);
}
void DLG_YWY_Analyse::OnCbnSelchangeCorpAnalyseGraph()
{
UpdateData(true);
ReDrawGraph();
}
void DLG_YWY_Analyse::OnCbnSelchangeCorpAnalyseDatatype()
{
UpdateData(true);
ReDrawGraph();
}
void DLG_YWY_Analyse::OnClickedCorpAnalyseShowvalue()
{
ReDrawGraph();
}