ClientForm.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. // CClientForm.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "ClientForm.h"
  6. #include "MyMdi.H"
  7. #include "SendMsgDlg.h"
  8. #include "SelBrunDevice.h"
  9. #include "SelExportType.h"
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CClientForm
  17. IMPLEMENT_DYNCREATE(CClientForm, MyFormView)
  18. CClientForm::CClientForm()
  19. : MyFormView(CClientForm::IDD)
  20. {
  21. //{{AFX_DATA_INIT(CClientForm)
  22. m_filter = _T("");
  23. //}}AFX_DATA_INIT
  24. }
  25. CClientForm::~CClientForm()
  26. {
  27. }
  28. void CClientForm::DoDataExchange(CDataExchange* pDX)
  29. {
  30. MyFormView::DoDataExchange(pDX);
  31. //{{AFX_DATA_MAP(CClientForm)
  32. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  33. DDX_Control(pDX, IDC_LIST2, m_List1);
  34. DDX_Control(pDX, IDC_STATIC1, m_static1);
  35. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  36. //}}AFX_DATA_MAP
  37. }
  38. BEGIN_MESSAGE_MAP(CClientForm, MyFormView)
  39. //{{AFX_MSG_MAP(CClientForm)
  40. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  41. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  42. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  43. ON_WM_TIMER()
  44. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  45. ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
  46. //}}AFX_MSG_MAP
  47. END_MESSAGE_MAP()
  48. /////////////////////////////////////////////////////////////////////////////
  49. // CClientForm diagnostics
  50. #ifdef _DEBUG
  51. void CClientForm::AssertValid() const
  52. {
  53. MyFormView::AssertValid();
  54. }
  55. void CClientForm::Dump(CDumpContext& dc) const
  56. {
  57. MyFormView::Dump(dc);
  58. }
  59. #endif //_DEBUG
  60. /////////////////////////////////////////////////////////////////////////////
  61. // CClientForm message handlers
  62. void CClientForm::OnInitialUpdate()
  63. {
  64. MyFormView::OnInitialUpdate();
  65. // TODO: Add your specialized code here and/or call the base class
  66. CMyMdi Mdi;
  67. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  68. m_bHideBtn = 0;
  69. if (g_dx >= 10000)
  70. {
  71. m_bHideBtn = 1;
  72. g_dx -= 10000;
  73. }
  74. // Here we create the outbar control using the splitter as its parent
  75. // and setting its id to the first pane.
  76. CRect rc2;
  77. GetWindowRect(rc2);
  78. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  79. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  80. if (m_bHideBtn)
  81. {
  82. CRect rc, rc2;
  83. // GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE);
  84. GetDlgItem(IDC_BUTTON2)->SetWindowText("导出");
  85. GetDlgItem(IDC_BUTTON2)->EnableWindow(IsHasRights2new(49));
  86. GetDlgItem(IDC_BUTTON3)->ShowWindow(SW_HIDE);
  87. GetDlgItem(IDC_BUTTON3)->GetWindowRect(rc);
  88. ScreenToClient(rc);
  89. GetDlgItem(IDC_BUTTON1)->GetWindowRect(rc2);
  90. ScreenToClient(rc2);
  91. rc2.right -= rc2.right - rc.right;
  92. rc2.left = rc.left;
  93. GetDlgItem(IDC_BUTTON1)->MoveWindow(rc2);
  94. m_static1.SetWindowText("订单客户");
  95. }
  96. m_static1.SetFont(&g_titlefont);
  97. #ifdef CHILD_VERSION
  98. m_List1.SetHeadings("订单号,100;家长姓名,100;宝宝姓名,100;手机,100;固定电话,100;地址,100;地区,100;宝宝生日,100;QQ,100;套系名称,100;套系价格,100");
  99. #else
  100. m_List1.SetHeadings("订单号,100;男宾姓名,100;女宾姓名,100;男宾电话,100;女宾电话,100;男宾地址,100;女宾地址,100;男宾地区,100;女宾地区,100;男宾生日,100;女宾生日,100;男宾QQ,100;女宾QQ,100;套系名称,100;套系价格,100" );
  101. #endif
  102. m_List1.LoadColumnInfo(108);
  103. g_sendhead.bsql = 0;
  104. g_sendhead.code[0] = 15;
  105. g_sendhead.code[1] = 6;
  106. g_sendhead.tabcount = 2;
  107. g_pMainWnd->ProcessChatMessageRequest2(15); if (g_bSendOK == 0)return;
  108. DataToArray(&m_List1array, &g_List1array); HidePrice();
  109. for (int i = 0; i < g_List1array.GetSize(); i++)
  110. {
  111. if (m_combo1.FindString(0, g_List1array.ElementAt(i).ElementAt(1)) == -1)
  112. m_combo1.AddString(g_List1array.ElementAt(i).ElementAt(1));
  113. }
  114. FillGrid();
  115. m_combo1.GetWindowRect(rc2);
  116. ScreenToClient(rc2);
  117. rc2.bottom += 200;
  118. m_combo1.MoveWindow(rc2);
  119. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  120. SetComboHei(&m_combo1, rc2.Height());
  121. }
  122. void CClientForm::FillGrid(int mode)
  123. {
  124. UpdateData();
  125. m_List1.DeleteAllItems2();
  126. int ii = 0;
  127. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  128. int count = 0;
  129. #ifdef CHILD_VERSION
  130. if (!m_area.IsEmpty())
  131. {
  132. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  133. {
  134. if (m_List1array.ElementAt(ii).ElementAt(6) == m_area)
  135. {
  136. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  137. }
  138. }
  139. }
  140. else
  141. {
  142. if (m_filter.IsEmpty())
  143. {
  144. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  145. {
  146. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  147. }
  148. }
  149. else
  150. {
  151. int type = GetType(m_filter);
  152. if (type == 1)//电话
  153. {
  154. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  155. {
  156. if (m_List1array.ElementAt(ii).ElementAt(3).Find(m_filter) != -1 || \
  157. m_List1array.ElementAt(ii).ElementAt(4).Find(m_filter) != -1)
  158. {
  159. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  160. }
  161. }
  162. }
  163. else if (type == 2)//拼音
  164. {
  165. m_filter.MakeUpper();
  166. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  167. {
  168. if (m_List1array.ElementAt(ii).ElementAt(11).Find(m_filter) != -1 || \
  169. m_List1array.ElementAt(ii).ElementAt(12).Find(m_filter) != -1)
  170. {
  171. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  172. }
  173. }
  174. }
  175. else
  176. {
  177. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  178. {
  179. if (m_List1array.ElementAt(ii).ElementAt(0).Find(m_filter) != -1 || \
  180. m_List1array.ElementAt(ii).ElementAt(1).Find(m_filter) != -1 || \
  181. m_List1array.ElementAt(ii).ElementAt(2).Find(m_filter) != -1 || \
  182. m_List1array.ElementAt(ii).ElementAt(3).Find(m_filter) != -1 || \
  183. m_List1array.ElementAt(ii).ElementAt(4).Find(m_filter) != -1 || \
  184. m_List1array.ElementAt(ii).ElementAt(9).Find(m_filter) != -1)
  185. {
  186. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  187. }
  188. }
  189. }
  190. }
  191. }
  192. #else
  193. if(!m_area.IsEmpty ())
  194. {
  195. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  196. {
  197. if(m_List1array.ElementAt (ii).ElementAt (7)==m_area || \
  198. m_List1array.ElementAt (ii).ElementAt (8)==m_area)
  199. {
  200. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  201. }
  202. }
  203. }
  204. else
  205. {
  206. if(m_filter.IsEmpty ())
  207. {
  208. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  209. {
  210. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  211. }
  212. }
  213. else
  214. {
  215. int type=GetType(m_filter);
  216. if(type==1)//电话
  217. {
  218. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  219. {
  220. if(m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1 || \
  221. m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1)
  222. {
  223. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  224. }
  225. }
  226. }
  227. else if(type==2)//拼音
  228. {
  229. m_filter.MakeUpper ();
  230. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  231. {
  232. if(m_List1array.ElementAt (ii).ElementAt (15).Find (m_filter)!=-1 || \
  233. m_List1array.ElementAt (ii).ElementAt (16).Find (m_filter)!=-1)
  234. {
  235. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  236. }
  237. }
  238. }
  239. else
  240. {
  241. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  242. {
  243. if(m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 || \
  244. m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 ||\
  245. m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 ||\
  246. m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1 ||\
  247. m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1 ||\
  248. m_List1array.ElementAt (ii).ElementAt (13).Find (m_filter)!=-1)
  249. {
  250. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  251. }
  252. }
  253. }
  254. }
  255. }
  256. #endif
  257. m_List1.m_arLabels.SetSize(count, 1);
  258. ii = count;
  259. m_List1.m_LabelCount = ii;
  260. m_List1.SetItemCountEx(ii);
  261. }
  262. void CClientForm::OnBUTclose()
  263. {
  264. // TODO: Add your control notification handler code here
  265. GetParent()->SendMessage(WM_CLOSE);
  266. }
  267. void CClientForm::OnSelchangeCombo1()
  268. {
  269. // TODO: Add your control notification handler code here
  270. SetTimer(1, 100, NULL);
  271. }
  272. void CClientForm::OnTimer(UINT nIDEvent)
  273. {
  274. // TODO: Add your message handler code here and/or call default
  275. KillTimer(nIDEvent);
  276. OnButton1();
  277. }
  278. BOOL CClientForm::PreTranslateMessage(MSG* pMsg)
  279. {
  280. // TODO: Add your specialized code here and/or call the base class
  281. try
  282. {
  283. if (pMsg->message == WM_KEYDOWN)
  284. {
  285. switch (pMsg->wParam)
  286. {
  287. case VK_RETURN:
  288. OnButton1();
  289. return 1;
  290. case 0x43: // copy
  291. if ((GetKeyState(VK_CONTROL) & 0x80))
  292. {
  293. GetFocus()->SendMessage(WM_COPY);
  294. return TRUE;
  295. }
  296. break;
  297. case 0x56: //Ctrl + V:
  298. if ((GetKeyState(VK_CONTROL) & 0x80))
  299. {
  300. GetFocus()->SendMessage(WM_PASTE);
  301. return TRUE;
  302. }
  303. break;
  304. case 0x58: // cut
  305. if ((GetKeyState(VK_CONTROL) & 0x80))
  306. {
  307. GetFocus()->SendMessage(WM_CUT);
  308. return TRUE;
  309. }
  310. break;
  311. case 0x5A: //undo
  312. case 0x59: //redo
  313. if ((GetKeyState(VK_CONTROL) & 0x80))
  314. {
  315. GetFocus()->SendMessage(WM_UNDO);
  316. return TRUE;
  317. }
  318. break;
  319. }
  320. }
  321. return MyFormView::PreTranslateMessage(pMsg);
  322. }
  323. catch (...)
  324. {
  325. }
  326. }
  327. void CClientForm::OnButton1()
  328. {
  329. // TODO: Add your control notification handler code here
  330. UpdateData();
  331. m_filter.TrimLeft();
  332. m_filter.TrimRight();
  333. m_area.Empty();
  334. FillGrid();
  335. }
  336. void CClientForm::OnButton2()
  337. {
  338. // TODO: Add your control notification handler code here
  339. if (m_bHideBtn)
  340. {
  341. GetClientPhone();
  342. return;
  343. }
  344. POSITION pos;
  345. pos = m_List1.GetFirstSelectedItemPosition();
  346. if (pos == NULL)
  347. {
  348. AfxMessageBox("请先选中您要发送短信的客人!", MB_ICONINFORMATION);
  349. return;
  350. }
  351. int iItem;
  352. CStringArray array;
  353. while (pos)
  354. {
  355. iItem = m_List1.GetNextSelectedItem(pos);
  356. array.Add(m_List1.GetItemText(iItem, 3));
  357. array.Add(m_List1.GetItemText(iItem, 4));
  358. }
  359. SendMsgDlg dlg;
  360. dlg.m_pArray = &array;
  361. dlg.DoModal();
  362. }
  363. void CClientForm::OnButton3()
  364. {
  365. // TODO: Add your control notification handler code here
  366. g_sendhead.bsql = 0;
  367. g_sendhead.code[0] = 82;
  368. g_sendhead.tabcount = 1;
  369. g_pMainWnd->ProcessChatMessageRequest2(1);
  370. if (g_bSendOK == 0)
  371. {
  372. return;
  373. }
  374. CArray<CStringArray, CStringArray>m_List1array;
  375. DataToArray(&m_List1array); HidePrice();
  376. if (m_List1array.GetSize() == 0)return;
  377. CStringArray array;
  378. for (int i = 0; i < m_List1array.GetSize(); i++)
  379. {
  380. array.Add(m_List1array.ElementAt(i).ElementAt(0));
  381. }
  382. SelBrunDevice dlg;
  383. dlg.pArray = &array;
  384. if (dlg.DoModal() == IDOK)
  385. {
  386. m_area = array.ElementAt(dlg.m_sel);
  387. FillGrid();
  388. }
  389. }
  390. void CClientForm::GetClientPhone()
  391. {
  392. SelExportType dlg;
  393. if (dlg.DoModal() != IDOK)return;
  394. if (dlg.m_type == 1)
  395. {
  396. ListToXLS(&m_List1, "c:\\客户资料.xls", 0);
  397. return;
  398. }
  399. #ifdef CHILD_VERSION
  400. CStdioFile fp;
  401. fp.Open("c:\\clientphone.txt", CFile::modeCreate | CFile::modeWrite);
  402. CString str;
  403. CString str1, str2, str3, str4, str5, str6, str7, str8, str9, str10, str11;
  404. CString phone;
  405. CString txname, txprice, mensi;
  406. int leng1 = 20;
  407. int leng2 = 20;
  408. int leng3 = 20;
  409. int leng4 = 20;
  410. int leng5 = 15;
  411. int leng6 = 15;
  412. int leng7 = 15;
  413. int leng8 = 15;
  414. int leng9 = 15;
  415. int leng10 = 15;
  416. int leng11 = 15;
  417. str1 = "家长姓名";
  418. str2 = "宝宝姓名";
  419. str3 = "手机";
  420. str4 = "电话";
  421. str5 = "QQ";
  422. str6 = "宝宝生日";
  423. str7 = "套系";
  424. str8 = "金额";
  425. FillLength(str1, leng1);
  426. FillLength(str2, leng2);
  427. FillLength(str3, leng3);
  428. FillLength(str4, leng4);
  429. FillLength(str5, leng5);
  430. FillLength(str6, leng6);
  431. FillLength(str7, leng7);
  432. FillLength(str8, leng8);
  433. str = str1 + str2 + str3 + str4 + str5 + str6 + str7 + str8 + "\n";
  434. fp.WriteString(str);
  435. for (int i = 0; i < m_List1.GetItemCount(); i++)
  436. {
  437. str1 = m_List1.GetItemText(i, 1);
  438. str2 = m_List1.GetItemText(i, 2);
  439. str3 = m_List1.GetItemText(i, 3);
  440. str4 = m_List1.GetItemText(i, 4);
  441. str5 = m_List1.GetItemText(i, 8);
  442. str6 = m_List1.GetItemText(i, 7);
  443. str7 = m_List1.GetItemText(i, 9);
  444. str8 = m_List1.GetItemText(i, 10);
  445. FillLength(str1, leng1);
  446. FillLength(str2, leng2);
  447. FillLength(str3, leng3);
  448. FillLength(str4, leng4);
  449. FillLength(str5, leng5);
  450. FillLength(str6, leng6);
  451. FillLength(str7, leng7);
  452. FillLength(str8, leng8);
  453. str = str1 + str2 + str3 + str4 + str5 + str6 + str7 + str8 + "\n";
  454. fp.WriteString(str);
  455. }
  456. fp.Close();
  457. MessageBox("电话已保存到c:\\clientphone.txt");
  458. ShellExecute(NULL, _T("open"), _T("c:\\clientphone.txt"), NULL, NULL, SW_SHOWMAXIMIZED);
  459. #else
  460. CStdioFile fp;
  461. fp.Open ("c:\\clientphone.txt", CFile::modeCreate|CFile::modeWrite);
  462. CString str;
  463. CString str1,str2,str3,str4,str5,str6,str7,str8,str9,str10,str11;
  464. CString phone;
  465. CString txname,txprice,mensi;
  466. int leng1=15;
  467. int leng2=15;
  468. int leng3=18;
  469. int leng4=18;
  470. int leng5=15;
  471. int leng6=15;
  472. int leng7=15;
  473. int leng8=15;
  474. int leng9=20;
  475. int leng10=15;
  476. str1="男宾";
  477. str2="女宾";
  478. str3="男宾电话";
  479. str4="女宾电话";
  480. str5="男宾QQ";
  481. str6="女宾QQ";
  482. str7="男宾生日";
  483. str8="女宾生日";
  484. str9="套系";
  485. str10="金额";
  486. FillLength(str1, leng1);
  487. FillLength(str2, leng2);
  488. FillLength(str3, leng3);
  489. FillLength(str4, leng4);
  490. FillLength(str5, leng5);
  491. FillLength(str6, leng6);
  492. FillLength(str7, leng7);
  493. FillLength(str8, leng8);
  494. FillLength(str9, leng9);
  495. FillLength(str10,leng10);
  496. str=str1+str2+str3+str4+str5+str6+str7+str8+str9+str10+"\n";
  497. fp.WriteString (str);
  498. for(int i=0; i<m_List1.GetItemCount (); i++)
  499. {
  500. str1=m_List1.GetItemText (i, 1);
  501. str2=m_List1.GetItemText (i, 2);
  502. str3=m_List1.GetItemText (i, 3);
  503. str4=m_List1.GetItemText (i, 4);
  504. str5=m_List1.GetItemText (i, 11);
  505. str6=m_List1.GetItemText (i, 12);
  506. str7=m_List1.GetItemText (i, 9);
  507. str8=m_List1.GetItemText (i, 10);
  508. str9=m_List1.GetItemText (i, 13);
  509. str10=m_List1.GetItemText (i, 14);
  510. FillLength(str1, leng1);
  511. FillLength(str2, leng2);
  512. FillLength(str3, leng3);
  513. FillLength(str4, leng4);
  514. FillLength(str5, leng5);
  515. FillLength(str6, leng6);
  516. FillLength(str7, leng7);
  517. FillLength(str8, leng8);
  518. FillLength(str9, leng9);
  519. FillLength(str10,leng10);
  520. str=str1+str2+str3+str4+str5+str6+str7+str8+str9+str10+"\n";
  521. fp.WriteString (str);
  522. }
  523. fp.Close ();
  524. MessageBox("电话已保存到c:\\clientphone.txt");
  525. ShellExecute(NULL, _T("open"), _T("c:\\clientphone.txt"), NULL, NULL, SW_SHOWMAXIMIZED);
  526. #endif
  527. }
  528. void CClientForm::HidePrice()
  529. {
  530. #ifdef LKAY_VERSION
  531. if(!m_bHideBtn)return;
  532. if(IsHasRights2new(31))return;
  533. for(int i=0; i< m_List1array.GetSize (); i++)
  534. {
  535. m_List1array.ElementAt (i).SetAt (3, "***");
  536. m_List1array.ElementAt (i).SetAt (4, "***");
  537. m_List1array.ElementAt (i).SetAt (9, "***");
  538. m_List1array.ElementAt (i).SetAt (10, "***");
  539. }
  540. #else
  541. if (!m_bHideBtn)return;
  542. if (IsHasRights2new(31))return;
  543. for (int i = 0; i < m_List1array.GetSize(); i++)
  544. {
  545. m_List1array.ElementAt(i).SetAt(9, "***");
  546. m_List1array.ElementAt(i).SetAt(10, "***");
  547. }
  548. #endif
  549. }