FileManage.cpp 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466
  1. // FileManage.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. //#include "ZLSoftC.h"
  5. #include "YLGL.h"
  6. #include "FileManage.h"
  7. #include "MyMdi.H"
  8. #include "ModifyDinDan.h"
  9. #include "InputPsw.h"
  10. #include "ImportPhoto.h"
  11. #include "ImportPhoto.h"
  12. #include "NeroDlg.h"
  13. #include "ClientRequirement.h"
  14. #include "ChoosePhotoSkin2.h"
  15. #include "./helper/ffsco.h"
  16. #include "TakeMoney4.h"
  17. #include "SelFile.h"
  18. #include "FileManage2.h"
  19. #include "FileManage3.h"
  20. #include "Lzari.h"
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. //#pragma comment(lib, "Shlwapi.lib")
  27. /////////////////////////////////////////////////////////////////////////////yes
  28. // FileManage
  29. IMPLEMENT_DYNCREATE(FileManage, MyFormView)
  30. FileManage::FileManage()
  31. : MyFormView(FileManage::IDD)
  32. {
  33. //{{AFX_DATA_INIT(FileManage)
  34. m_filter = _T("");
  35. m_check1 = FALSE;
  36. m_check2 = FALSE;
  37. m_curposition = _T("");
  38. m_curid=-1;
  39. //}}AFX_DATA_INIT
  40. }
  41. FileManage::~FileManage()
  42. {
  43. }
  44. void FileManage::DoDataExchange(CDataExchange* pDX)
  45. {
  46. MyFormView::DoDataExchange(pDX);
  47. //{{AFX_DATA_MAP(FileManage)
  48. DDX_Control(pDX, IDC_TREE1, m_mytree);
  49. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  50. DDX_Control(pDX, IDC_LIST2, m_List1);
  51. DDX_Control(pDX, IDC_STATIC1, m_static1);
  52. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  53. //}}AFX_DATA_MAP
  54. }
  55. BEGIN_MESSAGE_MAP(FileManage, MyFormView)
  56. //{{AFX_MSG_MAP(FileManage)
  57. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  58. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  59. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  60. ON_WM_TIMER()
  61. ON_BN_CLICKED(IDC_BUTshowphoto, OnBUTshowphoto)
  62. ON_BN_CLICKED(IDC_BUTexportphoto, OnBUTexportphoto)
  63. ON_BN_CLICKED(IDC_BUTimportphoto, OnBUTimportphoto)
  64. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  65. ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST2, OnItemchangedList2)
  66. ON_BN_CLICKED(IDC_BUTburncd, OnBUTFileManage)
  67. ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2)
  68. ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
  69. ON_BN_CLICKED(IDC_BUTburncd2, OnBUTburncd2)
  70. ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
  71. ON_BN_CLICKED(IDC_CHECK2, OnCheck2)
  72. ON_NOTIFY(NM_CLICK, IDC_TREE1, OnClickTree1)
  73. ON_NOTIFY(TVN_SELCHANGED, IDC_TREE1, OnSelchangedTree1)
  74. ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
  75. ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
  76. ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
  77. ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
  78. //}}AFX_MSG_MAP
  79. ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST2, OnCustomdrawList)
  80. END_MESSAGE_MAP()
  81. /////////////////////////////////////////////////////////////////////////////
  82. // FileManage diagnostics
  83. #ifdef _DEBUG
  84. void FileManage::AssertValid() const
  85. {
  86. MyFormView::AssertValid();
  87. }
  88. void FileManage::Dump(CDumpContext& dc) const
  89. {
  90. MyFormView::Dump(dc);
  91. }
  92. #endif //_DEBUG
  93. /////////////////////////////////////////////////////////////////////////////
  94. // FileManage message handlers
  95. void FileManage::OnInitialUpdate()
  96. {
  97. MyFormView::OnInitialUpdate();
  98. // SetDlgFont(this);
  99. // TODO: Add your specialized code here and/or call the base class
  100. CMyMdi Mdi;
  101. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  102. GetDlgItem(IDC_BUTburncd2)->EnableWindow(IsHasRights2new(49));
  103. // Here we create the outbar control using the splitter as its parent
  104. // and setting its id to the first pane.
  105. CRect rc2;
  106. GetWindowRect(rc2);
  107. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  108. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  109. m_static1.SetFont (&g_titlefont);
  110. GetDlgItem(IDC_BUTTON5)->EnableWindow(IsHasRights2new(49));
  111. int idarray[]={IDC_BUTTON4,IDC_BUTTON6,IDC_BUTTON5,IDC_BUTTON2,IDC_BUTclose};
  112. int idcount=5;
  113. int btnwid;
  114. CRect prerc;
  115. for(int a=idcount-2; a>=0; a--)
  116. {
  117. GetDlgItem(idarray[a+1])->GetWindowRect (prerc);
  118. ScreenToClient(prerc);
  119. GetDlgItem(idarray[a])->GetWindowRect (rc2);
  120. ScreenToClient(rc2);
  121. btnwid=rc2.Width ();
  122. rc2.right =prerc.left ;
  123. rc2.left =rc2.right -btnwid;
  124. GetDlgItem(idarray[a])->MoveWindow (rc2);
  125. }
  126. HICON icon[2];
  127. icon[0]=AfxGetApp()->LoadIcon (IDI_ICON12);
  128. icon[1]=AfxGetApp()->LoadIcon (IDI_ICON13);
  129. CImageList *m_imagelist=new CImageList;
  130. m_imagelist->Create(16,16,0,7,7);
  131. m_imagelist->SetBkColor (RGB(255,255,255));
  132. for(int n=0;n<2;n++)
  133. {
  134. m_imagelist->Add(icon[n]); //把图标载入图像列表控件
  135. }
  136. m_mytree.SetImageList(m_imagelist,TVSIL_NORMAL);
  137. m_binittree=0;
  138. GetData();
  139. m_binittree=1;
  140. m_combo1.GetWindowRect (rc2);
  141. ScreenToClient(rc2);
  142. rc2.bottom +=200;
  143. m_combo1.MoveWindow (rc2);
  144. GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
  145. SetComboHei(&m_combo1, rc2.Height ());
  146. m_List1.SetHeadings("存放位置,100;文件名,100;存入,100;日期,150;阅读级别,100;备注,100" );
  147. m_List1.LoadColumnInfo (405);
  148. for(int i=0; i<m_List2array.GetSize (); i++)
  149. {
  150. if(m_combo1.FindString(0, m_List2array.ElementAt (i).ElementAt (2))==-1)
  151. m_combo1.AddString (m_List2array.ElementAt (i).ElementAt (2) );
  152. }
  153. }
  154. void FileManage::FillGrid()
  155. {
  156. m_List1.DeleteAllItems2 ();
  157. int ii=0;
  158. m_List1.m_arLabels.SetSize( m_List2array.GetSize (), 1 );
  159. int count=0;
  160. if(m_filter.IsEmpty ())
  161. {
  162. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  163. {
  164. m_List1.m_arLabels.ElementAt (count++).Copy (m_List2array.ElementAt (ii));
  165. }
  166. }
  167. else
  168. {
  169. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  170. {
  171. if(m_List2array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 ||\
  172. m_List2array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 || \
  173. m_List2array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 || \
  174. m_List2array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1|| \
  175. m_List2array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1|| \
  176. m_List2array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1 )
  177. {
  178. m_List1.m_arLabels.ElementAt (count++).Copy (m_List2array.ElementAt (ii));
  179. }
  180. }
  181. }
  182. m_List1.m_arLabels.SetSize(count, 1);
  183. ii=count;
  184. m_List1.m_LabelCount=ii;
  185. m_List1.SetItemCountEx (ii);
  186. CString str;
  187. str.Format ("文件:%d (双击项目打查看文件)", ii);
  188. SetDlgItemText(IDC_STATIC2, str);
  189. }
  190. void FileManage::OnBUTclose()
  191. {
  192. // TODO: Add your control notification handler code here
  193. GetParent()->SendMessage(WM_CLOSE);
  194. }
  195. void FileManage::OnSelchangeCombo1()
  196. {
  197. // TODO: Add your control notification handler code here
  198. SetTimer(1, 100, NULL);
  199. }
  200. void FileManage::OnTimer(UINT nIDEvent)
  201. {
  202. // TODO: Add your message handler code here and/or call default
  203. KillTimer(nIDEvent);
  204. OnButton1();
  205. }
  206. BOOL FileManage::PreTranslateMessage(MSG* pMsg)
  207. {
  208. // TODO: Add your specialized code here and/or call the base class
  209. try
  210. {
  211. if(pMsg->message==WM_KEYDOWN)
  212. {
  213. switch (pMsg->wParam)
  214. {
  215. case VK_RETURN:
  216. OnButton1();
  217. return 1;
  218. case 0x43: // copy
  219. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  220. {
  221. GetFocus()->SendMessage(WM_COPY);
  222. return TRUE;
  223. }
  224. break;
  225. case 0x56: //Ctrl + V:
  226. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  227. {
  228. GetFocus()->SendMessage(WM_PASTE);
  229. return TRUE;
  230. }
  231. break;
  232. case 0x58: // cut
  233. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  234. {
  235. GetFocus()->SendMessage(WM_CUT);
  236. return TRUE;
  237. }
  238. break;
  239. case 0x5A: //undo
  240. case 0x59: //redo
  241. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  242. {
  243. GetFocus()->SendMessage(WM_UNDO);
  244. return TRUE;
  245. }
  246. break;
  247. }
  248. }
  249. return MyFormView::PreTranslateMessage(pMsg);
  250. }
  251. catch(...)
  252. {
  253. }
  254. }
  255. extern int CALLBACK BrowseProc(HWND hwnd, UINT msg, LPARAM lParam, LPARAM lpData);
  256. /*{
  257. switch(msg)
  258. {
  259. case BFFM_INITIALIZED:
  260. SendMessage(hwnd, BFFM_SETSELECTION, TRUE, NULL);
  261. break;
  262. case BFFM_SELCHANGED:
  263. {
  264. char szFileName[MAX_PATH];
  265. LPITEMIDLIST pidlCurrent = (LPITEMIDLIST)lParam;
  266. SHGetPathFromIDList(pidlCurrent, szFileName);
  267. SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szFileName);
  268. }
  269. break;
  270. }
  271. return 0;
  272. }*/
  273. void FileManage::GetSavePath(CString &path)
  274. {
  275. char lpszDisplayName[MAX_PATH], szFileName[MAX_PATH];
  276. LPITEMIDLIST pidlDesktop, pidlCurrent;
  277. if(SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidlDesktop)
  278. == NOERROR)
  279. {
  280. BROWSEINFO bi;
  281. bi.hwndOwner = this->m_hWnd;
  282. bi.pidlRoot = pidlDesktop;
  283. bi.pszDisplayName = lpszDisplayName;
  284. bi.lpszTitle = "\n文档保存的目录:";
  285. bi.ulFlags = BIF_STATUSTEXT&BIF_RETURNONLYFSDIRS ;
  286. bi.lpfn = BrowseProc;
  287. bi.lParam = 0;
  288. bi.iImage = 0;
  289. pidlCurrent = SHBrowseForFolder(&bi);
  290. SHGetPathFromIDList(pidlCurrent, szFileName);
  291. path = szFileName;
  292. }
  293. }
  294. int FileManage::FindArray(CStringArray *pArray, CString Str)
  295. {
  296. for(int i=0; i<pArray->GetSize (); i++)
  297. {
  298. if(pArray->ElementAt (i)==Str)
  299. return i;
  300. }
  301. return -1;
  302. }
  303. void FileManage::GetNo(CString str, CStringArray &array)
  304. {
  305. if(!str.IsEmpty ())
  306. {
  307. int pos=str.Find (",");
  308. while(pos!=-1)
  309. {
  310. if(FindArray(&array, str.Left (pos))==-1)
  311. array.Add (str.Left (pos));
  312. str=str.Right (str.GetLength ()-pos-1);
  313. pos=str.Find (",");
  314. }
  315. if(FindArray(&array, str)==-1)
  316. array.Add(str);
  317. }
  318. }
  319. CString FileManage::GetSelName(CString name, CArray<CStringArray, CStringArray>&spnamearray)
  320. {
  321. CString ret;
  322. name=","+name+",";
  323. CString str;
  324. for(int i=0; i<spnamearray.GetSize (); i++)
  325. {
  326. str=","+spnamearray.ElementAt (i).ElementAt (6)+",";
  327. if(str.Find (name)!=-1)
  328. {
  329. ret+=spnamearray.ElementAt (i).ElementAt (5);
  330. ret+=";";
  331. }
  332. }
  333. ret.TrimRight (";");
  334. ret.Replace ("*", "x");
  335. return ret;
  336. }
  337. void FileManage::OnBUTexportphoto()
  338. {
  339. if(IsHasRights2new(11)==0)return;
  340. // TODO: Add your control notification handler code here
  341. POSITION pos;
  342. pos=m_List1.GetFirstSelectedItemPosition();
  343. if(pos==NULL)
  344. {
  345. AfxMessageBox("请先选中您要导出片的定单!", MB_ICONINFORMATION);
  346. return;
  347. }
  348. int iItem=m_List1.GetNextSelectedItem(pos);
  349. CString id=m_List1.GetItemText (iItem, 0);
  350. CString path;
  351. path=g_path4+"\\";
  352. path+=id;
  353. path +="\\";
  354. CString temp;
  355. CStringArray array;
  356. using namespace helper_coffs;
  357. ffsco o;
  358. o.dirs(0);
  359. o.find(LPCSTR(path), LPCSTR("*.jpg"));
  360. ffsco::typeT coo;
  361. ffsco::typeT::iterator it;
  362. coo = o.co_file();
  363. for (it = coo.begin();
  364. coo.end() != it;
  365. it ++)
  366. {
  367. temp=(*it).c_str();
  368. if(temp.GetAt (temp.ReverseFind ('\\')+1)!='s' && temp.GetAt (temp.ReverseFind ('\\')+1)!='m')
  369. {
  370. array.Add (temp);
  371. }
  372. }
  373. if(array.GetSize ()==0)
  374. {
  375. AfxMessageBox("此单未导片!", MB_ICONINFORMATION);
  376. return;
  377. }
  378. CString dir;
  379. GetSavePath(dir);
  380. if(dir.IsEmpty())
  381. {
  382. return;
  383. }
  384. CString name1=m_List1.GetItemText (iItem, 1);
  385. CString name2=m_List1.GetItemText (iItem, 2);
  386. dir.TrimRight ('\\');
  387. dir+="\\";
  388. dir+=id;
  389. dir+=name1;
  390. dir+=name2;
  391. dir+="精修好的片";
  392. dir+="\\";
  393. ::CreateDirectory (dir, NULL);
  394. ImportPhoto dlg;
  395. dlg.m_mode =1;
  396. dlg.m_pArray=&array;
  397. dlg.m_savepath =dir;
  398. dlg.DoModal (); AfxMessageBox("导片成功!", MB_ICONINFORMATION);
  399. }
  400. void FileManage::OnBUTimportphoto()
  401. {
  402. }
  403. void FileManage::OnBUTshowphoto()
  404. {
  405. // TODO: Add your control notification handler code here
  406. POSITION pos;
  407. pos=m_List1.GetFirstSelectedItemPosition();
  408. if(pos==NULL)
  409. {
  410. AfxMessageBox("请先选中您要查看的定单!", MB_ICONINFORMATION);
  411. return;
  412. }
  413. int iItem=m_List1.GetNextSelectedItem(pos);
  414. CString status=m_List1.GetItemText (iItem, 4);
  415. CString id=m_List1.GetItemText (iItem, 0);
  416. if(status=="未设计")
  417. {
  418. AfxMessageBox("此单未导片!", MB_ICONINFORMATION);
  419. return;
  420. }
  421. /* ShowPic dlg;
  422. dlg.m_path=g_path3+"\\";
  423. dlg.m_path+=id;
  424. dlg.m_path +="\\";
  425. dlg.DoModal ();*/
  426. ChoosePhotoSkin2 dlg;
  427. dlg.m_mode2 =1;
  428. dlg.SetLiaPath ("3.lia");
  429. //dlg.m_id=id;
  430. dlg.m_strOrderNumber = id;
  431. dlg.m_path=g_path3+"\\";
  432. dlg.m_path+=id;
  433. dlg.m_path +="\\";
  434. dlg.DoModal ();
  435. for(int i=0; i<m_List1array.GetSize (); i++)
  436. {
  437. if(id==m_List1array.ElementAt (i).ElementAt (0))
  438. {
  439. break;
  440. }
  441. }
  442. }
  443. void FileManage::OnButton1()
  444. {
  445. // TODO: Add your control notification handler code here
  446. UpdateData();
  447. m_filter.TrimLeft ();
  448. m_filter.TrimRight ();
  449. FillGrid();
  450. }
  451. void FileManage::OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult)
  452. {
  453. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  454. // TODO: Add your control notification handler code here
  455. POSITION pos;
  456. pos=m_List1.GetFirstSelectedItemPosition();
  457. if(pos==NULL)
  458. {
  459. return;
  460. }
  461. int iItem=m_List1.GetNextSelectedItem(pos);
  462. CString waiter4=m_List1.GetItemText (iItem, 10);
  463. if(waiter4.IsEmpty () && IsHasRights2new(7) || IsHasRights2new(49) )
  464. {
  465. GetDlgItem(IDC_BUTimportphoto)->EnableWindow(1);
  466. }
  467. else if(waiter4==g_user.name && IsHasRights2new(7) )
  468. {
  469. GetDlgItem(IDC_BUTimportphoto)->EnableWindow(1);
  470. }
  471. else
  472. GetDlgItem(IDC_BUTimportphoto)->EnableWindow(0);
  473. *pResult = 0;
  474. }
  475. void FileManage::OnBUTFileManage()
  476. {
  477. // TODO: Add your control notification handler code here
  478. #ifdef ZLCX_VERSION
  479. //return;
  480. #endif
  481. POSITION pos;
  482. pos=m_List1.GetFirstSelectedItemPosition();
  483. if(pos==NULL)
  484. {
  485. return;
  486. }
  487. int iItem=m_List1.GetNextSelectedItem(pos);
  488. CString id=m_List1.GetItemText (iItem, 0);
  489. TakeMoney4 dlg;
  490. dlg.m_mode =5;
  491. dlg.m_id =id;
  492. dlg.m_name1 =m_List1.GetItemText (iItem, 1);
  493. dlg.m_name2 =m_List1.GetItemText (iItem, 2);
  494. if(dlg.DoModal ()!=IDOK)return;
  495. }
  496. void FileManage::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
  497. {
  498. // TODO: Add your control notification handler code here
  499. OnButton2();
  500. *pResult = 0;
  501. }
  502. void FileManage::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
  503. {
  504. NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
  505. // Take the default processing unless we set this to something else below.
  506. *pResult = 0;
  507. // First thing - check the draw stage. If it's the control's prepaint
  508. // stage, then tell Windows we want messages for every item.
  509. if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
  510. {
  511. *pResult = CDRF_NOTIFYITEMDRAW;
  512. }
  513. else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
  514. {
  515. // This is the prepaint stage for an item. Here's where we set the
  516. // item's text color. Our return value will tell Windows to draw the
  517. // item itself, but it will use the new color we set here.
  518. // We'll cycle the colors through red, green, and light blue.
  519. /* if(m_List1.m_arLabels.ElementAt (pLVCD->nmcd.dwItemSpec).ElementAt (8)!="0")
  520. pLVCD->clrText = RGB(220,0,0);
  521. else
  522. pLVCD->clrText = RGB(20,133,20);*/
  523. if(pLVCD->nmcd.dwItemSpec%2)
  524. pLVCD->clrTextBk = g_gridcol1;
  525. else
  526. pLVCD->clrTextBk = g_gridcol2;
  527. // Store the color back in the NMLVCUSTOMDRAW struct.
  528. // Tell Windows to paint the control itself.
  529. *pResult = CDRF_DODEFAULT;
  530. }
  531. }
  532. void FileManage::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
  533. {
  534. // TODO: Add your control notification handler code here
  535. POSITION pos;
  536. pos=m_List1.GetFirstSelectedItemPosition();
  537. if(pos==NULL)return;
  538. int iItem=m_List1.GetNextSelectedItem(pos);
  539. if(g_user.account=="admin")
  540. {
  541. GetDlgItem(IDC_BUTTON2)->EnableWindow(1);
  542. }
  543. else if(g_user.level!="")
  544. {
  545. if(atoi(g_user.level.Left(1))>=atoi(m_List1.GetItemText (iItem, 4)) )
  546. GetDlgItem(IDC_BUTTON2)->EnableWindow(1);
  547. else
  548. GetDlgItem(IDC_BUTTON2)->EnableWindow(0);
  549. }
  550. else
  551. GetDlgItem(IDC_BUTTON2)->EnableWindow(0);
  552. if(IsHasRights2new(49) || g_user.name==m_List1.GetItemText (iItem, 2))
  553. {
  554. GetDlgItem(IDC_BUTTON6)->EnableWindow(1);
  555. }
  556. else
  557. {
  558. GetDlgItem(IDC_BUTTON6)->EnableWindow(0);
  559. }
  560. *pResult = 0;
  561. }
  562. void FileManage::HidePrice()
  563. {
  564. }
  565. void FileManage::OnBUTburncd2()
  566. {
  567. // TODO: Add your control notification handler code here
  568. ListToXLS(&m_List1, "c:\\客人欠款.xls", 0);
  569. }
  570. //ZLCX
  571. void FileManage::OnCheck1()
  572. {
  573. // TODO: Add your control notification handler code here
  574. }
  575. void FileManage::OnCheck2()
  576. {
  577. // TODO: Add your control notification handler code here
  578. }
  579. void FileManage::OnClickTree1(NMHDR* pNMHDR, LRESULT* pResult)
  580. {
  581. // TODO: Add your control notification handler code here
  582. OnSelchangedTree1( pNMHDR, pResult) ;
  583. *pResult = 0;
  584. }
  585. CString FileManage::GetName(CString id)
  586. {
  587. for(int i=0; i<m_List1array.GetSize(); i++)
  588. {
  589. if(m_List1array.ElementAt(i).ElementAt(0)==id)
  590. {
  591. return m_List1array.ElementAt(i).ElementAt(2);
  592. }
  593. }
  594. return "";
  595. }
  596. void FileManage::AddChild(CString curid, HTREEITEM hParent)
  597. {
  598. HTREEITEM hChild;
  599. if(hParent==NULL)
  600. hChild=m_mytree.InsertItem(GetName(curid),0,1,TVI_ROOT,TVI_LAST);
  601. else
  602. hChild=m_mytree.InsertItem(GetName(curid),0,1,hParent,TVI_LAST);
  603. for(int i=0; i<m_List1array.GetSize(); i++)
  604. {
  605. if(m_List1array.ElementAt(i).ElementAt(1)==curid)
  606. {
  607. AddChild(m_List1array.ElementAt(i).ElementAt(0), hChild);
  608. }
  609. }
  610. }
  611. void FileManage::GetData()
  612. {
  613. g_sendhead.bsql=0;
  614. if(m_binittree)
  615. {
  616. g_sendhead.code[0]=233;
  617. g_sendhead.tabcount=1;
  618. g_pMainWnd->ProcessChatMessageRequest2(1);
  619. if(g_bSendOK==0)return;
  620. DataToArray(&m_List2array); CalPostion();
  621. if(
  622. m_curposition!="")
  623. FillGrid2();
  624. else
  625. FillGrid();
  626. return;
  627. }
  628. m_curid=-1;
  629. m_curposition="";
  630. CString str;
  631. str.Format ("当前柜:%s", m_curposition);
  632. SetDlgItemText(IDC_STATIC16, str);
  633. g_sendhead.code[0]=232;
  634. g_sendhead.code[1]=233;
  635. g_sendhead.tabcount=2;
  636. g_pMainWnd->ProcessChatMessageRequest2(1);
  637. if(g_bSendOK==0)return;
  638. DataToArray(&m_List1array,&m_List2array);CalPostion();
  639. m_mytree.DeleteAllItems();
  640. for(int i=0; i<m_List1array.GetSize(); i++)
  641. {
  642. if(m_List1array.ElementAt(i).ElementAt(1)=="")
  643. {
  644. AddChild(m_List1array.ElementAt(i).ElementAt(0), NULL);
  645. continue;
  646. HTREEITEM root0=m_mytree.InsertItem(m_List1array.ElementAt(i).ElementAt(2),0,1,TVI_ROOT,TVI_LAST);
  647. CString curid=m_List1array.ElementAt(i).ElementAt(0);
  648. for(int a=0; a<m_List1array.GetSize(); a++)
  649. {
  650. if(m_List1array.ElementAt(a).ElementAt(1)==curid)
  651. {
  652. HTREEITEM sub_son0=m_mytree.InsertItem(m_List1array.ElementAt(a).ElementAt(2),0,1,root0,TVI_LAST);
  653. CString childid=m_List1array.ElementAt(a).ElementAt(0);
  654. //while(1)
  655. {
  656. // BOOL bFind=0;
  657. for(int b=0; b<m_List1array.GetSize(); b++)
  658. {
  659. if(m_List1array.ElementAt(b).ElementAt(1)==childid)
  660. {
  661. // bFind=1;
  662. m_mytree.InsertItem(m_List1array.ElementAt(b).ElementAt(2),0,1,sub_son0,TVI_LAST);
  663. }
  664. }
  665. // if(bFind==0)break;
  666. }
  667. }
  668. }
  669. }
  670. }
  671. FillGrid();
  672. }
  673. void FileManage::GetChildId(CString oldstr, CString curid, CStringArray *pArray)
  674. {
  675. CString oldstrbak=oldstr;
  676. for(int i=0; i<m_List1array.GetSize(); i++)
  677. {
  678. oldstr=oldstrbak;
  679. if(m_List1array.ElementAt(i).ElementAt(1)==curid)
  680. {
  681. CString curid=m_List1array.ElementAt(i).ElementAt(0);
  682. oldstr+="\\"+GetName(curid);
  683. GetChildId(oldstr, curid, pArray);
  684. pArray->Add(oldstr); pArray->Add(curid);
  685. }
  686. }
  687. }
  688. CString FileManage::GetCurSelID(CString &path)
  689. {
  690. HTREEITEM hSelectedItem = m_mytree.GetSelectedItem();
  691. if(hSelectedItem==NULL)
  692. {
  693. return "";
  694. }
  695. CString m_strSelect;
  696. while(hSelectedItem)
  697. {
  698. m_strSelect="\\"+m_mytree.GetItemText(hSelectedItem)+m_strSelect;
  699. hSelectedItem=m_mytree.GetParentItem(hSelectedItem);
  700. }
  701. for(int i=0; i<m_List1array.GetSize(); i++)
  702. {
  703. if(m_List1array.ElementAt(i).ElementAt(1)!="")continue;//不是主则继续
  704. CString m_strSelect2;
  705. CString curid=m_List1array.ElementAt(i).ElementAt(0);
  706. m_strSelect2+="\\"+GetName(curid);
  707. CStringArray array;
  708. array.Add(m_strSelect2); array.Add(curid);
  709. GetChildId(m_strSelect2, curid, &array);
  710. for(int aa=0; aa<array.GetSize(); aa+=2)
  711. {
  712. if(m_strSelect==array.ElementAt(aa))
  713. {
  714. path=m_strSelect;
  715. return array.ElementAt(aa+1);
  716. }
  717. }
  718. continue;
  719. m_strSelect2+="\\"+m_List1array.ElementAt(i).ElementAt(2);
  720. if(m_strSelect==m_strSelect2)
  721. {
  722. return m_List1array.ElementAt(i).ElementAt(0);
  723. }
  724. AfxMessageBox("curid:"+curid);
  725. AfxMessageBox("curm_strSelect2:"+m_strSelect2);
  726. for(int a=0; a<m_List1array.GetSize(); a++)
  727. {
  728. if(m_List1array.ElementAt(a).ElementAt(1)==curid)
  729. {
  730. // m_strSelect2+="\\"+m_List1array.ElementAt(a).ElementAt(2);
  731. // AfxMessageBox("curm_strSelect2:"+m_strSelect2);
  732. if(m_strSelect==m_strSelect2+"\\"+m_List1array.ElementAt(a).ElementAt(2))
  733. {
  734. AfxMessageBox("find:"+m_List1array.ElementAt(a).ElementAt(0));
  735. return m_List1array.ElementAt(a).ElementAt(0);
  736. }
  737. }
  738. }
  739. }
  740. return "";
  741. }
  742. void FileManage::ShowFile(CStringArray *patharray)
  743. {
  744. if(patharray->GetSize()==0)return;
  745. if(patharray->GetSize()==1)
  746. {
  747. CString str=patharray->ElementAt(0);
  748. CString ext;
  749. if(str.Find(".")!=-1)
  750. ext=str.Right(str.GetLength()-str.ReverseFind('.')-1);
  751. ext.MakeLower ();
  752. if(0)//ext=="jpg" || ext=="jpeg" || ext=="png" || ext=="gif"|| ext=="bmp")
  753. {
  754. Image *m_pImg=NULL;
  755. ::LoadImageFromBuf (&m_pImg, str);
  756. if(m_pImg==NULL)
  757. {
  758. AfxMessageBox("无效图片文件!");return;
  759. }
  760. // ShowPhoto dlg;
  761. // dlg.m_pImg=m_pImg;
  762. // dlg.DoModal();
  763. delete m_pImg;
  764. }
  765. else
  766. {
  767. ShellExecute(NULL, _T("open"), str, NULL, NULL, SW_SHOWMAXIMIZED);
  768. }
  769. return;
  770. }
  771. SelFile dlg;
  772. dlg.m_pArray=patharray;
  773. dlg.DoModal();
  774. }
  775. void FileManage::OnButton2() // 查看文件;
  776. {
  777. POSITION pos;
  778. pos=m_List1.GetFirstSelectedItemPosition();
  779. if(pos==NULL)
  780. {
  781. AfxMessageBox("请先选中您要查看的文件!", MB_ICONINFORMATION);
  782. return;
  783. }
  784. int iItem=m_List1.GetNextSelectedItem(pos);
  785. if(g_user.account=="admin")
  786. {
  787. }
  788. else if(g_user.level!="")
  789. {
  790. if(atoi(g_user.level.Left(1))<atoi(m_List1.GetItemText (iItem, 4)) )
  791. return;
  792. }
  793. else
  794. return;
  795. CString date=m_List1.GetItemText (iItem, 3);
  796. CString m_path=m_List1.GetItemText (iItem, 1);
  797. if(1)
  798. {
  799. CString m_pathtemp=m_path;
  800. CString curfile;
  801. int pos=m_path.Find(";");
  802. CStringArray patharray;
  803. while(pos!=-1 || m_path!="")
  804. {
  805. if(pos!=-1)
  806. curfile=m_path.Left(pos);
  807. else
  808. {
  809. curfile=m_path;
  810. m_path="";
  811. }
  812. CString str=g_path1+"\\公告附件\\"+curfile;patharray.Add(str);
  813. if(pos!=-1)
  814. m_path=m_path.Right(m_path.GetLength()-pos-1);
  815. pos=m_path.Find(";");
  816. }
  817. m_path=m_pathtemp;
  818. char no[20];
  819. memset(no, 0, 20);
  820. strcpy(no, date);
  821. g_nSendCode=43;
  822. g_pMainWnd->ProcessChatMessageRequest2((BYTE*)no, 20);
  823. g_nSendCode=0;
  824. if(g_bSendOK==0)
  825. {
  826. return;
  827. }
  828. DWORD nReaded=0;
  829. int filepos=0;
  830. DeleteDirectory(g_mainpath+"\\公告");
  831. ::CreateDirectory(g_mainpath+"\\公告", NULL);
  832. CStringArray patharraytemp;
  833. if(1)
  834. {
  835. BYTE *lpszOut = NULL;
  836. int nOutSize = 0;
  837. LZARI Lzari;
  838. Lzari.UnCompress(g_pData,g_nLeng,lpszOut,nOutSize);
  839. CMemFile memfile;
  840. // memfile.Attach (lpszOut,nOutSize);
  841. delete []g_pData;
  842. g_pData=new BYTE[nOutSize];
  843. memcpy(g_pData, lpszOut,nOutSize);
  844. Lzari.Release();
  845. g_nLeng=nOutSize;
  846. }
  847. while(nReaded<g_nLeng)
  848. {
  849. if(filepos>=patharray.GetSize())break;
  850. CString path=patharray.ElementAt(filepos);filepos++;
  851. path=g_mainpath+"\\公告"+path.Right(path.GetLength()-path.ReverseFind('\\'));
  852. DWORD leng;
  853. memcpy(&leng, g_pData+nReaded, sizeof(DWORD));nReaded+=sizeof(DWORD);
  854. CFile fp;
  855. fp.Open(path, CFile::modeWrite|CFile::modeCreate);
  856. fp.Write(g_pData+nReaded, leng);nReaded+=leng;
  857. fp.Close();
  858. patharraytemp.Add(path);
  859. }
  860. patharray.RemoveAll();
  861. patharray.Copy(patharraytemp);
  862. ShowFile(&patharray);
  863. return;
  864. }
  865. }
  866. void FileManage::OnButton8() // 管理按钮;
  867. {
  868. // TODO: Add your control notification handler code here
  869. FileManage2 dlg;
  870. dlg.DoModal();
  871. m_binittree=0;
  872. GetData();
  873. m_binittree=1;
  874. }
  875. void FileManage::OnButton4() //存入文件;
  876. {
  877. // TODO: Add your control notification handler code here
  878. if(m_curid==-1)
  879. {
  880. AfxMessageBox("未选择当前柜!", MB_ICONINFORMATION);return;
  881. }
  882. FileManage3 dlg;
  883. UpdateData();
  884. dlg.m_curposition=m_curposition; // Jeff.当前文件柜位置;
  885. if(IDOK!=dlg.DoModal())return;
  886. CString m_path=dlg.m_path; // Jeff.文件名路径;
  887. CString level=dlg.level; // 阅读级别;
  888. CString m_bz=dlg.m_bz; // 备注;
  889. CString filename,curfile,filename2;
  890. BYTE *pData=new BYTE[1024*200*5+4000];
  891. DWORD length=0;
  892. DWORD fileleng;
  893. int filenum=0; // Jeff.选择的文件数量;
  894. int pos=m_path.Find(";");
  895. while(pos!=-1 || m_path!="")
  896. {
  897. if(filenum>=5)
  898. {
  899. AfxMessageBox("注意:文件太多,仅保存了前5个文件!", MB_ICONINFORMATION);
  900. break;
  901. }
  902. if(pos!=-1)
  903. curfile=m_path.Left(pos);
  904. else
  905. {
  906. curfile=m_path;
  907. m_path="";
  908. }
  909. CFile fp;
  910. if(fp.Open(curfile, CFile::modeRead))
  911. {
  912. filename2=curfile.Right(curfile.GetLength()-curfile.ReverseFind('\\')-1);
  913. filename+=filename2;
  914. filename+=";";
  915. fileleng=fp.GetLength();
  916. if(fileleng>1024*200)
  917. {
  918. CString ext;
  919. if(curfile.Find(".")!=-1)
  920. ext=curfile.Right(curfile.GetLength()-curfile.ReverseFind('.')-1);
  921. ext.MakeLower();
  922. if(!(ext=="jpg" || ext=="jpeg" || ext=="png"|| ext=="bmp"))
  923. {
  924. AfxMessageBox("文件太大,请上传小于200K的文件!");
  925. fp.Close();
  926. delete []pData;
  927. return;
  928. }
  929. else
  930. {
  931. fp.Close();
  932. Image *m_pImg=NULL;
  933. ::LoadImageFromBuf(&m_pImg, curfile);
  934. if(m_pImg==NULL)
  935. {
  936. AfxMessageBox("无效图片!");
  937. delete []pData;
  938. return;
  939. }
  940. Image *simg2=NULL;
  941. CRect rc2(0,0,1600,1600);
  942. RectFitDes(m_pImg->GetWidth(), m_pImg->GetHeight(), rc2);
  943. simg2=m_pImg->GetThumbnailImage(rc2.Width(), rc2.Height(), NULL, NULL);
  944. Graphics graphic2(simg2);//防止GetThumbnailImage影响质量
  945. graphic2.Clear(Color(255,255,255,255));
  946. graphic2.DrawImage(m_pImg, 0,0,simg2->GetWidth(), simg2->GetHeight() );
  947. if(m_pImg)delete m_pImg;
  948. m_pImg=NULL;
  949. CString path=g_mainpath+"\\1."+ext;
  950. ::SaveImageToFile2(simg2, path, 40);
  951. delete simg2;
  952. if(!fp.Open(path, CFile::modeRead))
  953. {
  954. AfxMessageBox("文件打开失败!");
  955. delete []pData;
  956. return;
  957. }
  958. fileleng=fp.GetLength();
  959. }
  960. }
  961. // 1.先存入文件的大小,sizeof(DWROD) fileleng;
  962. memcpy(pData+length, &fileleng, sizeof(fileleng));
  963. length+=sizeof(fileleng);
  964. // 2.再读入文件的数据;
  965. fp.Read(pData+length, fileleng);
  966. length+=fileleng;
  967. fp.Close();
  968. filenum++;
  969. }
  970. else
  971. {
  972. AfxMessageBox("附件未找到!", MB_ICONINFORMATION);
  973. }
  974. if(pos!=-1)
  975. m_path=m_path.Right(m_path.GetLength()-pos-1);
  976. pos=m_path.Find(";");
  977. }
  978. filename.TrimRight(";");
  979. CString sql;
  980. sql.Format("insert into [filemanage2]([parent],[filename],[clerk],[date],[level],[bz],[position]) values('%d','%s','%s','%s','%s','%s','%s')",
  981. m_curid, filename, g_user.name, "msgtimestamp2", level, m_bz, m_curposition);
  982. /* g_sendhead.bsql=1;
  983. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  984. AfxMessageBox("保存成功!", MB_ICONINFORMATION);*/
  985. // 3.写入SQL语句的长度;(当做另一文件来操作)
  986. fileleng=sql.GetLength();
  987. memcpy(pData+length, &fileleng, sizeof(fileleng));
  988. // 4.写入SQL语句;
  989. DWORD nSqlPos=length;
  990. length+=sizeof(fileleng);
  991. memcpy(pData+length, sql.GetBuffer(0), fileleng);
  992. sql.ReleaseBuffer();
  993. // 5.写入SQL语句在数据内的位置;
  994. length+=fileleng;
  995. memcpy(pData+length, &nSqlPos, sizeof(nSqlPos));
  996. length+=sizeof(nSqlPos);
  997. g_nSendCode=42;
  998. g_pMainWnd->ProcessChatMessageRequest2(pData, length);
  999. g_nSendCode=0;
  1000. delete []pData;
  1001. if(g_bSendOK==0)return;
  1002. AfxMessageBox("存入成功!", MB_ICONINFORMATION);
  1003. #if 1
  1004. CString strLog = _T("");
  1005. strLog.Format(_T("存入操作:位置:%s; 文件名:%s; 级别:%s"),
  1006. m_curposition,
  1007. filename,
  1008. level);
  1009. // 2015.03.08 添加删除日志;
  1010. WriteLog(strLog);
  1011. #endif
  1012. GetData();
  1013. }
  1014. void FileManage::OnButton5() // 删除按钮;
  1015. {
  1016. if(IsHasRights2new(49)==0)return;
  1017. // TODO: Add your control notification handler code here
  1018. POSITION pos;
  1019. pos=m_List1.GetFirstSelectedItemPosition();
  1020. if(pos==NULL)
  1021. {
  1022. AfxMessageBox("请先选中您要删除的文件!", MB_ICONINFORMATION);
  1023. return;
  1024. }
  1025. if(AfxMessageBox("确认删除此文件吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
  1026. int iItem=m_List1.GetNextSelectedItem(pos);
  1027. CString date=m_List1.GetItemText (iItem, 3);
  1028. CString position=m_List1.GetItemText (iItem, 0);
  1029. CString sql;
  1030. sql.Format("delete from filemanage2 where [date]='%s' ", date);
  1031. g_sendhead.bsql=1;
  1032. g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
  1033. #if 1
  1034. CString strLog = _T("");
  1035. strLog.Format(_T("删除操作:位置:%s; 文件名:%s;存入人:%s; 存入日期:%s; 级别:%s"),
  1036. m_List1.GetItemText(iItem,0),
  1037. m_List1.GetItemText(iItem,1),
  1038. m_List1.GetItemText(iItem,2),
  1039. m_List1.GetItemText(iItem,3),
  1040. m_List1.GetItemText(iItem,4));
  1041. // 2015.03.08 添加删除日志;
  1042. WriteLog(strLog);
  1043. #endif
  1044. GetData();
  1045. }
  1046. void FileManage::GetData2()
  1047. {
  1048. g_sendhead.bsql=0;
  1049. g_sendhead.code[0]=232;
  1050. g_sendhead.tabcount=1;
  1051. g_pMainWnd->ProcessChatMessageRequest2(1);
  1052. if(g_bSendOK==0)return;
  1053. DataToArray(&m_List1array);
  1054. m_curid=-1;
  1055. m_curposition="";
  1056. CString str;
  1057. str.Format ("当前柜:%s", m_curposition);
  1058. SetDlgItemText(IDC_STATIC16, str);
  1059. m_mytree.DeleteAllItems();
  1060. for(int i=0; i<m_List1array.GetSize(); i++)
  1061. {
  1062. if(m_List1array.ElementAt(i).ElementAt(1)=="")
  1063. {
  1064. AddChild(m_List1array.ElementAt(i).ElementAt(0), NULL);
  1065. continue;
  1066. HTREEITEM root0=m_mytree.InsertItem(m_List1array.ElementAt(i).ElementAt(2),0,1,TVI_ROOT,TVI_LAST);
  1067. CString curid=m_List1array.ElementAt(i).ElementAt(0);
  1068. for(int a=0; a<m_List1array.GetSize(); a++)
  1069. {
  1070. if(m_List1array.ElementAt(a).ElementAt(1)==curid)
  1071. {
  1072. HTREEITEM sub_son0=m_mytree.InsertItem(m_List1array.ElementAt(a).ElementAt(2),0,1,root0,TVI_LAST);
  1073. CString childid=m_List1array.ElementAt(a).ElementAt(0);
  1074. //while(1)
  1075. {
  1076. // BOOL bFind=0;
  1077. for(int b=0; b<m_List1array.GetSize(); b++)
  1078. {
  1079. if(m_List1array.ElementAt(b).ElementAt(1)==childid)
  1080. {
  1081. // bFind=1;
  1082. m_mytree.InsertItem(m_List1array.ElementAt(b).ElementAt(2),0,1,sub_son0,TVI_LAST);
  1083. }
  1084. }
  1085. // if(bFind==0)break;
  1086. }
  1087. }
  1088. }
  1089. }
  1090. }
  1091. }
  1092. void FileManage::OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult)
  1093. {
  1094. NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
  1095. // TODO: Add your control notification handler code here
  1096. // CString str=m_mytree.GetItemText(pNMTreeView->itemNew.hItem);
  1097. UpdateData();
  1098. HTREEITEM hSelectedItem = m_mytree.GetSelectedItem();
  1099. if(hSelectedItem==NULL)
  1100. {
  1101. m_curposition="";
  1102. CString str;
  1103. str.Format ("当前柜:%s", m_curposition);
  1104. SetDlgItemText(IDC_STATIC16, str);
  1105. m_curid=-1;
  1106. return;
  1107. }
  1108. m_curid=atoi(GetCurSelID(m_curposition));
  1109. CString str;
  1110. str.Format ("当前柜:%s", m_curposition);
  1111. SetDlgItemText(IDC_STATIC16, str);
  1112. FillGrid2();
  1113. *pResult = 0;
  1114. }
  1115. void FileManage::FillGrid2()
  1116. {
  1117. m_List1.DeleteAllItems2 ();
  1118. int ii=0;
  1119. m_List1.m_arLabels.SetSize( m_List2array.GetSize (), 1 );
  1120. int count=0;
  1121. CString filter=m_curposition+"\\";
  1122. CString str;
  1123. {
  1124. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  1125. {
  1126. str=m_List2array.ElementAt (ii).ElementAt (0)+"\\";
  1127. if(str.Find (filter)!=-1)
  1128. {
  1129. m_List1.m_arLabels.ElementAt (count++).Copy (m_List2array.ElementAt (ii));
  1130. }
  1131. }
  1132. }
  1133. m_List1.m_arLabels.SetSize(count, 1);
  1134. ii=count;
  1135. m_List1.m_LabelCount=ii;
  1136. m_List1.SetItemCountEx (ii);
  1137. str.Format ("当前柜:%s 文件:%d (双击项目打查看文件)", m_curposition, ii);
  1138. SetDlgItemText(IDC_STATIC2, str);
  1139. }
  1140. void FileManage::CalPostion()
  1141. {
  1142. CString id;
  1143. for(int i=0; i<m_List2array.GetSize(); i++)
  1144. {
  1145. id=m_List2array.ElementAt(i).ElementAt(6);
  1146. CString m_strSelect;//="\\"+GetName(id)+m_strSelect;
  1147. while(1)
  1148. {
  1149. BOOL bFind=0;
  1150. for(int a=0; a<m_List1array.GetSize(); a++)
  1151. {
  1152. if(id==m_List1array.ElementAt(a).ElementAt(0))
  1153. {
  1154. bFind=1;
  1155. m_strSelect="\\"+m_List1array.ElementAt(a).ElementAt(2)+m_strSelect;
  1156. id=m_List1array.ElementAt(a).ElementAt(1);
  1157. break;
  1158. }
  1159. }
  1160. if(bFind==0)break;
  1161. }
  1162. m_List2array.ElementAt(i).SetAt(0, m_strSelect);
  1163. }
  1164. }
  1165. void FileManage::OnButton6() // 修改按钮;
  1166. {
  1167. // TODO: Add your control notification handler code here
  1168. int iItem;
  1169. if(1)
  1170. {
  1171. POSITION pos;
  1172. pos=m_List1.GetFirstSelectedItemPosition();
  1173. if(pos==NULL)
  1174. {
  1175. AfxMessageBox("请先选中您要修改的文件!", MB_ICONINFORMATION);
  1176. return;
  1177. }
  1178. iItem=m_List1.GetNextSelectedItem(pos);
  1179. if(! (IsHasRights2new(49) || g_user.name==m_List1.GetItemText (iItem, 2)) )
  1180. {
  1181. return;
  1182. }
  1183. }
  1184. CString date=m_List1.GetItemText (iItem, 3);
  1185. CString position=m_List1.GetItemText (iItem, 0);
  1186. FileManage3 dlg;
  1187. dlg.m_bModify=1;
  1188. dlg.m_curposition=position;
  1189. CString m_patho=m_List1.GetItemText (iItem, 1);
  1190. dlg.m_path=m_patho;
  1191. dlg.level=m_List1.GetItemText (iItem, 4);
  1192. dlg.m_bz=m_List1.GetItemText (iItem, 5);
  1193. if(IDOK!=dlg.DoModal())return;
  1194. CString m_path=dlg.m_path;
  1195. if(m_path==m_patho)m_path="";
  1196. CString level=dlg.level;
  1197. CString m_bz=dlg.m_bz;
  1198. CString filename,curfile,filename2;
  1199. int pos=m_path.Find(";");
  1200. BYTE *pData=new BYTE[1024*200*5+4000];
  1201. DWORD length=0;
  1202. DWORD fileleng;
  1203. int filenum=0;
  1204. while(pos!=-1 || m_path!="")
  1205. {
  1206. if(filenum>=5)
  1207. {
  1208. AfxMessageBox("注意:文件太多,仅保存了前5个文件!", MB_ICONINFORMATION);
  1209. break;
  1210. }
  1211. if(pos!=-1)
  1212. curfile=m_path.Left(pos);
  1213. else
  1214. {
  1215. curfile=m_path;
  1216. m_path="";
  1217. }
  1218. CFile fp;
  1219. if(fp.Open(curfile, CFile::modeRead))
  1220. {
  1221. filename2=curfile.Right(curfile.GetLength()-curfile.ReverseFind('\\')-1);
  1222. filename+=filename2;
  1223. filename+=";";
  1224. fileleng=fp.GetLength();
  1225. if(fileleng>1024*200)
  1226. {
  1227. CString ext;
  1228. if(curfile.Find(".")!=-1)
  1229. ext=curfile.Right(curfile.GetLength()-curfile.ReverseFind('.')-1);
  1230. ext.MakeLower ();
  1231. if(!(ext=="jpg" || ext=="jpeg" || ext=="png"|| ext=="bmp"))
  1232. {
  1233. AfxMessageBox("文件太大,请上传小于200K的文件!");
  1234. fp.Close();
  1235. delete []pData;
  1236. return;
  1237. }
  1238. else
  1239. {
  1240. fp.Close();
  1241. Image *m_pImg=NULL;
  1242. ::LoadImageFromBuf(&m_pImg, curfile);
  1243. if(m_pImg==NULL)
  1244. {
  1245. AfxMessageBox("无效图片!");
  1246. delete []pData;
  1247. return;
  1248. }
  1249. Image *simg2=NULL;
  1250. CRect rc2(0,0,1600,1600);
  1251. RectFitDes(m_pImg->GetWidth(), m_pImg->GetHeight(), rc2);
  1252. simg2=m_pImg->GetThumbnailImage(rc2.Width (), rc2.Height (), NULL, NULL);
  1253. Graphics graphic2(simg2);//防止GetThumbnailImage影响质量
  1254. graphic2.Clear(Color(255,255,255,255));
  1255. graphic2.DrawImage(m_pImg, 0,0,simg2->GetWidth(), simg2->GetHeight() );
  1256. if(m_pImg)delete m_pImg;m_pImg=NULL;
  1257. CString path=g_mainpath+"\\1."+ext;
  1258. ::SaveImageToFile2 (simg2, path, 40); delete simg2;
  1259. if(!fp.Open(path, CFile::modeRead))
  1260. {
  1261. AfxMessageBox("文件打开失败!"); delete []pData;
  1262. return;
  1263. }
  1264. fileleng=fp.GetLength();
  1265. }
  1266. }
  1267. memcpy(pData+length, &fileleng, sizeof(fileleng));length+=sizeof(fileleng);
  1268. fp.Read(pData+length, fileleng);length+=fileleng;
  1269. fp.Close();
  1270. filenum++;
  1271. }
  1272. else
  1273. {
  1274. AfxMessageBox("附件未找到!", MB_ICONINFORMATION);
  1275. }
  1276. if(pos!=-1)
  1277. m_path=m_path.Right(m_path.GetLength()-pos-1);
  1278. pos=m_path.Find(";");
  1279. }
  1280. filename.TrimRight(";");
  1281. CString sql;
  1282. if(filename!="")
  1283. sql.Format("update [filemanage2] set [filename]='%s',[clerk]='%s',[date]='%s',[level]='%s',[bz]='%s' where [date]='%s' ",
  1284. filename, g_user.name, "msgtimestamp2", level, m_bz, date);
  1285. else
  1286. sql.Format("update [filemanage2] set [clerk]='%s',[date]='%s',[level]='%s',[bz]='%s' where [date]='%s' ",
  1287. g_user.name, "msgtimestamp2", level, m_bz, date);
  1288. fileleng=sql.GetLength();
  1289. memcpy(pData+length, &fileleng, sizeof(fileleng));
  1290. DWORD nSqlPos=length;
  1291. length+=sizeof(fileleng);
  1292. memcpy(pData+length, sql.GetBuffer(0), fileleng);
  1293. sql.ReleaseBuffer();
  1294. length+=fileleng;
  1295. memcpy(pData+length, &nSqlPos, sizeof(nSqlPos));
  1296. length+=sizeof(nSqlPos);
  1297. g_nSendCode=44;
  1298. g_pMainWnd->ProcessChatMessageRequest2(pData, length);
  1299. g_nSendCode=0;
  1300. delete []pData;
  1301. if(g_bSendOK==0)return;
  1302. AfxMessageBox("修改成功!", MB_ICONINFORMATION);
  1303. #if 1
  1304. CString strLog = _T("");
  1305. strLog.Format(_T("修改操作:位置:%s; 文件名:%s;存入人:%s; 存入日期:%s; 级别:%s 修改为:位置:%s; 文件名:%s;存入人:%s; 级别:%s"),
  1306. m_List1.GetItemText(iItem,0),
  1307. m_List1.GetItemText(iItem,1),
  1308. m_List1.GetItemText(iItem,2),
  1309. m_List1.GetItemText(iItem,3),
  1310. m_List1.GetItemText(iItem,4),
  1311. dlg.m_curposition,
  1312. filename==_T("")?m_List1.GetItemText(iItem,1):filename,
  1313. g_user.name,
  1314. dlg.level);
  1315. // 2015.03.08 添加删除日志;
  1316. WriteLog(strLog);
  1317. #endif
  1318. GetData();
  1319. }