private void SearchSubNode(TreeNode node, List <RightRelation> relations, string groupid, string hisworkid)
 {
     foreach (TreeNode nd in node.Nodes)
     {
         if (nd.Tag.GetType() == typeof(OpReportMaster))
         {
             SearchSubNode(nd, relations, groupid, hisworkid);
         }
         else
         {
             if (nd.Checked)
             {
                 Reportdat     dat      = (Reportdat)nd.Tag;
                 RightRelation relation = new RightRelation();
                 relation.groupid   = groupid;
                 relation.reportid  = dat.REPORT_ID.ToString();
                 relation.hisworkid = hisworkid;
                 if (cbIsGlobal.Checked)
                 {
                     relation.isGlobal = 1;
                 }
                 else
                 {
                     relation.isGlobal = 0;
                 }
                 relations.Add(relation);
             }
         }
     }
 }
예제 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            string groupId = this.lstGroup.SelectedItems[0].Tag.ToString();
            reportPermissionBLL reportBll = new reportPermissionBLL();

            try
            {
                List <RightRelation> relations = new List <RightRelation>();
                RightRelation        relation;
                foreach (TreeNode node in TvReport.Nodes)
                {
                    if (node.Tag.GetType() == typeof(OpReportMaster))
                    {
                        SearchSubNode(node, relations, groupId);
                    }
                    else
                    {
                        if (node.Checked)
                        {
                            Reportdat dat = (Reportdat)node.Tag;
                            relation          = new RightRelation();
                            relation.groupid  = groupId;
                            relation.reportid = dat.REPORT_ID.ToString();
                            relations.Add(relation);
                        }
                    }
                }
                reportBll.AllocRight(relations, Convert.ToInt32(groupId));
                MessageBox.Show("权限分配成功!");
            }
            catch (Exception err)
            {
                MessageBox.Show("权限分配失败,原因:" + err.Message);
            }
            finally
            {
                btnRefresh_Click(null, null);
            }
        }
        private void btnAlloc_Click(object sender, EventArgs e)
        {
            int cnt1 = 0;

            foreach (TreeNode ptn in tvGroup.Nodes)
            {
                foreach (TreeNode ctn in ptn.Nodes)
                {
                    if (ctn.Checked)
                    {
                        cnt1 += 1;
                    }
                }
            }
            if (cnt1 == 0)
            {
                MessageBox.Show("请在要分配的用户组前打‘√’");
                return;
            }
            try
            {
                List <RightRelation> relations = new List <RightRelation>();
                RightRelation        relation;
                foreach (TreeNode ptn in tvGroup.Nodes) //顶层节点
                {
                    foreach (TreeNode ctn in ptn.Nodes) //角色组节点
                    {
                        if (ctn.Checked)
                        {
                            foreach (TreeNode node in lvReport.Nodes)
                            {
                                if (node.Tag.GetType() == typeof(OpReportMaster))
                                {
                                    SearchSubNode(node, relations, ctn.Tag.ToString(), ptn.Tag.ToString());
                                }
                                else
                                {
                                    if (node.Checked)
                                    {
                                        Reportdat dat = (Reportdat)node.Tag;
                                        relation           = new RightRelation();
                                        relation.groupid   = ctn.Tag.ToString();
                                        relation.reportid  = dat.REPORT_ID.ToString();// lvi.ImageIndex.ToString();
                                        relation.hisworkid = ptn.Tag.ToString();
                                        if (cbIsGlobal.Checked)
                                        {
                                            relation.isGlobal = 1;
                                        }
                                        else
                                        {
                                            relation.isGlobal = 0;
                                        }
                                        relations.Add(relation);
                                    }
                                }
                            }
                        }
                    }
                }
                if (relations.Count == 0)
                {
                    MessageBox.Show("请在要分配的报表模板前打‘√’");
                    return;
                }
                // reportBll.AllocRight(relations);
                MessageBox.Show("权限分配成功!");
            }
            catch (Exception err)
            {
                MessageBox.Show("权限分配失败,原因:" + err.Message);
            }
            finally
            {
                Load_ReportRelation();
            }
        }