// DlgServicesStatistics.cpp : 实现文件 // #include "stdafx.h" #include "YLGL.h" #include "DlgServicesStatistics.h" #define SQL_QUERY _T("") // CDlgServicesStatistics 对话框 IMPLEMENT_DYNAMIC(CDlgServicesStatistics, CDialog) CDlgServicesStatistics::CDlgServicesStatistics(CWnd* pParent /*=NULL*/) : CDialog(CDlgServicesStatistics::IDD, pParent) { } CDlgServicesStatistics::~CDlgServicesStatistics() { } void CDlgServicesStatistics::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); DDX_Control(pDX, IDC_LIST1, m_list); DDX_Control(pDX, DTPICKER_BEGIN, m_dt_begin); DDX_Control(pDX, DTPICKER_END, m_dt_end); } BEGIN_MESSAGE_MAP(CDlgServicesStatistics, CDialog) ON_WM_SYSCOMMAND() ON_WM_CTLCOLOR() ON_NOTIFY(DTN_DATETIMECHANGE, DTPICKER_BEGIN, &CDlgServicesStatistics::OnDtnDatetimechangeBegin) ON_NOTIFY(DTN_DATETIMECHANGE, DTPICKER_END, &CDlgServicesStatistics::OnDtnDatetimechangeEnd) END_MESSAGE_MAP() // CDlgServicesStatistics 消息处理程序 BOOL CDlgServicesStatistics::OnInitDialog() { CDialog::OnInitDialog(); CenterWindow(); // 生成list列头; m_list.SetHeadings( _T("技术员,100"), _T("远程总数,100"), _T("非常满意,100"), _T("满意,100"), _T("一般,100"), _T("不满意,100"), NULL ); // 设置查询的开始时间; CTimeSpan tSpan(365, 0, 0, 0); CTime tBegin = CTime::GetCurrentTime() - tSpan; m_dt_begin.SetTime(&tBegin); UpdateData(); GetServiceStatisticsByServiceResult(); FillList(); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE } void CDlgServicesStatistics::OnOK() { // TODO: 在此添加专用代码和/或调用基类 CDialog::OnOK(); } void CDlgServicesStatistics::OnSysCommand(UINT nID, LPARAM lParam) { // TODO: 在此添加消息处理程序代码和/或调用默认值 if (nID == SC_MOVE || nID == 0xF012) return; CDialog::OnSysCommand(nID, lParam); } HBRUSH CDlgServicesStatistics::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: 在此更改 DC 的任何属性 switch(nCtlColor) { case CTLCOLOR_DLG: { return CreateSolidBrush(g_clr_dlg); } break; case CTLCOLOR_BTN: break; case CTLCOLOR_STATIC: { pDC->SetBkMode(TRANSPARENT); return CreateSolidBrush(g_clr_dlg); } break; } // TODO: 如果默认的不是所需画笔,则返回另一个画笔 return hbr; } void CDlgServicesStatistics::GetQueryPoint() { g_sendhead.bsql = FALSE; g_sendhead.code[0] = 200; g_sendhead.code[1] = 201; g_sendhead.tabcount = 2; g_pMainWnd->ProcessChatMessageRequest2(3); if ( g_bSendOK == 0 ) { return; } DataToArray(&m_AryCheckContent, &m_AryServiceResult); } void CDlgServicesStatistics::GetServiceStatisticsByServiceResult() { // 查询时间; CTime tBegin; CTime tEnd; m_dt_begin.GetTime(tBegin); m_dt_end.GetTime(tEnd); // 生成查询语句; CString strSQL = _T(""); strSQL.Format(_T(" [date] >= '%s' and [date] <= '%s'"), tBegin.Format(_T("%Y-%m-%d")), tEnd.Format(_T("%Y-%m-%d"))); g_sendhead.bsql = FALSE; g_sendhead.code[0] = 239; g_sendhead.tabcount = 1; g_pMainWnd->ProcessChatMessageRequest2(strSQL); if ( g_bSendOK == FALSE) return; DataToArray(&m_AryServiceStatistic); } void CDlgServicesStatistics::FillList() { int nIndex = 0; // 相当于订单数; DWORD dwRemoteCount = 0; // 远程总数; DWORD dwVeryGodd = 0; // 非常满意总数; DWORD dwGodd = 0; // 欠款总数; DWORD dwGeneral = 0; // 一般总数; DWORD dwDispleasure = 0; // 不满意总数; m_list.m_AryList.RemoveAll(); m_list.DeleteAllItems(); m_list.m_AryList.SetSize(m_AryServiceStatistic.GetSize()+1, 1); for ( int i = 0; i < m_AryServiceStatistic.GetSize(); i++ ) { m_list.m_AryList.ElementAt(nIndex).RemoveAll(); m_list.m_AryList.ElementAt(nIndex).Copy(m_AryServiceStatistic.ElementAt(i)); dwRemoteCount += _tstol(m_AryServiceStatistic.ElementAt(i).ElementAt(1)); dwVeryGodd += _tstol(m_AryServiceStatistic.ElementAt(i).ElementAt(2)); dwGodd += _tstol(m_AryServiceStatistic.ElementAt(i).ElementAt(3)); dwGeneral += _tstol(m_AryServiceStatistic.ElementAt(i).ElementAt(4)); dwDispleasure += _tstol(m_AryServiceStatistic.ElementAt(i).ElementAt(5)); nIndex++; } CString str; m_list.m_AryList.ElementAt(nIndex).RemoveAll(); m_list.m_AryList.ElementAt(nIndex).Add(_T("统计结果")); str.Format(_T("%ld"), dwRemoteCount); m_list.m_AryList.ElementAt(nIndex).Add(str); str.Format(_T("%ld"), dwVeryGodd); m_list.m_AryList.ElementAt(nIndex).Add(str); str.Format(_T("%ld"), dwGodd); m_list.m_AryList.ElementAt(nIndex).Add(str); str.Format(_T("%ld"), dwGeneral); m_list.m_AryList.ElementAt(nIndex).Add(str); str.Format(_T("%ld"), dwDispleasure); m_list.m_AryList.ElementAt(nIndex).Add(str); nIndex++; m_list.m_AryList.FreeExtra(); m_list.SetItemCountEx(nIndex); } void CDlgServicesStatistics::OnDtnDatetimechangeBegin(NMHDR *pNMHDR, LRESULT *pResult) { LPNMDATETIMECHANGE pDTChange = reinterpret_cast(pNMHDR); GetServiceStatisticsByServiceResult(); FillList(); *pResult = 0; } void CDlgServicesStatistics::OnDtnDatetimechangeEnd(NMHDR *pNMHDR, LRESULT *pResult) { LPNMDATETIMECHANGE pDTChange = reinterpret_cast(pNMHDR); GetServiceStatisticsByServiceResult(); FillList(); *pResult = 0; }