123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579 |
- // Satisfaction.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ylgl.h"
- #include "Satisfaction.h"
- #include "MyMdi.H"
- #include "SelBrunDevice.h"
- #include "SatisfactionSurvey.h"
- #include "SatisfactionCfg.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- SatisfactionSurvey* g_Surveydlg = NULL;
- IMPLEMENT_DYNCREATE(Satisfaction, MyFormView)
- Satisfaction::Satisfaction() : MyFormView(Satisfaction::IDD)
- , m_nCurSelIdx(-1)
- , m_strStartTimer(_T(""))
- , m_strEndTimer(_T(""))
- , m_nShowType(0)
- {
- memset(m_szColName, 0, sizeof(TCHAR)*64);
- }
- Satisfaction::~Satisfaction()
- {
- if(g_Surveydlg)
- g_Surveydlg->SendMessage(WM_CLOSE);
- g_Surveydlg = NULL;
- }
- void Satisfaction::DoDataExchange(CDataExchange* pDX)
- {
- MyFormView::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_LIST2, m_List1);
- }
- BEGIN_MESSAGE_MAP(Satisfaction, MyFormView)
- ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
- ON_BN_CLICKED(IDC_OpenSurvey_Btn, OnOpenSurveyBtn)
- ON_BN_CLICKED(IDC_OrderToday_Btn, OnOrderTodayBtn)
- ON_BN_CLICKED(IDC_Configuration_Btn, OnConfigurationBtn)
- ON_BN_CLICKED(IDC_TodayPhotograph_Btn, OnTodayPhotographBtn)
- ON_BN_CLICKED(IDC_ChoosePhotos_Btn, OnChoosePhotosBtn)
- ON_BN_CLICKED(IDC_LookSample_Btn, OnLookSampleBtn)
- ON_BN_CLICKED(IDC_CollectToday_Btn, OnCollectTodayBtn)
- ON_BN_CLICKED(IDC_WeddingToday_Btn, OnWeddingTodayBtn)
- ON_BN_CLICKED(IDC_SetSurveyItem_Btn, OnSetSurveyCfg)
- END_MESSAGE_MAP()
- #ifdef _DEBUG
- void Satisfaction::AssertValid() const
- {
- MyFormView::AssertValid();
- }
- void Satisfaction::Dump(CDumpContext& dc) const
- {
- MyFormView::Dump(dc);
- }
- #endif
- void Satisfaction::OnInitialUpdate()
- {
- MyFormView::OnInitialUpdate();
- CMyMdi Mdi;
- Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
- if(IsHasRights2new(19)==0)
- GetDlgItem(IDC_SetSurveyItem_Btn)->EnableWindow(0);
- CRect rc2;
- GetWindowRect(rc2);
- ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
- EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
- #ifdef CHILD_VERSION
- // 16 column
- m_List1.SetHeadings("订单号,120;家长姓名,120;宝宝姓名,120;手机,120;固定电话,120;订单日期,120;门市,120;满意度,120;拨打情况,120;回访日期,120;通话时长,120;回访人员,120;备注,120");
- #else
- // 16 column
- m_List1.SetHeadings("订单号,120;男宾姓名,120;女宾姓名,120;男宾电话,120;女宾电话,120;订单日期,120;门市,120;满意度,120;拨打情况,120;回访日期,120;通话时长,120;回访人员,120;备注,120");
- #endif
- m_List1.LoadColumnInfo(250);
- ScreenToClient(rc2);
- rc2.bottom += 200;
- GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
- GetData();
- }
- //------------------------------------------------
- /*
- 函数名: FillGrid
- 描述: 填表
- 参数:
- const int nTimeType 按时间类型显示数据
- 返回值:
- */
- //------------------------------------------------
- void Satisfaction::FillGrid(const int nTimeType)
- {
- //获取时间
- CTime startTime, endTime;
- ((CDateTimeCtrl*)GetDlgItem(IDC_Date_Start))->GetTime(startTime);
- ((CDateTimeCtrl*)GetDlgItem(IDC_Date_End))->GetTime(endTime);
- m_List1.DeleteAllItems2();
- int nCount = 0;
- int nSize = m_List1array.GetSize();
- m_List1.m_arLabels.SetSize(nSize, 1);
- int i=0;
- for(i=0; i<m_List1array.GetSize(); i++)
- {
- CString strtmp = _T(""); //时间日期
- int nY(0), nM(0), nD(0);
- int nObjIdx = 0; //对象索引
- switch(nTimeType)
- {
- case 0:
- case 1:
- case 6:
- strtmp = m_List1array.ElementAt(i).ElementAt(5); //订单
- nObjIdx = 25; //接单
- break;
- case 2:
- strtmp = m_List1array.ElementAt(i).ElementAt(6);
- nObjIdx = 15; //摄影
- break;
- case 3:
- strtmp = m_List1array.ElementAt(i).ElementAt(8);
- nObjIdx = 19; //选片
- break;
- case 4:
- strtmp = m_List1array.ElementAt(i).ElementAt(10);
- nObjIdx = 29; //看样/看设计
- break;
- case 5:
- strtmp = m_List1array.ElementAt(i).ElementAt(11);
- nObjIdx = 17; //化妆
- break;
- }
- if(strtmp == _T(""))
- continue;
- nY = _ttoi(strtmp.Mid(0,4));
- nM = _ttoi(strtmp.Mid(5,2));
- nD = _ttoi(strtmp.Mid(8,2));
-
- if(nY <= 0 || (nM <= 0 || nM > 12) || (nD > 31 || nD <=0))
- continue;
-
- CString strDinDanTime = _T("");
- CTime tm(nY, nM, nD, 0, 0, 0);
- /*
- if(tm >= startTime && tm <= endTime)
- {
- */
- CString strOrderNum = m_List1array.ElementAt(i).ElementAt(0);
- m_List1.m_arLabels.ElementAt(nCount).Add(strOrderNum); //订单号
- m_List1.m_arLabels.ElementAt(nCount).Add(m_List1array.ElementAt(i).ElementAt(1)); //家长姓名/男宾姓名
- m_List1.m_arLabels.ElementAt(nCount).Add(m_List1array.ElementAt(i).ElementAt(2)); //宝宝姓名/女宾姓名
- m_List1.m_arLabels.ElementAt(nCount).Add(m_List1array.ElementAt(i).ElementAt(3)); //手机/男宾电话
- m_List1.m_arLabels.ElementAt(nCount).Add(m_List1array.ElementAt(i).ElementAt(4)); //固定电话/女宾电话
- strtmp = m_List1array.ElementAt(nCount).ElementAt(0);
- nY = atoi(strtmp.Mid(0,4));
- nM = atoi(strtmp.Mid(4,2));
- nD = atoi(strtmp.Mid(6,2));
- strDinDanTime.Format(_T("%04d-%02d-%02d"), nY, nM, nD);
- m_List1.m_arLabels.ElementAt(nCount).Add(strDinDanTime); //订单时间
- CString strObjName = m_List1array.ElementAt(i).ElementAt(nObjIdx);
- m_List1.m_arLabels.ElementAt(nCount).Add(strObjName); //访问对象
- //获取满意度
- CString strScore = _T("");
- GetScoreAndSurveyObj(strObjName, strOrderNum, strScore);
- m_List1.m_arLabels.ElementAt(nCount).Add(strScore); //满意度
- m_List1.m_arLabels.ElementAt(nCount).Add(_T("")); //拨打情况
- m_List1.m_arLabels.ElementAt(nCount).Add(_T("")); //回访日期
- m_List1.m_arLabels.ElementAt(nCount).Add(_T("")); //通话时长
- CString strCS = _T("");
- for(int j=0; j<m_AllSurveyLogArr.GetSize(); j++)
- {
- CString strOrder = m_AllSurveyLogArr.ElementAt(j).ElementAt(5);
- if(strOrder == strOrderNum)
- {
- strCS = m_AllSurveyLogArr.ElementAt(j).ElementAt(11);
- break;
- }
- }
- m_List1.m_arLabels.ElementAt(nCount).Add(strCS); //回访人员
- m_List1.m_arLabels.ElementAt(nCount).Add(_T("")); //备注
- ++nCount;
- /*
- }
- */
- }
- if(nCount != 0)
- {
- m_List1.m_LabelCount = nCount;
- m_List1.SetItemCountEx(nCount);
- }
- }
- void Satisfaction::OnBUTclose() // 关闭按钮;
- {
- GetParent()->SendMessage(WM_CLOSE);
- }
- BOOL Satisfaction::PreTranslateMessage(MSG* pMsg)
- {
- try
- {
- if (pMsg->message == WM_KEYDOWN)
- {
- switch (pMsg->wParam)
- {
- case VK_RETURN:
- OnButton1();
- return 1;
- case 0x43: // copy
- if ((GetKeyState(VK_CONTROL) & 0x80))
- {
- GetFocus()->SendMessage(WM_COPY);
- return TRUE;
- }
- break;
- case 0x56: //Ctrl + V:
- if ((GetKeyState(VK_CONTROL) & 0x80))
- {
- GetFocus()->SendMessage(WM_PASTE);
- return TRUE;
- }
- break;
- case 0x58: // cut
- if ((GetKeyState(VK_CONTROL) & 0x80))
- {
- GetFocus()->SendMessage(WM_CUT);
- return TRUE;
- }
- break;
- case 0x5A: //undo
- case 0x59: //redo
- if ((GetKeyState(VK_CONTROL) & 0x80))
- {
- GetFocus()->SendMessage(WM_UNDO);
- return TRUE;
- }
- break;
- }
- }
- }
- catch (...)
- {
- }
- return MyFormView::PreTranslateMessage(pMsg);
- }
- void Satisfaction::OnButton1() // 查询按钮;
- {
- CTime startTime, endTime;
- ((CDateTimeCtrl*)GetDlgItem(IDC_Date_Start))->GetTime(startTime);
- ((CDateTimeCtrl*)GetDlgItem(IDC_Date_End))->GetTime(endTime);
-
- CString strStartCT(_T("")), strEndCT(_T(""));
- strStartCT = startTime.Format(_T("%Y%m%d"));
- strEndCT = endTime.Format(_T("%Y%m%d"));
- CString filter = _T("");
-
- m_List1array.RemoveAll();
- #ifdef LKAY_VERSION
- filter = _T("dindan@(dindantype<>'意向客户' or dindantype is null) and id between '") + strStartCT + _T("-000' and '") + strEndCT + _T("-999'");
- #else
- filter = _T("dindan@id between '") + strStartCT + _T("-000' and '") + strEndCT + _T("-999'");
- #endif
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 234; //获取dindan信息和对应的满意度记录
- g_sendhead.tabcount = 1;
- g_pMainWnd->ProcessChatMessageRequest2(filter);
- if (g_bSendOK == 0)
- return;
- DataToArray(&m_List1array);
- m_AllSurveyLogArr.RemoveAll();
- //获取所有记录
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 234;
- g_sendhead.tabcount = 1;
- CString strfilter = _T("GetAllSurveyData@") + strStartCT + _T("@") + strEndCT;
- g_pMainWnd->ProcessChatMessageRequest2(strfilter);
- if(g_bSendOK == 0)
- return;
- DataToArray(&m_AllSurveyLogArr);
- OnOrderTodayBtn();
- }
- void Satisfaction::GetData()
- {
- m_ScoreTypeArr.RemoveAll();
- //获取分数类型
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 234;
- g_sendhead.tabcount = 1;
- CString strfilter = _T("GetScoreType@");
- g_pMainWnd->ProcessChatMessageRequest2(strfilter);
- if(g_bSendOK == 0)
- return;
- DataToArray(&m_ScoreTypeArr);
- m_kindArr.RemoveAll();
- //获取服务类别
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 234;
- g_sendhead.tabcount = 1;
- strfilter = _T("SvrKind@");
- g_pMainWnd->ProcessChatMessageRequest2(strfilter);
- if(g_bSendOK == 0)
- return;
- DataToArray(&m_kindArr);
- m_cfgArr.RemoveAll();
- //获取配置信息
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 234;
- g_sendhead.tabcount = 1;
- strfilter = _T("SatisfactionCfg@");
- g_pMainWnd->ProcessChatMessageRequest2(strfilter);
- if (g_bSendOK == 0)
- return;
- DataToArray(&m_cfgArr);
- FillGrid(0);
- }
- void Satisfaction::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
- {
- LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
- // TODO: 在此添加控件通知处理程序代码
- NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
- if(pNMListView->iItem != -1)
- {
- //单击行列pNMListView->iItem, pNMListView->iSubItem
- m_nCurSelIdx = pNMListView->iItem;
- }
- *pResult = 0;
- }
- //打开调查项
- void Satisfaction::OnOpenSurveyBtn()
- {
- if(m_nCurSelIdx == -1)
- {
- MessageBox(_T("请选择订单!"));
- return;
- }
- CTime startTime, endTime;
- ((CDateTimeCtrl*)GetDlgItem(IDC_Date_Start))->GetTime(startTime);
- ((CDateTimeCtrl*)GetDlgItem(IDC_Date_End))->GetTime(endTime);
-
- CString strStartCT(_T("")), strEndCT(_T(""));
- strStartCT = startTime.Format(_T("%Y%m%d"));
- strEndCT = endTime.Format(_T("%Y%m%d"));
- int i = 0;
- CString strOrderNum = m_List1.GetItemText(m_nCurSelIdx, 0);
- CStringArray* pCurrDinDan = NULL;
- for(i=0; i<m_List1array.GetSize(); i++)
- {
- if(m_List1array.ElementAt(i).ElementAt(0) == strOrderNum)
- pCurrDinDan = &m_List1array.ElementAt(i);
- }
- if(pCurrDinDan == NULL)
- {
- MessageBox(_T("请选择订单!"));
- return;
- }
- if(g_Surveydlg)
- {
- g_Surveydlg->SendMessage(WM_CLOSE);
- g_Surveydlg = NULL;
- }
- //进入调查界面
- SatisfactionSurvey dlg;
- g_Surveydlg = &dlg;
- dlg.m_strOrderNum = strOrderNum; //订单号
- dlg.m_pCurrDindan = pCurrDinDan; //当前选择的订单
- dlg.m_pkindArr = &m_kindArr; //所有类型
- dlg.m_pCfgArr = &m_cfgArr; //相对应的调查配置表
- dlg.DoModal();
- //调查结束后需更新所有记录
- //获取所有记录
- m_AllSurveyLogArr.RemoveAll();
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 234;
- g_sendhead.tabcount = 1;
- CString strfilter = _T("GetAllSurveyData@") + strStartCT + _T("@") + strEndCT;
- g_pMainWnd->ProcessChatMessageRequest2(strfilter);
- if(g_bSendOK == 0)
- return;
- DataToArray(&m_AllSurveyLogArr);
- //更新显示数据
- FillGrid(m_nShowType);
- m_nCurSelIdx = -1;
- g_Surveydlg = NULL;
- GetData();
- OnButton1();
- }
- //订单
- void Satisfaction::OnOrderTodayBtn()
- {
- ChangeColName(_T("接单"));
- m_nShowType = 0;
- FillGrid(m_nShowType);
- }
- //形设
- void Satisfaction::OnConfigurationBtn()
- {
- ChangeColName(_T("接单"));
- m_nShowType = 1;
- FillGrid(m_nShowType);
- }
- //拍照
- void Satisfaction::OnTodayPhotographBtn()
- {
- ChangeColName(_T("摄影"));
- m_nShowType = 2;
- FillGrid(m_nShowType);
- }
- //选片
- void Satisfaction::OnChoosePhotosBtn()
- {
- ChangeColName(_T("选片"));
- m_nShowType = 3;
- FillGrid(m_nShowType);
- }
- //看样
- void Satisfaction::OnLookSampleBtn()
- {
- ChangeColName(_T("看样"));
- m_nShowType = 4;
- FillGrid(m_nShowType);
- }
- //化妆
- void Satisfaction::OnCollectTodayBtn()
- {
- ChangeColName(_T("化妆"));
- m_nShowType = 5;
- FillGrid(m_nShowType);
- }
- //婚庆
- void Satisfaction::OnWeddingTodayBtn()
- {
- ChangeColName(_T("接单"));
- m_nShowType = 6;
- FillGrid(m_nShowType);
- }
- void Satisfaction::ChangeColName(LPSTR lpName)
- {
- LVCOLUMN lov;
- lov.mask = LVCF_TEXT; //取字符掩码
- lov.pszText = m_szColName;
- lov.cchTextMax = MAX_PATH;
- m_List1.GetColumn(6, &lov);
- memset(m_szColName, 0, sizeof(TCHAR)*64);
- #ifdef VC60
- _tcscpy(m_szColName, lpName);
- #else
- _tcscpy_s(m_szColName, 64, lpName);
- #endif
- m_List1.SetColumn(6, &lov);
- }
- //------------------------------------------------------
- /*
- 函数名: GetScore
- 描述: 获取评分
- 参数:
- CString& strScore 返回评分
- 返回值:
- */
- //------------------------------------------------------
- void Satisfaction::GetScoreAndSurveyObj(const CString& strObj, const CString& strOrderNum, CString& strScore)
- {
- int nSegment = 0; //一条记录的总分
- int i(0), j(0);
- int nStatisticsNum = 0; //统计数量
- int nScore = 0;
- for(j=0; j<m_AllSurveyLogArr.GetSize(); j++)
- {
- if(m_AllSurveyLogArr.ElementAt(j).ElementAt(5) == strOrderNum && strObj == m_AllSurveyLogArr.ElementAt(j).ElementAt(4))
- {
- CString strKindName = m_AllSurveyLogArr.ElementAt(j).ElementAt(2);
- for(i=0; i<m_cfgArr.GetSize(); i++)
- {
- if(m_cfgArr.ElementAt(i).ElementAt(2) == strKindName)
- {
- //获取一条记录的总分
- nSegment = _ttoi(m_cfgArr.ElementAt(i).ElementAt(3));
- break;
- }
- }
- }
- if(nSegment != 0)
- break;
- }
-
- if(nSegment == 0)
- return;
- for(j=0; j<m_AllSurveyLogArr.GetSize(); j++)
- {
- if(m_AllSurveyLogArr.ElementAt(j).ElementAt(5) == strOrderNum && strObj == m_AllSurveyLogArr.ElementAt(j).ElementAt(4))
- {
- //统计满意度
- nScore += _ttoi(m_AllSurveyLogArr.ElementAt(j).ElementAt(6));
- ++nStatisticsNum;
- }
- }
- if(nStatisticsNum == 0)
- return;
- int nMaxScore = nSegment*nStatisticsNum; //总分
- int nAve = nMaxScore/5; //
- if(nScore <= nAve)
- strScore = _T("非常不满意");
- else if(nScore > nAve && nScore <= nAve*2)
- strScore = _T("不满意");
- else if(nScore > nAve*2 && nScore <= nAve*3)
- strScore = _T("一般");
- else if(nScore > nAve*3 && nScore <= nAve*4)
- strScore = _T("满意");
- else if(nScore > nAve*4 && nScore <= nAve*5)
- strScore = _T("非常满意");
- }
- void Satisfaction::OnSetSurveyCfg()
- {
- SatisfactionCfg dlg;
- dlg.DoModal();
- }
|