// FileManage2.cpp : implementation file // #include "stdafx.h" //#include "ZLSoftC.h" #include "YLGL.h" #include "FileManage2.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // FileManage2 dialog FileManage2::FileManage2(CWnd* pParent /*=NULL*/) : CDialog(FileManage2::IDD, pParent) { //{{AFX_DATA_INIT(FileManage2) m_text = _T(""); //}}AFX_DATA_INIT } void FileManage2::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(FileManage2) DDX_Control(pDX, IDC_TREE1, m_mytree); DDX_Text(pDX, IDC_EDIT1, m_text); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(FileManage2, CDialog) //{{AFX_MSG_MAP(FileManage2) ON_NOTIFY(TVN_SELCHANGED, IDC_TREE1, OnSelchangedTree1) ON_BN_CLICKED(IDC_BUTAddP, OnBUTAddP) ON_BN_CLICKED(IDC_BUTAddC, OnBUTAddC) ON_BN_CLICKED(IDC_BUTrename, OnBUTrename) ON_BN_CLICKED(IDC_BUTdel, OnBUTdel) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // FileManage2 message handlers BOOL FileManage2::OnInitDialog() { CDialog::OnInitDialog(); // SetDlgFont( this ); // TODO: Add extra initialization here GetDlgItem(IDC_BUTrename)->EnableWindow(IsHasRights2new(49)); GetDlgItem(IDC_BUTdel)->EnableWindow(IsHasRights2new(49)); 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); GetData(); CenterWindow(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void FileManage2::GetData() { 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_mytree.DeleteAllItems(); for(int i=0; iAdd(oldstr); pArray->Add(curid); } } } void FileManage2::OnBUTAddP() { // TODO: Add your control notification handler code here UpdateData(); m_text.TrimLeft(); m_text.TrimRight(); if( m_text=="" )return; if(m_text.Find("\\")!=-1 || m_text.Find("(")!=-1 || m_text.Find(")")!=-1) { AfxMessageBox("请不要包含\\,(,)字符", MB_ICONINFORMATION); return; } for(int i=0; iProcessChatMessageRequest2(sql);if(g_bSendOK==0)return; AfxMessageBox("保存成功!", MB_ICONINFORMATION); GetData(); } void FileManage2::OnBUTAddC() { // TODO: Add your control notification handler code here UpdateData(); m_text.TrimLeft(); m_text.TrimRight(); if( m_text=="" )return; if(m_text.Find("\\")!=-1 || m_text.Find("(")!=-1 || m_text.Find(")")!=-1) { AfxMessageBox("请不要包含\\,(,)字符", MB_ICONINFORMATION); return; } int pos; CString str; HTREEITEM hSelectedItem = m_mytree.GetSelectedItem(); if(hSelectedItem==NULL) { AfxMessageBox("请先选中上级项目!", MB_ICONINFORMATION); return; } CString path; CString parent=GetCurSelID(path); if(parent=="") { AfxMessageBox("出错了!", MB_ICONINFORMATION); return; } path+="\\"+m_text; if(CheckExist(path)) { AfxMessageBox("已存在此名称的项目,请重新命名!", MB_ICONINFORMATION); return; } CString sql; sql.Format("insert into [filemanage]([parent],[name])values('%s','%s')", parent, m_text); g_sendhead.bsql=1; g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return; AfxMessageBox("保存成功!", MB_ICONINFORMATION); GetData(); } void FileManage2::OnBUTrename() { // TODO: Add your control notification handler code here UpdateData(); m_text.TrimLeft(); m_text.TrimRight(); if( m_text=="" )return; if(m_text.Find("\\")!=-1 || m_text.Find("(")!=-1 || m_text.Find(")")!=-1) { AfxMessageBox("请不要包含\\,(,)字符", MB_ICONINFORMATION); return; } CString str; HTREEITEM hSelectedItem = m_mytree.GetSelectedItem(); if(hSelectedItem==NULL) { AfxMessageBox("请先选中您要改名的项目!", MB_ICONINFORMATION); return; } CString path; CString parent=GetCurSelID(path); if(parent=="") { AfxMessageBox("出错了!", MB_ICONINFORMATION); return; } int pos=path.ReverseFind('\\'); if(pos!=-1) path=path.Left(pos+1)+m_text; if(CheckExist(path)) { AfxMessageBox("已存在此名称的项目,请重新命名!", MB_ICONINFORMATION); return; } str=m_mytree.GetItemText(hSelectedItem); if(AfxMessageBox("是否将'"+str+"'改名为'"+m_text+"'?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return; CString sql; sql.Format("update [filemanage] set [name]='%s' where [autoid]=%s",m_text, parent); g_sendhead.bsql=1; g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return; AfxMessageBox("保存成功!", MB_ICONINFORMATION); GetData(); } void FileManage2::GetChildIds(CString curid, CStringArray *pArray) { for(int i=0; iAdd(curid); } } } void FileManage2::OnBUTdel() // 删除; { // TODO: Add your control notification handler code here CString str; HTREEITEM hSelectedItem = m_mytree.GetSelectedItem(); if(hSelectedItem==NULL) { AfxMessageBox("请先选中您要删除的项目!", MB_ICONINFORMATION); return; } CString path; CString parent=GetCurSelID(path); if(parent=="") { AfxMessageBox("出错了!", MB_ICONINFORMATION); return; } str=m_mytree.GetItemText(hSelectedItem); if(AfxMessageBox("警告:此操作将删除文件柜'"+str+"'包含其子柜中全部文件,是否继续?", MB_YESNO|MB_ICONINFORMATION)!=IDYES)return; CString id=parent; CStringArray array; array.Add(id); GetChildIds(id, &array); CString filter,filter2; for(int aa=0; aa4096) { AfxMessageBox("一次请删除少一点的项目!", MB_ICONINFORMATION); return; } CString sql; sql.Format("delete from [filemanage] where %s***delete from [filemanage2] where %s", filter, filter2); g_sendhead.bsql=1; g_pMainWnd->ProcessChatMessageRequest2(sql);if(g_bSendOK==0)return; AfxMessageBox("保存成功!", MB_ICONINFORMATION); GetData(); }