OldClient.cpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  1. // OldClient.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "OldClient.h"
  6. #include "MyMdi.H"
  7. #include "ModifyDinDan.h"
  8. #include "NeroDlg.h"
  9. #include "ClientRequirement.h"
  10. #include "./helper/ffsco.h"
  11. #include "AddOldClient.h"
  12. #include "AddOldClient2.h"
  13. #include "SendMsgDlg.h"
  14. #include "BasicExcelVC6.h"
  15. #include "Lzari.h"
  16. #include "SelExportType.h"
  17. #ifdef _DEBUG
  18. #define new DEBUG_NEW
  19. #undef THIS_FILE
  20. static char THIS_FILE[] = __FILE__;
  21. #endif
  22. /////////////////////////////////////////////////////////////////////////////
  23. // OldClient
  24. IMPLEMENT_DYNCREATE(OldClient, MyFormView)
  25. OldClient::OldClient()
  26. : MyFormView(OldClient::IDD)
  27. {
  28. //{{AFX_DATA_INIT(OldClient)
  29. m_filter = _T("");
  30. //}}AFX_DATA_INIT
  31. }
  32. OldClient::~OldClient()
  33. {
  34. }
  35. void OldClient::DoDataExchange(CDataExchange* pDX)
  36. {
  37. MyFormView::DoDataExchange(pDX);
  38. //{{AFX_DATA_MAP(OldClient)
  39. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  40. DDX_Control(pDX, IDC_LIST2, m_List1);
  41. DDX_Control(pDX, IDC_STATIC1, m_static1);
  42. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  43. //}}AFX_DATA_MAP
  44. }
  45. BEGIN_MESSAGE_MAP(OldClient, MyFormView)
  46. //{{AFX_MSG_MAP(OldClient)
  47. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  48. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  49. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  50. ON_WM_TIMER()
  51. ON_BN_CLICKED(IDC_BUTburncd, OnBUTOldClient)
  52. ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2)
  53. ON_BN_CLICKED(IDC_BUTburncd2, OnBUTburncd2)
  54. ON_BN_CLICKED(IDC_BUTburncd3, OnBUTburncd3)
  55. ON_BN_CLICKED(IDC_BUTsendmsg, OnBUTsendmsg)
  56. ON_BN_CLICKED(IDC_BUTprint3, OnBUTprint3)
  57. ON_BN_CLICKED(IDC_BUTimport, OnBUTimport)
  58. //}}AFX_MSG_MAP
  59. END_MESSAGE_MAP()
  60. /////////////////////////////////////////////////////////////////////////////
  61. // OldClient diagnostics
  62. #ifdef _DEBUG
  63. void OldClient::AssertValid() const
  64. {
  65. MyFormView::AssertValid();
  66. }
  67. void OldClient::Dump(CDumpContext& dc) const
  68. {
  69. MyFormView::Dump(dc);
  70. }
  71. #endif //_DEBUG
  72. /////////////////////////////////////////////////////////////////////////////
  73. // OldClient message handlers
  74. void OldClient::OnInitialUpdate()
  75. {
  76. MyFormView::OnInitialUpdate();
  77. GetDlgItem(IDC_BUTburncd3)->EnableWindow(IsHasRights2new(49));
  78. GetDlgItem(IDC_BUTprint3)->EnableWindow(IsHasRights2new(49));
  79. // TODO: Add your specialized code here and/or call the base class
  80. CMyMdi Mdi;
  81. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  82. // Here we create the outbar control using the splitter as its parent
  83. // and setting its id to the first pane.
  84. CRect rc2;
  85. GetWindowRect(rc2);
  86. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  87. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  88. int idarray[] = { IDC_BUTburncd, IDC_BUTburncd2, IDC_BUTburncd3, IDC_BUTimport, IDC_BUTsendmsg, IDC_BUTprint3, IDC_BUTclose };
  89. int idcount = 7;
  90. int btnwid;
  91. CRect prerc;
  92. for (int a = idcount - 2; a >= 0; a--)
  93. {
  94. GetDlgItem(idarray[a + 1])->GetWindowRect(prerc);
  95. ScreenToClient(prerc);
  96. GetDlgItem(idarray[a])->GetWindowRect(rc2);
  97. ScreenToClient(rc2);
  98. btnwid = rc2.Width();
  99. rc2.right = prerc.left;
  100. rc2.left = rc2.right - btnwid;
  101. GetDlgItem(idarray[a])->MoveWindow(rc2);
  102. }
  103. m_static1.SetFont(&g_titlefont);
  104. #ifdef CHILD_VERSION
  105. m_List1.SetHeadings("id,0;家长姓名,100;宝宝姓名,100;宝宝性别,100;电话,100;QQ,100;宝宝生日,100;套系,100;金额,100;订单日期,100;录入日期,100;录单,100");
  106. #else
  107. m_List1.SetHeadings("id,0;男宾姓名,100;女宾姓名,100;男宾电话,100;女宾电话,100;男宾QQ,100;女宾QQ,100;男宾生日,100;女宾生日,100;婚期,100;套系,100;金额,100;订单日期,100;录入日期,100;录单,100" );
  108. #endif
  109. m_List1.LoadColumnInfo(171);
  110. GetData();
  111. m_combo1.GetWindowRect(rc2);
  112. ScreenToClient(rc2);
  113. rc2.bottom += 200;
  114. m_combo1.MoveWindow(rc2);
  115. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  116. SetComboHei(&m_combo1, rc2.Height());
  117. }
  118. void OldClient::FillGrid()
  119. {
  120. m_List1.DeleteAllItems2();
  121. int ii = 0;
  122. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  123. int count = 0;
  124. #ifdef CHILD_VERSION
  125. if (m_filter.IsEmpty())
  126. {
  127. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  128. {
  129. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  130. }
  131. }
  132. else
  133. {
  134. int type = GetType(m_filter);
  135. if (type == 1)//电话
  136. {
  137. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  138. {
  139. if (m_List1array.ElementAt(ii).ElementAt(4).Find(m_filter) != -1)
  140. {
  141. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  142. }
  143. }
  144. }
  145. else if (type == 2)//拼音
  146. {
  147. m_filter.MakeUpper();
  148. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  149. {
  150. if (m_List1array.ElementAt(ii).ElementAt(12).Find(m_filter) != -1 || m_List1array.ElementAt(ii).ElementAt(13).Find(m_filter) != -1)
  151. {
  152. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  153. }
  154. }
  155. }
  156. else
  157. {
  158. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  159. {
  160. if (m_List1array.ElementAt(ii).ElementAt(0).Find(m_filter) != -1 || \
  161. m_List1array.ElementAt(ii).ElementAt(1).Find(m_filter) != -1 || \
  162. m_List1array.ElementAt(ii).ElementAt(2).Find(m_filter) != -1 || \
  163. m_List1array.ElementAt(ii).ElementAt(3).Find(m_filter) != -1 || \
  164. m_List1array.ElementAt(ii).ElementAt(4).Find(m_filter) != -1 || \
  165. m_List1array.ElementAt(ii).ElementAt(5).Find(m_filter) != -1 || \
  166. m_List1array.ElementAt(ii).ElementAt(6).Find(m_filter) != -1 || \
  167. m_List1array.ElementAt(ii).ElementAt(7).Find(m_filter) != -1 || \
  168. m_List1array.ElementAt(ii).ElementAt(8).Find(m_filter) != -1 || \
  169. m_List1array.ElementAt(ii).ElementAt(9).Find(m_filter) != -1 || \
  170. m_List1array.ElementAt(ii).ElementAt(10).Find(m_filter) != -1 || \
  171. m_List1array.ElementAt(ii).ElementAt(11).Find(m_filter) != -1 || \
  172. m_List1array.ElementAt(ii).ElementAt(12).Find(m_filter) != -1)
  173. {
  174. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  175. }
  176. }
  177. }
  178. }
  179. #else
  180. if(m_filter.IsEmpty ())
  181. {
  182. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  183. {
  184. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  185. }
  186. }
  187. else
  188. {
  189. int type=GetType(m_filter);
  190. if(type==1)//电话
  191. {
  192. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  193. {
  194. if(m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1 || m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1)
  195. {
  196. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  197. }
  198. }
  199. }
  200. else if(type==2)//拼音
  201. {
  202. m_filter.MakeUpper ();
  203. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  204. {
  205. if(m_List1array.ElementAt (ii).ElementAt (15).Find (m_filter)!=-1 || m_List1array.ElementAt (ii).ElementAt (16).Find (m_filter)!=-1)
  206. {
  207. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  208. }
  209. }
  210. }
  211. else
  212. {
  213. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  214. {
  215. if(m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 ||\
  216. m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 || \
  217. m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 || \
  218. m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1|| \
  219. m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1|| \
  220. m_List1array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1 || \
  221. m_List1array.ElementAt (ii).ElementAt (6).Find (m_filter)!=-1 || \
  222. m_List1array.ElementAt (ii).ElementAt (7).Find (m_filter)!=-1 || \
  223. m_List1array.ElementAt (ii).ElementAt (8).Find (m_filter)!=-1|| \
  224. m_List1array.ElementAt (ii).ElementAt (9).Find (m_filter)!=-1 || \
  225. m_List1array.ElementAt (ii).ElementAt (10).Find (m_filter)!=-1 || \
  226. m_List1array.ElementAt (ii).ElementAt (11).Find (m_filter)!=-1 || \
  227. m_List1array.ElementAt (ii).ElementAt (12).Find (m_filter)!=-1 || \
  228. m_List1array.ElementAt (ii).ElementAt (13).Find (m_filter)!=-1 || \
  229. m_List1array.ElementAt (ii).ElementAt (14).Find (m_filter)!=-1 )
  230. {
  231. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  232. }
  233. }
  234. }
  235. }
  236. #endif
  237. m_List1.m_arLabels.SetSize(count, 1);
  238. ii = count;
  239. m_List1.m_LabelCount = ii;
  240. m_List1.SetItemCountEx(ii);
  241. CString str;
  242. str.Format("客人:%d", ii);
  243. SetDlgItemText(IDC_STATIC2, str);
  244. CRect rc;
  245. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  246. ScreenToClient(rc);
  247. InvalidateRect(rc);
  248. }
  249. void OldClient::OnBUTclose()
  250. {
  251. // TODO: Add your control notification handler code here
  252. GetParent()->SendMessage(WM_CLOSE);
  253. }
  254. void OldClient::OnSelchangeCombo1()
  255. {
  256. // TODO: Add your control notification handler code here
  257. SetTimer(1, 100, NULL);
  258. }
  259. void OldClient::OnTimer(UINT nIDEvent)
  260. {
  261. // TODO: Add your message handler code here and/or call default
  262. KillTimer(nIDEvent);
  263. OnButton1();
  264. }
  265. BOOL OldClient::PreTranslateMessage(MSG* pMsg)
  266. {
  267. // TODO: Add your specialized code here and/or call the base class
  268. try
  269. {
  270. if (pMsg->message == WM_KEYDOWN)
  271. {
  272. switch (pMsg->wParam)
  273. {
  274. case VK_RETURN:
  275. OnButton1();
  276. return 1;
  277. case 0x43: // copy
  278. if ((GetKeyState(VK_CONTROL) & 0x80))
  279. {
  280. GetFocus()->SendMessage(WM_COPY);
  281. return TRUE;
  282. }
  283. break;
  284. case 0x56: //Ctrl + V:
  285. if ((GetKeyState(VK_CONTROL) & 0x80))
  286. {
  287. GetFocus()->SendMessage(WM_PASTE);
  288. return TRUE;
  289. }
  290. break;
  291. case 0x58: // cut
  292. if ((GetKeyState(VK_CONTROL) & 0x80))
  293. {
  294. GetFocus()->SendMessage(WM_CUT);
  295. return TRUE;
  296. }
  297. break;
  298. case 0x5A: //undo
  299. case 0x59: //redo
  300. if ((GetKeyState(VK_CONTROL) & 0x80))
  301. {
  302. GetFocus()->SendMessage(WM_UNDO);
  303. return TRUE;
  304. }
  305. break;
  306. }
  307. }
  308. return MyFormView::PreTranslateMessage(pMsg);
  309. }
  310. catch (...)
  311. {
  312. }
  313. return TRUE;
  314. }
  315. void OldClient::OnButton1()
  316. {
  317. // TODO: Add your control notification handler code here
  318. UpdateData();
  319. m_filter.TrimLeft();
  320. m_filter.TrimRight();
  321. FillGrid();
  322. }
  323. void OldClient::OnBUTOldClient()
  324. {
  325. // TODO: Add your control notification handler code here
  326. #ifdef CHILD_VERSION
  327. AddOldClient2 dlg;
  328. #else
  329. AddOldClient dlg;
  330. #endif
  331. if (dlg.DoModal() == IDOK)GetData();
  332. }
  333. void OldClient::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
  334. {
  335. // TODO: Add your control notification handler code here
  336. POSITION pos;
  337. pos = m_List1.GetFirstSelectedItemPosition();
  338. if (pos == NULL)return;
  339. OnBUTburncd2();
  340. *pResult = 0;
  341. }
  342. void OldClient::OnBUTburncd2() // 修改客户信息;
  343. {
  344. // TODO: Add your control notification handler code here
  345. POSITION pos;
  346. pos = m_List1.GetFirstSelectedItemPosition();
  347. if (pos == NULL)
  348. {
  349. AfxMessageBox("请先选中您要修改的客户!", MB_ICONINFORMATION);
  350. return;
  351. }
  352. int iItem = m_List1.GetNextSelectedItem(pos);
  353. #ifdef CHILD_VERSION
  354. AddOldClient2 dlg;
  355. #else
  356. AddOldClient dlg;
  357. #endif
  358. dlg.m_bAdd = 0;
  359. dlg.id = m_List1.GetItemText(iItem, 0);
  360. if (dlg.DoModal() == IDOK)GetData();
  361. }
  362. void OldClient::OnBUTburncd3()
  363. {
  364. // TODO: Add your control notification handler code here
  365. POSITION pos;
  366. pos = m_List1.GetFirstSelectedItemPosition();
  367. if (pos == NULL)
  368. {
  369. AfxMessageBox("请先选中您要删除的客户!", MB_ICONINFORMATION);
  370. return;
  371. }
  372. int iItem = m_List1.GetNextSelectedItem(pos);
  373. CString id = m_List1.GetItemText(iItem, 0);
  374. if (AfxMessageBox("确认删除吗?", MB_YESNO | MB_ICONINFORMATION) != IDYES)return;
  375. CString sql;
  376. sql.Format("delete from client3 where id=%d ", atoi(id));
  377. g_sendhead.bsql = 1;
  378. g_pMainWnd->ProcessChatMessageRequest2(sql); if (g_bSendOK == 0)return;
  379. GetData();
  380. }
  381. void OldClient::OnBUTsendmsg()
  382. {
  383. // TODO: Add your control notification handler code here
  384. POSITION pos;
  385. pos = m_List1.GetFirstSelectedItemPosition();
  386. if (pos == NULL)
  387. {
  388. AfxMessageBox("请先选中您要发送短信的客人!", MB_ICONINFORMATION);
  389. return;
  390. }
  391. int iItem;
  392. CStringArray array;
  393. while (pos)
  394. {
  395. iItem = m_List1.GetNextSelectedItem(pos);
  396. #ifndef CHILD_VERSION
  397. if(!m_List1.GetItemText (iItem, 3).IsEmpty ())
  398. array.Add (m_List1.GetItemText (iItem, 3));
  399. #endif
  400. if (!m_List1.GetItemText(iItem, 4).IsEmpty())
  401. array.Add(m_List1.GetItemText(iItem, 4));
  402. }
  403. SendMsgDlg dlg;
  404. dlg.m_mode = 2;
  405. dlg.m_pArray = &array;
  406. dlg.DoModal();
  407. }
  408. void OldClient::OnBUTprint3() // 按钮:导出按钮;
  409. {
  410. // TODO: Add your control notification handler code here
  411. SelExportType dlg;
  412. if (dlg.DoModal() != IDOK)return;
  413. if (dlg.m_type == 1)
  414. {
  415. ListToXLS(&m_List1, "c:\\客户资料.xls", 0);
  416. return;
  417. }
  418. #ifdef CHILD_VERSION
  419. CStdioFile fp;
  420. fp.Open("c:\\clientphone.txt", CFile::modeCreate | CFile::modeWrite);
  421. CString str;
  422. CString str1, str2, str3, str4, str5, str6, str7, str8, str9, str10, str11;
  423. CString phone;
  424. CString txname, txprice, mensi;
  425. int leng1 = 15;
  426. int leng2 = 15;
  427. int leng3 = 15;
  428. int leng4 = 18;
  429. int leng5 = 15;
  430. int leng6 = 15;
  431. int leng7 = 15;
  432. int leng8 = 15;
  433. int leng9 = 15;
  434. int leng10 = 15;
  435. int leng11 = 15;
  436. str1 = "家长姓名";
  437. str2 = "宝宝姓名";
  438. str3 = "宝宝性别";
  439. str4 = "电话";
  440. str5 = "QQ";
  441. str6 = "宝宝生日";
  442. str7 = "套系";
  443. str8 = "金额";
  444. str9 = "订单日期";
  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. FillLength(str9, leng9);
  454. str = str1 + str2 + str3 + str4 + str5 + str6 + str7 + str8 + str9 + "\n";
  455. fp.WriteString(str);
  456. for (int i = 0; i < m_List1.GetItemCount(); i++)
  457. {
  458. str1 = m_List1.GetItemText(i, 1);
  459. str2 = m_List1.GetItemText(i, 2);
  460. str3 = m_List1.GetItemText(i, 3);
  461. str4 = m_List1.GetItemText(i, 4);
  462. str5 = m_List1.GetItemText(i, 5);
  463. str6 = m_List1.GetItemText(i, 6);
  464. str7 = m_List1.GetItemText(i, 7);
  465. str8 = m_List1.GetItemText(i, 8);
  466. str9 = m_List1.GetItemText(i, 9);
  467. FillLength(str1, leng1);
  468. FillLength(str2, leng2);
  469. FillLength(str3, leng3);
  470. FillLength(str4, leng4);
  471. FillLength(str5, leng5);
  472. FillLength(str6, leng6);
  473. FillLength(str7, leng7);
  474. FillLength(str8, leng8);
  475. FillLength(str9, leng9);
  476. str = str1 + str2 + str3 + str4 + str5 + str6 + str7 + str8 + str9 + "\n";
  477. fp.WriteString(str);
  478. }
  479. fp.Close();
  480. MessageBox("电话已保存到c:\\clientphone.txt");
  481. ShellExecute(NULL, _T("open"), _T("c:\\clientphone.txt"), NULL, NULL, SW_SHOWMAXIMIZED);
  482. #else
  483. CStdioFile fp;
  484. fp.Open ("c:\\clientphone.txt", CFile::modeCreate|CFile::modeWrite);
  485. CString str;
  486. CString str1,str2,str3,str4,str5,str6,str7,str8,str9,str10,str11;
  487. CString phone;
  488. CString txname,txprice,mensi;
  489. int leng1=10;
  490. int leng2=10;
  491. int leng3=18;
  492. int leng4=18;
  493. int leng5=15;
  494. int leng6=15;
  495. int leng7=15;
  496. int leng8=15;
  497. int leng9=15;
  498. int leng10=15;
  499. int leng11=15;
  500. str1="男宾";
  501. str2="女宾";
  502. str3="男宾电话";
  503. str4="女宾电话";
  504. str5="男宾QQ";
  505. str6="女宾QQ";
  506. str7="男宾生日";
  507. str8="女宾生日";
  508. str9="婚期";
  509. str10="套系";
  510. str11="金额";
  511. FillLength(str1, leng1);
  512. FillLength(str2, leng2);
  513. FillLength(str3, leng3);
  514. FillLength(str4, leng4);
  515. FillLength(str5, leng5);
  516. FillLength(str6, leng6);
  517. FillLength(str7, leng7);
  518. FillLength(str8, leng8);
  519. FillLength(str9, leng9);
  520. FillLength(str10,leng10);
  521. FillLength(str11,leng11);
  522. str=str1+str2+str3+str4+str5+str6+str7+str8+str9+str10+str11+"\n";
  523. fp.WriteString (str);
  524. for(int i=0; i<m_List1.GetItemCount (); i++)
  525. {
  526. str1=m_List1.GetItemText (i, 1);
  527. str2=m_List1.GetItemText (i, 2);
  528. str3=m_List1.GetItemText (i, 3);
  529. str4=m_List1.GetItemText (i, 4);
  530. str5=m_List1.GetItemText (i, 5);
  531. str6=m_List1.GetItemText (i, 6);
  532. str7=m_List1.GetItemText (i, 7);
  533. str8=m_List1.GetItemText (i, 8);
  534. str9=m_List1.GetItemText (i, 9);
  535. str10=m_List1.GetItemText (i, 10);
  536. str11=m_List1.GetItemText (i, 11);
  537. FillLength(str1, leng1);
  538. FillLength(str2, leng2);
  539. FillLength(str3, leng3);
  540. FillLength(str4, leng4);
  541. FillLength(str5, leng5);
  542. FillLength(str6, leng6);
  543. FillLength(str7, leng7);
  544. FillLength(str8, leng8);
  545. FillLength(str9, leng9);
  546. FillLength(str10,leng10);
  547. FillLength(str11,leng11);
  548. str=str1+str2+str3+str4+str5+str6+str7+str8+str9+str10+str11+"\n";
  549. fp.WriteString (str);
  550. }
  551. fp.Close ();
  552. MessageBox("电话已保存到c:\\clientphone.txt");
  553. ShellExecute(NULL, _T("open"), _T("c:\\clientphone.txt"), NULL, NULL, SW_SHOWMAXIMIZED);
  554. #endif
  555. }
  556. void OldClient::GetData()
  557. {
  558. g_sendhead.bsql = 0;
  559. g_sendhead.code[0] = 138;
  560. g_sendhead.tabcount = 1;
  561. g_pMainWnd->ProcessChatMessageRequest2(1); if (g_bSendOK == 0)return;
  562. DataToArray(&m_List1array);
  563. HidePrice();
  564. FillGrid();
  565. }
  566. void CheckDate(CString &date)
  567. {
  568. date.Replace("\\", "-");
  569. date.Replace("/", "-");
  570. int pos = date.Find("-");
  571. if (pos == -1)
  572. {
  573. date = "";
  574. return;
  575. }
  576. if (pos < 4)
  577. {
  578. date = "";
  579. return;
  580. }
  581. CString year = date.Left(4);
  582. date = date.Right(date.GetLength() - pos - 1);
  583. pos = date.Find("-");
  584. if (pos == -1)
  585. {
  586. date = "";
  587. return;
  588. }
  589. CString month = date.Left(pos);
  590. CString day = date.Right(date.GetLength() - pos - 1);
  591. date.Format("%d-%02d-%02d", atoi(year), atoi(month), atoi(day));
  592. }
  593. void OldClient::OnBUTimport() // Jeff.导入按钮;
  594. {
  595. #ifdef CHILD_VERSION
  596. OnBUTimport2();
  597. return;
  598. #endif
  599. using namespace YExcel;
  600. // TODO: Add your control notification handler code here
  601. BasicExcel e;
  602. CFileDialog fdlg(true, NULL, "", OFN_HIDEREADONLY, "Excel files(*.xls)|*.xls||");
  603. if (fdlg.DoModal() != IDOK)return;
  604. CString path = fdlg.GetPathName();
  605. e.Load(path);
  606. BasicExcelWorksheet* sheet1 = e.GetWorksheet("Sheet1");
  607. if (sheet1)
  608. {
  609. size_t maxRows = sheet1->GetTotalRows();
  610. size_t maxCols = sheet1->GetTotalCols();
  611. if (maxCols > 12)maxCols = 12;
  612. if (maxCols < 12)
  613. {
  614. AfxMessageBox("格式不对:缺少项目!"); return;
  615. }
  616. if (maxRows < 2)
  617. {
  618. AfxMessageBox("没有资料!"); return;
  619. }
  620. CStringArray array;
  621. for (size_t r = 0; r < maxRows; ++r)
  622. {
  623. for (size_t c = 0; c < maxCols; ++c)
  624. {
  625. BasicExcelCell* cell = sheet1->Cell(r, c);
  626. switch (cell->Type())
  627. {
  628. case BasicExcelCell::STRING:
  629. array.Add(cell->GetString());
  630. break;
  631. case BasicExcelCell::WSTRING:
  632. {
  633. int leng = wcslen(cell->GetWString());
  634. char* ppszA = new char[2 * leng + 1];
  635. memset(ppszA, 0, 2 * leng + 1);
  636. WideCharToMultiByte(CP_ACP, 0, cell->GetWString(), -1, ppszA, leng * 2, NULL, NULL);
  637. CString str = ppszA; str.TrimLeft(); str.TrimRight();
  638. array.Add(str);
  639. delete[]ppszA;
  640. }
  641. break;
  642. default:
  643. array.Add("");
  644. }
  645. }
  646. if (r == 0)
  647. {
  648. if (array.GetSize() != maxCols)
  649. {
  650. AfxMessageBox("资料读取错误"); return;
  651. }
  652. if (array.ElementAt(0) != "订单日期")
  653. {
  654. AfxMessageBox("格式错误2"); return;
  655. }
  656. array.RemoveAll();
  657. }
  658. }
  659. ///////////////////////
  660. CString sql, temp;
  661. CString m_name1, m_name2, strRes1, strRes2;
  662. CString m_date, m_phone1, m_phone2, m_qq1, m_qq2, m_taoxiname, m_taoxijiage, m_time3, m_birthday1, m_birthday2;
  663. int count = 0;
  664. for (int i = 0; i < array.GetSize(); i += 12)
  665. {
  666. m_date = array.ElementAt(i + 0);
  667. m_name1 = array.ElementAt(i + 1);
  668. m_birthday1 = array.ElementAt(i + 2);
  669. m_qq1 = array.ElementAt(i + 3);
  670. m_phone1 = array.ElementAt(i + 4);
  671. m_name2 = array.ElementAt(i + 5);
  672. m_birthday2 = array.ElementAt(i + 6);
  673. m_qq2 = array.ElementAt(i + 7);
  674. m_phone2 = array.ElementAt(i + 8);
  675. m_time3 = array.ElementAt(i + 9);
  676. m_taoxiname = array.ElementAt(i + 10);
  677. m_taoxijiage = array.ElementAt(i + 11);
  678. CheckDate(m_time3);
  679. CheckDate(m_date);
  680. CheckDate(m_birthday1);
  681. CheckDate(m_birthday2);
  682. ChinesePinYin::GetFirstLetter(m_name1, strRes1);
  683. ChinesePinYin::GetFirstLetter(m_name2, strRes2);
  684. if (m_name1.IsEmpty() && m_name2.IsEmpty())continue;
  685. if (CheckExist(m_name1, m_name2, m_phone1, m_phone2))continue;
  686. temp.Format("insert into [client3]([name],[name2],[phone],[phone2],[qq],[qq2],[birthday],[birthday2],[time3],[pinyin],[pinyin2],[date],[ren],[dandate],[taoxiname],[taoxijiage])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", m_name1, m_name2, m_phone1, m_phone2, m_qq1, m_qq2, m_birthday1, m_birthday2, m_time3, strRes1, strRes2, g_date, g_user.name, m_date, m_taoxiname, m_taoxijiage);
  687. sql += temp;
  688. sql += "***";
  689. count++;
  690. if (count == 10)
  691. {
  692. sql.TrimRight("***");
  693. g_sendhead.bsql = 1;
  694. g_pMainWnd->ProcessChatMessageRequest2(sql);
  695. if (g_bSendOK == 0)
  696. {
  697. AfxMessageBox("保存过程中出现错误!");
  698. return;
  699. }
  700. sql.Empty(); count = 0; GetData();
  701. }
  702. }
  703. /////////////////////////////////////
  704. if (!sql.IsEmpty())
  705. {
  706. sql.TrimRight("***");
  707. g_sendhead.bsql = 1;
  708. g_pMainWnd->ProcessChatMessageRequest2(sql);
  709. if (g_bSendOK == 0)
  710. {
  711. AfxMessageBox("保存过程中出现错误!");
  712. return;
  713. }
  714. sql.Empty(); count = 0; GetData();
  715. }
  716. ///////////////////////
  717. }
  718. else
  719. AfxMessageBox("格式错误,或文件未关闭!!");
  720. }
  721. BOOL OldClient::CheckExist(CString m_name1, CString m_name2, CString m_phone1, CString m_phone2)
  722. {
  723. #ifdef CHILD_VERSION
  724. for (int i = 0; i < m_List1array.GetSize(); i++)
  725. {
  726. if (m_List1array.ElementAt(i).ElementAt(1) == m_name1 && m_List1array.ElementAt(i).ElementAt(2) == m_name2\
  727. && m_List1array.ElementAt(i).ElementAt(4) == m_phone1)return 1;
  728. }
  729. #else
  730. for(int i=0; i<m_List1array.GetSize (); i++)
  731. {
  732. if(m_List1array.ElementAt (i).ElementAt (1)==m_name1 && m_List1array.ElementAt (i).ElementAt (2)==m_name2\
  733. && (m_List1array.ElementAt (i).ElementAt (3)==m_phone1 || m_List1array.ElementAt (i).ElementAt (4)==m_phone2) )return 1;
  734. }
  735. #endif
  736. return 0;
  737. }
  738. void OldClient::OnBUTimport2() // 儿童版导入客户资料;
  739. {
  740. using namespace YExcel;
  741. // TODO: Add your control notification handler code here
  742. BasicExcel e;
  743. CFileDialog fdlg(true, NULL, "", OFN_HIDEREADONLY, "Excel files(*.xls)|*.xls||");
  744. if (fdlg.DoModal() != IDOK)return;
  745. CString path = fdlg.GetPathName();
  746. e.Load(path);
  747. BasicExcelWorksheet* sheet1 = e.GetWorksheet("Sheet1");
  748. if (sheet1)
  749. {
  750. size_t maxRows = sheet1->GetTotalRows();
  751. size_t maxCols = sheet1->GetTotalCols();
  752. if (maxCols > 9)maxCols = 9;
  753. if (maxCols < 9)
  754. {
  755. AfxMessageBox("格式不对:缺少项目!"); return;
  756. }
  757. if (maxRows < 2)
  758. {
  759. AfxMessageBox("没有资料!"); return;
  760. }
  761. CStringArray array;
  762. for (size_t r = 0; r < maxRows; ++r)
  763. {
  764. for (size_t c = 0; c < maxCols; ++c)
  765. {
  766. BasicExcelCell* cell = sheet1->Cell(r, c);
  767. switch (cell->Type())
  768. {
  769. case BasicExcelCell::STRING:
  770. array.Add(cell->GetString());
  771. break;
  772. case BasicExcelCell::WSTRING:
  773. {
  774. int leng = wcslen(cell->GetWString());
  775. char* ppszA = new char[2 * leng + 1];
  776. memset(ppszA, 0, 2 * leng + 1);
  777. WideCharToMultiByte(CP_ACP, 0, cell->GetWString(), -1, ppszA, leng * 2, NULL, NULL);
  778. CString str = ppszA; str.TrimLeft(); str.TrimRight();
  779. array.Add(str);
  780. delete[]ppszA;
  781. }
  782. break;
  783. default:
  784. array.Add("");
  785. }
  786. }
  787. if (r == 0)
  788. {
  789. if (array.GetSize() != maxCols)
  790. {
  791. AfxMessageBox("资料读取错误"); return;
  792. }
  793. if (array.ElementAt(0) != "订单日期")
  794. {
  795. AfxMessageBox("格式错误2"); return;
  796. }
  797. array.RemoveAll();
  798. }
  799. }
  800. ///////////////////////
  801. CString sql, temp;
  802. CString m_name1, m_name2, strRes1, strRes2;
  803. CString m_date, m_phone1, m_qq1, m_taoxiname, m_taoxijiage, m_birthday1, m_sex;
  804. int count = 0;
  805. for (int i = 0; i < array.GetSize(); i += 9)
  806. {
  807. m_date = array.ElementAt(i + 0);
  808. m_name2 = array.ElementAt(i + 1);
  809. m_name1 = array.ElementAt(i + 2);
  810. m_phone1 = array.ElementAt(i + 3);
  811. m_qq1 = array.ElementAt(i + 4);
  812. m_taoxiname = array.ElementAt(i + 5);
  813. m_taoxijiage = array.ElementAt(i + 6);
  814. m_birthday1 = array.ElementAt(i + 7);
  815. CheckDate(m_birthday1);
  816. CheckDate(m_date);
  817. m_sex = array.ElementAt(i + 8);
  818. ChinesePinYin::GetFirstLetter(m_name1, strRes1);
  819. ChinesePinYin::GetFirstLetter(m_name2, strRes2);
  820. if (m_name1.IsEmpty() && m_name2.IsEmpty())continue;
  821. if (CheckExist(m_name1, m_name2, m_phone1, ""))continue;
  822. temp.Format("insert into [client3]([name],[name2],[phone],[qq],[birthday],[sex],[pinyin],[pinyin2],[date],[ren],[dandate],[taoxiname],[taoxijiage])values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s')", m_name1, m_name2, m_phone1, m_qq1, m_birthday1, m_sex, strRes1, strRes2, g_date, g_user.name, m_date, m_taoxiname, m_taoxijiage);
  823. sql += temp;
  824. sql += "***";
  825. count++;
  826. if (count == 10)
  827. {
  828. sql.TrimRight("***");
  829. g_sendhead.bsql = 1;
  830. g_pMainWnd->ProcessChatMessageRequest2(sql);
  831. if (g_bSendOK == 0)
  832. {
  833. AfxMessageBox("保存过程中出现错误!");
  834. return;
  835. }
  836. sql.Empty(); count = 0; GetData();
  837. }
  838. ::Sleep(1000);
  839. }
  840. /////////////////////////////////////
  841. if (!sql.IsEmpty())
  842. {
  843. sql.TrimRight("***");
  844. g_sendhead.bsql = 1;
  845. g_pMainWnd->ProcessChatMessageRequest2(sql);
  846. if (g_bSendOK == 0)
  847. {
  848. AfxMessageBox("保存过程中出现错误!");
  849. return;
  850. }
  851. sql.Empty(); count = 0; GetData();
  852. }
  853. ///////////////////////
  854. }
  855. else
  856. AfxMessageBox("格式错误,或文件未关闭!!");
  857. }
  858. void OldClient::HidePrice()
  859. {
  860. #ifdef LKAY_VERSION
  861. if(IsHasRights2new(31))return;
  862. for(int i=0; i< m_List1array.GetSize (); i++)
  863. {
  864. m_List1array.ElementAt (i).SetAt (5, "***");
  865. m_List1array.ElementAt (i).SetAt (4, "***");
  866. m_List1array.ElementAt (i).SetAt (8, "***");
  867. m_List1array.ElementAt (i).SetAt (7, "***");
  868. }
  869. #else
  870. if (IsHasRights2new(31))return;
  871. #ifdef CHILD_VERSION
  872. for (int i = 0; i < m_List1array.GetSize(); i++)
  873. {
  874. m_List1array.ElementAt(i).SetAt(4, "***");
  875. m_List1array.ElementAt(i).SetAt(5, "***");
  876. }
  877. #else
  878. for(int i=0; i< m_List1array.GetSize (); i++)
  879. {
  880. m_List1array.ElementAt (i).SetAt (3, "***");
  881. m_List1array.ElementAt (i).SetAt (4, "***");
  882. m_List1array.ElementAt (i).SetAt (5, "***");
  883. m_List1array.ElementAt (i).SetAt (6, "***");
  884. }
  885. #endif
  886. #endif
  887. }