12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466 |
- // FileManage.cpp : implementation file
- //
- #include "stdafx.h"
- //#include "ZLSoftC.h"
- #include "YLGL.h"
- #include "FileManage.h"
- #include "MyMdi.H"
- #include "ModifyDinDan.h"
- #include "InputPsw.h"
- #include "ImportPhoto.h"
- #include "ImportPhoto.h"
- #include "NeroDlg.h"
- #include "ClientRequirement.h"
- #include "ChoosePhotoSkin2.h"
- #include "./helper/ffsco.h"
- #include "TakeMoney4.h"
- #include "SelFile.h"
- #include "FileManage2.h"
- #include "FileManage3.h"
- #include "Lzari.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- //#pragma comment(lib, "Shlwapi.lib")
- /////////////////////////////////////////////////////////////////////////////yes
- // FileManage
- IMPLEMENT_DYNCREATE(FileManage, MyFormView)
- FileManage::FileManage()
- : MyFormView(FileManage::IDD)
- {
- //{{AFX_DATA_INIT(FileManage)
- m_filter = _T("");
- m_check1 = FALSE;
- m_check2 = FALSE;
- m_curposition = _T("");
- m_curid=-1;
- //}}AFX_DATA_INIT
- }
- FileManage::~FileManage()
- {
- }
- void FileManage::DoDataExchange(CDataExchange* pDX)
- {
- MyFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(FileManage)
- DDX_Control(pDX, IDC_TREE1, m_mytree);
- DDX_Control(pDX, IDC_COMBO1, m_combo1);
- DDX_Control(pDX, IDC_LIST2, m_List1);
- DDX_Control(pDX, IDC_STATIC1, m_static1);
- DDX_CBString(pDX, IDC_COMBO1, m_filter);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(FileManage, MyFormView)
- //{{AFX_MSG_MAP(FileManage)
- ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
- ON_WM_TIMER()
- ON_BN_CLICKED(IDC_BUTshowphoto, OnBUTshowphoto)
- ON_BN_CLICKED(IDC_BUTexportphoto, OnBUTexportphoto)
- ON_BN_CLICKED(IDC_BUTimportphoto, OnBUTimportphoto)
- ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
- ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST2, OnItemchangedList2)
- ON_BN_CLICKED(IDC_BUTburncd, OnBUTFileManage)
- ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2)
- ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
- ON_BN_CLICKED(IDC_BUTburncd2, OnBUTburncd2)
- ON_BN_CLICKED(IDC_CHECK1, OnCheck1)
- ON_BN_CLICKED(IDC_CHECK2, OnCheck2)
- ON_NOTIFY(NM_CLICK, IDC_TREE1, OnClickTree1)
- ON_NOTIFY(TVN_SELCHANGED, IDC_TREE1, OnSelchangedTree1)
- ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
- ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
- ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
- ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
- //}}AFX_MSG_MAP
- ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST2, OnCustomdrawList)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // FileManage diagnostics
- #ifdef _DEBUG
- void FileManage::AssertValid() const
- {
- MyFormView::AssertValid();
- }
- void FileManage::Dump(CDumpContext& dc) const
- {
- MyFormView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // FileManage message handlers
- void FileManage::OnInitialUpdate()
- {
- MyFormView::OnInitialUpdate();
- // SetDlgFont(this);
- // TODO: Add your specialized code here and/or call the base class
- CMyMdi Mdi;
- Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
- GetDlgItem(IDC_BUTburncd2)->EnableWindow(IsHasRights2new(49));
- // Here we create the outbar control using the splitter as its parent
- // and setting its id to the first pane.
- CRect rc2;
- GetWindowRect(rc2);
- ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
- EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
- m_static1.SetFont (&g_titlefont);
- GetDlgItem(IDC_BUTTON5)->EnableWindow(IsHasRights2new(49));
- int idarray[]={IDC_BUTTON4,IDC_BUTTON6,IDC_BUTTON5,IDC_BUTTON2,IDC_BUTclose};
- int idcount=5;
- int btnwid;
- CRect prerc;
- for(int a=idcount-2; a>=0; a--)
- {
- GetDlgItem(idarray[a+1])->GetWindowRect (prerc);
- ScreenToClient(prerc);
- GetDlgItem(idarray[a])->GetWindowRect (rc2);
- ScreenToClient(rc2);
- btnwid=rc2.Width ();
- rc2.right =prerc.left ;
- rc2.left =rc2.right -btnwid;
- GetDlgItem(idarray[a])->MoveWindow (rc2);
- }
- HICON icon[2];
- icon[0]=AfxGetApp()->LoadIcon (IDI_ICON12);
- icon[1]=AfxGetApp()->LoadIcon (IDI_ICON13);
- CImageList *m_imagelist=new CImageList;
- m_imagelist->Create(16,16,0,7,7);
- m_imagelist->SetBkColor (RGB(255,255,255));
- for(int n=0;n<2;n++)
- {
- m_imagelist->Add(icon[n]); //把图标载入图像列表控件
- }
- m_mytree.SetImageList(m_imagelist,TVSIL_NORMAL);
- m_binittree=0;
- GetData();
- m_binittree=1;
- m_combo1.GetWindowRect (rc2);
- ScreenToClient(rc2);
- rc2.bottom +=200;
- m_combo1.MoveWindow (rc2);
- GetDlgItem(IDC_BUTclose)->GetWindowRect(rc2);
- SetComboHei(&m_combo1, rc2.Height ());
- m_List1.SetHeadings("存放位置,100;文件名,100;存入,100;日期,150;阅读级别,100;备注,100" );
- m_List1.LoadColumnInfo (405);
- for(int i=0; i<m_List2array.GetSize (); i++)
- {
- if(m_combo1.FindString(0, m_List2array.ElementAt (i).ElementAt (2))==-1)
- m_combo1.AddString (m_List2array.ElementAt (i).ElementAt (2) );
- }
- }
- void FileManage::FillGrid()
- {
- m_List1.DeleteAllItems2 ();
- int ii=0;
- m_List1.m_arLabels.SetSize( m_List2array.GetSize (), 1 );
- int count=0;
- if(m_filter.IsEmpty ())
- {
- for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
- {
- m_List1.m_arLabels.ElementAt (count++).Copy (m_List2array.ElementAt (ii));
- }
- }
- else
- {
- for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
- {
- if(m_List2array.ElementAt (ii).ElementAt (0).Find (m_filter)!=-1 ||\
- m_List2array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1 || \
- m_List2array.ElementAt (ii).ElementAt (2).Find (m_filter)!=-1 || \
- m_List2array.ElementAt (ii).ElementAt (3).Find (m_filter)!=-1|| \
- m_List2array.ElementAt (ii).ElementAt (4).Find (m_filter)!=-1|| \
- m_List2array.ElementAt (ii).ElementAt (5).Find (m_filter)!=-1 )
- {
- m_List1.m_arLabels.ElementAt (count++).Copy (m_List2array.ElementAt (ii));
- }
- }
- }
- m_List1.m_arLabels.SetSize(count, 1);
- ii=count;
- m_List1.m_LabelCount=ii;
- m_List1.SetItemCountEx (ii);
- CString str;
- str.Format ("文件:%d (双击项目打查看文件)", ii);
- SetDlgItemText(IDC_STATIC2, str);
- }
- void FileManage::OnBUTclose()
- {
- // TODO: Add your control notification handler code here
- GetParent()->SendMessage(WM_CLOSE);
- }
- void FileManage::OnSelchangeCombo1()
- {
- // TODO: Add your control notification handler code here
- SetTimer(1, 100, NULL);
- }
- void FileManage::OnTimer(UINT nIDEvent)
- {
- // TODO: Add your message handler code here and/or call default
- KillTimer(nIDEvent);
- OnButton1();
- }
- BOOL FileManage::PreTranslateMessage(MSG* pMsg)
- {
- // TODO: Add your specialized code here and/or call the base class
- try
- {
- if(pMsg->message==WM_KEYDOWN)
- {
- switch (pMsg->wParam)
- {
- case VK_RETURN:
- OnButton1();
- return 1;
- case 0x43: // copy
- if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
- {
- GetFocus()->SendMessage(WM_COPY);
- return TRUE;
- }
- break;
- case 0x56: //Ctrl + V:
- if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
- {
- GetFocus()->SendMessage(WM_PASTE);
- return TRUE;
- }
- break;
- case 0x58: // cut
- if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
- {
- GetFocus()->SendMessage(WM_CUT);
- return TRUE;
- }
- break;
- case 0x5A: //undo
- case 0x59: //redo
- if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
- {
- GetFocus()->SendMessage(WM_UNDO);
- return TRUE;
- }
- break;
- }
- }
- return MyFormView::PreTranslateMessage(pMsg);
- }
- catch(...)
- {
- }
- }
- extern int CALLBACK BrowseProc(HWND hwnd, UINT msg, LPARAM lParam, LPARAM lpData);
- /*{
- switch(msg)
- {
- case BFFM_INITIALIZED:
- SendMessage(hwnd, BFFM_SETSELECTION, TRUE, NULL);
- break;
- case BFFM_SELCHANGED:
- {
- char szFileName[MAX_PATH];
- LPITEMIDLIST pidlCurrent = (LPITEMIDLIST)lParam;
- SHGetPathFromIDList(pidlCurrent, szFileName);
- SendMessage(hwnd, BFFM_SETSTATUSTEXT, 0, (LPARAM)szFileName);
- }
- break;
- }
- return 0;
- }*/
- void FileManage::GetSavePath(CString &path)
- {
- char lpszDisplayName[MAX_PATH], szFileName[MAX_PATH];
- LPITEMIDLIST pidlDesktop, pidlCurrent;
- if(SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidlDesktop)
- == NOERROR)
- {
- BROWSEINFO bi;
- bi.hwndOwner = this->m_hWnd;
- bi.pidlRoot = pidlDesktop;
- bi.pszDisplayName = lpszDisplayName;
- bi.lpszTitle = "\n文档保存的目录:";
- bi.ulFlags = BIF_STATUSTEXT&BIF_RETURNONLYFSDIRS ;
- bi.lpfn = BrowseProc;
- bi.lParam = 0;
- bi.iImage = 0;
- pidlCurrent = SHBrowseForFolder(&bi);
- SHGetPathFromIDList(pidlCurrent, szFileName);
- path = szFileName;
- }
- }
- int FileManage::FindArray(CStringArray *pArray, CString Str)
- {
- for(int i=0; i<pArray->GetSize (); i++)
- {
- if(pArray->ElementAt (i)==Str)
- return i;
- }
- return -1;
- }
- void FileManage::GetNo(CString str, CStringArray &array)
- {
- if(!str.IsEmpty ())
- {
- int pos=str.Find (",");
- while(pos!=-1)
- {
- if(FindArray(&array, str.Left (pos))==-1)
- array.Add (str.Left (pos));
- str=str.Right (str.GetLength ()-pos-1);
- pos=str.Find (",");
- }
- if(FindArray(&array, str)==-1)
- array.Add(str);
- }
- }
- CString FileManage::GetSelName(CString name, CArray<CStringArray, CStringArray>&spnamearray)
- {
- CString ret;
- name=","+name+",";
- CString str;
- for(int i=0; i<spnamearray.GetSize (); i++)
- {
- str=","+spnamearray.ElementAt (i).ElementAt (6)+",";
- if(str.Find (name)!=-1)
- {
- ret+=spnamearray.ElementAt (i).ElementAt (5);
- ret+=";";
- }
- }
- ret.TrimRight (";");
- ret.Replace ("*", "x");
- return ret;
- }
- void FileManage::OnBUTexportphoto()
- {
- if(IsHasRights2new(11)==0)return;
- // TODO: Add your control notification handler code here
- POSITION pos;
- pos=m_List1.GetFirstSelectedItemPosition();
- if(pos==NULL)
- {
- AfxMessageBox("请先选中您要导出片的定单!", MB_ICONINFORMATION);
- return;
- }
- int iItem=m_List1.GetNextSelectedItem(pos);
- CString id=m_List1.GetItemText (iItem, 0);
- CString path;
- path=g_path4+"\\";
- path+=id;
- path +="\\";
- CString temp;
- CStringArray array;
- using namespace helper_coffs;
- ffsco o;
- o.dirs(0);
- o.find(LPCSTR(path), LPCSTR("*.jpg"));
- ffsco::typeT coo;
- ffsco::typeT::iterator it;
- coo = o.co_file();
- for (it = coo.begin();
- coo.end() != it;
- it ++)
- {
- temp=(*it).c_str();
- if(temp.GetAt (temp.ReverseFind ('\\')+1)!='s' && temp.GetAt (temp.ReverseFind ('\\')+1)!='m')
- {
- array.Add (temp);
- }
- }
- if(array.GetSize ()==0)
- {
- AfxMessageBox("此单未导片!", MB_ICONINFORMATION);
- return;
- }
- CString dir;
- GetSavePath(dir);
- if(dir.IsEmpty())
- {
- return;
- }
- CString name1=m_List1.GetItemText (iItem, 1);
- CString name2=m_List1.GetItemText (iItem, 2);
- dir.TrimRight ('\\');
- dir+="\\";
- dir+=id;
- dir+=name1;
- dir+=name2;
- dir+="精修好的片";
- dir+="\\";
- ::CreateDirectory (dir, NULL);
- ImportPhoto dlg;
- dlg.m_mode =1;
- dlg.m_pArray=&array;
- dlg.m_savepath =dir;
- dlg.DoModal (); AfxMessageBox("导片成功!", MB_ICONINFORMATION);
- }
- void FileManage::OnBUTimportphoto()
- {
- }
- void FileManage::OnBUTshowphoto()
- {
- // TODO: Add your control notification handler code here
- POSITION pos;
- pos=m_List1.GetFirstSelectedItemPosition();
- if(pos==NULL)
- {
- AfxMessageBox("请先选中您要查看的定单!", MB_ICONINFORMATION);
- return;
- }
- int iItem=m_List1.GetNextSelectedItem(pos);
- CString status=m_List1.GetItemText (iItem, 4);
- CString id=m_List1.GetItemText (iItem, 0);
- if(status=="未设计")
- {
- AfxMessageBox("此单未导片!", MB_ICONINFORMATION);
- return;
- }
- /* ShowPic dlg;
- dlg.m_path=g_path3+"\\";
- dlg.m_path+=id;
- dlg.m_path +="\\";
- dlg.DoModal ();*/
- ChoosePhotoSkin2 dlg;
- dlg.m_mode2 =1;
- dlg.SetLiaPath ("3.lia");
- //dlg.m_id=id;
- dlg.m_strOrderNumber = id;
- dlg.m_path=g_path3+"\\";
- dlg.m_path+=id;
- dlg.m_path +="\\";
- dlg.DoModal ();
- for(int i=0; i<m_List1array.GetSize (); i++)
- {
- if(id==m_List1array.ElementAt (i).ElementAt (0))
- {
- break;
- }
- }
- }
- void FileManage::OnButton1()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- m_filter.TrimLeft ();
- m_filter.TrimRight ();
- FillGrid();
- }
- void FileManage::OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult)
- {
- NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
- // TODO: Add your control notification handler code here
- POSITION pos;
- pos=m_List1.GetFirstSelectedItemPosition();
- if(pos==NULL)
- {
- return;
- }
- int iItem=m_List1.GetNextSelectedItem(pos);
- CString waiter4=m_List1.GetItemText (iItem, 10);
- if(waiter4.IsEmpty () && IsHasRights2new(7) || IsHasRights2new(49) )
- {
- GetDlgItem(IDC_BUTimportphoto)->EnableWindow(1);
- }
- else if(waiter4==g_user.name && IsHasRights2new(7) )
- {
- GetDlgItem(IDC_BUTimportphoto)->EnableWindow(1);
- }
- else
- GetDlgItem(IDC_BUTimportphoto)->EnableWindow(0);
- *pResult = 0;
- }
- void FileManage::OnBUTFileManage()
- {
- // TODO: Add your control notification handler code here
- #ifdef ZLCX_VERSION
- //return;
- #endif
- POSITION pos;
- pos=m_List1.GetFirstSelectedItemPosition();
- if(pos==NULL)
- {
- return;
- }
- int iItem=m_List1.GetNextSelectedItem(pos);
- CString id=m_List1.GetItemText (iItem, 0);
- TakeMoney4 dlg;
- dlg.m_mode =5;
- dlg.m_id =id;
- dlg.m_name1 =m_List1.GetItemText (iItem, 1);
- dlg.m_name2 =m_List1.GetItemText (iItem, 2);
- if(dlg.DoModal ()!=IDOK)return;
- }
- void FileManage::OnDblclkList2(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- OnButton2();
- *pResult = 0;
- }
- void FileManage::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
- {
- NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
- // Take the default processing unless we set this to something else below.
- *pResult = 0;
- // First thing - check the draw stage. If it's the control's prepaint
- // stage, then tell Windows we want messages for every item.
- if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
- {
- *pResult = CDRF_NOTIFYITEMDRAW;
- }
- else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
- {
- // This is the prepaint stage for an item. Here's where we set the
- // item's text color. Our return value will tell Windows to draw the
- // item itself, but it will use the new color we set here.
- // We'll cycle the colors through red, green, and light blue.
- /* if(m_List1.m_arLabels.ElementAt (pLVCD->nmcd.dwItemSpec).ElementAt (8)!="0")
- pLVCD->clrText = RGB(220,0,0);
- else
- pLVCD->clrText = RGB(20,133,20);*/
- if(pLVCD->nmcd.dwItemSpec%2)
- pLVCD->clrTextBk = g_gridcol1;
- else
- pLVCD->clrTextBk = g_gridcol2;
- // Store the color back in the NMLVCUSTOMDRAW struct.
- // Tell Windows to paint the control itself.
- *pResult = CDRF_DODEFAULT;
- }
- }
- void FileManage::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- POSITION pos;
- pos=m_List1.GetFirstSelectedItemPosition();
- if(pos==NULL)return;
- int iItem=m_List1.GetNextSelectedItem(pos);
- if(g_user.account=="admin")
- {
- GetDlgItem(IDC_BUTTON2)->EnableWindow(1);
- }
- else if(g_user.level!="")
- {
- if(atoi(g_user.level.Left(1))>=atoi(m_List1.GetItemText (iItem, 4)) )
- GetDlgItem(IDC_BUTTON2)->EnableWindow(1);
- else
- GetDlgItem(IDC_BUTTON2)->EnableWindow(0);
- }
- else
- GetDlgItem(IDC_BUTTON2)->EnableWindow(0);
- if(IsHasRights2new(49) || g_user.name==m_List1.GetItemText (iItem, 2))
- {
- GetDlgItem(IDC_BUTTON6)->EnableWindow(1);
- }
- else
- {
- GetDlgItem(IDC_BUTTON6)->EnableWindow(0);
- }
- *pResult = 0;
- }
- void FileManage::HidePrice()
- {
- }
- void FileManage::OnBUTburncd2()
- {
- // TODO: Add your control notification handler code here
- ListToXLS(&m_List1, "c:\\客人欠款.xls", 0);
- }
- //ZLCX
- void FileManage::OnCheck1()
- {
- // TODO: Add your control notification handler code here
- }
- void FileManage::OnCheck2()
- {
- // TODO: Add your control notification handler code here
- }
- void FileManage::OnClickTree1(NMHDR* pNMHDR, LRESULT* pResult)
- {
- // TODO: Add your control notification handler code here
- OnSelchangedTree1( pNMHDR, pResult) ;
- *pResult = 0;
- }
- CString FileManage::GetName(CString id)
- {
- for(int i=0; i<m_List1array.GetSize(); i++)
- {
- if(m_List1array.ElementAt(i).ElementAt(0)==id)
- {
- return m_List1array.ElementAt(i).ElementAt(2);
- }
- }
- return "";
- }
- void FileManage::AddChild(CString curid, HTREEITEM hParent)
- {
- HTREEITEM hChild;
- if(hParent==NULL)
- hChild=m_mytree.InsertItem(GetName(curid),0,1,TVI_ROOT,TVI_LAST);
- else
- hChild=m_mytree.InsertItem(GetName(curid),0,1,hParent,TVI_LAST);
- for(int i=0; i<m_List1array.GetSize(); i++)
- {
- if(m_List1array.ElementAt(i).ElementAt(1)==curid)
- {
- AddChild(m_List1array.ElementAt(i).ElementAt(0), hChild);
- }
- }
- }
- void FileManage::GetData()
- {
- g_sendhead.bsql=0;
- if(m_binittree)
- {
- g_sendhead.code[0]=233;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(1);
- if(g_bSendOK==0)return;
- DataToArray(&m_List2array); CalPostion();
- if(
- m_curposition!="")
- FillGrid2();
- else
- FillGrid();
- return;
- }
- m_curid=-1;
- m_curposition="";
- CString str;
- str.Format ("当前柜:%s", m_curposition);
- SetDlgItemText(IDC_STATIC16, str);
- g_sendhead.code[0]=232;
- g_sendhead.code[1]=233;
- g_sendhead.tabcount=2;
- g_pMainWnd->ProcessChatMessageRequest2(1);
- if(g_bSendOK==0)return;
- DataToArray(&m_List1array,&m_List2array);CalPostion();
- m_mytree.DeleteAllItems();
- for(int i=0; i<m_List1array.GetSize(); i++)
- {
- if(m_List1array.ElementAt(i).ElementAt(1)=="")
- {
- AddChild(m_List1array.ElementAt(i).ElementAt(0), NULL);
- continue;
- HTREEITEM root0=m_mytree.InsertItem(m_List1array.ElementAt(i).ElementAt(2),0,1,TVI_ROOT,TVI_LAST);
- CString curid=m_List1array.ElementAt(i).ElementAt(0);
- for(int a=0; a<m_List1array.GetSize(); a++)
- {
- if(m_List1array.ElementAt(a).ElementAt(1)==curid)
- {
- HTREEITEM sub_son0=m_mytree.InsertItem(m_List1array.ElementAt(a).ElementAt(2),0,1,root0,TVI_LAST);
- CString childid=m_List1array.ElementAt(a).ElementAt(0);
- //while(1)
- {
- // BOOL bFind=0;
- for(int b=0; b<m_List1array.GetSize(); b++)
- {
- if(m_List1array.ElementAt(b).ElementAt(1)==childid)
- {
- // bFind=1;
- m_mytree.InsertItem(m_List1array.ElementAt(b).ElementAt(2),0,1,sub_son0,TVI_LAST);
- }
- }
- // if(bFind==0)break;
- }
- }
- }
- }
- }
- FillGrid();
- }
- void FileManage::GetChildId(CString oldstr, CString curid, CStringArray *pArray)
- {
- CString oldstrbak=oldstr;
- for(int i=0; i<m_List1array.GetSize(); i++)
- {
- oldstr=oldstrbak;
- if(m_List1array.ElementAt(i).ElementAt(1)==curid)
- {
- CString curid=m_List1array.ElementAt(i).ElementAt(0);
- oldstr+="\\"+GetName(curid);
- GetChildId(oldstr, curid, pArray);
- pArray->Add(oldstr); pArray->Add(curid);
- }
- }
- }
- CString FileManage::GetCurSelID(CString &path)
- {
- HTREEITEM hSelectedItem = m_mytree.GetSelectedItem();
- if(hSelectedItem==NULL)
- {
- return "";
- }
- CString m_strSelect;
- while(hSelectedItem)
- {
- m_strSelect="\\"+m_mytree.GetItemText(hSelectedItem)+m_strSelect;
- hSelectedItem=m_mytree.GetParentItem(hSelectedItem);
- }
- for(int i=0; i<m_List1array.GetSize(); i++)
- {
- if(m_List1array.ElementAt(i).ElementAt(1)!="")continue;//不是主则继续
- CString m_strSelect2;
- CString curid=m_List1array.ElementAt(i).ElementAt(0);
- m_strSelect2+="\\"+GetName(curid);
- CStringArray array;
- array.Add(m_strSelect2); array.Add(curid);
- GetChildId(m_strSelect2, curid, &array);
- for(int aa=0; aa<array.GetSize(); aa+=2)
- {
- if(m_strSelect==array.ElementAt(aa))
- {
- path=m_strSelect;
- return array.ElementAt(aa+1);
- }
- }
- continue;
- m_strSelect2+="\\"+m_List1array.ElementAt(i).ElementAt(2);
- if(m_strSelect==m_strSelect2)
- {
- return m_List1array.ElementAt(i).ElementAt(0);
- }
- AfxMessageBox("curid:"+curid);
- AfxMessageBox("curm_strSelect2:"+m_strSelect2);
- for(int a=0; a<m_List1array.GetSize(); a++)
- {
- if(m_List1array.ElementAt(a).ElementAt(1)==curid)
- {
- // m_strSelect2+="\\"+m_List1array.ElementAt(a).ElementAt(2);
- // AfxMessageBox("curm_strSelect2:"+m_strSelect2);
- if(m_strSelect==m_strSelect2+"\\"+m_List1array.ElementAt(a).ElementAt(2))
- {
- AfxMessageBox("find:"+m_List1array.ElementAt(a).ElementAt(0));
- return m_List1array.ElementAt(a).ElementAt(0);
- }
- }
- }
- }
- return "";
- }
- void FileManage::ShowFile(CStringArray *patharray)
- {
- if(patharray->GetSize()==0)return;
- if(patharray->GetSize()==1)
- {
- CString str=patharray->ElementAt(0);
- CString ext;
- if(str.Find(".")!=-1)
- ext=str.Right(str.GetLength()-str.ReverseFind('.')-1);
- ext.MakeLower ();
- if(0)//ext=="jpg" || ext=="jpeg" || ext=="png" || ext=="gif"|| ext=="bmp")
- {
- Image *m_pImg=NULL;
- ::LoadImageFromBuf (&m_pImg, str);
- if(m_pImg==NULL)
- {
- AfxMessageBox("无效图片文件!");return;
- }
- // ShowPhoto dlg;
- // dlg.m_pImg=m_pImg;
- // dlg.DoModal();
- delete m_pImg;
- }
- else
- {
- ShellExecute(NULL, _T("open"), str, NULL, NULL, SW_SHOWMAXIMIZED);
- }
- return;
- }
- SelFile dlg;
- dlg.m_pArray=patharray;
- dlg.DoModal();
- }
- void FileManage::OnButton2() // 查看文件;
- {
- POSITION pos;
- pos=m_List1.GetFirstSelectedItemPosition();
- if(pos==NULL)
- {
- AfxMessageBox("请先选中您要查看的文件!", MB_ICONINFORMATION);
- return;
- }
- int iItem=m_List1.GetNextSelectedItem(pos);
- if(g_user.account=="admin")
- {
- }
- else if(g_user.level!="")
- {
- if(atoi(g_user.level.Left(1))<atoi(m_List1.GetItemText (iItem, 4)) )
- return;
- }
- else
- return;
- CString date=m_List1.GetItemText (iItem, 3);
- CString m_path=m_List1.GetItemText (iItem, 1);
- if(1)
- {
- CString m_pathtemp=m_path;
- CString curfile;
- int pos=m_path.Find(";");
- CStringArray patharray;
- while(pos!=-1 || m_path!="")
- {
- if(pos!=-1)
- curfile=m_path.Left(pos);
- else
- {
- curfile=m_path;
- m_path="";
- }
- CString str=g_path1+"\\公告附件\\"+curfile;patharray.Add(str);
- if(pos!=-1)
- m_path=m_path.Right(m_path.GetLength()-pos-1);
- pos=m_path.Find(";");
- }
- m_path=m_pathtemp;
- char no[20];
- memset(no, 0, 20);
- strcpy(no, date);
- g_nSendCode=43;
- g_pMainWnd->ProcessChatMessageRequest2((BYTE*)no, 20);
- g_nSendCode=0;
- if(g_bSendOK==0)
- {
- return;
- }
- DWORD nReaded=0;
- int filepos=0;
- DeleteDirectory(g_mainpath+"\\公告");
- ::CreateDirectory(g_mainpath+"\\公告", NULL);
- CStringArray patharraytemp;
- if(1)
- {
- BYTE *lpszOut = NULL;
- int nOutSize = 0;
- LZARI Lzari;
- Lzari.UnCompress(g_pData,g_nLeng,lpszOut,nOutSize);
- CMemFile memfile;
- // memfile.Attach (lpszOut,nOutSize);
- delete []g_pData;
- g_pData=new BYTE[nOutSize];
- memcpy(g_pData, lpszOut,nOutSize);
- Lzari.Release();
- g_nLeng=nOutSize;
- }
- while(nReaded<g_nLeng)
- {
- if(filepos>=patharray.GetSize())break;
- CString path=patharray.ElementAt(filepos);filepos++;
- path=g_mainpath+"\\公告"+path.Right(path.GetLength()-path.ReverseFind('\\'));
- DWORD leng;
- memcpy(&leng, g_pData+nReaded, sizeof(DWORD));nReaded+=sizeof(DWORD);
- CFile fp;
- fp.Open(path, CFile::modeWrite|CFile::modeCreate);
- fp.Write(g_pData+nReaded, leng);nReaded+=leng;
- fp.Close();
- patharraytemp.Add(path);
- }
- patharray.RemoveAll();
- patharray.Copy(patharraytemp);
- ShowFile(&patharray);
- return;
- }
- }
- void FileManage::OnButton8() // 管理按钮;
- {
- // TODO: Add your control notification handler code here
- FileManage2 dlg;
- dlg.DoModal();
- m_binittree=0;
- GetData();
- m_binittree=1;
- }
- void FileManage::OnButton4() //存入文件;
- {
- // TODO: Add your control notification handler code here
- if(m_curid==-1)
- {
- AfxMessageBox("未选择当前柜!", MB_ICONINFORMATION);return;
- }
- FileManage3 dlg;
- UpdateData();
- dlg.m_curposition=m_curposition; // Jeff.当前文件柜位置;
- if(IDOK!=dlg.DoModal())return;
- CString m_path=dlg.m_path; // Jeff.文件名路径;
- CString level=dlg.level; // 阅读级别;
- CString m_bz=dlg.m_bz; // 备注;
- CString filename,curfile,filename2;
- BYTE *pData=new BYTE[1024*200*5+4000];
- DWORD length=0;
- DWORD fileleng;
- int filenum=0; // Jeff.选择的文件数量;
- int pos=m_path.Find(";");
- while(pos!=-1 || m_path!="")
- {
- if(filenum>=5)
- {
- AfxMessageBox("注意:文件太多,仅保存了前5个文件!", MB_ICONINFORMATION);
- break;
- }
- if(pos!=-1)
- curfile=m_path.Left(pos);
- else
- {
- curfile=m_path;
- m_path="";
- }
- CFile fp;
- if(fp.Open(curfile, CFile::modeRead))
- {
- filename2=curfile.Right(curfile.GetLength()-curfile.ReverseFind('\\')-1);
- filename+=filename2;
- filename+=";";
- fileleng=fp.GetLength();
- if(fileleng>1024*200)
- {
- CString ext;
- if(curfile.Find(".")!=-1)
- ext=curfile.Right(curfile.GetLength()-curfile.ReverseFind('.')-1);
- ext.MakeLower();
- if(!(ext=="jpg" || ext=="jpeg" || ext=="png"|| ext=="bmp"))
- {
- AfxMessageBox("文件太大,请上传小于200K的文件!");
- fp.Close();
- delete []pData;
- return;
- }
- else
- {
- fp.Close();
- Image *m_pImg=NULL;
- ::LoadImageFromBuf(&m_pImg, curfile);
- if(m_pImg==NULL)
- {
- AfxMessageBox("无效图片!");
- delete []pData;
- return;
- }
- Image *simg2=NULL;
- CRect rc2(0,0,1600,1600);
- RectFitDes(m_pImg->GetWidth(), m_pImg->GetHeight(), rc2);
- simg2=m_pImg->GetThumbnailImage(rc2.Width(), rc2.Height(), NULL, NULL);
- Graphics graphic2(simg2);//防止GetThumbnailImage影响质量
- graphic2.Clear(Color(255,255,255,255));
- graphic2.DrawImage(m_pImg, 0,0,simg2->GetWidth(), simg2->GetHeight() );
- if(m_pImg)delete m_pImg;
- m_pImg=NULL;
- CString path=g_mainpath+"\\1."+ext;
- ::SaveImageToFile2(simg2, path, 40);
- delete simg2;
- if(!fp.Open(path, CFile::modeRead))
- {
- AfxMessageBox("文件打开失败!");
- delete []pData;
- return;
- }
- fileleng=fp.GetLength();
- }
- }
- // 1.先存入文件的大小,sizeof(DWROD) fileleng;
- memcpy(pData+length, &fileleng, sizeof(fileleng));
- length+=sizeof(fileleng);
- // 2.再读入文件的数据;
- fp.Read(pData+length, fileleng);
- length+=fileleng;
- fp.Close();
- filenum++;
- }
- else
- {
- AfxMessageBox("附件未找到!", MB_ICONINFORMATION);
- }
- if(pos!=-1)
- m_path=m_path.Right(m_path.GetLength()-pos-1);
- pos=m_path.Find(";");
- }
- filename.TrimRight(";");
- CString sql;
- sql.Format("insert into [filemanage2]([parent],[filename],[clerk],[date],[level],[bz],[position]) values('%d','%s','%s','%s','%s','%s','%s')",
- m_curid, filename, g_user.name, "msgtimestamp2", level, m_bz, m_curposition);
- /* g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
- AfxMessageBox("保存成功!", MB_ICONINFORMATION);*/
- // 3.写入SQL语句的长度;(当做另一文件来操作)
- fileleng=sql.GetLength();
- memcpy(pData+length, &fileleng, sizeof(fileleng));
- // 4.写入SQL语句;
- DWORD nSqlPos=length;
- length+=sizeof(fileleng);
- memcpy(pData+length, sql.GetBuffer(0), fileleng);
- sql.ReleaseBuffer();
- // 5.写入SQL语句在数据内的位置;
- length+=fileleng;
- memcpy(pData+length, &nSqlPos, sizeof(nSqlPos));
- length+=sizeof(nSqlPos);
- g_nSendCode=42;
- g_pMainWnd->ProcessChatMessageRequest2(pData, length);
- g_nSendCode=0;
- delete []pData;
- if(g_bSendOK==0)return;
- AfxMessageBox("存入成功!", MB_ICONINFORMATION);
- #if 1
- CString strLog = _T("");
- strLog.Format(_T("存入操作:位置:%s; 文件名:%s; 级别:%s"),
- m_curposition,
- filename,
- level);
- // 2015.03.08 添加删除日志;
- WriteLog(strLog);
- #endif
- GetData();
- }
- void FileManage::OnButton5() // 删除按钮;
- {
- if(IsHasRights2new(49)==0)return;
- // TODO: Add your control notification handler code here
- POSITION pos;
- pos=m_List1.GetFirstSelectedItemPosition();
- if(pos==NULL)
- {
- AfxMessageBox("请先选中您要删除的文件!", MB_ICONINFORMATION);
- return;
- }
- if(AfxMessageBox("确认删除此文件吗?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return;
- int iItem=m_List1.GetNextSelectedItem(pos);
- CString date=m_List1.GetItemText (iItem, 3);
- CString position=m_List1.GetItemText (iItem, 0);
-
- CString sql;
- sql.Format("delete from filemanage2 where [date]='%s' ", date);
- g_sendhead.bsql=1;
- g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return;
- #if 1
- CString strLog = _T("");
- strLog.Format(_T("删除操作:位置:%s; 文件名:%s;存入人:%s; 存入日期:%s; 级别:%s"),
- m_List1.GetItemText(iItem,0),
- m_List1.GetItemText(iItem,1),
- m_List1.GetItemText(iItem,2),
- m_List1.GetItemText(iItem,3),
- m_List1.GetItemText(iItem,4));
- // 2015.03.08 添加删除日志;
- WriteLog(strLog);
- #endif
- GetData();
- }
- void FileManage::GetData2()
- {
- g_sendhead.bsql=0;
- g_sendhead.code[0]=232;
- g_sendhead.tabcount=1;
- g_pMainWnd->ProcessChatMessageRequest2(1);
- if(g_bSendOK==0)return;
- DataToArray(&m_List1array);
- m_curid=-1;
- m_curposition="";
- CString str;
- str.Format ("当前柜:%s", m_curposition);
- SetDlgItemText(IDC_STATIC16, str);
- m_mytree.DeleteAllItems();
- for(int i=0; i<m_List1array.GetSize(); i++)
- {
- if(m_List1array.ElementAt(i).ElementAt(1)=="")
- {
- AddChild(m_List1array.ElementAt(i).ElementAt(0), NULL);
- continue;
- HTREEITEM root0=m_mytree.InsertItem(m_List1array.ElementAt(i).ElementAt(2),0,1,TVI_ROOT,TVI_LAST);
- CString curid=m_List1array.ElementAt(i).ElementAt(0);
- for(int a=0; a<m_List1array.GetSize(); a++)
- {
- if(m_List1array.ElementAt(a).ElementAt(1)==curid)
- {
- HTREEITEM sub_son0=m_mytree.InsertItem(m_List1array.ElementAt(a).ElementAt(2),0,1,root0,TVI_LAST);
- CString childid=m_List1array.ElementAt(a).ElementAt(0);
- //while(1)
- {
- // BOOL bFind=0;
- for(int b=0; b<m_List1array.GetSize(); b++)
- {
- if(m_List1array.ElementAt(b).ElementAt(1)==childid)
- {
- // bFind=1;
- m_mytree.InsertItem(m_List1array.ElementAt(b).ElementAt(2),0,1,sub_son0,TVI_LAST);
- }
- }
- // if(bFind==0)break;
- }
- }
- }
- }
- }
- }
- void FileManage::OnSelchangedTree1(NMHDR* pNMHDR, LRESULT* pResult)
- {
- NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
- // TODO: Add your control notification handler code here
- // CString str=m_mytree.GetItemText(pNMTreeView->itemNew.hItem);
- UpdateData();
- HTREEITEM hSelectedItem = m_mytree.GetSelectedItem();
- if(hSelectedItem==NULL)
- {
- m_curposition="";
- CString str;
- str.Format ("当前柜:%s", m_curposition);
- SetDlgItemText(IDC_STATIC16, str);
- m_curid=-1;
- return;
- }
- m_curid=atoi(GetCurSelID(m_curposition));
- CString str;
- str.Format ("当前柜:%s", m_curposition);
- SetDlgItemText(IDC_STATIC16, str);
- FillGrid2();
- *pResult = 0;
- }
- void FileManage::FillGrid2()
- {
- m_List1.DeleteAllItems2 ();
- int ii=0;
- m_List1.m_arLabels.SetSize( m_List2array.GetSize (), 1 );
- int count=0;
- CString filter=m_curposition+"\\";
- CString str;
- {
- for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
- {
- str=m_List2array.ElementAt (ii).ElementAt (0)+"\\";
- if(str.Find (filter)!=-1)
- {
- m_List1.m_arLabels.ElementAt (count++).Copy (m_List2array.ElementAt (ii));
- }
- }
- }
- m_List1.m_arLabels.SetSize(count, 1);
- ii=count;
- m_List1.m_LabelCount=ii;
- m_List1.SetItemCountEx (ii);
- str.Format ("当前柜:%s 文件:%d (双击项目打查看文件)", m_curposition, ii);
- SetDlgItemText(IDC_STATIC2, str);
- }
- void FileManage::CalPostion()
- {
- CString id;
- for(int i=0; i<m_List2array.GetSize(); i++)
- {
- id=m_List2array.ElementAt(i).ElementAt(6);
- CString m_strSelect;//="\\"+GetName(id)+m_strSelect;
- while(1)
- {
- BOOL bFind=0;
- for(int a=0; a<m_List1array.GetSize(); a++)
- {
- if(id==m_List1array.ElementAt(a).ElementAt(0))
- {
- bFind=1;
- m_strSelect="\\"+m_List1array.ElementAt(a).ElementAt(2)+m_strSelect;
- id=m_List1array.ElementAt(a).ElementAt(1);
- break;
- }
- }
- if(bFind==0)break;
- }
- m_List2array.ElementAt(i).SetAt(0, m_strSelect);
- }
- }
- void FileManage::OnButton6() // 修改按钮;
- {
- // TODO: Add your control notification handler code here
- int iItem;
- if(1)
- {
- POSITION pos;
- pos=m_List1.GetFirstSelectedItemPosition();
- if(pos==NULL)
- {
- AfxMessageBox("请先选中您要修改的文件!", MB_ICONINFORMATION);
- return;
- }
- iItem=m_List1.GetNextSelectedItem(pos);
- if(! (IsHasRights2new(49) || g_user.name==m_List1.GetItemText (iItem, 2)) )
- {
- return;
- }
- }
- CString date=m_List1.GetItemText (iItem, 3);
- CString position=m_List1.GetItemText (iItem, 0);
- FileManage3 dlg;
- dlg.m_bModify=1;
- dlg.m_curposition=position;
- CString m_patho=m_List1.GetItemText (iItem, 1);
- dlg.m_path=m_patho;
- dlg.level=m_List1.GetItemText (iItem, 4);
- dlg.m_bz=m_List1.GetItemText (iItem, 5);
- if(IDOK!=dlg.DoModal())return;
- CString m_path=dlg.m_path;
- if(m_path==m_patho)m_path="";
- CString level=dlg.level;
- CString m_bz=dlg.m_bz;
- CString filename,curfile,filename2;
- int pos=m_path.Find(";");
- BYTE *pData=new BYTE[1024*200*5+4000];
- DWORD length=0;
- DWORD fileleng;
- int filenum=0;
- while(pos!=-1 || m_path!="")
- {
- if(filenum>=5)
- {
- AfxMessageBox("注意:文件太多,仅保存了前5个文件!", MB_ICONINFORMATION);
- break;
- }
- if(pos!=-1)
- curfile=m_path.Left(pos);
- else
- {
- curfile=m_path;
- m_path="";
- }
- CFile fp;
- if(fp.Open(curfile, CFile::modeRead))
- {
- filename2=curfile.Right(curfile.GetLength()-curfile.ReverseFind('\\')-1);
- filename+=filename2;
- filename+=";";
- fileleng=fp.GetLength();
- if(fileleng>1024*200)
- {
- CString ext;
- if(curfile.Find(".")!=-1)
- ext=curfile.Right(curfile.GetLength()-curfile.ReverseFind('.')-1);
- ext.MakeLower ();
- if(!(ext=="jpg" || ext=="jpeg" || ext=="png"|| ext=="bmp"))
- {
- AfxMessageBox("文件太大,请上传小于200K的文件!");
- fp.Close();
- delete []pData;
- return;
- }
- else
- {
- fp.Close();
- Image *m_pImg=NULL;
- ::LoadImageFromBuf(&m_pImg, curfile);
- if(m_pImg==NULL)
- {
- AfxMessageBox("无效图片!");
- delete []pData;
- return;
- }
- Image *simg2=NULL;
- CRect rc2(0,0,1600,1600);
- RectFitDes(m_pImg->GetWidth(), m_pImg->GetHeight(), rc2);
- simg2=m_pImg->GetThumbnailImage(rc2.Width (), rc2.Height (), NULL, NULL);
- Graphics graphic2(simg2);//防止GetThumbnailImage影响质量
- graphic2.Clear(Color(255,255,255,255));
- graphic2.DrawImage(m_pImg, 0,0,simg2->GetWidth(), simg2->GetHeight() );
- if(m_pImg)delete m_pImg;m_pImg=NULL;
- CString path=g_mainpath+"\\1."+ext;
- ::SaveImageToFile2 (simg2, path, 40); delete simg2;
- if(!fp.Open(path, CFile::modeRead))
- {
- AfxMessageBox("文件打开失败!"); delete []pData;
- return;
- }
- fileleng=fp.GetLength();
- }
- }
- memcpy(pData+length, &fileleng, sizeof(fileleng));length+=sizeof(fileleng);
- fp.Read(pData+length, fileleng);length+=fileleng;
- fp.Close();
- filenum++;
- }
- else
- {
- AfxMessageBox("附件未找到!", MB_ICONINFORMATION);
- }
- if(pos!=-1)
- m_path=m_path.Right(m_path.GetLength()-pos-1);
- pos=m_path.Find(";");
- }
- filename.TrimRight(";");
- CString sql;
- if(filename!="")
- sql.Format("update [filemanage2] set [filename]='%s',[clerk]='%s',[date]='%s',[level]='%s',[bz]='%s' where [date]='%s' ",
- filename, g_user.name, "msgtimestamp2", level, m_bz, date);
- else
- sql.Format("update [filemanage2] set [clerk]='%s',[date]='%s',[level]='%s',[bz]='%s' where [date]='%s' ",
- g_user.name, "msgtimestamp2", level, m_bz, date);
- fileleng=sql.GetLength();
- memcpy(pData+length, &fileleng, sizeof(fileleng));
- DWORD nSqlPos=length;
- length+=sizeof(fileleng);
- memcpy(pData+length, sql.GetBuffer(0), fileleng);
- sql.ReleaseBuffer();
- length+=fileleng;
- memcpy(pData+length, &nSqlPos, sizeof(nSqlPos));
- length+=sizeof(nSqlPos);
- g_nSendCode=44;
- g_pMainWnd->ProcessChatMessageRequest2(pData, length);
- g_nSendCode=0;
- delete []pData;
- if(g_bSendOK==0)return;
- AfxMessageBox("修改成功!", MB_ICONINFORMATION);
- #if 1
- CString strLog = _T("");
- strLog.Format(_T("修改操作:位置:%s; 文件名:%s;存入人:%s; 存入日期:%s; 级别:%s 修改为:位置:%s; 文件名:%s;存入人:%s; 级别:%s"),
- m_List1.GetItemText(iItem,0),
- m_List1.GetItemText(iItem,1),
- m_List1.GetItemText(iItem,2),
- m_List1.GetItemText(iItem,3),
- m_List1.GetItemText(iItem,4),
- dlg.m_curposition,
- filename==_T("")?m_List1.GetItemText(iItem,1):filename,
- g_user.name,
- dlg.level);
- // 2015.03.08 添加删除日志;
- WriteLog(strLog);
- #endif
- GetData();
- }
|