123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921 |
- #include "stdafx.h"
- #include "ylgl.h"
- #include "SatisfactionSurvey.h"
- #include "SatisfactionSurveyDef.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- SatisfactionSurvey::SatisfactionSurvey(CWnd* pParent)
- : CDialog(SatisfactionSurvey::IDD, pParent)
- , m_pkindArr(NULL)
- , m_pCfgArr(NULL)
- , m_strOrderNum(_T(""))
- , m_nIsAddNewLog(1)
- , m_pCurrDindan(NULL)
- {
- memset(&m_Rt, 0, sizeof(CRect));
- memset(&m_WndRt, 0, sizeof(CRect));
- }
- void SatisfactionSurvey::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO_SurveyType, m_KindCombox);
- DDX_Control(pDX, IDC_LIST_ObjName, m_NameList);
- }
- BEGIN_MESSAGE_MAP(SatisfactionSurvey, CDialog)
- ON_WM_SYSCOMMAND()
- ON_WM_CLOSE()
- ON_WM_SIZE()
- ON_BN_CLICKED(IDC_OnSave_Btn, OnSaveBtn)
- ON_CBN_SELCHANGE(IDC_COMBO_SurveyType, OnCbnSelchangeCombo1)
- ON_BN_CLICKED(IDC_OnCancel_Btn, OnCancelBtn)
- ON_NOTIFY(NM_CLICK, IDC_LIST_ObjName, OnNMClickList1)
-
- END_MESSAGE_MAP()
- BOOL SatisfactionSurvey::OnInitDialog()
- {
- CDialog::OnInitDialog();
- if(!m_pkindArr)
- return FALSE;
- int i=0;
- CArray<CStringArray, CStringArray> kindArr;
- for(i=0; i<m_pkindArr->GetSize(); i++)
- m_KindCombox.AddString(m_pkindArr->ElementAt(i).ElementAt(1));
- // CString strTypeName = m_pkindArr->ElementAt(0).ElementAt(1);
- CString strTypeName = _T("");
- m_KindCombox.SetCurSel(0);
- m_NameList.InsertColumn( 0, _T("名字"), LVCFMT_LEFT, 70 );//插入列
- m_NameList.InsertColumn( 1, _T("状态"), LVCFMT_LEFT, 65 );//插入列
- m_NameList.SetExtendedStyle(m_NameList.GetExtendedStyle() | LVS_EX_FLATSB | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP);
- //获取数据
- GetData();
- FillGrid(strTypeName);
- this->CenterWindow (g_pMainWnd);
- this->GetWindowRect(&m_WndRt);
- m_Rt = m_WndRt;
- ScreenToClient(&m_Rt);
- m_Rt.DeflateRect(3, 85);
- if(m_NameList.GetItemCount() == 0)
- return FALSE;
- //设置选中
- m_NameList.SetItemState(0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
- CString strObjName = m_NameList.GetItemText(0, 0);
- if(strObjName == _T(""))
- return FALSE;
- Init(strTypeName, strObjName);
- /*
- //订单景点
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 234;
- g_sendhead.tabcount = 1;
- CString strfilter = _T("dindanjd@id='") + m_strOrderNum + _T("'");
- g_pMainWnd->ProcessChatMessageRequest2(strfilter);
- if(g_bSendOK == 0)
- return FALSE;
- DataToArray(&m_dindanjdArr);
- */
-
- return TRUE;
- }
- void SatisfactionSurvey::GetData()
- {
- //订单人员数据
- m_RYDDArr.RemoveAll();
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 234;
- g_sendhead.tabcount = 1;
- CString strfilter = _T("surveyrenyuan@ry.dimission='在职' and dd.id='") + m_strOrderNum + _T("' and ry.name in (dd.waiter1,dd.waiter2,dd.waiter3,dd.waiter4,dd.waiter5,dd.waiter6,dd.waiter7,dd.waiter8)");
- g_pMainWnd->ProcessChatMessageRequest2(strfilter);
- if (g_bSendOK == 0)
- return;
- DataToArray(&m_RYDDArr);
- //获取当前订单的调查记录
- m_CurrSurveyLogs.RemoveAll();
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 234;
- g_sendhead.tabcount = 1;
- strfilter = _T("GetAllSurveyData@") + m_strOrderNum;
- g_pMainWnd->ProcessChatMessageRequest2(strfilter);
- if (g_bSendOK == 0)
- return;
- DataToArray(&m_CurrSurveyLogs);
- /*
- for(int i=0; i<m_CurrSurveyLogs.GetSize(); i++)
- {
- for(int j=0; j<m_CurrSurveyLogs.ElementAt(i).GetSize(); j++)
- printf("%s\n", m_CurrSurveyLogs.ElementAt(i).ElementAt(j));
- printf("\n");
- }
- */
-
- //订单景点
- /*
- id 订单号
- date 拍照日期
- time ##景点拍照预约时间
- waiter1 摄影师
- waiter2 化妆师/导导师
- status 景点的拍照状态
- waiter12 摄影师助理
- waiter22 化妆师助理
- bookingdate ##景点拍照预约日期
- dress 礼服
- clerk 录单人
- inputtime 录入时间
- */
- m_dindanjdArr.RemoveAll();
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 234;
- g_sendhead.tabcount = 1;
- strfilter = _T("dindanjd@id='") + m_strOrderNum + _T("'");
- g_pMainWnd->ProcessChatMessageRequest2(strfilter);
- if(g_bSendOK == 0)
- return;
- DataToArray(&m_dindanjdArr);
- //获取员工
- m_RenYuanArr.RemoveAll();
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 5;
- g_sendhead.tabcount = 1;
- strfilter = _T("dimission='在职'");
- g_pMainWnd->ProcessChatMessageRequest2(strfilter);
- if (g_bSendOK == 0)
- return;
-
- DataToArray(&m_RenYuanArr);
- }
- /*----------------------------------------
- 函数名: FillGrid
- 描述: 填充表格
- 参数:
- 返回值:
- ----------------------------------------*/
- void SatisfactionSurvey::FillGrid(const CString& strTypeName)
- {
- m_NameList.DeleteAllItems();
- CString strObjName = _T(""); //对象名:人员名或调查的对象名
- int idx = 0;
- //已调查
- for(int j=0; j<m_CurrSurveyLogs.GetSize(); j++)
- {
- CStringArray* p = &m_CurrSurveyLogs.ElementAt(j);
- if(p != NULL)
- {
- if(strTypeName == p->ElementAt(2) && p->ElementAt(4) != strObjName)
- {
- strObjName = p->ElementAt(4);
- int nRow = m_NameList.InsertItem(idx, p->ElementAt(4));
- m_NameList.SetItemText(nRow, 1, p->ElementAt(9));
- }
- }
- ++idx;
- }
- FillDataByTypeName(strTypeName);
- }
- /*----------------------------------------
- 函数名: CheckNameList
- 描述: 检查名字列表是否已存在同名
- 参数:
- IN CONST CString& strName
- 返回值: 有同名=TRUE, 没有=FALSE;
- ----------------------------------------*/
- BOOL SatisfactionSurvey::CheckNameList(IN CONST CString& strName)
- {
- int nSize = m_NameList.GetItemCount();
- for(int i=0; i<nSize; i++)
- {
- if(strName == m_NameList.GetItemText(i, 0))
- return TRUE;
- }
- return FALSE;
- }
- /*----------------------------------------
- 函数名: FillDataByTypeName
- 描述: 通过对象类型填充调查对象数据
- 参数:
- const CString& strTypeName
- 返回值:
- ----------------------------------------*/
- void SatisfactionSurvey::FillDataByTypeName(const CString& strTypeName)
- {
- if(!m_pCurrDindan)
- return;
- int nIdx = m_NameList.GetItemCount();
- int i=0;
- CString strObjName = _T("");
- if(strTypeName == _T("门市"))
- {
- strObjName = m_pCurrDindan->ElementAt(25);
- if(strObjName == _T(""))
- return;
- if(!CheckNameList(strObjName))
- {
- int nRow = m_NameList.InsertItem(nIdx, strObjName);
- m_NameList.SetItemText(nRow, 1, _T("未调查"));
- }
- }
- else if(strTypeName == _T("摄影"))
- {
- strObjName = m_pCurrDindan->ElementAt(15);
- if(strObjName == _T(""))
- return;
- if(!CheckNameList(strObjName))
- {
- int nRow = m_NameList.InsertItem(nIdx, strObjName);
- m_NameList.SetItemText(nRow, 1, _T("未调查"));
- }
- for(i=0; i<m_dindanjdArr.GetSize(); i++)
- {
- strObjName = m_dindanjdArr.ElementAt(i).ElementAt(3);
- if(strObjName == _T(""))
- continue;
- if(CheckNameList(strObjName))
- continue;
- int nRow = m_NameList.InsertItem(nIdx, strObjName);
- m_NameList.SetItemText(nRow, 1, _T("未调查"));
- }
- }
- else if(strTypeName == _T("化妆"))
- {
- strObjName = m_pCurrDindan->ElementAt(17);
- if(strObjName == _T(""))
- return;
- if(!CheckNameList(strObjName))
- {
- int nRow = m_NameList.InsertItem(nIdx, strObjName);
- m_NameList.SetItemText(nRow, 1, _T("未调查"));
- }
- for(i=0; i<m_dindanjdArr.GetSize(); i++)
- {
- strObjName = m_dindanjdArr.ElementAt(i).ElementAt(4);
- if(strObjName == _T(""))
- continue;
- if(CheckNameList(strObjName))
- continue;
- int nRow = m_NameList.InsertItem(nIdx, strObjName);
- m_NameList.SetItemText(nRow, 1, _T("未调查"));
- }
- }
- else if(strTypeName == _T("选片"))
- {
- strObjName = m_pCurrDindan->ElementAt(19);
- if(strObjName == _T(""))
- return;
- if(!CheckNameList(strObjName))
- {
- int nRow = m_NameList.InsertItem(nIdx, strObjName);
- m_NameList.SetItemText(nRow, 1, _T("未调查"));
- }
- }
- else if(strTypeName == _T("设计"))
- {
- strObjName = m_pCurrDindan->ElementAt(21);
- if(strObjName == _T(""))
- return;
- if(!CheckNameList(strObjName))
- {
- int nRow = m_NameList.InsertItem(nIdx, strObjName);
- m_NameList.SetItemText(nRow, 1, _T("未调查"));
- }
- }
- else if(strTypeName == _T("初修"))
- {
- strObjName = m_pCurrDindan->ElementAt(23);
- if(strObjName == _T(""))
- return;
- if(!CheckNameList(strObjName))
- {
- int nRow = m_NameList.InsertItem(nIdx, strObjName);
- m_NameList.SetItemText(nRow, 1, _T("未调查"));
- }
- }
- else if(strTypeName == _T("精修"))
- {
- strObjName = m_pCurrDindan->ElementAt(27);
- if(strObjName == _T(""))
- return;
- if(!CheckNameList(strObjName))
- {
- int nRow = m_NameList.InsertItem(nIdx, strObjName);
- m_NameList.SetItemText(nRow, 1, _T("未调查"));
- }
- }
- else if(strTypeName == _T("形设"))
- {
-
- }
- else if(strTypeName == _T("取件"))
- {
-
- }
- else if(strTypeName == _T("礼服"))
- {
-
- }
- else if(strTypeName == _T("摄影助理"))
- {
- CString strObjName = _T("");
- for(i=0; i<m_dindanjdArr.GetSize(); i++)
- {
- strObjName = m_dindanjdArr.ElementAt(i).ElementAt(6);
- if(strObjName == _T(""))
- continue;
- if(CheckNameList(strObjName))
- continue;
- int nRow = m_NameList.InsertItem(nIdx, strObjName);
- m_NameList.SetItemText(nRow, 1, _T("未调查"));
- }
- }
- else if(strTypeName == _T("化妆助理"))
- {
- CString strObjName = _T("");
- for(i=0; i<m_dindanjdArr.GetSize(); i++)
- {
- strObjName = m_dindanjdArr.ElementAt(i).ElementAt(7);
- if(strObjName == _T(""))
- continue;
- if(CheckNameList(strObjName))
- continue;
- int nRow = m_NameList.InsertItem(nIdx, strObjName);
- m_NameList.SetItemText(nRow, 1, _T("未调查"));
- }
- }
- }
- /*----------------------------------------
- 函数名: Init
- 描述: 初始化
- 参数:
- const CString& strTypeName, // 部门名称如:门市、摄影、选片...
- const CString& strObjName // 对象名如:张三、李四...
- 返回值:
- ----------------------------------------*/
- void SatisfactionSurvey::Init(const CString& strTypeName, const CString& strObjName)
- {
- if(!m_pCurrDindan || strTypeName == _T("") || strObjName == _T(""))
- return;
- m_nIsAddNewLog = 1;
- CRect rt(0, 0, 0, 0);
- rt = m_Rt;
- int i=0;
- for(i = 0; i<m_CurrSurveyLogs.GetSize(); i++)
- {
- CStringArray* pStrArr = &m_CurrSurveyLogs.ElementAt(i);
- if(pStrArr != NULL)
- {
- //是否为旧的记录
- if(pStrArr->ElementAt(5) == m_strOrderNum && pStrArr->ElementAt(2) == strTypeName && strObjName == pStrArr->ElementAt(4))
- {
- m_nIsAddNewLog = 0;
- ((CButton*)GetDlgItem(IDC_OnSave_Btn))->SetWindowText(_T("修改"));
- CString strContent = pStrArr->ElementAt(pStrArr->GetSize() - 1);
- int nScoreType = _ttoi(pStrArr->ElementAt(8));
- int nScore = _ttoi(pStrArr->ElementAt(6));
- int nMaxScore = _ttoi(pStrArr->ElementAt(7));
- SSurveyData* p = new SSurveyData();
- p->dwSurveyLogID = _ttol(pStrArr->ElementAt(0));
- p->nCfgID = _ttoi(pStrArr->ElementAt(1));
- p->nScoreType = nScoreType;
- p->nMaxScore = nMaxScore;
- p->strDesc = strContent;
- //创建子控件
- CreateChildCtrl(p->vChidCtrl, strContent, nScoreType - 1, nMaxScore, rt);
- int idx = 0;
- std::vector<SCTRLINFO*>::iterator ii = p->vChidCtrl.begin();
- for(;ii != p->vChidCtrl.end();)
- {
- SCTRLINFO* p = (*ii);
- if(p != NULL && p->nType == TYPE_CHECKBOX)
- {
- ++idx;
- ((CButton*)p->pCtrl)->SetCheck(0);
- if(idx == nScore)
- ((CButton*)p->pCtrl)->SetCheck(1);
- }
- ++ii;
- }
- m_SurveyData.push_back(p);
- }
- }
- }
- //添加新记录
- if(m_nIsAddNewLog)
- {
- ((CButton*)GetDlgItem(IDC_OnSave_Btn))->SetWindowText(_T("保存"));
- //创建子控件
- if(!m_pCfgArr)
- return;
- BOOL bCreate = FALSE;
- for(i=0; i<m_pCfgArr->GetSize(); i++)
- {
- CString strKindName = m_pCfgArr->ElementAt(i).ElementAt(2);
- if(strTypeName != strKindName)
- continue;
- CString strContent = m_pCfgArr->ElementAt(i).ElementAt(m_pCfgArr->ElementAt(i).GetSize() - 1);
- int nScoreType = _ttoi(m_pCfgArr->ElementAt(i).ElementAt(4));
- int nMaxScore = _ttoi(m_pCfgArr->ElementAt(i).ElementAt(3));
- SSurveyData* p = new SSurveyData();
- p->dwSurveyLogID = 0;
- p->nCfgID = _ttoi(m_pCfgArr->ElementAt(i).ElementAt(0));
- p->nScoreType = nScoreType;
- p->nMaxScore = nMaxScore;
- p->strDesc = strContent;
- CreateChildCtrl(p->vChidCtrl, strContent, nScoreType - 1, nMaxScore, rt);
- m_SurveyData.push_back(p);
- bCreate = TRUE;
- }
- if(!bCreate)
- MessageBox(_T("没有设置调查事项"));
- }
- }
- //----------------------------------------
- /*
- 函数名: CreateChildCtrl
- 描述: 创建控件
- 参数:
- CString& strContent, 调查内容
- const int nScoreType, 评分类型
- const int nSize 复选框数量
- CRect& lastrt 返回最后的位置
- 返回值:
- */
- //----------------------------------------
- void SatisfactionSurvey::CreateChildCtrl(std::vector<SCTRLINFO*>& vChidCtr, CString& strContent, const int nScoreType, const int nSize, CRect& lastrt)
- {
- int nBord = 5;
- int nH(0), nW(0);
- lastrt.left = m_Rt.left;
- lastrt.right = m_Rt.right;
- CWnd* p = CreateStatic(this, g_nIdxCtrlID, strContent, lastrt);
- if(p != NULL)
- {
- SCTRLINFO* pC = new SCTRLINFO;
- pC->nID = g_nIdxCtrlID;
- pC->nType = TYPE_STATIC;
- pC->pCtrl = p;
- vChidCtr.push_back(pC);
- ++g_nIdxCtrlID;
- nH = lastrt.bottom - lastrt.top;
- lastrt.top = lastrt.bottom + nBord;
- }
- lastrt.left = m_Rt.left;
- p = NULL;
-
- //创建checkbox控件
- for(int i=0; i<nSize; i++)
- {
- lastrt.left = m_Rt.left + 195 + (nW + nBord)*i;
- CWnd* p = CreateCheckBox(this, g_nIdxCtrlID, szstrScoreCN[nScoreType*nSize+i], lastrt);
- if(p != NULL)
- {
- SCTRLINFO* pC = new SCTRLINFO;
- pC->nID = g_nIdxCtrlID;
- pC->nType = TYPE_CHECKBOX;
- pC->pCtrl = p;
- vChidCtr.push_back(pC);
- ++g_nIdxCtrlID;
- nW = lastrt.right - lastrt.left;
- }
- }
- lastrt.left = m_Rt.left;
- lastrt.top = lastrt.bottom + nBord;
- //是否超出默认的窗体大小
- this->GetWindowRect(&m_Rt);
- ScreenToClient(&m_Rt);
- m_Rt.DeflateRect(3, 85);
- if(m_Rt.bottom < lastrt.top)
- {
- CRect wndrt(0, 0, 0, 0);
- this->GetWindowRect(&wndrt);
- wndrt.top = wndrt.top - 50/2;
- wndrt.bottom = wndrt.bottom + 50/2;
- this->MoveWindow(wndrt);
- }
- else
- {
- this->MoveWindow(m_WndRt);
- }
- }
- //取消
- void SatisfactionSurvey::OnCancelBtn()
- {
- // printf("OnCancelBtn");
- m_pkindArr = NULL;
- m_pCurrDindan = NULL;
- ClearSurveyData();
- // printf("clear finish\n");
- CDialog::OnCancel();
- }
- /*----------------------------------------
- 函数名: OnSaveBtn
- 描述: 保存
- 参数:
- 返回值:
- ----------------------------------------*/
- void SatisfactionSurvey::OnSaveBtn()
- {
- int nItem = m_NameList.GetNextItem(-1, LVNI_SELECTED);
- CString strSql = _T("");
- std::vector<SSurveyData*>::iterator iter = m_SurveyData.begin();
- for(;iter != m_SurveyData.end();)
- {
- SSurveyData* pss = (*iter);
- if(pss != NULL)
- {
- int nScore = 0;
- std::vector<SCTRLINFO*>::iterator ii = pss->vChidCtrl.begin();
- for(;ii != pss->vChidCtrl.end();)
- {
- SCTRLINFO* pci = (*ii);
- if(pci != NULL && pci->nType == TYPE_CHECKBOX)
- {
- //计算得分
- ++nScore;
- if(pci->pCtrl != NULL && ((CButton*)pci->pCtrl)->GetCheck())
- break;
- }
- ++ii;
- }
- CString strSurveyLogID = _T("");
- strSurveyLogID.Format(_T("%d"), pss->dwSurveyLogID);
- CString strCfgID = _T("");
- strCfgID.Format(_T("%d"), pss->nCfgID);
- CString strScore = _T("");
- strScore.Format(_T("%d"), nScore);
- CTime ct = CTime::GetCurrentTime();
- CString strCurTime = ct.Format(_T("%Y-%m-%d"));
-
- if(m_nIsAddNewLog == 0)
- {
- //修改
- strSql = _T("UPDATE SatisfactionSurvey SET Score=") + strScore + (",SurveyTime='") + strCurTime + _T("',SurveyCS='") + g_user.name + _T("' WHERE SurveyLogID=") + strSurveyLogID;
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strSql);
- if(g_bSendOK == 0)
- {
- MessageBox(_T(""));
- return;
- }
- }
- else
- {
- int i = 0;
- CString strObjID = _T("");
- CString strObjName = _T("");
- CString strName = m_NameList.GetItemText(nItem, 0);
- for(i=0; i<m_RYDDArr.GetSize(); i++)
- {
- if(m_RYDDArr.ElementAt(i).ElementAt(2) == strName)
- {
- strObjID = m_RYDDArr.ElementAt(i).ElementAt(0);
- strObjName = strName;
- break;
- }
- }
- if(strObjID == _T("") || strObjName == _T(""))
- {
- //查找订单景点
- int nIdx = m_KindCombox.GetCurSel();
- CString strType = _T("");
- m_KindCombox.GetLBText(nIdx, strType);
- if(strType != _T(""))
- {
- for(i=0; i < m_dindanjdArr.GetSize(); ++i)
- {
- if(strName == m_dindanjdArr.ElementAt(i).ElementAt(3)
- || strName == m_dindanjdArr.ElementAt(i).ElementAt(4)
- || strName == m_dindanjdArr.ElementAt(i).ElementAt(6)
- || strName == m_dindanjdArr.ElementAt(i).ElementAt(7))
- strObjName = strName;
- GetRenYuanIDForName(strObjName, strObjID);
- if(strObjID != _T("") && strObjName != _T(""))
- break;
- }
- }
- }
- if(strObjID == _T("") || strObjName == _T(""))
- {
- MessageBox(_T("调查对象有误!"));
- return;
- }
-
- //添加保存
- strSql = _T("INSERT INTO SatisfactionSurvey (cfgID,ObjID,ObjName,OrderID,Score,State,SurveyTime,SurveyCS) VALUES (") + strCfgID + _T(",'") + strObjID + _T("','") + strObjName + _T("','") + m_strOrderNum + _T("',") + strScore + _T(",'已调查','") + strCurTime + _T("','") + g_user.name + _T("')");
- g_sendhead.bsql = 1;
- g_pMainWnd->ProcessChatMessageRequest2(strSql);
- if(g_bSendOK == 0)
- return;
- }
- }
- ++iter;
- }
- if(m_nIsAddNewLog == 0)
- MessageBox(_T("修改成功"));
- else
- MessageBox(_T("保存成功"));
- m_nIsAddNewLog = 0;
- m_NameList.SetItemText(nItem, 1, _T("已调查"));
- ((CButton*)GetDlgItem(IDC_OnSave_Btn))->SetWindowText(_T("修改"));
- //获取当前订单的调查记录
- m_CurrSurveyLogs.RemoveAll();
- g_sendhead.bsql = 0;
- g_sendhead.code[0] = 234;
- g_sendhead.tabcount = 1;
- CString strfilter = _T("GetAllSurveyData@") + m_strOrderNum;
- g_pMainWnd->ProcessChatMessageRequest2(strfilter);
- if (g_bSendOK == 0)
- return;
- /*
- fieldArr.Add(_T("LogID")); //记录ID
- fieldArr.Add(_T("cfgID")); //服务配置ID
- fieldArr.Add(_T("KindName")); //服务类型
- fieldArr.Add(_T("ObjID")); //对象ID
- fieldArr.Add(_T("ObjName")); //对象名
- fieldArr.Add(_T("OrderID")); //订单ID
- fieldArr.Add(_T("Score")); //得分
- fieldArr.Add(_T("MaxScore")); //最高得分
- fieldArr.Add(_T("TypeID")); //显示得分类型
- fieldArr.Add(_T("States")); //状态
- fieldArr.Add(_T("SurveyTime")); //调查时间
- fieldArr.Add(_T("SurveyCS")); //调查客服
- fieldArr.Add(_T("sfncfgDesc")); //调查内容
- */
- DataToArray(&m_CurrSurveyLogs);
- /*
- for(int i=0; i<m_CurrSurveyLogs.GetSize(); i++)
- {
- for(int j=0; j<m_CurrSurveyLogs.ElementAt(i).GetSize(); j++)
- printf("%s\n", m_CurrSurveyLogs.ElementAt(i).ElementAt(j));
- printf("\n");
- }
- */
- }
- /*----------------------------------------
- 函数名: OnCbnSelchangeCombo1
- 描述: 选择类型
- 参数:
- 返回值:
- ----------------------------------------*/
- void SatisfactionSurvey::OnCbnSelchangeCombo1()
- {
- // TODO: 在此添加控件通知处理程序代码
- int nIdx = m_KindCombox.GetCurSel();
- CString strTypeName = _T("");
- m_KindCombox.GetLBText(nIdx, strTypeName);
- if(strTypeName == _T(""))
- {
- MessageBox(_T("先选择类型!"));
- return;
- }
- ClearSurveyData();
- FillGrid(strTypeName);
- if(m_NameList.GetItemCount() > 0)
- m_NameList.SetItemState(0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
- CString strObjName = m_NameList.GetItemText(0, 0);
- if(strObjName == _T(""))
- {
- MessageBox(_T("没有调查的事件!"));
- return;
- }
- Init(strTypeName, strObjName);
- }
- /*----------------------------------------
- 函数名: ClearSurveyData
- 描述: 清除调查数据
- 参数:
- 返回值:
- ----------------------------------------*/
- void SatisfactionSurvey::ClearSurveyData()
- {
- std::vector<SSurveyData*>::iterator iter = m_SurveyData.begin();
- for(;iter != m_SurveyData.end();++iter)
- {
- SSurveyData* p = (*iter);
- if(p == NULL)
- continue;
- std::vector<SCTRLINFO*>::iterator ii = p->vChidCtrl.begin();
- for(;ii != p->vChidCtrl.end();++ii)
- {
- SCTRLINFO* pi = (*ii);
- if(pi == NULL)
- continue;
- if(pi->pCtrl)
- {
- // pi->pCtrl->DestroyWindow();
- // pi->pCtrl->OnDestroy();
- delete pi->pCtrl;
- pi->pCtrl = NULL;
- }
- delete pi;
- }
- p->vChidCtrl.clear();
- delete p;
- }
- m_SurveyData.clear();
- g_nIdxCtrlID = 0;
- }
- void SatisfactionSurvey::OnSize(UINT nType, int cx, int cy)
- {
- CDialog::OnSize(nType, cx, cy);
- }
- BOOL SatisfactionSurvey::OnCommand(WPARAM wParam, LPARAM lParam)
- {
- HWND hWndCtrl = (HWND)lParam;
- CWnd* pCWnd = FromHandle(hWndCtrl);
- UINT nChidID = pCWnd->GetDlgCtrlID();
- SSurveyData* pSel = NULL; //勾选的调查项
- CButton* pSelBtn = NULL; //初选中的按钮
- if(nChidID >= 90001 && nChidID < 99999)
- {
- std::vector<SSurveyData*>::iterator iter = m_SurveyData.begin();
- for(;iter != m_SurveyData.end();)
- {
- //每条调查项
- SSurveyData* p = (*iter);
- if(p != NULL)
- {
- std::vector<SCTRLINFO*>::iterator ii = p->vChidCtrl.begin();
- for(;ii != p->vChidCtrl.end();)
- {
- //子控件
- SCTRLINFO* pci = (*ii);
- if(pci != NULL && pci->nType == TYPE_CHECKBOX)
- {
- CButton* pb = (CButton*)pci->pCtrl;
- if(pb != NULL)
- {
- // pb->SetCheck(0);
- if(nChidID == pci->pCtrl->GetDlgCtrlID())
- {
- //选中的控件
- pSel = p;
- pSelBtn = pb;
- break;
- }
- // pb->SetCheck(1);
- }
- }
- ++ii;
- }
- if(pSel)
- break;
- }
- ++iter;
- }
- if(pSel && pSelBtn)
- {
- std::vector<SCTRLINFO*>::iterator ii = pSel->vChidCtrl.begin();
- for(;ii != pSel->vChidCtrl.end();)
- {
- SCTRLINFO* pci = (*ii);
- if(pci != NULL && pci->nType == TYPE_CHECKBOX)
- ((CButton*)pci->pCtrl)->SetCheck(0);
- ++ii;
- }
- pSelBtn->SetCheck(!pSelBtn->GetCheck());
- pSel = NULL;
- pSelBtn = NULL;
- }
- }
- return CDialog::OnCommand(wParam, lParam);
- }
- void SatisfactionSurvey::OnNMClickList1(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_NameList.SetItemState(pNMListView->iItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
- CString strObjName = m_NameList.GetItemText(pNMListView->iItem, 0);
- int nIdx = m_KindCombox.GetCurSel();
- if(nIdx == -1)
- return;
- if(strObjName == _T(""))
- return;
- CString strTypeName = _T("");
- m_KindCombox.GetLBText(nIdx, strTypeName);
- ClearSurveyData();
- Init(strTypeName, strObjName);
- }
- *pResult = 0;
- }
- void SatisfactionSurvey::OnClose()
- {
- OnCancelBtn();
- }
- /*----------------------------------------
- 函数名: GetRenYuanIDForName
- 描述: 通过员工名获取员工ID
- 参数:
- IN CONST CString& strName, 员工名
- CString& strID 返回ID
- 返回值:
- ----------------------------------------*/
- void SatisfactionSurvey::GetRenYuanIDForName(IN CONST CString& strName, CString& strID)
- {
- for(int i=0; i<m_RenYuanArr.GetSize(); ++i)
- {
- if(strName == m_RenYuanArr.ElementAt(i).ElementAt(1))
- strID = m_RenYuanArr.ElementAt(i).ElementAt(0);
- }
- }
|