⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.aspx.cs

📁 开源OA办公自动化系统源码20080613
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.IO;
using System.Web;
using ptw.FileManager.Model;
using ptw.FileManager.Web.Processor;
using System.Data.SqlClient;
public partial class Manage_Main : System.Web.UI.Page
{
    protected string backHtml;
    protected string folderPath = HttpContext.Current.Request.QueryString["path"];
    protected System.Text.StringBuilder currPath = new System.Text.StringBuilder("");

    protected int folderNum = 0;
    protected int fileNum = 0;

    protected System.Text.StringBuilder builder = new System.Text.StringBuilder("");

    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection("database=Oa_test;uid=sa;pwd=sa;server=.");
        con.Open();
        string sql = "select dutyid from userinfo where username='"+Session["UserName"].ToString()+"'";
        SqlCommand com = new SqlCommand(sql,con);
        SqlDataReader dr = com.ExecuteReader();
        dr.Read();
        int dutyid = Convert.ToInt32(dr.GetValue(0));
        if (dutyid != 7)
        {
            Response.Write("<script>alert('对不起,你不是管理员!');window.location.href='../../../Main.aspx';</script>");
        }
        con.Close();
        // 操作处理
        FileManagerProcessor fileManage = new FileManagerProcessor(Request.QueryString["act"]);
        builder.Append(fileManage.Value);

        if (string.IsNullOrEmpty(folderPath))
        {
            folderPath = Server.MapPath(".");
        }
        
        // 组合路径, 快速导航
        string comePath = "";
        foreach (string q in folderPath.Split('\\'))
        {
            comePath += q;
            currPath.AppendFormat("<a href=\"Main.aspx?path={1}\">{0}</a>", q + "\\", comePath);
            comePath += "\\";
        }

        // 返回上级
        if (new DirectoryInfo(folderPath).Root.ToString().Replace("\\", "") != folderPath.ToUpper())
        {
            string previousFolder = folderPath.Substring(0, folderPath.LastIndexOf("\\"));            
            backHtml = "<tr class=\"m-row2\"><td colspan=\"5\"><a href=\"Main.aspx?path=" + Server.UrlEncode(previousFolder) + "\"><img src=\"../Images/IcoLeft.gif\" alt=\"返回上级\" align=\"absmiddle\" /> 返回上级</a></td></tr>";
        }
        else
        {
            folderPath += "\\";
        }
        
        // 绑定数据
        fileManage = new FileManagerProcessor();
        List<FileFolderInfo> files = fileManage.GetDirectories(folderPath);

        if (fileManage.Access)
        {
            folderNum = fileManage.FolderNum;
            fileNum = fileManage.FileNum;

            rptList.DataSource = files;
            rptList.DataBind();
        }
        else
        {
            builder.Append("无权限访问该目录. <a href='javascript:history.go(-1);' style='font-weight: normal'>后退</a>");
        }


        if (builder.ToString() != "")
        {
            string builderResult = builder.ToString();
            builder = new System.Text.StringBuilder("");
            builder.AppendFormat("<script type=\"text/javascript\">$(\"#tips\").show(); $(\"#tipsMsg\").html(\"{0}\"); </script>", builderResult.Replace(@"\", @"\\"));
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -