private void BindData()
    {
        Rpt_FolderBLL _bll = new Rpt_FolderBLL((int)ViewState["ID"]);

        lbl_ID.Text              = _bll.Model.ID.ToString();
        tbx_Name.Text            = _bll.Model.Name;
        tree_SuperID.SelectValue = _bll.Model.SuperID.ToString();

        btn_Save.Text      = "修改";
        btn_Save.ForeColor = System.Drawing.Color.Red;
        btn_Delete.Enabled = true;
        MessageBox.ShowConfirm(btn_Delete, "数据删除将不可恢复,确定删除么?");
        btn_Cancel.Enabled = true;
        bt_AddSub.Enabled  = true;

        lbl_AlertInfo.Text = "";

        if ((int)ViewState["ID"] == 1)
        {
            btn_Save.Enabled = false;
        }
        else
        {
            btn_Save.Enabled = true;
            BindRight();
        }

        btn_Delete.Enabled = Rpt_FolderBLL.GetModelList("SuperID=" + ViewState["ID"].ToString()).Count == 0;
    }
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] == 1) return;

        Rpt_FolderBLL _bll;
        if ((int)ViewState["ID"] == 0)
        {
            _bll = new Rpt_FolderBLL();
        }
        else
        {
            _bll = new Rpt_FolderBLL((int)ViewState["ID"]);
        }

        _bll.Model.Name = tbx_Name.Text;
        _bll.Model.SuperID = int.Parse(tree_SuperID.SelectValue);

        _bll.Model.Level = new Rpt_FolderBLL(_bll.Model.SuperID).Model.Level + 1;

        if ((int)ViewState["ID"] == 0)
        {
            int ret = _bll.Add();
            if (ret < 0)
            {
                lbl_AlertInfo.Text = "添加目录失败!";
                return;
            }
            else
                ViewState["ID"] = ret;
        }
        else
        {
            if (_bll.Model.SuperID == _bll.Model.ID) return;
            int ret = _bll.Update();

            switch (ret)
            {
                case -1:
                    lbl_AlertInfo.Text = "更新目录失败!";
                    return;
                case -2:
                    lbl_AlertInfo.Text = "更新目录失败,不能将当前目录设置为上级目录";
                    return;
                case -3:
                    lbl_AlertInfo.Text = "更新目录失败,不能将当前目录的子目录设置为上级目录";
                    return;
            }
        }

        SaveRight();

        DataCache.RemoveCache("Cache-TreeTableBLL-GetAllNode-MCS_Reports.dbo.Rpt_Folder");
        tree_SuperID.DataSource = null;

        Response.Redirect("Rpt_FolderManage.aspx?ID=" + ViewState["ID"].ToString());
    }
 protected void btn_Delete_Click(object sender, EventArgs e)
 {
     Rpt_FolderBLL _bll = new Rpt_FolderBLL(int.Parse(lbl_ID.Text));
     if (_bll.Delete() < 0)
     {
         lbl_AlertInfo.Text = "该目录包含下级目录,请勿删除";
         return;
     }
     lbl_AlertInfo.Text = "";
     Response.Redirect("Rpt_FolderManage.aspx?SuperID=" + _bll.Model.SuperID.ToString());
 }
    protected void btn_Delete_Click(object sender, EventArgs e)
    {
        Rpt_FolderBLL _bll = new Rpt_FolderBLL(int.Parse(lbl_ID.Text));

        if (_bll.Delete() < 0)
        {
            lbl_AlertInfo.Text = "该目录包含下级目录,请勿删除";
            return;
        }
        lbl_AlertInfo.Text = "";
        Response.Redirect("Rpt_FolderManage.aspx?SuperID=" + _bll.Model.SuperID.ToString());
    }
    private void BindData()
    {
        IList <Rpt_Folder> _folder_list = Rpt_FolderBLL.GetModelList(" superid=" + (string)ViewState["FolderID"]);

        rp_1.DataSource = _folder_list;
        rp_1.DataBind();

        IList <Rpt_Report> _file_list = Rpt_ReportBLL.GetModelList(" folder=" + (string)ViewState["FolderID"]);

        rp_2.DataSource = _file_list;
        rp_2.DataBind();
    }
    private void BindTree(TreeNodeCollection TNC, int SuperID)
    {
        Rpt_FolderBLL      _bll       = new Rpt_FolderBLL();
        IList <Rpt_Folder> _modellist = _bll._GetModelList("SuperID=" + SuperID.ToString());

        foreach (Rpt_Folder _model in _modellist)
        {
            TreeNode tn = new TreeNode();
            tn.Text     = _model.Name;
            tn.Value    = _model.ID.ToString();
            tn.ImageUrl = "~/Images/gif/gif-0030.gif";
            TNC.Add(tn);
            //if (_model.ID == 1)
            BindTree(tn.ChildNodes, _model.ID);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //初始化当前目录ID
            ViewState["FolderID"] = Request.QueryString["FolderID"] != null ? Request.QueryString["FolderID"].ToString() : "76";
            //上层目录
            Rpt_FolderBLL fbll = new Rpt_FolderBLL(int.Parse((string)ViewState["FolderID"]));
            superid = fbll.Model.SuperID != 0 ? fbll.Model.SuperID : 1;
            //当前目录路径
            //pathname = TreeTableBLL.GetFullPathName("MCS_Reports.dbo.Rpt_Folder", "ID", "Name", "SuperID", 0, int.Parse((string)ViewState["FolderID"]));
            pathname = TreeTableBLL.GetFullPathName("MCS_Reports.dbo.Rpt_Folder", int.Parse((string)ViewState["FolderID"]));

            BindData();
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            //初始化当前目录ID
            ViewState["FolderID"] = Request.QueryString["FolderID"] != null ? Request.QueryString["FolderID"].ToString() : "76";
            //上层目录
            Rpt_FolderBLL fbll = new Rpt_FolderBLL(int.Parse((string)ViewState["FolderID"]));
            superid = fbll.Model.SuperID != 0 ? fbll.Model.SuperID : 1;
            //当前目录路径
            //pathname = TreeTableBLL.GetFullPathName("MCS_Reports.dbo.Rpt_Folder", "ID", "Name", "SuperID", 0, int.Parse((string)ViewState["FolderID"]));
            pathname = TreeTableBLL.GetFullPathName("MCS_Reports.dbo.Rpt_Folder", int.Parse((string)ViewState["FolderID"]));

            BindData();
        }
    }
    private void BindTree(TreeNodeCollection TNC, int SuperID)
    {
        IList <Rpt_FolderRight> rights = Rpt_FolderRightBLL.GetAssignedRightByUser(Session["UserName"].ToString());

        foreach (Rpt_Folder folder in Rpt_FolderBLL.GetModelList("SuperID=" + SuperID.ToString()))
        {
            if (folder.ID > 1 && rights.FirstOrDefault(p => p.Folder == folder.ID) == null)
            {
                continue;
            }
            TreeNode tn = new TreeNode();
            tn.Text     = folder.Name;
            tn.Value    = folder.ID.ToString();
            tn.ImageUrl = "~/Images/gif/gif-0030.gif";
            TNC.Add(tn);
            //if (folder.ID == 1)
            BindTree(tn.ChildNodes, folder.ID);
        }
    }
    protected void btn_Save_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["ID"] == 1)
        {
            return;
        }

        Rpt_FolderBLL _bll;

        if ((int)ViewState["ID"] == 0)
        {
            _bll = new Rpt_FolderBLL();
        }
        else
        {
            _bll = new Rpt_FolderBLL((int)ViewState["ID"]);
        }

        _bll.Model.Name    = tbx_Name.Text;
        _bll.Model.SuperID = int.Parse(tree_SuperID.SelectValue);

        _bll.Model.Level = new Rpt_FolderBLL(_bll.Model.SuperID).Model.Level + 1;

        if ((int)ViewState["ID"] == 0)
        {
            int ret = _bll.Add();
            if (ret < 0)
            {
                lbl_AlertInfo.Text = "添加目录失败!";
                return;
            }
            else
            {
                ViewState["ID"] = ret;
            }
        }
        else
        {
            if (_bll.Model.SuperID == _bll.Model.ID)
            {
                return;
            }
            int ret = _bll.Update();

            switch (ret)
            {
            case -1:
                lbl_AlertInfo.Text = "更新目录失败!";
                return;

            case -2:
                lbl_AlertInfo.Text = "更新目录失败,不能将当前目录设置为上级目录";
                return;

            case -3:
                lbl_AlertInfo.Text = "更新目录失败,不能将当前目录的子目录设置为上级目录";
                return;
            }
        }

        SaveRight();

        DataCache.RemoveCache("Cache-TreeTableBLL-GetAllNode-MCS_Reports.dbo.Rpt_Folder");
        tree_SuperID.DataSource = null;

        Response.Redirect("Rpt_FolderManage.aspx?ID=" + ViewState["ID"].ToString());
    }
    private void BindTree(TreeNodeCollection TNC, int SuperID)
    {
        Rpt_FolderBLL _bll = new Rpt_FolderBLL();
        IList<Rpt_Folder> _modellist = _bll._GetModelList("SuperID=" + SuperID.ToString());

        foreach (Rpt_Folder _model in _modellist)
        {
            TreeNode tn = new TreeNode();
            tn.Text = _model.Name;
            tn.Value = _model.ID.ToString();
            tn.ImageUrl = "~/Images/gif/gif-0030.gif";
            TNC.Add(tn);
            //if (_model.ID == 1)
            BindTree(tn.ChildNodes, _model.ID);
        }
    }
    private void BindData()
    {
        Rpt_FolderBLL _bll = new Rpt_FolderBLL((int)ViewState["ID"]);
        lbl_ID.Text = _bll.Model.ID.ToString();
        tbx_Name.Text = _bll.Model.Name;
        tree_SuperID.SelectValue = _bll.Model.SuperID.ToString();

        btn_Save.Text = "修改";
        btn_Save.ForeColor = System.Drawing.Color.Red;
        btn_Delete.Enabled = true;
        MessageBox.ShowConfirm(btn_Delete, "数据删除将不可恢复,确定删除么?");
        btn_Cancel.Enabled = true;
        bt_AddSub.Enabled = true;

        lbl_AlertInfo.Text = "";

        if ((int)ViewState["ID"] == 1)
        {
            btn_Save.Enabled = false;
        }
        else
        {
            btn_Save.Enabled = true;
            BindRight();
        }

        btn_Delete.Enabled = Rpt_FolderBLL.GetModelList("SuperID=" + ViewState["ID"].ToString()).Count == 0;
    }