private void DelRole() { TreeNode _node = this.tvRole.SelectedNode; if (_node == null) { return; } if ((_node.Tag as Role).ID == "roleadmin") { MessageBox.Show("该角色为系统默认角色,不能删除!", "提示"); return; } if (MessageBox.Show("是否要删除该角色?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No) { return; } if (_node.Nodes.Count > 0) { MessageBox.Show("该角色有子角色,不能删除"); return; } try { PrivilegeService _proxy = Common.Util.CreateProxy(); using (_proxy as IDisposable) { try { FrameWork.Management.PublicTrans.BeginTransaction(); _proxy.RemoveRole(_node.Tag as Role); FrameWork.Management.PublicTrans.Commit(); } catch (Exception e) { FrameWork.Management.PublicTrans.RollBack(); throw e; } } } catch (Exception e) { MessageBox.Show(e.Message, "提示"); return; } _node.Parent.Nodes.Remove(_node); }