FineUI 官方论坛
标题:
如何添加模块权限,手动在数据库中添加“other”字段数据吗
[打印本页]
作者:
��ɶ����
时间:
2013-4-11 06:52
标题:
如何添加模块权限,手动在数据库中添加“other”字段数据吗
如图,如果我要再加个编辑的权限,在哪里加?
是数据库中直接手动增加数据吗?
作者:
��ɶ����
时间:
2013-4-11 07:48
没人解答么{:soso_e154:}{:soso_e150:}
作者:
appletreegd
时间:
2013-4-16 15:59
��ɶ���� 发表于 2013-4-11 07:48
没人解答么
您多看几下代码就懂了。。。
作者:
wanghenan
时间:
2013-6-9 11:15
本帖最后由 wanghenan 于 2013-6-9 11:41 编辑
��ɶ���� 发表于 2013-4-11 07:48
没人解答么
[attach]2453[/attach]
这是我自己加的一个导出权限,步骤如下:
1.在ModulePowerType.cs文件中添加一个枚举,需要改两个地方:
第一个地方:
/// <summary>
/// 模块的权限列表
/// 在此为每个模块定义可用的权限列表
/// </summary>
public enum ModulePowerType
{
None,
// 浏览权限是公共的,每个模块都有
CanRead,
//CanDelete,
//CanEdit,
//CanAdd,
// 比如这里为核心菜单模块定义了三种权限
CoreMenu_New,
CoreMenu_Edit,
CoreMenu_Delete,
CoreJobTitle_New,
CoreJobTitle_Edit,
CoreJobTitle_Delete,
CoreJobTitleUser_New,
CoreJobTitleUser_Delete,
CoreDept_New,
CoreDept_Edit,
CoreDept_Delete,
CoreDeptUser_New,
CoreDeptUser_Delete,
CoreRole_New,
CoreRole_Edit,
CoreRole_Delete,
CoreUser_New,
CoreUser_Export, //导出
CoreUser_Edit,
CoreUser_Delete,
CoreUser_ChangePassword,
CoreRoleUser_New,
CoreRoleUser_Delete,
CoreRoleModule_Edit,
CoreRoleMenu_Edit,
CoreLog_Delete,
CoreConf_Edit,
CorePassword_Edit
}
复制代码
第二个地方:
/// <summary>
/// 权限的显示标题
/// </summary>
/// <param name="power"></param>
/// <returns></returns>
public static string GetTitle(ModulePowerType power)
{
string result = "未定义!";
string powerTypeName = ModulePowerTypeHelper.GetPowerTypeName(power);
if (powerTypeName == "New")
{
result = "新增";
}
else if (powerTypeName == "Delete")
{
result = "删除";
}
else if (powerTypeName == "Edit")
{
result = "编辑";
}
else if (powerTypeName == "Export") //导出
{
result = "导出";
}
else
{
switch (power)
{
case ModulePowerType.CoreUser_ChangePassword:
result = "修改密码";
break;
}
}
return result;
}
复制代码
2.在PageBase.cs文件中添加
/// <summary>
/// 检查当前用户是否拥有当前页面所属模块的导出权限
/// </summary>
/// <returns></returns>
protected bool CheckPowerExport()
{
return CheckPower(GetModulePowerType("Export"));
}
复制代码
protected void CheckPowerExportWithButton(FineUI.Button btn)
{
if (!CheckPowerExport())
{
CheckPowerFailWithButton(btn);
}
}
复制代码
3.在user.aspx中修改添加以下部分:
<Toolbars>
<x:Toolbar ID="Toolbar1" runat="server">
<Items>
<x:Button ID="btnDeleteSelected" Icon="Delete" runat="server" Text="删除选中记录" OnClick="btnDeleteSelected_Click">
</x:Button>
<x:ToolbarSeparator runat="server">
</x:ToolbarSeparator>
<x:Button ID="btnChangeEnableUsers" Icon="GroupEdit" EnablePostBack="false" runat="server"
Text="设置启用状态">
<Menu runat="server">
<x:MenuButton ID="btnEnableUsers" OnClick="btnEnableUsers_Click" runat="server" Text="启用选中记录">
</x:MenuButton>
<x:MenuButton ID="btnDisableUsers" OnClick="btnDisableUsers_Click" runat="server"
Text="禁用选中记录">
</x:MenuButton>
</Menu>
</x:Button>
<!--导出权限-->
<x:Button ID="btnExport" runat="server" Icon="Disk" EnablePostBack="false" Text="导出Excel">
</x:Button>
<x:ToolbarFill ID="ToolbarFill1" runat="server">
</x:ToolbarFill>
<x:Button ID="btnNew" runat="server" Icon="Add" EnablePostBack="false" Text="新增用户">
</x:Button>
</Items>
</x:Toolbar>
</Toolbars>
复制代码
4.在user.cs中修改如下:
private void LoadData()
{
// 权限检查
CheckPowerEditWithButton(btnChangeEnableUsers);
CheckPowerDeleteWithButton(btnDeleteSelected);
CheckPowerNewWithButton(btnNew);
CheckPowerExportWithButton(btnExport); //导出
ResolveDeleteButtonForGrid(btnDeleteSelected, Grid1);
ResolveEnableStatusButtonForGrid(btnEnableUsers, Grid1, true);
ResolveEnableStatusButtonForGrid(btnDisableUsers, Grid1, false);
btnNew.OnClientClick = Window1.GetShowReference("~/admin/user_new.aspx", "新增用户");
//// 默认的排序列和排序方向
//Grid1.SortColumnIndex = 0;
//Grid1.SortDirection = "DESC";
// 每页记录数
Grid1.PageSize = XConfigHelper.PageSize;
ddlGridPageSize.SelectedValue = XConfigHelper.PageSize.ToString();
//// 点击删除按钮时,至少选中一项
//ResolveDeleteGridItem(btnDeleteSelected, Grid1);
BindGrid();
}
复制代码
protected void CheckPowerExportWithButton(FineUI.Button btn)
{
if (!CheckPowerExport())
{
CheckPowerFailWithButton(btn);
}
}
复制代码
5.最后的效果就是这样:
[attach]2455[/attach]
[attach]2456[/attach]
[attach]2453[/attach]
欢迎光临 FineUI 官方论坛 (https://fineui.com/bbs/)
Powered by Discuz! X3.4