OldClient.cpp 24 KB

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