Ejemplo n.º 1
0
        void RefreshBusinessTree()
        {
            treeBusiness.Nodes.Clear();

            TreeNode root = treeBusiness.Nodes.Add("root", "业务列表");

            root.ImageIndex         = 0;
            root.SelectedImageIndex = 0;
            List <SYS_BUSINESSGROUP> groups = BusinessServcie.BusinessGroups();

            foreach (SYS_BUSINESSGROUP group in groups)
            {
                TreeNode groupNode = root.Nodes.Add(group.ID + "", group.GROUPNAME);

                groupNode.ContextMenuStrip   = cmsBusinesses;
                groupNode.ImageIndex         = 0;
                groupNode.SelectedImageIndex = 0;
                groupNode.Tag = group;

                List <SYS_BUSINESS> businesses = BusinessServcie.Businesses(group.ID);
                foreach (SYS_BUSINESS business in businesses)
                {
                    TreeNode businessNode = groupNode.Nodes.Add(business.ID + "", business.BUSINESSNAME + "(" + business.ID + ")");
                    businessNode.ImageIndex         = 0;
                    businessNode.SelectedImageIndex = 0;
                    businessNode.ContextMenuStrip   = cmsBusiness;
                    businessNode.Tag = business;

                    TreeNode rolesNode = businessNode.Nodes.Add("role", "角色列表");
                    rolesNode.ImageIndex         = 1;
                    rolesNode.SelectedImageIndex = 1;
                    rolesNode.ContextMenuStrip   = cmsRoles;
                    List <SYS_BUSINESSROLE> roles = BusinessServcie.BusinessRoles(business.ID);
                    foreach (SYS_BUSINESSROLE role in roles)
                    {
                        TreeNode roleNode = rolesNode.Nodes.Add(role.ID + "", role.ROLENAME);
                        roleNode.ImageIndex         = 2;
                        roleNode.SelectedImageIndex = 2;
                        roleNode.ContextMenuStrip   = cmsRole;
                        roleNode.Tag = role;
                    }
                    rolesNode.Expand();

                    TreeNode materialsNode = businessNode.Nodes.Add("material", "材料清单");
                    materialsNode.ImageIndex         = 3;
                    materialsNode.SelectedImageIndex = 3;
                    materialsNode.ContextMenuStrip   = cmsMaterials;
                    List <SYS_BUSINESSMATERIAL> materials = BusinessServcie.BusinessMaterials(business.ID);
                    foreach (SYS_BUSINESSMATERIAL material in materials)
                    {
                        TreeNode materialNode = materialsNode.Nodes.Add(material.ID + "", material.MATERIALNAME + "(" + material.ID + ")");
                        materialNode.ImageIndex         = 4;
                        materialNode.SelectedImageIndex = 4;
                        materialNode.ContextMenuStrip   = cmsMaterial;
                        materialNode.Tag = material;
                    }
                    materialsNode.Expand();

                    TreeNode formsNode = businessNode.Nodes.Add("form", "表单列表");
                    formsNode.ImageIndex         = 5;
                    formsNode.SelectedImageIndex = 5;
                    formsNode.ContextMenuStrip   = cmsForms;
                    List <SYS_BUSINESSFORM> forms = BusinessServcie.BusinessForms(business.ID);
                    foreach (SYS_BUSINESSFORM form in forms)
                    {
                        TreeNode formNode = formsNode.Nodes.Add(form.ID + "", form.FORMNAME + "(" + form.ID + ")");
                        formNode.ImageIndex         = 6;
                        formNode.SelectedImageIndex = 6;
                        formNode.ContextMenuStrip   = cmsForm;
                        formNode.Tag = form;
                    }
                    formsNode.Expand();

                    TreeNode processesNode = businessNode.Nodes.Add("process", "流程");
                    processesNode.ImageIndex         = 7;
                    processesNode.SelectedImageIndex = 7;
                    processesNode.ContextMenuStrip   = cmsProcesses;
                    List <SYS_BUSINESSPROCESS> processes = BusinessServcie.BusinessProcesses(business.ID);
                    foreach (SYS_BUSINESSPROCESS process in processes)
                    {
                        TreeNode processNode = processesNode.Nodes.Add(process.ID + "", process.PROCESSNAME + "(" + process.ID + ")");
                        processNode.ImageIndex         = 8;
                        processNode.SelectedImageIndex = 8;
                        processNode.ContextMenuStrip   = cmsProcess;
                        processNode.Tag = process;
                    }
                    processesNode.Expand();
                }
                groupNode.Expand();
            }
            root.Expand();
        }