OldClient.cpp 25 KB

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