Example #1
0
    private void BindTree()
    {
        DataTable dt     = UserDeptSelectBus.GetDeptInfoByCompanyCD(ShowType, OprtType);
        DataTable Userdt = null;

        if (!string.IsNullOrEmpty(ShowType) && Convert.ToInt32(ShowType) > 1)
        {
            Userdt = DeptQuarterEmployeeBus.GetUserInfo(ShowType, OprtType);
        }
        //<img  src=\"../../../Images/folder-closed.gif\"/>
        //<img  src=\"../../../Images/jsdoc.gif\"/>
        //根节点
        TreeNode rootNode = new TreeNode();

        rootNode.Text = " <span style=\"font-size:16px\"> " + ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyName + " </span>";

        rootNode.Value = "0";
        if (dt != null && dt.Rows.Count > 0)
        {
            DataRow[] rows = dt.Select("SuperDeptID IS NULL");
            if (rows.Length > 0)
            {
                TreeNode childNode = null;
                for (int i = 0; i < rows.Length; i++)
                {
                    childNode             = new TreeNode();
                    childNode.Value       = rows[i]["ID"].ToString();
                    childNode.Text        = "<img  src=\"../../../Images/folder-closed.gif\" border=\"0\"/><span style=\"font-size:15px\"> " + rows[i]["DeptName"].ToString() + " </span>";
                    childNode.NavigateUrl = "javascript:void(0);";
                    if (!string.IsNullOrEmpty(ShowType) && Convert.ToInt32(ShowType) > 1)
                    {
                        TreeNode Usernode = null;
                        if (Userdt != null && Userdt.Rows.Count > 0)
                        {
                            string    UserExprssion = "DeptID='" + childNode.Value + "'";
                            DataRow[] UserRow       = Userdt.Select(UserExprssion);
                            if (UserRow.Length > 0)
                            {
                                for (int j = 0; j < UserRow.Length; j++)
                                {
                                    Usernode             = new TreeNode();
                                    Usernode.Value       = UserRow[j]["ID"].ToString();
                                    Usernode.Text        = "<img  src=\"../../../Images/jsdoc.gif\" border=\"0\" /><span style=\"font-size:14px\"> " + UserRow[j]["QuarterName"].ToString() + "&nbsp;&nbsp;&nbsp; " + UserRow[j]["EmployeesName"].ToString() + " </span>";
                                    Usernode.NavigateUrl = string.Format("javascript:javascript:void(0)");
                                    childNode.ChildNodes.Add(Usernode);
                                }
                            }
                        }
                    }
                    rootNode.ChildNodes.Add(childNode);

                    BindChildNode(childNode.Value, childNode, dt, Userdt);
                }
            }
        }
        UserDeptTree.Nodes.Add(rootNode);
    }
Example #2
0
    private void BindTree()
    {
        DataTable dt     = UserDeptSelectBus.GetDeptInfoByCompanyCD(ShowType, OprtType);
        DataTable Userdt = null;

        if (!string.IsNullOrEmpty(ShowType) && Convert.ToInt32(ShowType) > 1)
        {
            string isShowLizhi = "0";
            if (this.RblIsShowLizhi.Checked)
            {
                isShowLizhi = "1";
            }
            Userdt = UserDeptSelectBus.GetUserInfo(ShowType, OprtType, isShowLizhi);
        }
        //根节点
        TreeNode rootNode = new TreeNode();

        rootNode.Text  = ((UserInfoUtil)SessionUtil.Session["UserInfo"]).CompanyName + "组织机构";
        rootNode.Value = "0";
        if (dt != null && dt.Rows.Count > 0)
        {
            DataRow[] rows = dt.Select("SuperDeptID IS NULL");
            if (rows.Length > 0)
            {
                TreeNode childNode = null;
                for (int i = 0; i < rows.Length; i++)
                {
                    childNode = new TreeNode();
                    if (ShowType == "1" && OprtType == "2")
                    {
                        if (rows[i]["SuperDeptID"] == DBNull.Value)
                        {
                            /* Edit by ellen at 2010-08-23 16:18 */
                            if (rows[i]["subflag"].ToString() == "0")
                            {
                                childNode.Value       = rows[i]["ID"].ToString();
                                childNode.Text        = rows[i]["DeptName"].ToString();
                                childNode.NavigateUrl = string.Format("javascript:void('{0},{1}');", childNode.Text, childNode.Value);
                                childNode.ToolTip     = "部门";
                            }
                            else
                            {
                                childNode.Value       = rows[i]["ID"].ToString();
                                childNode.Text        = rows[i]["DeptName"].ToString();
                                childNode.NavigateUrl = "javascript:void(0);";
                                childNode.ToolTip     = "分公司";
                            }
                        }
                    }
                    else
                    {
                        childNode.Value       = rows[i]["ID"].ToString();
                        childNode.Text        = rows[i]["DeptName"].ToString();
                        childNode.NavigateUrl = "javascript:void(0);";
                    }
                    if (!string.IsNullOrEmpty(ShowType) && Convert.ToInt32(ShowType) > 1)
                    {
                        TreeNode Usernode = null;
                        if (Userdt != null && Userdt.Rows.Count > 0)
                        {
                            string    UserExprssion = "DeptID='" + childNode.Value + "'";
                            DataRow[] UserRow       = Userdt.Select(UserExprssion);
                            if (UserRow.Length > 0)
                            {
                                for (int j = 0; j < UserRow.Length; j++)
                                {
                                    Usernode       = new TreeNode();
                                    Usernode.Value = UserRow[j]["ID"].ToString();
                                    Usernode.Text  = UserRow[j]["EmployeesName"].ToString();

                                    if (ShowType == "2" && OprtType == "2")
                                    {
                                        Usernode.NavigateUrl = string.Format("javascript:void('{0},{1}');", Usernode.Text, Usernode.Value);
                                    }
                                    else
                                    {
                                        Usernode.NavigateUrl = string.Format("javascript:void(0);");
                                    }
                                    childNode.ChildNodes.Add(Usernode);
                                }
                            }
                        }
                    }
                    rootNode.ChildNodes.Add(childNode);
                    BindChildNode(childNode.Value, childNode, dt, Userdt);
                }
            }
        }
        UserDeptTree.Nodes.Add(rootNode);
    }