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 "InputPsw.h"
  9. #include "TakeMoney2.h"
  10. #include "NeroDlg.h"
  11. #include "ClientRequirement.h"
  12. #include "./helper/ffsco.h"
  13. #include "AddOldClient.h"
  14. #include "AddOldClient2.h"
  15. #include "SendMsgDlg.h"
  16. #include "BasicExcelVC6.h"
  17. #include "Lzari.h"
  18. #include "SelExportType.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. /////////////////////////////////////////////////////////////////////////////
  25. // OldClient
  26. IMPLEMENT_DYNCREATE(OldClient, MyFormView)
  27. OldClient::OldClient()
  28. : MyFormView(OldClient::IDD)
  29. {
  30. //{{AFX_DATA_INIT(OldClient)
  31. m_filter = _T("");
  32. //}}AFX_DATA_INIT
  33. }
  34. OldClient::~OldClient()
  35. {
  36. }
  37. void OldClient::DoDataExchange(CDataExchange* pDX)
  38. {
  39. MyFormView::DoDataExchange(pDX);
  40. //{{AFX_DATA_MAP(OldClient)
  41. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  42. DDX_Control(pDX, IDC_LIST2, m_List1);
  43. DDX_Control(pDX, IDC_STATIC1, m_static1);
  44. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  45. //}}AFX_DATA_MAP
  46. }
  47. BEGIN_MESSAGE_MAP(OldClient, MyFormView)
  48. //{{AFX_MSG_MAP(OldClient)
  49. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  50. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  51. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  52. ON_WM_TIMER()
  53. ON_BN_CLICKED(IDC_BUTburncd, OnBUTOldClient)
  54. ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2)
  55. ON_BN_CLICKED(IDC_BUTburncd2, OnBUTburncd2)
  56. ON_BN_CLICKED(IDC_BUTburncd3, OnBUTburncd3)
  57. ON_BN_CLICKED(IDC_BUTsendmsg, OnBUTsendmsg)
  58. ON_BN_CLICKED(IDC_BUTprint3, OnBUTprint3)
  59. ON_BN_CLICKED(IDC_BUTimport, OnBUTimport)
  60. //}}AFX_MSG_MAP
  61. END_MESSAGE_MAP()
  62. /////////////////////////////////////////////////////////////////////////////
  63. // OldClient diagnostics
  64. #ifdef _DEBUG
  65. void OldClient::AssertValid() const
  66. {
  67. MyFormView::AssertValid();
  68. }
  69. void OldClient::Dump(CDumpContext& dc) const
  70. {
  71. MyFormView::Dump(dc);
  72. }
  73. #endif //_DEBUG
  74. /////////////////////////////////////////////////////////////////////////////
  75. // OldClient message handlers
  76. void OldClient::OnInitialUpdate()
  77. {
  78. MyFormView::OnInitialUpdate();
  79. GetDlgItem(IDC_BUTburncd3)->EnableWindow(IsHasRights2new(49));
  80. GetDlgItem(IDC_BUTprint3)->EnableWindow(IsHasRights2new(49));
  81. // TODO: Add your specialized code here and/or call the base class
  82. CMyMdi Mdi;
  83. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  84. // Here we create the outbar control using the splitter as its parent
  85. // and setting its id to the first pane.
  86. CRect rc2;
  87. GetWindowRect(rc2);
  88. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  89. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  90. int idarray[] = { IDC_BUTburncd, IDC_BUTburncd2, IDC_BUTburncd3, IDC_BUTimport, IDC_BUTsendmsg, IDC_BUTprint3, IDC_BUTclose };
  91. int idcount = 7;
  92. int btnwid;
  93. CRect prerc;
  94. for (int a = idcount - 2; a >= 0; a--)
  95. {
  96. GetDlgItem(idarray[a + 1])->GetWindowRect(prerc);
  97. ScreenToClient(prerc);
  98. GetDlgItem(idarray[a])->GetWindowRect(rc2);
  99. ScreenToClient(rc2);
  100. btnwid = rc2.Width();
  101. rc2.right = prerc.left;
  102. rc2.left = rc2.right - btnwid;
  103. GetDlgItem(idarray[a])->MoveWindow(rc2);
  104. }
  105. m_static1.SetFont(&g_titlefont);
  106. #ifdef CHILD_VERSION
  107. m_List1.SetHeadings("id,0;家长姓名,100;宝宝姓名,100;宝宝性别,100;电话,100;QQ,100;宝宝生日,100;套系,100;金额,100;订单日期,100;录入日期,100;录单,100");
  108. #else
  109. m_List1.SetHeadings("id,0;男宾姓名,100;女宾姓名,100;男宾电话,100;女宾电话,100;男宾QQ,100;女宾QQ,100;男宾生日,100;女宾生日,100;婚期,100;套系,100;金额,100;订单日期,100;录入日期,100;录单,100" );
  110. #endif
  111. m_List1.LoadColumnInfo(171);
  112. GetData();
  113. m_combo1.GetWindowRect(rc2);
  114. ScreenToClient(rc2);
  115. rc2.bottom += 200;
  116. m_combo1.MoveWindow(rc2);
  117. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  118. SetComboHei(&m_combo1, rc2.Height());
  119. }
  120. void OldClient::FillGrid()
  121. {
  122. m_List1.DeleteAllItems2();
  123. int ii = 0;
  124. m_List1.m_arLabels.SetSize(m_List1array.GetSize(), 1);
  125. int count = 0;
  126. #ifdef CHILD_VERSION
  127. if (m_filter.IsEmpty())
  128. {
  129. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  130. {
  131. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  132. }
  133. }
  134. else
  135. {
  136. int type = GetType(m_filter);
  137. if (type == 1)//电话
  138. {
  139. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  140. {
  141. if (m_List1array.ElementAt(ii).ElementAt(4).Find(m_filter) != -1)
  142. {
  143. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  144. }
  145. }
  146. }
  147. else if (type == 2)//拼音
  148. {
  149. m_filter.MakeUpper();
  150. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  151. {
  152. if (m_List1array.ElementAt(ii).ElementAt(12).Find(m_filter) != -1 || m_List1array.ElementAt(ii).ElementAt(13).Find(m_filter) != -1)
  153. {
  154. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  155. }
  156. }
  157. }
  158. else
  159. {
  160. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  161. {
  162. if (m_List1array.ElementAt(ii).ElementAt(0).Find(m_filter) != -1 || \
  163. m_List1array.ElementAt(ii).ElementAt(1).Find(m_filter) != -1 || \
  164. m_List1array.ElementAt(ii).ElementAt(2).Find(m_filter) != -1 || \
  165. m_List1array.ElementAt(ii).ElementAt(3).Find(m_filter) != -1 || \
  166. m_List1array.ElementAt(ii).ElementAt(4).Find(m_filter) != -1 || \
  167. m_List1array.ElementAt(ii).ElementAt(5).Find(m_filter) != -1 || \
  168. m_List1array.ElementAt(ii).ElementAt(6).Find(m_filter) != -1 || \
  169. m_List1array.ElementAt(ii).ElementAt(7).Find(m_filter) != -1 || \
  170. m_List1array.ElementAt(ii).ElementAt(8).Find(m_filter) != -1 || \
  171. m_List1array.ElementAt(ii).ElementAt(9).Find(m_filter) != -1 || \
  172. m_List1array.ElementAt(ii).ElementAt(10).Find(m_filter) != -1 || \
  173. m_List1array.ElementAt(ii).ElementAt(11).Find(m_filter) != -1 || \
  174. m_List1array.ElementAt(ii).ElementAt(12).Find(m_filter) != -1)
  175. {
  176. m_List1.m_arLabels.ElementAt(count++).Copy(m_List1array.ElementAt(ii));
  177. }
  178. }
  179. }
  180. }
  181. #else
  182. if(m_filter.IsEmpty ())
  183. {
  184. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  185. {
  186. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  187. }
  188. }
  189. else
  190. {
  191. int type=GetType(m_filter);
  192. if(type==1)//电话
  193. {
  194. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  195. {
  196. if(m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1 || m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1)
  197. {
  198. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  199. }
  200. }
  201. }
  202. else if(type==2)//拼音
  203. {
  204. m_filter.MakeUpper ();
  205. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  206. {
  207. if(m_List1array.ElementAt (ii).ElementAt (15).Find (m_filter)!=-1 || m_List1array.ElementAt (ii).ElementAt (16).Find (m_filter)!=-1)
  208. {
  209. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  210. }
  211. }
  212. }
  213. else
  214. {
  215. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  216. {
  217. if(m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 ||\
  218. m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 || \
  219. m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 || \
  220. m_List1array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1|| \
  221. m_List1array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1|| \
  222. m_List1array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1 || \
  223. m_List1array.ElementAt (ii).ElementAt (6).Find (m_filter)!=-1 || \
  224. m_List1array.ElementAt (ii).ElementAt (7).Find (m_filter)!=-1 || \
  225. m_List1array.ElementAt (ii).ElementAt (8).Find (m_filter)!=-1|| \
  226. m_List1array.ElementAt (ii).ElementAt (9).Find (m_filter)!=-1 || \
  227. m_List1array.ElementAt (ii).ElementAt (10).Find (m_filter)!=-1 || \
  228. m_List1array.ElementAt (ii).ElementAt (11).Find (m_filter)!=-1 || \
  229. m_List1array.ElementAt (ii).ElementAt (12).Find (m_filter)!=-1 || \
  230. m_List1array.ElementAt (ii).ElementAt (13).Find (m_filter)!=-1 || \
  231. m_List1array.ElementAt (ii).ElementAt (14).Find (m_filter)!=-1 )
  232. {
  233. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  234. }
  235. }
  236. }
  237. }
  238. #endif
  239. m_List1.m_arLabels.SetSize(count, 1);
  240. ii = count;
  241. m_List1.m_LabelCount = ii;
  242. m_List1.SetItemCountEx(ii);
  243. CString str;
  244. str.Format("客人:%d", ii);
  245. SetDlgItemText(IDC_STATIC2, str);
  246. CRect rc;
  247. GetDlgItem(IDC_STATIC2)->GetWindowRect(rc);
  248. ScreenToClient(rc);
  249. InvalidateRect(rc);
  250. }
  251. void OldClient::OnBUTclose()
  252. {
  253. // TODO: Add your control notification handler code here
  254. GetParent()->SendMessage(WM_CLOSE);
  255. }
  256. void OldClient::OnSelchangeCombo1()
  257. {
  258. // TODO: Add your control notification handler code here
  259. SetTimer(1, 100, NULL);
  260. }
  261. void OldClient::OnTimer(UINT nIDEvent)
  262. {
  263. // TODO: Add your message handler code here and/or call default
  264. KillTimer(nIDEvent);
  265. OnButton1();
  266. }
  267. BOOL OldClient::PreTranslateMessage(MSG* pMsg)
  268. {
  269. // TODO: Add your specialized code here and/or call the base class
  270. try
  271. {
  272. if (pMsg->message == WM_KEYDOWN)
  273. {
  274. switch (pMsg->wParam)
  275. {
  276. case VK_RETURN:
  277. OnButton1();
  278. return 1;
  279. case 0x43: // copy
  280. if ((GetKeyState(VK_CONTROL) & 0x80))
  281. {
  282. GetFocus()->SendMessage(WM_COPY);
  283. return TRUE;
  284. }
  285. break;
  286. case 0x56: //Ctrl + V:
  287. if ((GetKeyState(VK_CONTROL) & 0x80))
  288. {
  289. GetFocus()->SendMessage(WM_PASTE);
  290. return TRUE;
  291. }
  292. break;
  293. case 0x58: // cut
  294. if ((GetKeyState(VK_CONTROL) & 0x80))
  295. {
  296. GetFocus()->SendMessage(WM_CUT);
  297. return TRUE;
  298. }
  299. break;
  300. case 0x5A: //undo
  301. case 0x59: //redo
  302. if ((GetKeyState(VK_CONTROL) & 0x80))
  303. {
  304. GetFocus()->SendMessage(WM_UNDO);
  305. return TRUE;
  306. }
  307. break;
  308. }
  309. }
  310. return MyFormView::PreTranslateMessage(pMsg);
  311. }
  312. catch (...)
  313. {
  314. }
  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. GetFirstLetter(m_name1, strRes1);
  684. 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. GetFirstLetter(m_name1, strRes1);
  820. 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. }