コード例 #1
0
        private void AddNode(int imageIndex, int indexadd, DERole deRole)
        {
            TreeNode node = new TreeNode(deRole.Name, imageIndex, imageIndex)
            {
                Tag = deRole
            };

            this.tvwRole.Nodes.Add(node);
            if (this.hsTable.ContainsKey(deRole.Oid))
            {
                node.ImageIndex         = indexadd;
                node.SelectedImageIndex = indexadd;
            }
            else
            {
                ArrayList list = new ArrayList();
                foreach (Guid guid in this.roles.Keys)
                {
                    if (guid == deRole.Oid)
                    {
                        list = this.roles[guid] as ArrayList;
                        if ((list != null) && (list.Count > 0))
                        {
                            node.ImageIndex         = indexadd;
                            node.SelectedImageIndex = indexadd;
                        }
                        break;
                    }
                }
            }
        }
コード例 #2
0
 private void btnDel_Click(object sender, EventArgs e)
 {
     if ((this.tvwRole.SelectedNode == null) || !(this.tvwRole.SelectedNode.Tag is DERole))
     {
         MessageBoxPLM.Show("请先选择角色。");
     }
     else
     {
         DERole tag = this.tvwRole.SelectedNode.Tag as DERole;
         foreach (ListViewItem item in this.lvwTeam.SelectedItems)
         {
             if (item.ImageIndex == ClientData.MyImageList.GetIconIndex("ICO_MSG_OFFLINE"))
             {
                 break;
             }
             Guid      guid = (Guid)item.Tag;
             ArrayList list = this.hsTable[tag.Oid] as ArrayList;
             if ((list != null) && list.Contains(guid))
             {
                 item.Remove();
                 list.Remove(guid);
             }
         }
     }
 }
コード例 #3
0
 private void tvwRole_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (this.tvwRole.SelectedNode != null)
     {
         DERole tag = this.tvwRole.SelectedNode.Tag as DERole;
         if (tag != null)
         {
             ArrayList list  = this.hsTable[tag.Oid] as ArrayList;
             ArrayList list2 = new ArrayList();
             foreach (Guid guid in this.roles.Keys)
             {
                 if (guid == tag.Oid)
                 {
                     list2 = this.roles[guid] as ArrayList;
                     break;
                 }
             }
             this.lvwTeam.Items.Clear();
             this.selusers.Clear();
             if ((list != null) && list.Contains(Guid.Empty))
             {
                 this.ckbSysRole.Checked = true;
                 this.ckbSysRole_CheckedChanged(this.ckbSysRole, null);
             }
             else
             {
                 this.ckbSysRole.Checked = false;
             }
             ArrayList list3 = new ArrayList();
             foreach (Guid guid2 in list2)
             {
                 if ((guid2 != Guid.Empty) && !list3.Contains(guid2))
                 {
                     list3.Add(guid2);
                     DEUser       userByOid = PLUser.Agent.GetUserByOid(guid2);
                     ListViewItem item      = this.lvwTeam.Items.Add(userByOid.LogId, ClientData.MyImageList.GetIconIndex("ICO_RSP_USER"));
                     string       str       = "父级";
                     if ((list != null) && list.Contains(guid2))
                     {
                         str = "本身";
                     }
                     item.SubItems.AddRange(new string[] { userByOid.Name, str });
                     item.Tag = userByOid.Oid;
                     this.selusers.Add(userByOid.Oid);
                 }
             }
         }
     }
 }
