Exemple #1
0
        private void  移节点ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode curNode = treeView_nav.SelectedNode;
            TreeNode newNode = (TreeNode)curNode.Clone();
            TreeNode pNode   = curNode.Parent;

            if (pNode.Nodes.Count == 1)
            {
                MessageBoxEx.Show("只有一个节点,无须上下移动!  ", "下移节点");
            }
            else
            {
                TreeNode     nextNode  = curNode.NextNode;
                FileDBHelper fdbHelper = new FileDBHelper();
                fdbHelper.changeDisporder(int.Parse("" + curNode.Tag), int.Parse("" + nextNode.Tag));
                if (nextNode.NextNode != null)
                {
                    pNode.Nodes.Insert(nextNode.NextNode.Index, newNode);
                }
                else
                {
                    pNode.Nodes.Add(newNode);
                }
                pNode.Nodes.Remove(curNode);
                treeView_nav.SelectedNode = newNode;
            }
        }
Exemple #2
0
        private void btn_sure_Click(object sender, EventArgs e)
        {
            String adminName = this.tbox_username.Text.Trim();
            String adminPwd  = this.tbox_password.Text.Trim();

            if ("".Equals(adminName) || "".Equals(adminPwd))
            {
                MessageBoxEx.Show("请填写完整!   ");
            }
            else
            {
                System.Security.Cryptography.MD5 md5 = new MD5CryptoServiceProvider();
                byte[]       output = md5.ComputeHash(Encoding.Default.GetBytes(adminPwd));
                string       md5Pwd = BitConverter.ToString(output).Replace("-", "").ToLower();
                FileDBHelper fbh    = new FileDBHelper();
                fbh.saveUserAndPwd(adminName, md5Pwd);
                if (fbh.GetSucces())
                {
                    isSuccess = true;
                }
                else
                {
                    isSuccess = false;
                }
                this.DialogResult = DialogResult.OK;
            }
        }
Exemple #3
0
        private void 粘贴节点ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode     pNode     = treeView_nav.SelectedNode;
            FileDBHelper fdbHelper = new FileDBHelper();

            fdbHelper.saveFileNode(treeNode_Cut.Text, int.Parse("" + treeNode_Cut.Tag), int.Parse("" + pNode.Tag));
            pNode.Nodes.Add(treeNode_Cut);
            pNode.ExpandAll();
            treeNode_Cut = null;
        }
Exemple #4
0
        private void DeleteFile(Int32 i)
        {
            FileDBHelper fileDBHelper = new FileDBHelper();

            fileDBHelper.deleteFile(i);
            if (fileDBHelper.GetSucces())
            {
                refreshDataGridView();
            }
        }
