以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  关于执行某一操作权限判断的问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=86952)

--  作者:hopestarxia
--  发布时间:2016/6/29 16:18:00
--  关于执行某一操作权限判断的问题
设计了一个窗口,窗口中关联的为Table控件,控件关联assetcard表;
在窗口中加了一个按钮控件(“删除”按钮),想当点击删除按钮时判断操作员的情况执行不同的操作;
具体如下:操作员角色定义了以下三种:浏览并编辑,浏览只编辑本部,浏览不编辑
              操作员用户分组:定义的为部门;
下面写出来的语句只能实现如果是角色定义为"浏览并编辑“的,可以删除,其他两种”浏览只编辑本部,浏览不编辑“点击删除按钮则出现提示“无权操作”

想实现:如果操作员角色为“浏览并编辑”的点击删除按钮,可以执行删除操作;
            如果操作员角色为"浏览只编辑本部",则在点击删除按钮时,先判断准备删除的数据行是否是操作员对应的分组
即(User.Group)是否等于assetcard表中的(部门)列值,如果相等,执行删除操作,如果不等于,则提示“不能删除非本部门资料”,
           如果操作员角色为浏览不编辑”的点击删除按钮,则直接提示没有权限的提示;

请老师们帮助指导一下,下面语句应该如何修改才能实现想要的需求。


If User.IsRole("浏览并编辑")  Then
    
Dim Result As DialogResult
Result = MessageBox.Show("确定要删除选定的资料吗?","提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
    
Tables("assetcard").Current.Delete

          Else
DataTables("assetcard").Save()
        End If

Else

    MessageBox.show("你无权执行此项操作!")
End If

--  作者:大红袍
--  发布时间:2016/6/29 16:24:00
--  

If User.IsRole("浏览并编辑")  Then
   
ElseIf User.IsRole("浏览只编辑本部") Then
    If  Tables("assetcard").Current("部门") <> user.Group Then
        msgbox("你不是本部,不能删除!")
        Return
    End If
ElseIf User.IsRole("浏览不编辑") Then
    MessageBox.show("你无权执行此项操作!")
    Return
End If

Dim Result As DialogResult
Result = MessageBox.Show("确定要删除选定的资料吗?","提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
    Tables("assetcard").Current.Delete
End If


--  作者:hopestarxia
--  发布时间:2016/6/29 17:48:00
--  谢谢!
If User.IsRole("浏览并编辑")  Then

Dim Result As DialogResult
Result = MessageBox.Show("确定要删除选定的资料吗?","提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
    Tables("assetcard").Current.Delete

    End If

Else 

 If User.IsRole("浏览只编辑本部") Then
    If  Tables("assetcard").Current("部门") = user.Group Then

Dim Result As DialogResult
Result = MessageBox.Show("确定要删除选定的资料吗?","提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
    Tables("assetcard").Current.Delete
Else
        msgbox("不能删除非本部门的资产卡片!")
End If

Else
           MessageBox.show("你无权执行此项操作!")
End If

End If


End If

谢谢,我总照着这个方向去捉摸了,你的语句简洁实用,谢谢老师,