ChoosePhotoForm.cpp 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. // ChoosePhotoForm.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "ChoosePhotoForm.h"
  6. #include "MyMdi.H"
  7. #include "ModifyDinDan.h"
  8. #include "InputPsw.h"
  9. #include "ClientDlg.h"
  10. #include "ImportPhoto.h"
  11. #include "TakeMoney2.h"
  12. #include "ImportPhoto.h"
  13. #include "ChoosePhotoSkin2.h"
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. #pragma comment(lib, "Shlwapi.lib")
  20. /////////////////////////////////////////////////////////////////////////////
  21. // ChoosePhotoForm
  22. IMPLEMENT_DYNCREATE(ChoosePhotoForm, CFormView)
  23. ChoosePhotoForm::ChoosePhotoForm()
  24. : CFormView(ChoosePhotoForm::IDD)
  25. {
  26. //{{AFX_DATA_INIT(ChoosePhotoForm)
  27. m_filter = _T("");
  28. //}}AFX_DATA_INIT
  29. }
  30. ChoosePhotoForm::~ChoosePhotoForm()
  31. {
  32. }
  33. void ChoosePhotoForm::DoDataExchange(CDataExchange* pDX)
  34. {
  35. CFormView::DoDataExchange(pDX);
  36. //{{AFX_DATA_MAP(ChoosePhotoForm)
  37. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  38. DDX_Control(pDX, IDC_LIST2, m_List1);
  39. DDX_Control(pDX, IDC_STATIC1, m_static1);
  40. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  41. //}}AFX_DATA_MAP
  42. }
  43. BEGIN_MESSAGE_MAP(ChoosePhotoForm, CFormView)
  44. //{{AFX_MSG_MAP(ChoosePhotoForm)
  45. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  46. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  47. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  48. ON_WM_TIMER()
  49. ON_BN_CLICKED(IDC_BUTshowphoto, OnBUTshowphoto)
  50. ON_BN_CLICKED(IDC_BUTmoney, OnBUTmoney)
  51. ON_BN_CLICKED(IDC_BUTexportphoto, OnBUTexportphoto)
  52. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  53. //}}AFX_MSG_MAP
  54. END_MESSAGE_MAP()
  55. /////////////////////////////////////////////////////////////////////////////
  56. // ChoosePhotoForm diagnostics
  57. #ifdef _DEBUG
  58. void ChoosePhotoForm::AssertValid() const
  59. {
  60. CFormView::AssertValid();
  61. }
  62. void ChoosePhotoForm::Dump(CDumpContext& dc) const
  63. {
  64. CFormView::Dump(dc);
  65. }
  66. #endif //_DEBUG
  67. /////////////////////////////////////////////////////////////////////////////
  68. // ChoosePhotoForm message handlers
  69. void ChoosePhotoForm::OnInitialUpdate()
  70. {
  71. CFormView::OnInitialUpdate();
  72. // TODO: Add your specialized code here and/or call the base class
  73. CMyMdi Mdi;
  74. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  75. // Here we create the outbar control using the splitter as its parent
  76. // and setting its id to the first pane.
  77. CRect rc2;
  78. GetWindowRect(rc2);
  79. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  80. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  81. m_static1.SetFont (&g_titlefont);
  82. m_List1.SetHeadings("订单号,100;男宾姓名,100;女宾姓名,100;修片,100;选片,100;选片日期,100;加急,100;取件日期,100;接单人,100;选片人,100;套系名称,100;套系价格,100;男宾电话,100;女宾电话,100" );
  83. m_List1.LoadColumnInfo (116);
  84. if(g_bShowOK==0)
  85. {
  86. CString filter="status3='未取'";
  87. g_sendhead.bsql=0;
  88. g_sendhead.code[0]=28;
  89. g_sendhead.tabcount=1;
  90. g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
  91. }
  92. else
  93. {
  94. g_sendhead.bsql=0;
  95. g_sendhead.code[0]=28;
  96. g_sendhead.tabcount=1;
  97. g_pMainWnd->ProcessChatMessageRequest2(1);if(g_bSendOK==0)return;
  98. }
  99. DataToArray(&m_List1array);
  100. m_combo1.AddString (g_user.name);
  101. for(int i=0; i<g_userarray.GetSize (); i++)
  102. {
  103. m_combo1.AddString (g_userarray.ElementAt (i).ElementAt (1) );
  104. }
  105. FillGrid();
  106. m_combo1.GetWindowRect (rc2);
  107. ScreenToClient(rc2);
  108. rc2.bottom +=200;
  109. m_combo1.MoveWindow (rc2);
  110. GetDlgItem(IDC_BUTshowphoto)->EnableWindow(IsHasRights2new(15));
  111. }
  112. void ChoosePhotoForm::FillGrid(BOOL bStatus)
  113. {
  114. m_List1.DeleteAllItems2 ();
  115. int ii=0;
  116. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  117. int count=0;
  118. if(m_filter.IsEmpty ())
  119. {
  120. if(bStatus)
  121. {
  122. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  123. {
  124. if(m_List1array.ElementAt (ii).ElementAt (3)=="OK"&&m_List1array.ElementAt (ii).ElementAt (4)!="OK")
  125. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  126. }
  127. }
  128. else
  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. }
  136. else
  137. {
  138. if(bStatus)
  139. {
  140. int type=GetType(m_filter);
  141. if(type==1)//电话
  142. {
  143. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  144. {
  145. if( m_List1array.ElementAt (ii).ElementAt (3)=="OK"&&m_List1array.ElementAt (ii).ElementAt (4)!="OK"&&(m_List1array.ElementAt (ii).ElementAt (12).Find (m_filter)!=-1 || \
  146. m_List1array.ElementAt (ii).ElementAt (13).Find (m_filter)!=-1))
  147. {
  148. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  149. }
  150. }
  151. }
  152. else if(type==2)//拼音
  153. {
  154. m_filter.MakeUpper ();
  155. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  156. {
  157. if( m_List1array.ElementAt (ii).ElementAt (3)=="OK"&&m_List1array.ElementAt (ii).ElementAt (4)!="OK"&&(m_List1array.ElementAt (ii).ElementAt (14).Find (m_filter)!=-1 || \
  158. m_List1array.ElementAt (ii).ElementAt (15).Find (m_filter)!=-1))
  159. {
  160. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  161. }
  162. }
  163. }
  164. else
  165. {
  166. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  167. {
  168. if( m_List1array.ElementAt (ii).ElementAt (3)=="OK"&&m_List1array.ElementAt (ii).ElementAt (4)!="OK"&&(m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 ||\
  169. m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 || \
  170. m_List1array.ElementAt (ii).ElementAt (2).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 (12).Find (m_filter)!=-1 || \
  175. m_List1array.ElementAt (ii).ElementAt (13).Find (m_filter)!=-1 ))
  176. {
  177. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  178. }
  179. }
  180. }
  181. }
  182. else
  183. {
  184. int type=GetType(m_filter);
  185. if(type==1)//电话
  186. {
  187. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  188. {
  189. if(m_List1array.ElementAt (ii).ElementAt (12).Find (m_filter)!=-1 || \
  190. m_List1array.ElementAt (ii).ElementAt (13).Find (m_filter)!=-1)
  191. {
  192. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  193. }
  194. }
  195. }
  196. else if(type==2)//拼音
  197. {
  198. m_filter.MakeUpper ();
  199. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  200. {
  201. if(m_List1array.ElementAt (ii).ElementAt (14).Find (m_filter)!=-1 || \
  202. m_List1array.ElementAt (ii).ElementAt (15).Find (m_filter)!=-1)
  203. {
  204. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  205. }
  206. }
  207. }
  208. else
  209. {
  210. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  211. {
  212. if(m_List1array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 ||\
  213. m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 || \
  214. m_List1array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 || \
  215. m_List1array.ElementAt (ii).ElementAt (8).Find (m_filter)!=-1 || \
  216. m_List1array.ElementAt (ii).ElementAt (9).Find (m_filter)!=-1|| \
  217. m_List1array.ElementAt (ii).ElementAt (10).Find (m_filter)!=-1 || \
  218. m_List1array.ElementAt (ii).ElementAt (12).Find (m_filter)!=-1 || \
  219. m_List1array.ElementAt (ii).ElementAt (13).Find (m_filter)!=-1 )
  220. {
  221. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  222. }
  223. }
  224. }
  225. }
  226. }
  227. m_List1.m_arLabels.SetSize(count, 1);
  228. ii=count;
  229. m_List1.m_LabelCount=ii;
  230. m_List1.SetItemCountEx (ii);
  231. CString str;
  232. str.Format ("单数:%d", ii);
  233. SetDlgItemText(IDC_STATIC2, str);
  234. }
  235. void ChoosePhotoForm::OnBUTclose()
  236. {
  237. // TODO: Add your control notification handler code here
  238. GetParent()->SendMessage(WM_CLOSE);
  239. }
  240. void ChoosePhotoForm::OnSelchangeCombo1()
  241. {
  242. // TODO: Add your control notification handler code here
  243. SetTimer(1, 100, NULL);
  244. }
  245. void ChoosePhotoForm::OnTimer(UINT nIDEvent)
  246. {
  247. // TODO: Add your message handler code here and/or call default
  248. KillTimer(nIDEvent);
  249. OnButton1();
  250. }
  251. BOOL ChoosePhotoForm::PreTranslateMessage(MSG* pMsg)
  252. {
  253. // TODO: Add your specialized code here and/or call the base class
  254. try
  255. {
  256. if(pMsg->message==WM_KEYDOWN)
  257. {
  258. switch (pMsg->wParam)
  259. {
  260. case VK_RETURN:
  261. OnButton1();
  262. return 1;
  263. case 0x43: // copy
  264. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  265. {
  266. GetFocus()->SendMessage(WM_COPY);
  267. return TRUE;
  268. }
  269. break;
  270. case 0x56: //Ctrl + V:
  271. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  272. {
  273. GetFocus()->SendMessage(WM_PASTE);
  274. return TRUE;
  275. }
  276. break;
  277. case 0x58: // cut
  278. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  279. {
  280. GetFocus()->SendMessage(WM_CUT);
  281. return TRUE;
  282. }
  283. break;
  284. case 0x5A: //undo
  285. case 0x59: //redo
  286. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  287. {
  288. GetFocus()->SendMessage(WM_UNDO);
  289. return TRUE;
  290. }
  291. break;
  292. }
  293. }
  294. return CFormView::PreTranslateMessage(pMsg);
  295. }
  296. catch(...)
  297. {
  298. }
  299. }
  300. void ChoosePhotoForm::OnBUTshowphoto()
  301. {
  302. if(IsHasRights2new(15)==0)return;
  303. // TODO: Add your control notification handler code here
  304. POSITION pos;
  305. pos=m_List1.GetFirstSelectedItemPosition();
  306. if(pos==NULL)
  307. {
  308. AfxMessageBox("请先选中您要选片的定单!", MB_ICONINFORMATION);
  309. return;
  310. }
  311. int iItem=m_List1.GetNextSelectedItem(pos);
  312. CString id=m_List1.GetItemText (iItem, 0);
  313. ChoosePhotoSkin2 dlg;
  314. dlg.SetLiaPath ("3.lia");
  315. dlg.m_id=id;
  316. dlg.m_path=g_path2+"\\";
  317. dlg.m_path+=dlg.m_id;
  318. dlg.m_path +="\\";
  319. dlg.DoModal ();
  320. if(dlg.m_bSave)
  321. {
  322. for(int i=0; i<m_List1array.GetSize (); i++)
  323. {
  324. if(id==m_List1array.ElementAt (i).ElementAt (0))
  325. {
  326. m_List1array.ElementAt (i).SetAt (4, "OK");
  327. m_List1array.ElementAt (i).SetAt (5, dlg.m_time4);
  328. m_List1array.ElementAt (i).SetAt (6, dlg.m_urgent);
  329. m_List1array.ElementAt (i).SetAt (7, dlg.m_time5);
  330. m_List1array.ElementAt (i).SetAt (9, dlg.m_waiter3);
  331. FillGrid();
  332. break;
  333. }
  334. }
  335. }
  336. }
  337. void ChoosePhotoForm::OnBUTmoney()
  338. {
  339. // TODO: Add your control notification handler code here
  340. if(IsHasRights2(11)==0)return;
  341. // TODO: Add your control notification handler code here
  342. UpdateData();
  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 str;
  353. TakeMoney2 dlg;
  354. dlg.m_mode =1;
  355. dlg.m_id =id;
  356. dlg.m_name1 =m_List1.GetItemText (iItem, 1);
  357. dlg.m_name2 =m_List1.GetItemText (iItem, 2);
  358. if(dlg.DoModal ()!=IDOK)return;
  359. }
  360. void ChoosePhotoForm::OnBUTexportphoto()
  361. {
  362. // TODO: Add your control notification handler code here
  363. UpdateData();
  364. POSITION pos;
  365. pos=m_List1.GetFirstSelectedItemPosition();
  366. if(pos==NULL)
  367. {
  368. AfxMessageBox("请先选中您要导片的定单!", MB_ICONINFORMATION);
  369. return;
  370. }
  371. int iItem=m_List1.GetNextSelectedItem(pos);
  372. CString status2=m_List1.GetItemText (iItem, 3);
  373. if(status2!="OK")
  374. {
  375. AfxMessageBox("此单未选片!", MB_ICONINFORMATION);
  376. return;
  377. }
  378. CString id=m_List1.GetItemText (iItem, 0);
  379. CString name1=m_List1.GetItemText (iItem, 1);
  380. CString name2=m_List1.GetItemText (iItem, 2);
  381. CString filter="id='"+id+"'";
  382. g_sendhead.bsql=0;
  383. g_sendhead.code[0]=50;
  384. g_sendhead.tabcount=1;
  385. g_pMainWnd->ProcessChatMessageRequest2(filter);if(g_bSendOK==0)return;
  386. CArray<CStringArray, CStringArray>sparray;
  387. DataToArray( &sparray);
  388. CString path=g_path2+"\\";
  389. path+=id;
  390. path +="\\";
  391. ////////////////////////////////////////
  392. CString str;
  393. CStringArray noarray;
  394. for(int i=0; i<sparray.GetSize (); i++)
  395. {
  396. str=sparray.ElementAt (i).ElementAt (6);
  397. GetNo(str, noarray);
  398. }
  399. if(noarray.GetSize ()==0)
  400. {
  401. AfxMessageBox("没有选中照片!", MB_ICONINFORMATION);
  402. return;
  403. }
  404. CString dir;
  405. GetSavePath(dir);
  406. if(dir.IsEmpty())return;
  407. dir.TrimRight ('\\');
  408. dir+="\\";
  409. dir+=id;
  410. dir+=name1;
  411. dir+=name2;
  412. dir+="选片";
  413. dir+="\\";
  414. ::CreateDirectory (dir, NULL);
  415. CStringArray array;
  416. CString src,des;
  417. for(i=0; i<noarray.GetSize (); i++)
  418. {
  419. src.Format ("%s%s.jpg", path, noarray.ElementAt (i));
  420. if(!::PathFileExists (src))
  421. src.Format ("%s%s.jpeg", path, noarray.ElementAt (i));
  422. if(FindArray(&array, &src)==-1)
  423. array.Add (src);
  424. }
  425. ImportPhoto dlg;
  426. dlg.m_mode =1;
  427. dlg.m_pArray=&array;
  428. dlg.m_savepath =dir;
  429. dlg.DoModal ();
  430. AfxMessageBox("导片成功!", MB_ICONINFORMATION);
  431. }
  432. void ChoosePhotoForm::GetNo(CString str, CStringArray &array)
  433. {
  434. if(!str.IsEmpty ())
  435. {
  436. int pos=str.Find (",");
  437. while(pos!=-1)
  438. {
  439. array.Add (str.Left (pos));
  440. str=str.Right (str.GetLength ()-pos-1);
  441. pos=str.Find (",");
  442. }
  443. array.Add(str);
  444. }
  445. }
  446. int CALLBACK BrowseProc(HWND hwnd, UINT msg, LPARAM lParam, LPARAM lpData)
  447. {
  448. switch(msg)
  449. {
  450. case BFFM_INITIALIZED:
  451. SendMessage(hwnd, BFFM_SETSELECTION, TRUE, NULL);
  452. break;
  453. case BFFM_SELCHANGED:
  454. {
  455. char szFileName[MAX_PATH];
  456. LPITEMIDLIST pidlCurrent = (LPITEMIDLIST)lParam;
  457. SHGetPathFromIDList(pidlCurrent, szFileName);
  458. SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szFileName);
  459. }
  460. break;
  461. }
  462. return 0;
  463. }
  464. void GetSavePath(CString &path)
  465. {
  466. char lpszDisplayName[MAX_PATH], szFileName[MAX_PATH];
  467. LPITEMIDLIST pidlDesktop, pidlCurrent;
  468. if(SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidlDesktop)
  469. == NOERROR)
  470. {
  471. BROWSEINFO bi;
  472. bi.hwndOwner = g_pMainWnd->m_hWnd;
  473. bi.pidlRoot = pidlDesktop;
  474. bi.pszDisplayName = lpszDisplayName;
  475. bi.lpszTitle = "\n文档保存的目录:";
  476. bi.ulFlags = BIF_STATUSTEXT&BIF_RETURNONLYFSDIRS ;
  477. bi.lpfn = BrowseProc;
  478. bi.lParam = 0;
  479. bi.iImage = 0;
  480. pidlCurrent = SHBrowseForFolder(&bi);
  481. SHGetPathFromIDList(pidlCurrent, szFileName);
  482. path = szFileName;
  483. }
  484. }
  485. int ChoosePhotoForm::FindArray(CStringArray *pArray, CString *pStr)
  486. {
  487. for(int i=0; i<pArray->GetSize (); i++)
  488. {
  489. if(pArray->ElementAt (i)==*pStr)
  490. return i;
  491. }
  492. return -1;
  493. }
  494. void ChoosePhotoForm::OnButton1()
  495. {
  496. // TODO: Add your control notification handler code here
  497. UpdateData();
  498. m_filter.TrimLeft ();
  499. m_filter.TrimRight ();
  500. FillGrid();
  501. }
  502. void ChoosePhotoForm::OnButton2()
  503. {
  504. // TODO: Add your control notification handler code here
  505. UpdateData();
  506. m_filter.TrimLeft ();
  507. m_filter.TrimRight ();
  508. FillGrid(1);
  509. }