Exemple #5
0
        private void btn_saveNode_Click(object sender, EventArgs e)
        {
            FileDBHelper dbHelper = new FileDBHelper();

            if (editMode == 1)
            {
                dbHelper.insertFileNode(this.textBox_NodeName.Text, parentID);
            }
            else if (editMode == 2)
            {
                dbHelper.saveFileNode(this.textBox_NodeName.Text, selfID);
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemple #6
0
        private void deleteFileNode(int nodeID)
        {
            this.Invoke(new MethodInvoker(delegate {
                imgLoadding.Visible = true;
            }));
            FileDBHelper fdbHelper = new FileDBHelper();

            fdbHelper.deleteFileNode(nodeID);
            if (fdbHelper.GetSucces())
            {
                loadData();
            }
            this.Invoke(new MethodInvoker(delegate {
                imgLoadding.Visible = false;
            }));
        }
Exemple #7
0
        private void refreshTreeView()
        {
            TreeNodeCollection nodes = this.treeView_nav.Nodes;

            nodes[0].Nodes.Clear();
            FileDBHelper imgHelper        = new FileDBHelper();
            string       connectionString = DBSource.ConnectionStringPBox;
            string       commandText      = @"SELECT * FROM FileNode ORDER BY disporder";

            helperPBox = new dBHelper(connectionString);
            if (helperPBox.Load(commandText, "") == true)
            {
                DataTable dataSource = helperPBox.DataSet.Tables[0];
                CreateTreeViewRecursive(nodes[0].Nodes, dataSource, 0);
            }
            this.treeView_nav.ExpandAll();
        }
Exemple #8
0
        private void btn_saveNode_Click(object sender, EventArgs e)
        {
            FileDBHelper dbHelper = new FileDBHelper();

            if ("".Equals(this.textBox_FilePath.Text.Trim()))
            {
                dbHelper.saveFile(fileID, this.textBox_FileName.Text);
            }
            else
            {
                dbHelper.saveFile(fileID, this.textBox_FileName.Text);
                dbHelper.saveFileData(fileID, File.ReadAllBytes(this.textBox_FilePath.Text.Trim()));
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemple #9
0
        private void insertFiles(FileInfo[] fileInfos, int nodeID)
        {
            FileDBHelper imgHelper = new FileDBHelper();

            this.Invoke(new MethodInvoker(delegate
            {
                imgLoadding.Visible = true;
            }));
            imgHelper.InsertFiles(fileInfos, nodeID);
            if (imgHelper.GetSucces())
            {
                refreshDataGridView();
            }
            this.Invoke(new MethodInvoker(delegate
            {
                imgLoadding.Visible = false;
            }));
        }
Exemple #10
0
        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Int32  fid = Convert.ToInt32(dataGridView_FileList.CurrentRow.Cells["file_id"].Value);
            string connectionStringPBox  = DBSource.ConnectionStringPBox;
            string connectionStringPData = DBSource.ConnectionStringPData;
            string commandText           = @"SELECT file_id,file_name,file_type,file_size,file_nodeid FROM FileMemo where file_id = " + fid;

            helperPBox = new dBHelper(connectionStringPBox);
            FileStream fs;

            if (helperPBox.Load(commandText, "") == true)
            {
                if (fid > 0 && helperPBox.DataSet.Tables[0].Rows.Count > 0)
                {
                    DataRow       dataRow    = helperPBox.DataSet.Tables[0].Select("file_id=" + fid)[0];
                    string        filename   = dataRow["file_name"].ToString();
                    string        filetype   = dataRow["file_type"].ToString();
                    List <Byte[]> l_fileData = new FileDBHelper().getFileData(fid);

                    this.saveFileDialog_File.Title      = "另存" + filename;
                    this.saveFileDialog_File.Filter     = filetype + "|" + filetype;
                    this.saveFileDialog_File.DefaultExt = filetype;
                    this.saveFileDialog_File.FileName   = filename;
                    if (this.saveFileDialog_File.ShowDialog() == DialogResult.OK)
                    {
                        FileInfo fi = new FileInfo(saveFileDialog_File.FileName);
                        fs = fi.OpenWrite();
                        for (int i = 0; i < l_fileData.Count; i++)
                        {
                            fs.Write(l_fileData[i], 0, l_fileData[i].Length);
                        }
                        fs.Close();
                    }
                }
            }
        }
Exemple #11
0
        private void openFileViewer(Int32 fileID)
        {
            string connectionStringPBox  = DBSource.ConnectionStringPBox;
            string connectionStringPData = DBSource.ConnectionStringPData;
            string commandText           = @"SELECT file_id,file_name,file_type,file_size,file_nodeid FROM FileMemo where file_id = " + fileID;

            helperPBox = new dBHelper(connectionStringPBox);
            if (helperPBox.Load(commandText, "") == true)
            {
                if (fileID > 0 && helperPBox.DataSet.Tables[0].Rows.Count > 0)
                {
                    DataRow       dataRow    = helperPBox.DataSet.Tables[0].Select("file_id=" + fileID)[0];
                    string        filename   = dataRow["file_name"].ToString();
                    string        filetype   = dataRow["file_type"].ToString();
                    List <Byte[]> l_fileData = new FileDBHelper().getFileData(fileID);
                    if (l_fileData.Count == 0)
                    {
                        MessageBoxEx.Show("找不到对应数据文件!");
                        return;
                    }
                    SkinTabPage tp = new SkinTabPage();
                    tp.Text = filename;
                    switch (filetype)
                    {
                    case ".jpg":
                    case ".png":
                    case ".bmp":
                    case ".gif":
                    {
                        if (Directory.Exists(Application.StartupPath + "\\temp") == false)
                        {
                            Directory.CreateDirectory(Application.StartupPath + "\\temp");
                        }
                        FileStream fs;
                        FileInfo   fi = new FileInfo(Application.StartupPath + "\\temp\\" + filename + filetype);
                        if (!fi.Exists || !IsFileInUse(fi.FullName))
                        {
                            fs = fi.OpenWrite();
                            for (int i = 0; i < l_fileData.Count; i++)
                            {
                                fs.Write(l_fileData[i], 0, l_fileData[i].Length);
                            }
                            fs.Close();
                            try
                            {
                                Bitmap    bmap         = new Bitmap(Application.StartupPath + "\\temp\\" + filename + filetype);
                                PicViewer uc_picviewer = new PicViewer();
                                uc_picviewer.showPic(filename, bmap);
                                uc_picviewer.Dock = DockStyle.Fill;
                                tp.Controls.Add(uc_picviewer);
                                tabControl_Viewer.TabPages.Add(tp);
                            }
                            catch (Exception exp) { }
                        }
                        break;
                    }

                    case ".doc":
                    case ".docx":
                    case ".xls":
                    case ".xlsx":
                    case ".ppt":
                    case ".pptx":
                    {
                        if (Directory.Exists(Application.StartupPath + "\\temp") == false)
                        {
                            Directory.CreateDirectory(Application.StartupPath + "\\temp");
                        }
                        FileStream fs;
                        FileInfo   fi = new FileInfo(Application.StartupPath + "\\temp\\" + filename + filetype);
                        if (!fi.Exists || !IsFileInUse(fi.FullName))
                        {
                            fs = fi.OpenWrite();
                            for (int i = 0; i < l_fileData.Count; i++)
                            {
                                fs.Write(l_fileData[i], 0, l_fileData[i].Length);
                            }
                            fs.Close();
                            DocViewer uc_docviewer = new DocViewer();
                            tp.Tag            = uc_docviewer;
                            uc_docviewer.Dock = DockStyle.Fill;
                            tp.Controls.Add(uc_docviewer);
                            tabControl_Viewer.TabPages.Add(tp);
                            uc_docviewer.openFile(Application.StartupPath + "\\temp\\" + filename + filetype);
                        }
                        break;
                    }

                    case ".txt":
                    case ".sql":
                    case ".log":
                    {
                        if (Directory.Exists(Application.StartupPath + "\\temp") == false)
                        {
                            Directory.CreateDirectory(Application.StartupPath + "\\temp");
                        }
                        FileStream fs;
                        FileInfo   fi = new FileInfo(Application.StartupPath + "\\temp\\" + filename + filetype);
                        if (!fi.Exists || !IsFileInUse(fi.FullName))
                        {
                            fs = fi.OpenWrite();
                            for (int i = 0; i < l_fileData.Count; i++)
                            {
                                fs.Write(l_fileData[i], 0, l_fileData[i].Length);
                            }
                            fs.Close();
                            StreamReader sr        = new StreamReader(Application.StartupPath + "\\temp\\" + filename + filetype, Encoding.Default);
                            TxtViewer    txtViewer = new TxtViewer();
                            txtViewer.Dock = DockStyle.Fill;
                            tp.Controls.Add(txtViewer);
                            tabControl_Viewer.TabPages.Add(tp);
                            txtViewer.showTxt(sr.ReadToEnd());
                            sr.Close();
                        }
                        break;
                    }

                    case ".htm":
                    case ".html":
                    case ".mht":
                    {
                        if (Directory.Exists(Application.StartupPath + "\\temp") == false)
                        {
                            Directory.CreateDirectory(Application.StartupPath + "\\temp");
                        }
                        FileStream fs;
                        FileInfo   fi = new FileInfo(Application.StartupPath + "\\temp\\" + filename + filetype);
                        if (!fi.Exists || !IsFileInUse(fi.FullName))
                        {
                            fs = fi.OpenWrite();
                            for (int i = 0; i < l_fileData.Count; i++)
                            {
                                fs.Write(l_fileData[i], 0, l_fileData[i].Length);
                            }
                            fs.Close();
                            WebViewer webViewer = new WebViewer();
                            webViewer.Dock = DockStyle.Fill;
                            tp.Controls.Add(webViewer);
                            tabControl_Viewer.TabPages.Add(tp);
                            webViewer.openFile(Application.StartupPath + "\\temp\\" + filename + filetype);
                        }
                        break;
                    }

                    case ".pdf":
                    {
                        if (Directory.Exists(Application.StartupPath + "\\temp") == false)
                        {
                            Directory.CreateDirectory(Application.StartupPath + "\\temp");
                        }
                        FileStream fs;
                        FileInfo   fi = new FileInfo(Application.StartupPath + "\\temp\\" + filename + filetype);
                        if (!fi.Exists || !IsFileInUse(fi.FullName))
                        {
                            fs = fi.OpenWrite();
                            for (int i = 0; i < l_fileData.Count; i++)
                            {
                                fs.Write(l_fileData[i], 0, l_fileData[i].Length);
                            }
                            fs.Close();
                            PDFViewer pdfViewer = new PDFViewer();
                            pdfViewer.Dock = DockStyle.Fill;
                            tp.Controls.Add(pdfViewer);
                            tabControl_Viewer.TabPages.Add(tp);
                            pdfViewer.openFile(Application.StartupPath + "\\temp\\" + filename + filetype);
                        }
                        break;
                    }

                    case ".mp4":
                    case ".avi":
                    case ".rm":
                    case ".rmvb":
                    case ".flv":
                    case ".xr":
                    case ".wmv":
                    {
                        if (Directory.Exists(Application.StartupPath + "\\temp") == false)
                        {
                            Directory.CreateDirectory(Application.StartupPath + "\\temp");
                        }
                        FileStream fs;
                        FileInfo   fi = new FileInfo(Application.StartupPath + "\\temp\\" + filename + filetype);
                        if (!fi.Exists || !IsFileInUse(fi.FullName))
                        {
                            fs = fi.OpenWrite();
                            for (int i = 0; i < l_fileData.Count; i++)
                            {
                                fs.Write(l_fileData[i], 0, l_fileData[i].Length);
                            }
                            fs.Close();
                        }
                        FrmPlayer aplayer = new FrmPlayer();
                        aplayer.Text = filename;
                        aplayer.Show();
                        aplayer.openFile(Application.StartupPath + "\\temp\\" + filename + filetype);
                        break;
                    }
                    }
                    tabControl_Viewer.SelectedTab = tp;
                }
            }
        }