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