コード例 #4
0
        private bool UserInRole(string userLogId, string p)
        {
            BRRole brRole = new BRRole();
            DERole role   = brRole.GetRoleByName(p);

            if (role == null)
            {
                return(false);
            }
            var users = brRole.GetUsersByRole(role.Oid);

            foreach (var user in users)
            {
                if (((DEUser)user).LogId == userLogId)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #5
0
 private void ckbSysRole_CheckedChanged(object sender, EventArgs e)
 {
     if ((this.tvwRole.SelectedNode == null) || !(this.tvwRole.SelectedNode.Tag is DERole))
     {
         MessageBoxPLM.Show("请先选择角色。");
     }
     else
     {
         DERole tag = this.tvwRole.SelectedNode.Tag as DERole;
         if (tag != null)
         {
             for (int i = this.lvwTeam.Items.Count; i > 0; i--)
             {
                 ListViewItem item = this.lvwTeam.Items[i - 1];
                 if (item.ImageIndex == ClientData.MyImageList.GetIconIndex("ICO_MSG_OFFLINE"))
                 {
                     Guid      guid = (Guid)item.Tag;
                     ArrayList list = this.hsTable[tag.Oid] as ArrayList;
                     for (int j = list.Count - 1; j >= 0; j--)
                     {
                         if (((Guid)list[j]) == guid)
                         {
                             list.Remove(list[j]);
                             break;
                         }
                     }
                     item.Remove();
                 }
             }
             if (!this.ckbSysRole.Checked)
             {
                 ArrayList list6 = this.hsTable[tag.Oid] as ArrayList;
                 if (list6 != null)
                 {
                     for (int k = list6.Count - 1; k >= 0; k--)
                     {
                         list6.Remove(Guid.Empty);
                     }
                 }
             }
             else
             {
                 ArrayList usersByRole = this.plRole.GetUsersByRole(tag.Oid);
                 ArrayList list3       = this.hsTable[tag.Oid] as ArrayList;
                 ArrayList list4       = new ArrayList();
                 foreach (Guid guid2 in this.roles.Keys)
                 {
                     if (guid2 == tag.Oid)
                     {
                         list4 = this.roles[guid2] as ArrayList;
                         break;
                     }
                 }
                 ArrayList list5 = new ArrayList();
                 foreach (DEUser user in usersByRole)
                 {
                     if (list3 == null)
                     {
                         list3 = new ArrayList {
                             Guid.Empty,
                             user.Oid
                         };
                         this.hsTable.Add(tag.Oid, list3);
                     }
                     else
                     {
                         if (!list3.Contains(Guid.Empty))
                         {
                             list3.Add(Guid.Empty);
                         }
                         if (!list4.Contains(user.Oid))
                         {
                             if (list5.Contains(user.Oid) || list3.Contains(user.Oid))
                             {
                                 goto Label_0322;
                             }
                             list5.Add(user.Oid);
                             ListViewItem item2 = this.lvwTeam.Items.Add(user.LogId, ClientData.MyImageList.GetIconIndex("ICO_MSG_OFFLINE"));
                             item2.SubItems.Add(user.Name);
                             item2.Tag = user.Oid;
                         }
                         if (!list3.Contains(user.Oid))
                         {
                             list3.Add(user.Oid);
                         }
                         Label_0322 :;
                     }
                 }
             }
         }
     }
 }
コード例 #6
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if ((this.tvwRole.SelectedNode == null) || !(this.tvwRole.SelectedNode.Tag is DERole))
     {
         MessageBoxPLM.Show("请先选择角色。");
     }
     else
     {
         DERole            tag     = this.tvwRole.SelectedNode.Tag as DERole;
         frmUserOrgProduct product = new frmUserOrgProduct(this.folder, this.product);
         product.ShowDialog();
         if ((product.Tag != null) && (product.Tag is ArrayList))
         {
             ArrayList list = product.Tag as ArrayList;
             foreach (Guid guid in list)
             {
                 DEUser    userByOid = PLUser.Agent.GetUserByOid(guid);
                 ArrayList list2     = this.hsTable[tag.Oid] as ArrayList;
                 ArrayList list3     = new ArrayList();
                 if ((list2 == null) || !list2.Contains(guid))
                 {
                     bool flag = true;
                     foreach (Guid guid2 in this.roles.Keys)
                     {
                         if (guid2 == tag.Oid)
                         {
                             list3 = this.roles[guid2] as ArrayList;
                             if ((list3 != null) && list3.Contains(guid))
                             {
                                 foreach (ListViewItem item in this.lvwTeam.Items)
                                 {
                                     if (item.Text == userByOid.LogId)
                                     {
                                         flag = false;
                                         item.SubItems[2].Text = "";
                                         break;
                                     }
                                 }
                             }
                             break;
                         }
                     }
                     if (flag)
                     {
                         ListViewItem item2 = this.lvwTeam.Items.Add(userByOid.LogId, ClientData.MyImageList.GetIconIndex("ICO_RSP_USER"));
                         item2.SubItems.Add(userByOid.Name);
                         item2.Tag = userByOid.Oid;
                     }
                     if (list2 == null)
                     {
                         list2 = new ArrayList {
                             guid
                         };
                         this.hsTable.Add(tag.Oid, list2);
                     }
                     else
                     {
                         list2.Add(guid);
                     }
                 }
             }
         }
     }
 }