許可權管理,不但有角色大方面來控制使用者所擁有的許可權,還是以模組來控制,這樣可以讓許可權分得更細些。
這方法與角色管理表結構與儲存過程是一樣的,只是一些表名寫字段名稱不一樣而已。
在asp.net後台管理介面如下截圖:
資料表[module]結構如下:
setansi_nulls
ongo
setquoted_identifier
ongo
create
table
[dbo].
[module](
[moduleid][
smallint
]identity(1
,1) not
null,[
modulename][
nvarchar](
50)
notnull,[
description][
nvarchar](
100)
notnull
,primary
keyclustered([
moduleid
]asc
)with
(pad_index
=off
, statistics_norecompute
=off
, ignore_dup_key
=off
, allow_row_locks =on
, allow_page_locks =on
) on
[primary],
constraint
[uk_module_ud980sa6
]unique
nonclustered([
modulename
]asc
)with
(pad_index
=off
, statistics_norecompute
=off
, ignore_dup_key
=off
, allow_row_locks =on
, allow_page_locks =on
) on
[primary])
on[primary]go
插入儲存過程usp_module_insert:
setansi_nulls
ongo
setquoted_identifier
ongo
create
procedure
[dbo].
[usp_module_insert](
@modulename
nvarchar(50
),@description
nvarchar(50
))asselect
[modulename
]from
[module
]where
[modulename]=
@modulename
if@@rowcount
>
0begin
raiserror(n'
此模組已經存在,無法新增!',
16,1)
return
endelse
begin
transaction
insert
into
dbo.module(
[modulename],
[description])
values
(@modulename
,@description)if
@@error
<>
0begin
rollback
transaction
endcommit
transaction
更新儲存過程usp_module_update:
setansi_nulls
ongo
setquoted_identifier
ongo
create
procedure
[dbo].
[usp_module_update](
@idtinyint
,@modulename
nvarchar(50
),@description
nvarchar(50
))asselect
[modulename
]from
[module
]where
[modulename]=
@modulename
and[
moduleid
]<>
@idif
@@rowcount
>
0begin
raiserror(n'
此模組已經存在,無法更新!',
16,1)
return
endelse
begin
transaction
update
[module
]set
[modulename]=
@modulename,[
description]=
@description
where
[moduleid]=
@idif
@@error
<>
0begin
rollback
transaction
endcommit
transaction
go
許可權管理模組設計
許可權管理是沒個專案中都會設計的模組,根據自己專案的經驗與閱讀的相關資料做了乙個下面的乙個許可權管理模組的程式 一 簡介 本模組涉及兩個級別的單位 單位級別一以及其下屬多個單位 單位級別二 多個不同的使用者角色如 系統管理員,裝置一科管理員,裝置二科管理員,材料科管理員,單位管理員,普通使用者等,沒...
許可權管理 模組與頁面關係
把控制的頁面分類,即以模組來分類,如同角色所擁有頁面一樣,最終我們只為使用者分配某一模組,來控制到使用者只能訪問相關的頁面。asp.net前端介面 在資料庫,表 modulepages 結構如下,參考角色與頁面關係表結構一樣 實現為模組分配頁面的事件,還得寫分配事件的儲存過程 setansi nul...
許可權管理 使用者與模組關係
使用者與模組關係功能,您可以寫成跟使用者與角色關係一樣。不過下面實現方法會看到更多的許可權控制。介面如下截圖 資料表結構如下 setansi nulls ongo setquoted identifier ongo create table dbo usersmodule usersid int n...