ShowPic3.cpp 21 KB

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