ShowPic3.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870
  1. // ShowPic3.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "dbserver.h"
  5. #include "ShowPic3.h"
  6. #include "./helper/ffsco.h"
  7. #include "DelPhotoSet.h"
  8. #include <process.h>
  9. #include "Lzari.h"
  10. #include "mysqldata.h"
  11. #define THUMBNAIL_WIDTH 100
  12. #define THUMBNAIL_HEIGHT 90
  13. #include "ConnectThread.h"
  14. #include "ShowPhoto.h"
  15. using namespace helper_coffs;
  16. /////////////////////////////////////////////////////////////////////////////
  17. // ShowPic3 dialog IDC_BU IDC_COMBO2
  18. ShowPic3::ShowPic3(CWnd* pParent /*=NULL*/): CDialog(ShowPic3::IDD, pParent)
  19. {
  20. //{{AFX_DATA_INIT(ShowPic3)
  21. m_check1 = 1;
  22. //}}AFX_DATA_INIT
  23. m_bTerminate = false;
  24. m_bRunning = false;
  25. m_hThread = NULL;
  26. }
  27. void ShowPic3::DoDataExchange(CDataExchange* pDX)
  28. {
  29. CDialog::DoDataExchange(pDX);
  30. //{{AFX_DATA_MAP(ShowPic3)
  31. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  32. DDX_Control(pDX, IDC_LIST2, m_List2);
  33. DDX_Control(pDX, IDC_LIST1, m_List1);
  34. DDX_Check(pDX, IDC_CHECK1, m_check1);
  35. //}}AFX_DATA_MAP
  36. }
  37. BEGIN_MESSAGE_MAP(ShowPic3, CDialog)
  38. //{{AFX_MSG_MAP(ShowPic3)
  39. ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
  40. ON_WM_DESTROY()
  41. ON_BN_CLICKED(IDC_BUTdelall, OnBUTdelall)
  42. ON_BN_CLICKED(IDC_BUTdel, OnBUTdel)
  43. ON_LBN_SELCHANGE(IDC_LIST2, OnSelchangeList2)
  44. ON_BN_CLICKED(IDC_BTNshow1, OnBTNshow1)
  45. ON_BN_CLICKED(IDC_BTNshow2, OnBTNshow2)
  46. ON_BN_CLICKED(IDC_BTNshow3, OnBTNshow3)
  47. ON_BN_CLICKED(IDC_BTNshow4, OnBTNshow4)
  48. ON_BN_CLICKED(IDC_BUTdel1, OnBUTdel1)
  49. ON_BN_CLICKED(IDC_BUTdel2, OnBUTdel2)
  50. ON_BN_CLICKED(IDC_BUTdel3, OnBUTdel3)
  51. ON_BN_CLICKED(IDC_BUTdel4, OnBUTdel4)
  52. ON_WM_CTLCOLOR()
  53. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  54. //}}AFX_MSG_MAP
  55. END_MESSAGE_MAP()
  56. /////////////////////////////////////////////////////////////////////////////
  57. // ShowPic3 message handlers
  58. extern int FindArray(CStringArray *pArray, CString Str);
  59. extern void GetPathFromNetShareName(CString name, CString &sRet);
  60. BOOL ShowPic3::OnInitDialog()
  61. {
  62. CDialog::OnInitDialog();
  63. CString str = "\r\n 1. 备份硬盘要与原保存硬盘要为2块独立硬盘(保存在同一块硬盘起不到保护作用)。\r\n\
  64. 2. 备份硬盘满后可以更换一块新的备份硬盘(如需帮助,请与利亚方舟技术联系)\r\n\
  65. 3. 备份硬盘满后可以按文件夹修改日期从前往后的顺序刻进光盘后删除\r\n\
  66. 4. 如不需要保存备份,可以在管理备份照片中手工删除备份";
  67. GetDlgItem(IDC_STATIC1)->SetWindowText(str);
  68. m_combo1.AddString("全部");
  69. m_combo1.AddString("取完件1个月");
  70. m_combo1.AddString("取完件2个月");
  71. m_combo1.AddString("取完件3个月");
  72. m_combo1.AddString("取完件6个月");
  73. m_combo1.AddString("取完件9个月");
  74. m_combo1.AddString("取完件12个月");
  75. m_combo1.AddString("取完件18个月");
  76. m_combo1.AddString("取完件24个月");
  77. m_combo1.AddString("取完件36个月");
  78. m_combo1.SetCurSel(0);
  79. CRect rc, rc2;
  80. GetWindowRect(rc2);
  81. DEVMODE g_dm;
  82. g_dm.dmSize = sizeof(DEVMODE);
  83. EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &g_dm);
  84. int wid = g_dm.dmPelsWidth * 3 / 4;
  85. int hei = g_dm.dmPelsHeight * 3 / 4;
  86. ::MoveWindow(m_hWnd, 0, 0, wid, hei, TRUE);
  87. CenterWindow();
  88. GetClientRect(rc);
  89. GetDlgItem(IDC_STATIC1)->GetWindowRect(rc2);
  90. ScreenToClient(rc2);
  91. rc2.left = 0;
  92. rc2.right = rc.right;
  93. GetDlgItem(IDC_STATIC1)->MoveWindow(rc2);
  94. GetDlgItem(IDC_STATIC2)->MoveWindow(rc2);
  95. m_List2.GetWindowRect(rc2);
  96. ScreenToClient(rc2);
  97. int dt = rc2.left;
  98. rc2.bottom = rc.bottom - dt;
  99. m_List2.MoveWindow(rc2);
  100. m_List1.GetWindowRect(rc2);
  101. ScreenToClient(rc2);
  102. rc2.bottom = rc.bottom - dt;
  103. rc2.right = rc.right - dt;
  104. m_List1.MoveWindow(rc2);
  105. {
  106. m_List1array.RemoveAll();
  107. for (int a = g_dbpool.GetSize() - 1; a >= 0; a--)
  108. {
  109. CDatabase *pCurdb = NULL;
  110. ODBCConnGuard ConnGuard(pCurdb , -1, 3000);
  111. if ( pCurdb == NULL )
  112. continue;
  113. CString filter = "status3='OK'";
  114. CRecordset myset(pCurdb);
  115. CString sql = "select count(*) as cot from dindan"; if (!filter.IsEmpty())sql += " where " + filter;
  116. myset.Open(CRecordset::forwardOnly, sql);
  117. myset.GetFieldValue("cot", sql);
  118. myset.Close();
  119. int count = atol(sql);
  120. sql.Format("%d", a - 1);
  121. // if(a==0)sql="-1";
  122. int oldsize = m_List1array.GetSize();
  123. m_List1array.SetSize(oldsize + count, 1);
  124. CRstDindanForm rsSt; rsSt.m_pDatabase = pCurdb; if (!filter.IsEmpty())rsSt.m_strFilter = filter;
  125. rsSt.m_strSort = "id";
  126. rsSt.Open();
  127. int ii = 0;
  128. while (!rsSt.IsEOF())
  129. {
  130. m_List1array.ElementAt(oldsize + ii).RemoveAll();
  131. m_List1array.ElementAt(oldsize + ii).Add(rsSt.id);
  132. m_List1array.ElementAt(oldsize + ii).Add(rsSt.name1);
  133. m_List1array.ElementAt(oldsize + ii).Add(rsSt.name2);
  134. m_List1array.ElementAt(oldsize + ii).Add(rsSt.time5);
  135. ii++;
  136. rsSt.MoveNext(); if (m_List1array.GetSize() <= (oldsize + ii))break;
  137. }
  138. rsSt.Close(); m_List1array.SetSize(oldsize + ii, 1);
  139. }
  140. }
  141. {
  142. CDatabase *pMaindb = NULL;
  143. ODBCConnGuard ConnGuard(pMaindb , -1, 3000);
  144. if ( pMaindb )
  145. {
  146. CRstversion rsSt; rsSt.m_pDatabase = pMaindb;
  147. rsSt.Open();
  148. if (!rsSt.IsEOF())
  149. {
  150. g_path1 = rsSt.m_bakserver1;
  151. g_path2 = rsSt.m_bakserver2;
  152. g_path4 = rsSt.m_bakserver3;
  153. g_path3 = rsSt.m_bakserver4;
  154. }
  155. rsSt.Close();
  156. }
  157. }
  158. #ifdef CHILD_VERSION
  159. if(g_path1.Find(":")==-1&& g_path1!="")
  160. g_path1="\\\\"+g_path1+"\\客户原片备份(儿童管理软件)$";
  161. if(1)//(localname.CompareNoCase (g_path1)==0 || CompareIP(localname, g_path1)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\客户原片备份(儿童管理软件)$"))
  162. GetPathFromNetShareName("客户原片备份(儿童管理软件)$", g_path1);
  163. if(g_path2.Find(":")==-1&& g_path2!="")
  164. g_path2="\\\\"+g_path2+"\\修好的片备份(儿童管理软件)$";
  165. if(1)//((localname.CompareNoCase (g_path2)==0 || CompareIP(localname, g_path2)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\修好的片备份(儿童管理软件)$"))
  166. GetPathFromNetShareName("修好的片备份(儿童管理软件)$", g_path2);
  167. if(g_path4.Find(":")==-1&& g_path4!="")
  168. g_path4="\\\\"+g_path4+"\\精修好的片备份(儿童管理软件)$";
  169. if(1)//((localname.CompareNoCase (g_path4)==0 || CompareIP(localname, g_path4)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\精修好的片备份(儿童管理软件)$"))
  170. GetPathFromNetShareName("精修好的片备份(儿童管理软件)$", g_path4);
  171. if(g_path3.Find(":")==-1&& g_path3!="")
  172. g_path3="\\\\"+g_path3+"\\设计好的片备份(儿童管理软件)$";
  173. if(1)//((localname.CompareNoCase (g_path3)==0 || CompareIP(localname, g_path3)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\设计好的片备份(儿童管理软件)$"))
  174. GetPathFromNetShareName("设计好的片备份(儿童管理软件)$", g_path3);
  175. #else
  176. if (g_path1.Find(":") == -1 && g_path1 != "")
  177. g_path1 = "\\\\" + g_path1 + "\\客户原片备份(管理软件)$";
  178. if (1)//((localname.CompareNoCase (g_path1)==0 || CompareIP(localname, g_path1)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\客户原片备份(管理软件)$"))
  179. GetPathFromNetShareName("客户原片备份(管理软件)$", g_path1);
  180. if (g_path2.Find(":") == -1 && g_path2 != "")
  181. g_path2 = "\\\\" + g_path2 + "\\修好的片备份(管理软件)$";
  182. if (1)//((localname.CompareNoCase (g_path2)==0 || CompareIP(localname, g_path2)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\修好的片备份(管理软件)$"))
  183. GetPathFromNetShareName("修好的片备份(管理软件)$", g_path2);
  184. if (g_path4.Find(":") == -1 && g_path4 != "")
  185. g_path4 = "\\\\" + g_path4 + "\\精修好的片备份(管理软件)$";
  186. if (1)//((localname.CompareNoCase (g_path4)==0 || CompareIP(localname, g_path4)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\精修好的片备份(管理软件)$"))
  187. GetPathFromNetShareName("精修好的片备份(管理软件)$", g_path4);
  188. if (g_path3.Find(":") == -1 && g_path3 != "")
  189. g_path3 = "\\\\" + g_path3 + "\\设计好的片备份(管理软件)$";
  190. if (1)//((localname.CompareNoCase (g_path3)==0 || CompareIP(localname, g_path3)==0) && CheckFolderFileExist("\\\\"+g_path1+"\\设计好的片备份(管理软件)$"))
  191. GetPathFromNetShareName("设计好的片备份(管理软件)$", g_path3);
  192. #endif
  193. LoadPhotos();
  194. for (int i = 0; i < m_List1array.GetSize(); i++)
  195. {
  196. str = m_List1array.ElementAt(i).ElementAt(0);
  197. if (FindArray(&m_dirarray1, str) == -1)
  198. {
  199. if (FindArray(&m_dirarray2, str) == -1)
  200. {
  201. if (FindArray(&m_dirarray3, str) == -1)
  202. {
  203. if (FindArray(&m_dirarray4, str) == -1)
  204. {
  205. continue;
  206. }
  207. }
  208. }
  209. }
  210. str += "\r\n";
  211. str += m_List1array.ElementAt(i).ElementAt(1);
  212. str += m_List1array.ElementAt(i).ElementAt(2);
  213. if (m_List2.GetCount() % 2)
  214. m_List2.AddEntry(str, RGB(204, 204, 204), m_List2.GetCount());
  215. else
  216. m_List2.AddEntry(str, RGB(190, 190, 190), m_List2.GetCount());
  217. m_idarray.Add(str);
  218. m_datearray.Add(m_List1array.ElementAt(i).ElementAt(3));
  219. }
  220. m_List2.Invalidate();
  221. m_ImageListThumb.Create(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, ILC_COLOR24, 0, 1);
  222. m_List1.SetImageList(&m_ImageListThumb, LVSIL_NORMAL);
  223. return TRUE; // return TRUE unless you set the focus to a control
  224. // EXCEPTION: OCX Property Pages should return FALSE
  225. }
  226. extern void LoadImageFromFile(Image **img, CString path);
  227. extern void LoadImageFromBuf(Image **img, CString path);
  228. int GetOrientation(Image *image)
  229. {
  230. try
  231. {
  232. if (image)
  233. {
  234. UINT totalBufferSize;
  235. UINT numProperties;
  236. image->GetPropertySize(&totalBufferSize, &numProperties);
  237. // Allocate the buffer that will receive the property items.
  238. PropertyItem* pAllItems = (PropertyItem*)malloc(totalBufferSize);
  239. // Fill the buffer.
  240. image->GetAllPropertyItems(totalBufferSize, numProperties, pAllItems);
  241. // Print the id data member of each property item.
  242. for (UINT j = 0; j < numProperties; ++j)
  243. {
  244. if (PropertyTagOrientation == pAllItems[j].id)
  245. {
  246. short* ptrLong = (short*)(pAllItems[j].value);
  247. int ret = (int)*ptrLong;
  248. free(pAllItems);
  249. return ret;
  250. }
  251. }
  252. free(pAllItems);
  253. }
  254. }
  255. catch (...)
  256. {
  257. }
  258. return 1;
  259. }
  260. unsigned __stdcall LoadThumbNail20(LPVOID lpParam)
  261. {
  262. try
  263. {
  264. ShowPic3 *pDlg = (ShowPic3*)lpParam;
  265. CListCtrl *ListCtrl = &pDlg->m_List1;
  266. CImageList* pImgList = &pDlg->m_ImageListThumb;
  267. // reset our image list
  268. for (int i = 0; i < pImgList->GetImageCount(); i++)
  269. pImgList->Remove(i);
  270. // remove all items from list view
  271. ListCtrl->DeleteAllItems();
  272. pImgList->SetImageCount(pDlg->m_vFileName.size());
  273. TCHAR path[MAX_PATH];
  274. vector<CString>::iterator iter;
  275. // Set redraw to FALSE to avoid flickering during adding new items
  276. ListCtrl->SetRedraw(FALSE);
  277. int nIndex = 0;
  278. CString str, spath;
  279. for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
  280. {
  281. str = *iter;
  282. spath.Empty();
  283. if (str.Left(str.ReverseFind('\\') + 1) != pDlg->m_path)
  284. {
  285. spath = str.Left(str.ReverseFind('\\') + 1);
  286. spath = spath.Right(spath.GetLength() - pDlg->m_path.GetLength());
  287. }
  288. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  289. str = spath + str.Left(str.GetLength() - 4);
  290. ListCtrl->InsertItem(nIndex, str, nIndex);
  291. }
  292. ListCtrl->SetRedraw(TRUE);
  293. ListCtrl->Invalidate();
  294. const float fRatio = (float)THUMBNAIL_HEIGHT / THUMBNAIL_WIDTH;
  295. int XDest, YDest, nDestWidth, nDestHeight;
  296. nIndex = 0;
  297. SolidBrush whitebrush(Color(255, 255, 255, 255));
  298. for (iter = pDlg->m_vFileName.begin(); iter != pDlg->m_vFileName.end() && pDlg->m_bTerminate != true; iter++, nIndex++)
  299. {
  300. // Load Image File
  301. Image *image = NULL;
  302. Bitmap *pBmp = NULL;
  303. str = *iter;
  304. spath = str.Left(str.ReverseFind('\\') + 1);
  305. spath += "s";
  306. spath += str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  307. if (::CheckFileExist(spath))
  308. ::LoadImageFromBuf(&image, spath);
  309. else
  310. {
  311. str.MakeLower();
  312. if (str.Right(3) != "jpg")continue;
  313. ::LoadImageFromBuf(&image, str);
  314. }
  315. if (image == NULL)continue;
  316. int orientation = GetOrientation(image);
  317. if (orientation == 8)
  318. image->RotateFlip(Rotate270FlipNone);
  319. else if (orientation == 6)
  320. image->RotateFlip(Rotate90FlipNone);
  321. if (image->GetWidth() == 0)
  322. continue;
  323. // Calculate Rect to fit to canvas
  324. const float fImgRatio = (float)image->GetHeight() / image->GetWidth();
  325. if (fImgRatio > fRatio)
  326. {
  327. nDestWidth = THUMBNAIL_HEIGHT / fImgRatio;
  328. XDest = (THUMBNAIL_WIDTH - nDestWidth) / 2;
  329. YDest = 0;
  330. nDestHeight = THUMBNAIL_HEIGHT;
  331. }
  332. else
  333. {
  334. XDest = 0;
  335. nDestWidth = THUMBNAIL_WIDTH;
  336. nDestHeight = THUMBNAIL_WIDTH*fImgRatio;
  337. YDest = (THUMBNAIL_HEIGHT - nDestHeight) / 2;
  338. }
  339. pBmp = new Bitmap(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT, PixelFormat24bppRGB);
  340. Graphics graph2(pBmp);
  341. graph2.Clear(Color(255, 192, 192, 192));
  342. graph2.FillRectangle(&whitebrush, 1, 1, THUMBNAIL_WIDTH - 2, THUMBNAIL_HEIGHT - 2);
  343. Graphics graph(pBmp);
  344. Rect desRect(XDest, YDest, nDestWidth, nDestHeight);
  345. // Draw Image
  346. graph.DrawImage(image, desRect, 0, 0, image->GetWidth(), image->GetHeight(), UnitPixel);
  347. delete image;
  348. // Attach to Bitmap and Replace image in CImageList
  349. CBitmap bitmap;
  350. HBITMAP hbmp;
  351. pBmp->GetHBITMAP(Color(255, 255, 255, 255), &hbmp);
  352. bitmap.Attach(hbmp);
  353. pImgList->Replace(nIndex, &bitmap, NULL);
  354. delete pBmp;
  355. // Redraw only a current item for removing flickering and fast speed.
  356. ListCtrl->RedrawItems(nIndex, nIndex);
  357. // Release used DC and Object
  358. }
  359. ListCtrl->Invalidate();
  360. pDlg->m_bRunning = false;
  361. pDlg->m_bTerminate = false;
  362. _endthreadex(0);
  363. return 0;
  364. }
  365. catch (...)
  366. {
  367. }
  368. return 1;
  369. }
  370. void ShowPic3::LoadThumbImages()
  371. {
  372. TerminateThread();
  373. m_hThread = (HANDLE)_beginthreadex(NULL, 0, LoadThumbNail20, (LPVOID)this, 0/* CREATE_SUSPENDED*/, &m_dwThreadID);
  374. m_bRunning = true;
  375. }
  376. BOOL ShowPic3::TerminateThread()
  377. {
  378. if (!m_bRunning)
  379. return TRUE;
  380. m_bTerminate = true;
  381. for (;;)
  382. {
  383. if (::WaitForSingleObject(m_hThread, 0) == WAIT_OBJECT_0)
  384. break;
  385. MSG msg;
  386. while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
  387. {
  388. if (!AfxGetApp()->PumpMessage())
  389. break;
  390. }
  391. }
  392. ::CloseHandle(m_hThread);
  393. return TRUE;
  394. }
  395. extern void LoadImageFromBuf(Image **img, CString path);
  396. void ShowPic3::OnDblclkList1(NMHDR* pNMHDR, LRESULT* pResult)
  397. {
  398. // TODO: Add your control notification handler code here
  399. POSITION pos;
  400. pos = m_List1.GetFirstSelectedItemPosition();
  401. if (pos == NULL)
  402. {
  403. return;
  404. }
  405. int iItem = m_List1.GetNextSelectedItem(pos);
  406. Image *m_pImg = NULL;
  407. ::LoadImageFromBuf(&m_pImg, m_patharray1.ElementAt(iItem));
  408. ShowPhoto dlg;
  409. dlg.m_pImg = m_pImg;
  410. dlg.DoModal();
  411. delete m_pImg;
  412. /* ShowPic22 dlg;
  413. dlg.m_pos=iItem;
  414. dlg.m_pPathArray=&m_patharray1;
  415. dlg.DoModal ();*/
  416. *pResult = 0;
  417. }
  418. void ShowPic3::OnDestroy()
  419. {
  420. TerminateThread();
  421. CDialog::OnDestroy();
  422. // TODO: Add your message handler code here
  423. }
  424. extern BOOL myisdigit(CString str);
  425. void ShowPic3::LoadPhotos()
  426. {
  427. if (g_path1 == "")return;
  428. CString str;
  429. if (1)
  430. {
  431. ffsco o;
  432. o.dirs(0);
  433. o.find(LPCSTR(g_path1), LPCSTR("*.*"));
  434. ffsco::typeT coo;
  435. ffsco::typeT::iterator it;
  436. coo = o.co_dir();
  437. for (it = coo.begin(); coo.end() != it; it++)
  438. {
  439. str = (*it).c_str();
  440. if (str == g_path1 + "\\")continue;
  441. str.TrimRight("\\");
  442. str = str.Right(str.GetLength() - str.ReverseFind('\\') - 1);
  443. m_dirarray1.Add(str);
  444. }
  445. }
  446. }
  447. void ShowPic3::OnBUTdel()
  448. {
  449. DelPhotoSet dlg;
  450. dlg.DoModal();
  451. }
  452. void ShowPic3::OnSelchangeList2()
  453. {
  454. // TODO: Add your control notification handler code here
  455. UpdateData();
  456. int pos = m_List2.GetCurSel();
  457. if (pos == -1)return;
  458. CString str;
  459. m_List2.GetText(pos, str);
  460. pos = str.Find("\r\n");
  461. if (pos == -1)return;;
  462. m_id = str.Left(pos);
  463. ShowPhoto1();
  464. if (m_patharray1.GetSize() == 0)OnBTNshow2();
  465. if (m_patharray1.GetSize() == 0)OnBTNshow3();
  466. if (m_patharray1.GetSize() == 0)OnBTNshow4();
  467. }
  468. void ShowPic3::ShowPhoto1()
  469. {
  470. if (m_id == "")
  471. {
  472. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  473. }
  474. CString str;
  475. m_path = g_path1 + "\\" + m_id + "\\";
  476. m_patharray1.RemoveAll();
  477. if (1)
  478. {
  479. ffsco o;
  480. o.dirs(1);
  481. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  482. ffsco::typeT coo;
  483. ffsco::typeT::iterator it;
  484. coo = o.co_file();
  485. for (it = coo.begin();
  486. coo.end() != it;
  487. it++)
  488. {
  489. str = (*it).c_str();
  490. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  491. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  492. str.MakeLower();
  493. m_patharray1.Add(str);
  494. }
  495. }
  496. if (m_bRunning)return;
  497. CStringArray *pArray = &m_patharray1;
  498. m_vFileName.clear();
  499. for (int i = 0; i < pArray->GetSize(); i++)
  500. {
  501. CString filePath = pArray->ElementAt(i);
  502. filePath.MakeLower();
  503. m_vFileName.push_back(filePath);
  504. }
  505. LoadThumbImages();
  506. }
  507. void ShowPic3::ShowPhoto2()
  508. {
  509. if (m_id == "")
  510. {
  511. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  512. }
  513. CString str;
  514. m_path = g_path2 + "\\" + m_id + "\\";
  515. m_patharray1.RemoveAll();
  516. if (1)
  517. {
  518. ffsco o;
  519. o.dirs(1);
  520. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  521. ffsco::typeT coo;
  522. ffsco::typeT::iterator it;
  523. coo = o.co_file();
  524. for (it = coo.begin();
  525. coo.end() != it;
  526. it++)
  527. {
  528. str = (*it).c_str();
  529. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  530. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  531. str.MakeLower();
  532. m_patharray1.Add(str);
  533. }
  534. }
  535. if (m_bRunning)return;
  536. CStringArray *pArray = &m_patharray1;
  537. m_vFileName.clear();
  538. for (int i = 0; i < pArray->GetSize(); i++)
  539. {
  540. CString filePath = pArray->ElementAt(i);
  541. filePath.MakeLower();
  542. m_vFileName.push_back(filePath);
  543. }
  544. LoadThumbImages();
  545. }
  546. void ShowPic3::ShowPhoto3()
  547. {
  548. if (m_id == "")
  549. {
  550. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  551. }
  552. CString str;
  553. m_path = g_path3 + "\\" + m_id + "\\";
  554. m_patharray1.RemoveAll();
  555. if (1)
  556. {
  557. ffsco o;
  558. o.dirs(1);
  559. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  560. ffsco::typeT coo;
  561. ffsco::typeT::iterator it;
  562. coo = o.co_file();
  563. for (it = coo.begin();
  564. coo.end() != it;
  565. it++)
  566. {
  567. str = (*it).c_str();
  568. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  569. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  570. str.MakeLower();
  571. m_patharray1.Add(str);
  572. }
  573. }
  574. if (m_bRunning)return;
  575. CStringArray *pArray = &m_patharray1;
  576. m_vFileName.clear();
  577. for (int i = 0; i < pArray->GetSize(); i++)
  578. {
  579. CString filePath = pArray->ElementAt(i);
  580. filePath.MakeLower();
  581. m_vFileName.push_back(filePath);
  582. }
  583. LoadThumbImages();
  584. }
  585. void ShowPic3::ShowPhoto4()
  586. {
  587. if (m_id == "")
  588. {
  589. AfxMessageBox("请先选中客人!", MB_ICONINFORMATION); return;
  590. }
  591. CString str;
  592. m_path = g_path4 + "\\" + m_id + "\\";
  593. m_patharray1.RemoveAll();
  594. if (1)
  595. {
  596. ffsco o;
  597. o.dirs(1);
  598. o.find(LPCSTR(m_path), LPCSTR("*.jpg"));
  599. ffsco::typeT coo;
  600. ffsco::typeT::iterator it;
  601. coo = o.co_file();
  602. for (it = coo.begin();
  603. coo.end() != it;
  604. it++)
  605. {
  606. str = (*it).c_str();
  607. if (str.GetAt(str.ReverseFind('\\') + 1) == 's')continue;
  608. if (str.GetAt(str.ReverseFind('\\') + 1) == 'm')continue;
  609. str.MakeLower();
  610. m_patharray1.Add(str);
  611. }
  612. }
  613. if (m_bRunning)return;
  614. CStringArray *pArray = &m_patharray1;
  615. m_vFileName.clear();
  616. for (int i = 0; i < pArray->GetSize(); i++)
  617. {
  618. CString filePath = pArray->ElementAt(i);
  619. filePath.MakeLower();
  620. m_vFileName.push_back(filePath);
  621. }
  622. LoadThumbImages();
  623. }
  624. void ShowPic3::OnBTNshow1()
  625. {
  626. // TODO: Add your control notification handler code here
  627. ShowPhoto1();
  628. }
  629. void ShowPic3::OnBTNshow2()
  630. {
  631. // TODO: Add your control notification handler code here
  632. ShowPhoto2();
  633. }
  634. void ShowPic3::OnBTNshow3()
  635. {
  636. // TODO: Add your control notification handler code here
  637. ShowPhoto4();
  638. }
  639. void ShowPic3::OnBTNshow4()
  640. {
  641. // TODO: Add your control notification handler code here
  642. ShowPhoto3();
  643. }
  644. void ShowPic3::OnBUTdelall()
  645. {
  646. // TODO: Add your control notification handler code here
  647. if (m_id == "")
  648. {
  649. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  650. }
  651. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  652. DeleteDirectory(g_path1 + "\\" + m_id + "\\");
  653. DeleteDirectory(g_path2 + "\\" + m_id + "\\");
  654. DeleteDirectory(g_path3 + "\\" + m_id + "\\");
  655. DeleteDirectory(g_path4 + "\\" + m_id + "\\");
  656. OnBTNshow1();
  657. }
  658. void ShowPic3::OnBUTdel1()
  659. {
  660. // TODO: Add your control notification handler code here
  661. if (m_id == "")
  662. {
  663. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  664. }
  665. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  666. DeleteDirectory(g_path1 + "\\" + m_id + "\\"); OnBTNshow1();
  667. }
  668. void ShowPic3::OnBUTdel2()
  669. {
  670. // TODO: Add your control notification handler code here
  671. if (m_id == "")
  672. {
  673. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  674. }
  675. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  676. DeleteDirectory(g_path2 + "\\" + m_id + "\\"); OnBTNshow2();
  677. }
  678. void ShowPic3::OnBUTdel3()
  679. {
  680. // TODO: Add your control notification handler code here
  681. if (m_id == "")
  682. {
  683. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  684. }
  685. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  686. DeleteDirectory(g_path4 + "\\" + m_id + "\\"); OnBTNshow3();
  687. }
  688. void ShowPic3::OnBUTdel4()
  689. {
  690. // TODO: Add your control notification handler code here
  691. if (m_id == "")
  692. {
  693. AfxMessageBox("请先选中您要删除的客人!", MB_ICONINFORMATION); return;
  694. }
  695. if (AfxMessageBox("删除后将无法恢复, 确认删除吗?", MB_YESNO | MB_ICONSTOP) != IDYES)return;
  696. DeleteDirectory(g_path3 + "\\" + m_id + "\\"); OnBTNshow4();
  697. }
  698. HBRUSH ShowPic3::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  699. {
  700. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  701. // TODO: Change any attributes of the DC here
  702. if (nCtlColor == CTLCOLOR_STATIC && pWnd->GetDlgCtrlID() == IDC_STATIC1)
  703. {
  704. pDC->SetBkMode(TRANSPARENT); //设置字体背景为透明
  705. return (HBRUSH)::GetStockObject(WHITE_BRUSH); // 设置背景色
  706. }
  707. // TODO: Return a different brush if the default is not desired
  708. return hbr;
  709. }
  710. void ShowPic3::OnSelchangeCombo1()
  711. {
  712. // TODO: Add your control notification handler code here
  713. int pos = m_combo1.GetCurSel();
  714. if (pos != -1)
  715. {
  716. CString str;
  717. m_combo1.GetLBText(pos, str);
  718. int days = -1;
  719. if (str == "全部")days = -1;
  720. else if (str == "取完件1个月")days = 31;
  721. else if (str == "取完件2个月")days = 31 + 30;
  722. else if (str == "取完件3个月")days = 31 * 2 + 30;
  723. else if (str == "取完件6个月")days = 31 * 3 + 30 * 3;
  724. else if (str == "取完件9个月")days = 31 * 5 + 30 * 4;
  725. else if (str == "取完件12个月")days = 365;
  726. else if (str == "取完件18个月")days = 365 + 31 * 3 + 30 * 3;
  727. else if (str == "取完件24个月")days = 365 * 2;
  728. else if (str == "取完件36个月")days = 365 * 3;
  729. m_List2.ResetContent();
  730. CString date;
  731. CTime today = CTime::GetCurrentTime();
  732. CTimeSpan dt;
  733. for (int i = 0; i < m_datearray.GetSize(); i++)
  734. {
  735. date = m_datearray.ElementAt(i);
  736. // MessageBox(date);
  737. CTime tm = GetTmFromStr(date);
  738. dt = today - tm;
  739. // str.Format("%d", dt.GetDays());
  740. // MessageBox(str);
  741. if (days != -1 && dt.GetDays() < days)continue;
  742. str = m_idarray.ElementAt(i);
  743. if (m_List2.GetCount() % 2)
  744. m_List2.AddEntry(str, RGB(204, 204, 204), m_List2.GetCount());
  745. else
  746. m_List2.AddEntry(str, RGB(190, 190, 190), m_List2.GetCount());
  747. }
  748. m_List2.Invalidate();
  749. }
  750. }