Client2Form.cpp 24 KB

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