SatisfactionSurvey.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921
  1. #include "stdafx.h"
  2. #include "ylgl.h"
  3. #include "SatisfactionSurvey.h"
  4. #include "SatisfactionSurveyDef.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. SatisfactionSurvey::SatisfactionSurvey(CWnd* pParent)
  11. : CDialog(SatisfactionSurvey::IDD, pParent)
  12. , m_pkindArr(NULL)
  13. , m_pCfgArr(NULL)
  14. , m_strOrderNum(_T(""))
  15. , m_nIsAddNewLog(1)
  16. , m_pCurrDindan(NULL)
  17. {
  18. memset(&m_Rt, 0, sizeof(CRect));
  19. memset(&m_WndRt, 0, sizeof(CRect));
  20. }
  21. void SatisfactionSurvey::DoDataExchange(CDataExchange* pDX)
  22. {
  23. CDialog::DoDataExchange(pDX);
  24. DDX_Control(pDX, IDC_COMBO_SurveyType, m_KindCombox);
  25. DDX_Control(pDX, IDC_LIST_ObjName, m_NameList);
  26. }
  27. BEGIN_MESSAGE_MAP(SatisfactionSurvey, CDialog)
  28. ON_WM_SYSCOMMAND()
  29. ON_WM_CLOSE()
  30. ON_WM_SIZE()
  31. ON_BN_CLICKED(IDC_OnSave_Btn, OnSaveBtn)
  32. ON_CBN_SELCHANGE(IDC_COMBO_SurveyType, OnCbnSelchangeCombo1)
  33. ON_BN_CLICKED(IDC_OnCancel_Btn, OnCancelBtn)
  34. ON_NOTIFY(NM_CLICK, IDC_LIST_ObjName, OnNMClickList1)
  35. END_MESSAGE_MAP()
  36. BOOL SatisfactionSurvey::OnInitDialog()
  37. {
  38. CDialog::OnInitDialog();
  39. if(!m_pkindArr)
  40. return FALSE;
  41. int i=0;
  42. CArray<CStringArray, CStringArray> kindArr;
  43. for(i=0; i<m_pkindArr->GetSize(); i++)
  44. m_KindCombox.AddString(m_pkindArr->ElementAt(i).ElementAt(1));
  45. // CString strTypeName = m_pkindArr->ElementAt(0).ElementAt(1);
  46. CString strTypeName = _T("");
  47. m_KindCombox.SetCurSel(0);
  48. m_NameList.InsertColumn( 0, _T("名字"), LVCFMT_LEFT, 70 );//插入列
  49. m_NameList.InsertColumn( 1, _T("状态"), LVCFMT_LEFT, 65 );//插入列
  50. m_NameList.SetExtendedStyle(m_NameList.GetExtendedStyle() | LVS_EX_FLATSB | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_HEADERDRAGDROP);
  51. //获取数据
  52. GetData();
  53. FillGrid(strTypeName);
  54. this->CenterWindow (g_pMainWnd);
  55. this->GetWindowRect(&m_WndRt);
  56. m_Rt = m_WndRt;
  57. ScreenToClient(&m_Rt);
  58. m_Rt.DeflateRect(3, 85);
  59. if(m_NameList.GetItemCount() == 0)
  60. return FALSE;
  61. //设置选中
  62. m_NameList.SetItemState(0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
  63. CString strObjName = m_NameList.GetItemText(0, 0);
  64. if(strObjName == _T(""))
  65. return FALSE;
  66. Init(strTypeName, strObjName);
  67. /*
  68. //订单景点
  69. g_sendhead.bsql = 0;
  70. g_sendhead.code[0] = 234;
  71. g_sendhead.tabcount = 1;
  72. CString strfilter = _T("dindanjd@id='") + m_strOrderNum + _T("'");
  73. g_pMainWnd->ProcessChatMessageRequest2(strfilter);
  74. if(g_bSendOK == 0)
  75. return FALSE;
  76. DataToArray(&m_dindanjdArr);
  77. */
  78. return TRUE;
  79. }
  80. void SatisfactionSurvey::GetData()
  81. {
  82. //订单人员数据
  83. m_RYDDArr.RemoveAll();
  84. g_sendhead.bsql = 0;
  85. g_sendhead.code[0] = 234;
  86. g_sendhead.tabcount = 1;
  87. 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)");
  88. g_pMainWnd->ProcessChatMessageRequest2(strfilter);
  89. if (g_bSendOK == 0)
  90. return;
  91. DataToArray(&m_RYDDArr);
  92. //获取当前订单的调查记录
  93. m_CurrSurveyLogs.RemoveAll();
  94. g_sendhead.bsql = 0;
  95. g_sendhead.code[0] = 234;
  96. g_sendhead.tabcount = 1;
  97. strfilter = _T("GetAllSurveyData@") + m_strOrderNum;
  98. g_pMainWnd->ProcessChatMessageRequest2(strfilter);
  99. if (g_bSendOK == 0)
  100. return;
  101. DataToArray(&m_CurrSurveyLogs);
  102. /*
  103. for(int i=0; i<m_CurrSurveyLogs.GetSize(); i++)
  104. {
  105. for(int j=0; j<m_CurrSurveyLogs.ElementAt(i).GetSize(); j++)
  106. printf("%s\n", m_CurrSurveyLogs.ElementAt(i).ElementAt(j));
  107. printf("\n");
  108. }
  109. */
  110. //订单景点
  111. /*
  112. id 订单号
  113. date 拍照日期
  114. time ##景点拍照预约时间
  115. waiter1 摄影师
  116. waiter2 化妆师/导导师
  117. status 景点的拍照状态
  118. waiter12 摄影师助理
  119. waiter22 化妆师助理
  120. bookingdate ##景点拍照预约日期
  121. dress 礼服
  122. clerk 录单人
  123. inputtime 录入时间
  124. */
  125. m_dindanjdArr.RemoveAll();
  126. g_sendhead.bsql = 0;
  127. g_sendhead.code[0] = 234;
  128. g_sendhead.tabcount = 1;
  129. strfilter = _T("dindanjd@id='") + m_strOrderNum + _T("'");
  130. g_pMainWnd->ProcessChatMessageRequest2(strfilter);
  131. if(g_bSendOK == 0)
  132. return;
  133. DataToArray(&m_dindanjdArr);
  134. //获取员工
  135. m_RenYuanArr.RemoveAll();
  136. g_sendhead.bsql = 0;
  137. g_sendhead.code[0] = 5;
  138. g_sendhead.tabcount = 1;
  139. strfilter = _T("dimission='在职'");
  140. g_pMainWnd->ProcessChatMessageRequest2(strfilter);
  141. if (g_bSendOK == 0)
  142. return;
  143. DataToArray(&m_RenYuanArr);
  144. }
  145. /*----------------------------------------
  146. 函数名: FillGrid
  147. 描述: 填充表格
  148. 参数:
  149. 返回值:
  150. ----------------------------------------*/
  151. void SatisfactionSurvey::FillGrid(const CString& strTypeName)
  152. {
  153. m_NameList.DeleteAllItems();
  154. CString strObjName = _T(""); //对象名:人员名或调查的对象名
  155. int idx = 0;
  156. //已调查
  157. for(int j=0; j<m_CurrSurveyLogs.GetSize(); j++)
  158. {
  159. CStringArray* p = &m_CurrSurveyLogs.ElementAt(j);
  160. if(p != NULL)
  161. {
  162. if(strTypeName == p->ElementAt(2) && p->ElementAt(4) != strObjName)
  163. {
  164. strObjName = p->ElementAt(4);
  165. int nRow = m_NameList.InsertItem(idx, p->ElementAt(4));
  166. m_NameList.SetItemText(nRow, 1, p->ElementAt(9));
  167. }
  168. }
  169. ++idx;
  170. }
  171. FillDataByTypeName(strTypeName);
  172. }
  173. /*----------------------------------------
  174. 函数名: CheckNameList
  175. 描述: 检查名字列表是否已存在同名
  176. 参数:
  177. IN CONST CString& strName
  178. 返回值: 有同名=TRUE, 没有=FALSE;
  179. ----------------------------------------*/
  180. BOOL SatisfactionSurvey::CheckNameList(IN CONST CString& strName)
  181. {
  182. int nSize = m_NameList.GetItemCount();
  183. for(int i=0; i<nSize; i++)
  184. {
  185. if(strName == m_NameList.GetItemText(i, 0))
  186. return TRUE;
  187. }
  188. return FALSE;
  189. }
  190. /*----------------------------------------
  191. 函数名: FillDataByTypeName
  192. 描述: 通过对象类型填充调查对象数据
  193. 参数:
  194. const CString& strTypeName
  195. 返回值:
  196. ----------------------------------------*/
  197. void SatisfactionSurvey::FillDataByTypeName(const CString& strTypeName)
  198. {
  199. if(!m_pCurrDindan)
  200. return;
  201. int nIdx = m_NameList.GetItemCount();
  202. int i=0;
  203. CString strObjName = _T("");
  204. if(strTypeName == _T("门市"))
  205. {
  206. strObjName = m_pCurrDindan->ElementAt(25);
  207. if(strObjName == _T(""))
  208. return;
  209. if(!CheckNameList(strObjName))
  210. {
  211. int nRow = m_NameList.InsertItem(nIdx, strObjName);
  212. m_NameList.SetItemText(nRow, 1, _T("未调查"));
  213. }
  214. }
  215. else if(strTypeName == _T("摄影"))
  216. {
  217. strObjName = m_pCurrDindan->ElementAt(15);
  218. if(strObjName == _T(""))
  219. return;
  220. if(!CheckNameList(strObjName))
  221. {
  222. int nRow = m_NameList.InsertItem(nIdx, strObjName);
  223. m_NameList.SetItemText(nRow, 1, _T("未调查"));
  224. }
  225. for(i=0; i<m_dindanjdArr.GetSize(); i++)
  226. {
  227. strObjName = m_dindanjdArr.ElementAt(i).ElementAt(3);
  228. if(strObjName == _T(""))
  229. continue;
  230. if(CheckNameList(strObjName))
  231. continue;
  232. int nRow = m_NameList.InsertItem(nIdx, strObjName);
  233. m_NameList.SetItemText(nRow, 1, _T("未调查"));
  234. }
  235. }
  236. else if(strTypeName == _T("化妆"))
  237. {
  238. strObjName = m_pCurrDindan->ElementAt(17);
  239. if(strObjName == _T(""))
  240. return;
  241. if(!CheckNameList(strObjName))
  242. {
  243. int nRow = m_NameList.InsertItem(nIdx, strObjName);
  244. m_NameList.SetItemText(nRow, 1, _T("未调查"));
  245. }
  246. for(i=0; i<m_dindanjdArr.GetSize(); i++)
  247. {
  248. strObjName = m_dindanjdArr.ElementAt(i).ElementAt(4);
  249. if(strObjName == _T(""))
  250. continue;
  251. if(CheckNameList(strObjName))
  252. continue;
  253. int nRow = m_NameList.InsertItem(nIdx, strObjName);
  254. m_NameList.SetItemText(nRow, 1, _T("未调查"));
  255. }
  256. }
  257. else if(strTypeName == _T("选片"))
  258. {
  259. strObjName = m_pCurrDindan->ElementAt(19);
  260. if(strObjName == _T(""))
  261. return;
  262. if(!CheckNameList(strObjName))
  263. {
  264. int nRow = m_NameList.InsertItem(nIdx, strObjName);
  265. m_NameList.SetItemText(nRow, 1, _T("未调查"));
  266. }
  267. }
  268. else if(strTypeName == _T("设计"))
  269. {
  270. strObjName = m_pCurrDindan->ElementAt(21);
  271. if(strObjName == _T(""))
  272. return;
  273. if(!CheckNameList(strObjName))
  274. {
  275. int nRow = m_NameList.InsertItem(nIdx, strObjName);
  276. m_NameList.SetItemText(nRow, 1, _T("未调查"));
  277. }
  278. }
  279. else if(strTypeName == _T("初修"))
  280. {
  281. strObjName = m_pCurrDindan->ElementAt(23);
  282. if(strObjName == _T(""))
  283. return;
  284. if(!CheckNameList(strObjName))
  285. {
  286. int nRow = m_NameList.InsertItem(nIdx, strObjName);
  287. m_NameList.SetItemText(nRow, 1, _T("未调查"));
  288. }
  289. }
  290. else if(strTypeName == _T("精修"))
  291. {
  292. strObjName = m_pCurrDindan->ElementAt(27);
  293. if(strObjName == _T(""))
  294. return;
  295. if(!CheckNameList(strObjName))
  296. {
  297. int nRow = m_NameList.InsertItem(nIdx, strObjName);
  298. m_NameList.SetItemText(nRow, 1, _T("未调查"));
  299. }
  300. }
  301. else if(strTypeName == _T("形设"))
  302. {
  303. }
  304. else if(strTypeName == _T("取件"))
  305. {
  306. }
  307. else if(strTypeName == _T("礼服"))
  308. {
  309. }
  310. else if(strTypeName == _T("摄影助理"))
  311. {
  312. CString strObjName = _T("");
  313. for(i=0; i<m_dindanjdArr.GetSize(); i++)
  314. {
  315. strObjName = m_dindanjdArr.ElementAt(i).ElementAt(6);
  316. if(strObjName == _T(""))
  317. continue;
  318. if(CheckNameList(strObjName))
  319. continue;
  320. int nRow = m_NameList.InsertItem(nIdx, strObjName);
  321. m_NameList.SetItemText(nRow, 1, _T("未调查"));
  322. }
  323. }
  324. else if(strTypeName == _T("化妆助理"))
  325. {
  326. CString strObjName = _T("");
  327. for(i=0; i<m_dindanjdArr.GetSize(); i++)
  328. {
  329. strObjName = m_dindanjdArr.ElementAt(i).ElementAt(7);
  330. if(strObjName == _T(""))
  331. continue;
  332. if(CheckNameList(strObjName))
  333. continue;
  334. int nRow = m_NameList.InsertItem(nIdx, strObjName);
  335. m_NameList.SetItemText(nRow, 1, _T("未调查"));
  336. }
  337. }
  338. }
  339. /*----------------------------------------
  340. 函数名: Init
  341. 描述: 初始化
  342. 参数:
  343. const CString& strTypeName, // 部门名称如:门市、摄影、选片...
  344. const CString& strObjName // 对象名如:张三、李四...
  345. 返回值:
  346. ----------------------------------------*/
  347. void SatisfactionSurvey::Init(const CString& strTypeName, const CString& strObjName)
  348. {
  349. if(!m_pCurrDindan || strTypeName == _T("") || strObjName == _T(""))
  350. return;
  351. m_nIsAddNewLog = 1;
  352. CRect rt(0, 0, 0, 0);
  353. rt = m_Rt;
  354. int i=0;
  355. for(i = 0; i<m_CurrSurveyLogs.GetSize(); i++)
  356. {
  357. CStringArray* pStrArr = &m_CurrSurveyLogs.ElementAt(i);
  358. if(pStrArr != NULL)
  359. {
  360. //是否为旧的记录
  361. if(pStrArr->ElementAt(5) == m_strOrderNum && pStrArr->ElementAt(2) == strTypeName && strObjName == pStrArr->ElementAt(4))
  362. {
  363. m_nIsAddNewLog = 0;
  364. ((CButton*)GetDlgItem(IDC_OnSave_Btn))->SetWindowText(_T("修改"));
  365. CString strContent = pStrArr->ElementAt(pStrArr->GetSize() - 1);
  366. int nScoreType = _ttoi(pStrArr->ElementAt(8));
  367. int nScore = _ttoi(pStrArr->ElementAt(6));
  368. int nMaxScore = _ttoi(pStrArr->ElementAt(7));
  369. SSurveyData* p = new SSurveyData();
  370. p->dwSurveyLogID = _ttol(pStrArr->ElementAt(0));
  371. p->nCfgID = _ttoi(pStrArr->ElementAt(1));
  372. p->nScoreType = nScoreType;
  373. p->nMaxScore = nMaxScore;
  374. p->strDesc = strContent;
  375. //创建子控件
  376. CreateChildCtrl(p->vChidCtrl, strContent, nScoreType - 1, nMaxScore, rt);
  377. int idx = 0;
  378. std::vector<SCTRLINFO*>::iterator ii = p->vChidCtrl.begin();
  379. for(;ii != p->vChidCtrl.end();)
  380. {
  381. SCTRLINFO* p = (*ii);
  382. if(p != NULL && p->nType == TYPE_CHECKBOX)
  383. {
  384. ++idx;
  385. ((CButton*)p->pCtrl)->SetCheck(0);
  386. if(idx == nScore)
  387. ((CButton*)p->pCtrl)->SetCheck(1);
  388. }
  389. ++ii;
  390. }
  391. m_SurveyData.push_back(p);
  392. }
  393. }
  394. }
  395. //添加新记录
  396. if(m_nIsAddNewLog)
  397. {
  398. ((CButton*)GetDlgItem(IDC_OnSave_Btn))->SetWindowText(_T("保存"));
  399. //创建子控件
  400. if(!m_pCfgArr)
  401. return;
  402. BOOL bCreate = FALSE;
  403. for(i=0; i<m_pCfgArr->GetSize(); i++)
  404. {
  405. CString strKindName = m_pCfgArr->ElementAt(i).ElementAt(2);
  406. if(strTypeName != strKindName)
  407. continue;
  408. CString strContent = m_pCfgArr->ElementAt(i).ElementAt(m_pCfgArr->ElementAt(i).GetSize() - 1);
  409. int nScoreType = _ttoi(m_pCfgArr->ElementAt(i).ElementAt(4));
  410. int nMaxScore = _ttoi(m_pCfgArr->ElementAt(i).ElementAt(3));
  411. SSurveyData* p = new SSurveyData();
  412. p->dwSurveyLogID = 0;
  413. p->nCfgID = _ttoi(m_pCfgArr->ElementAt(i).ElementAt(0));
  414. p->nScoreType = nScoreType;
  415. p->nMaxScore = nMaxScore;
  416. p->strDesc = strContent;
  417. CreateChildCtrl(p->vChidCtrl, strContent, nScoreType - 1, nMaxScore, rt);
  418. m_SurveyData.push_back(p);
  419. bCreate = TRUE;
  420. }
  421. if(!bCreate)
  422. MessageBox(_T("没有设置调查事项"));
  423. }
  424. }
  425. //----------------------------------------
  426. /*
  427. 函数名: CreateChildCtrl
  428. 描述: 创建控件
  429. 参数:
  430. CString& strContent, 调查内容
  431. const int nScoreType, 评分类型
  432. const int nSize 复选框数量
  433. CRect& lastrt 返回最后的位置
  434. 返回值:
  435. */
  436. //----------------------------------------
  437. void SatisfactionSurvey::CreateChildCtrl(std::vector<SCTRLINFO*>& vChidCtr, CString& strContent, const int nScoreType, const int nSize, CRect& lastrt)
  438. {
  439. int nBord = 5;
  440. int nH(0), nW(0);
  441. lastrt.left = m_Rt.left;
  442. lastrt.right = m_Rt.right;
  443. CWnd* p = CreateStatic(this, g_nIdxCtrlID, strContent, lastrt);
  444. if(p != NULL)
  445. {
  446. SCTRLINFO* pC = new SCTRLINFO;
  447. pC->nID = g_nIdxCtrlID;
  448. pC->nType = TYPE_STATIC;
  449. pC->pCtrl = p;
  450. vChidCtr.push_back(pC);
  451. ++g_nIdxCtrlID;
  452. nH = lastrt.bottom - lastrt.top;
  453. lastrt.top = lastrt.bottom + nBord;
  454. }
  455. lastrt.left = m_Rt.left;
  456. p = NULL;
  457. //创建checkbox控件
  458. for(int i=0; i<nSize; i++)
  459. {
  460. lastrt.left = m_Rt.left + 195 + (nW + nBord)*i;
  461. CWnd* p = CreateCheckBox(this, g_nIdxCtrlID, szstrScoreCN[nScoreType*nSize+i], lastrt);
  462. if(p != NULL)
  463. {
  464. SCTRLINFO* pC = new SCTRLINFO;
  465. pC->nID = g_nIdxCtrlID;
  466. pC->nType = TYPE_CHECKBOX;
  467. pC->pCtrl = p;
  468. vChidCtr.push_back(pC);
  469. ++g_nIdxCtrlID;
  470. nW = lastrt.right - lastrt.left;
  471. }
  472. }
  473. lastrt.left = m_Rt.left;
  474. lastrt.top = lastrt.bottom + nBord;
  475. //是否超出默认的窗体大小
  476. this->GetWindowRect(&m_Rt);
  477. ScreenToClient(&m_Rt);
  478. m_Rt.DeflateRect(3, 85);
  479. if(m_Rt.bottom < lastrt.top)
  480. {
  481. CRect wndrt(0, 0, 0, 0);
  482. this->GetWindowRect(&wndrt);
  483. wndrt.top = wndrt.top - 50/2;
  484. wndrt.bottom = wndrt.bottom + 50/2;
  485. this->MoveWindow(wndrt);
  486. }
  487. else
  488. {
  489. this->MoveWindow(m_WndRt);
  490. }
  491. }
  492. //取消
  493. void SatisfactionSurvey::OnCancelBtn()
  494. {
  495. // printf("OnCancelBtn");
  496. m_pkindArr = NULL;
  497. m_pCurrDindan = NULL;
  498. ClearSurveyData();
  499. // printf("clear finish\n");
  500. CDialog::OnCancel();
  501. }
  502. /*----------------------------------------
  503. 函数名: OnSaveBtn
  504. 描述: 保存
  505. 参数:
  506. 返回值:
  507. ----------------------------------------*/
  508. void SatisfactionSurvey::OnSaveBtn()
  509. {
  510. int nItem = m_NameList.GetNextItem(-1, LVNI_SELECTED);
  511. CString strSql = _T("");
  512. std::vector<SSurveyData*>::iterator iter = m_SurveyData.begin();
  513. for(;iter != m_SurveyData.end();)
  514. {
  515. SSurveyData* pss = (*iter);
  516. if(pss != NULL)
  517. {
  518. int nScore = 0;
  519. std::vector<SCTRLINFO*>::iterator ii = pss->vChidCtrl.begin();
  520. for(;ii != pss->vChidCtrl.end();)
  521. {
  522. SCTRLINFO* pci = (*ii);
  523. if(pci != NULL && pci->nType == TYPE_CHECKBOX)
  524. {
  525. //计算得分
  526. ++nScore;
  527. if(pci->pCtrl != NULL && ((CButton*)pci->pCtrl)->GetCheck())
  528. break;
  529. }
  530. ++ii;
  531. }
  532. CString strSurveyLogID = _T("");
  533. strSurveyLogID.Format(_T("%d"), pss->dwSurveyLogID);
  534. CString strCfgID = _T("");
  535. strCfgID.Format(_T("%d"), pss->nCfgID);
  536. CString strScore = _T("");
  537. strScore.Format(_T("%d"), nScore);
  538. CTime ct = CTime::GetCurrentTime();
  539. CString strCurTime = ct.Format(_T("%Y-%m-%d"));
  540. if(m_nIsAddNewLog == 0)
  541. {
  542. //修改
  543. strSql = _T("UPDATE SatisfactionSurvey SET Score=") + strScore + (",SurveyTime='") + strCurTime + _T("',SurveyCS='") + g_user.name + _T("' WHERE SurveyLogID=") + strSurveyLogID;
  544. g_sendhead.bsql = 1;
  545. g_pMainWnd->ProcessChatMessageRequest2(strSql);
  546. if(g_bSendOK == 0)
  547. {
  548. MessageBox(_T(""));
  549. return;
  550. }
  551. }
  552. else
  553. {
  554. int i = 0;
  555. CString strObjID = _T("");
  556. CString strObjName = _T("");
  557. CString strName = m_NameList.GetItemText(nItem, 0);
  558. for(i=0; i<m_RYDDArr.GetSize(); i++)
  559. {
  560. if(m_RYDDArr.ElementAt(i).ElementAt(2) == strName)
  561. {
  562. strObjID = m_RYDDArr.ElementAt(i).ElementAt(0);
  563. strObjName = strName;
  564. break;
  565. }
  566. }
  567. if(strObjID == _T("") || strObjName == _T(""))
  568. {
  569. //查找订单景点
  570. int nIdx = m_KindCombox.GetCurSel();
  571. CString strType = _T("");
  572. m_KindCombox.GetLBText(nIdx, strType);
  573. if(strType != _T(""))
  574. {
  575. for(i=0; i < m_dindanjdArr.GetSize(); ++i)
  576. {
  577. if(strName == m_dindanjdArr.ElementAt(i).ElementAt(3)
  578. || strName == m_dindanjdArr.ElementAt(i).ElementAt(4)
  579. || strName == m_dindanjdArr.ElementAt(i).ElementAt(6)
  580. || strName == m_dindanjdArr.ElementAt(i).ElementAt(7))
  581. strObjName = strName;
  582. GetRenYuanIDForName(strObjName, strObjID);
  583. if(strObjID != _T("") && strObjName != _T(""))
  584. break;
  585. }
  586. }
  587. }
  588. if(strObjID == _T("") || strObjName == _T(""))
  589. {
  590. MessageBox(_T("调查对象有误!"));
  591. return;
  592. }
  593. //添加保存
  594. 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("')");
  595. g_sendhead.bsql = 1;
  596. g_pMainWnd->ProcessChatMessageRequest2(strSql);
  597. if(g_bSendOK == 0)
  598. return;
  599. }
  600. }
  601. ++iter;
  602. }
  603. if(m_nIsAddNewLog == 0)
  604. MessageBox(_T("修改成功"));
  605. else
  606. MessageBox(_T("保存成功"));
  607. m_nIsAddNewLog = 0;
  608. m_NameList.SetItemText(nItem, 1, _T("已调查"));
  609. ((CButton*)GetDlgItem(IDC_OnSave_Btn))->SetWindowText(_T("修改"));
  610. //获取当前订单的调查记录
  611. m_CurrSurveyLogs.RemoveAll();
  612. g_sendhead.bsql = 0;
  613. g_sendhead.code[0] = 234;
  614. g_sendhead.tabcount = 1;
  615. CString strfilter = _T("GetAllSurveyData@") + m_strOrderNum;
  616. g_pMainWnd->ProcessChatMessageRequest2(strfilter);
  617. if (g_bSendOK == 0)
  618. return;
  619. /*
  620. fieldArr.Add(_T("LogID")); //记录ID
  621. fieldArr.Add(_T("cfgID")); //服务配置ID
  622. fieldArr.Add(_T("KindName")); //服务类型
  623. fieldArr.Add(_T("ObjID")); //对象ID
  624. fieldArr.Add(_T("ObjName")); //对象名
  625. fieldArr.Add(_T("OrderID")); //订单ID
  626. fieldArr.Add(_T("Score")); //得分
  627. fieldArr.Add(_T("MaxScore")); //最高得分
  628. fieldArr.Add(_T("TypeID")); //显示得分类型
  629. fieldArr.Add(_T("States")); //状态
  630. fieldArr.Add(_T("SurveyTime")); //调查时间
  631. fieldArr.Add(_T("SurveyCS")); //调查客服
  632. fieldArr.Add(_T("sfncfgDesc")); //调查内容
  633. */
  634. DataToArray(&m_CurrSurveyLogs);
  635. /*
  636. for(int i=0; i<m_CurrSurveyLogs.GetSize(); i++)
  637. {
  638. for(int j=0; j<m_CurrSurveyLogs.ElementAt(i).GetSize(); j++)
  639. printf("%s\n", m_CurrSurveyLogs.ElementAt(i).ElementAt(j));
  640. printf("\n");
  641. }
  642. */
  643. }
  644. /*----------------------------------------
  645. 函数名: OnCbnSelchangeCombo1
  646. 描述: 选择类型
  647. 参数:
  648. 返回值:
  649. ----------------------------------------*/
  650. void SatisfactionSurvey::OnCbnSelchangeCombo1()
  651. {
  652. // TODO: 在此添加控件通知处理程序代码
  653. int nIdx = m_KindCombox.GetCurSel();
  654. CString strTypeName = _T("");
  655. m_KindCombox.GetLBText(nIdx, strTypeName);
  656. if(strTypeName == _T(""))
  657. {
  658. MessageBox(_T("先选择类型!"));
  659. return;
  660. }
  661. ClearSurveyData();
  662. FillGrid(strTypeName);
  663. if(m_NameList.GetItemCount() > 0)
  664. m_NameList.SetItemState(0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
  665. CString strObjName = m_NameList.GetItemText(0, 0);
  666. if(strObjName == _T(""))
  667. {
  668. MessageBox(_T("没有调查的事件!"));
  669. return;
  670. }
  671. Init(strTypeName, strObjName);
  672. }
  673. /*----------------------------------------
  674. 函数名: ClearSurveyData
  675. 描述: 清除调查数据
  676. 参数:
  677. 返回值:
  678. ----------------------------------------*/
  679. void SatisfactionSurvey::ClearSurveyData()
  680. {
  681. std::vector<SSurveyData*>::iterator iter = m_SurveyData.begin();
  682. for(;iter != m_SurveyData.end();++iter)
  683. {
  684. SSurveyData* p = (*iter);
  685. if(p == NULL)
  686. continue;
  687. std::vector<SCTRLINFO*>::iterator ii = p->vChidCtrl.begin();
  688. for(;ii != p->vChidCtrl.end();++ii)
  689. {
  690. SCTRLINFO* pi = (*ii);
  691. if(pi == NULL)
  692. continue;
  693. if(pi->pCtrl)
  694. {
  695. // pi->pCtrl->DestroyWindow();
  696. // pi->pCtrl->OnDestroy();
  697. delete pi->pCtrl;
  698. pi->pCtrl = NULL;
  699. }
  700. delete pi;
  701. }
  702. p->vChidCtrl.clear();
  703. delete p;
  704. }
  705. m_SurveyData.clear();
  706. g_nIdxCtrlID = 0;
  707. }
  708. void SatisfactionSurvey::OnSize(UINT nType, int cx, int cy)
  709. {
  710. CDialog::OnSize(nType, cx, cy);
  711. }
  712. BOOL SatisfactionSurvey::OnCommand(WPARAM wParam, LPARAM lParam)
  713. {
  714. HWND hWndCtrl = (HWND)lParam;
  715. CWnd* pCWnd = FromHandle(hWndCtrl);
  716. UINT nChidID = pCWnd->GetDlgCtrlID();
  717. SSurveyData* pSel = NULL; //勾选的调查项
  718. CButton* pSelBtn = NULL; //初选中的按钮
  719. if(nChidID >= 90001 && nChidID < 99999)
  720. {
  721. std::vector<SSurveyData*>::iterator iter = m_SurveyData.begin();
  722. for(;iter != m_SurveyData.end();)
  723. {
  724. //每条调查项
  725. SSurveyData* p = (*iter);
  726. if(p != NULL)
  727. {
  728. std::vector<SCTRLINFO*>::iterator ii = p->vChidCtrl.begin();
  729. for(;ii != p->vChidCtrl.end();)
  730. {
  731. //子控件
  732. SCTRLINFO* pci = (*ii);
  733. if(pci != NULL && pci->nType == TYPE_CHECKBOX)
  734. {
  735. CButton* pb = (CButton*)pci->pCtrl;
  736. if(pb != NULL)
  737. {
  738. // pb->SetCheck(0);
  739. if(nChidID == pci->pCtrl->GetDlgCtrlID())
  740. {
  741. //选中的控件
  742. pSel = p;
  743. pSelBtn = pb;
  744. break;
  745. }
  746. // pb->SetCheck(1);
  747. }
  748. }
  749. ++ii;
  750. }
  751. if(pSel)
  752. break;
  753. }
  754. ++iter;
  755. }
  756. if(pSel && pSelBtn)
  757. {
  758. std::vector<SCTRLINFO*>::iterator ii = pSel->vChidCtrl.begin();
  759. for(;ii != pSel->vChidCtrl.end();)
  760. {
  761. SCTRLINFO* pci = (*ii);
  762. if(pci != NULL && pci->nType == TYPE_CHECKBOX)
  763. ((CButton*)pci->pCtrl)->SetCheck(0);
  764. ++ii;
  765. }
  766. pSelBtn->SetCheck(!pSelBtn->GetCheck());
  767. pSel = NULL;
  768. pSelBtn = NULL;
  769. }
  770. }
  771. return CDialog::OnCommand(wParam, lParam);
  772. }
  773. void SatisfactionSurvey::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult)
  774. {
  775. LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
  776. // TODO: 在此添加控件通知处理程序代码
  777. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  778. if(pNMListView->iItem != -1)
  779. {
  780. //单击行列pNMListView->iItem, pNMListView->iSubItem
  781. // m_NameList.SetItemState(pNMListView->iItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
  782. CString strObjName = m_NameList.GetItemText(pNMListView->iItem, 0);
  783. int nIdx = m_KindCombox.GetCurSel();
  784. if(nIdx == -1)
  785. return;
  786. if(strObjName == _T(""))
  787. return;
  788. CString strTypeName = _T("");
  789. m_KindCombox.GetLBText(nIdx, strTypeName);
  790. ClearSurveyData();
  791. Init(strTypeName, strObjName);
  792. }
  793. *pResult = 0;
  794. }
  795. void SatisfactionSurvey::OnClose()
  796. {
  797. OnCancelBtn();
  798. }
  799. /*----------------------------------------
  800. 函数名: GetRenYuanIDForName
  801. 描述: 通过员工名获取员工ID
  802. 参数:
  803. IN CONST CString& strName, 员工名
  804. CString& strID 返回ID
  805. 返回值:
  806. ----------------------------------------*/
  807. void SatisfactionSurvey::GetRenYuanIDForName(IN CONST CString& strName, CString& strID)
  808. {
  809. for(int i=0; i<m_RenYuanArr.GetSize(); ++i)
  810. {
  811. if(strName == m_RenYuanArr.ElementAt(i).ElementAt(1))
  812. strID = m_RenYuanArr.ElementAt(i).ElementAt(0);
  813. }
  814. }