以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  请教关于窗口录入权限的问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=70057)

--  作者:guning007
--  发布时间:2015/6/15 11:11:00
--  请教关于窗口录入权限的问题
我在订单表中的PrepareEdit表事件中加入了如下代码

If e.Col.Name = "审核" AndAlso e.Row("审核") = False Then \'如果尚未审核
    If User.name <> "张三" AndAlso User.name <> "李四" Then
        e.Cancel = True \'只有以上三人才能审核
    End If
ElseIf e.Row("审核") = True Then \'如果此行已经审批了
    If e.Col.Name <> "发货" AndAlso e.Col.Name <> "采购" Then
        If User.name <> "开发者" Then
            e.Cancel = True
        End If
    End If
End If


If e.Col.Name = "采购" AndAlso e.Row("采购") = False Then
    If e.Row("审核") = True
        If User.name <> "张三" AndAlso User.name <> "王五" Then
            e.Cancel = True
        End If
    Else e.Row("审核") = False
        e.Cancel = True
    End If 
ElseIf e.Row("采购") = True Then
    If e.Col.Name = "采购" 
        If User.name <> "开发者" Then
            e.Cancel = True
        End If
    End If
End If


If e.Col.Name = "发货" AndAlso e.Row("发货") = False Then
    If e.Row("采购") = True
        If User.name <> "张三" AndAlso User.name <> "王五" Then
            e.Cancel = True
        End If
    Else e.Row("采购") = False
        e.Cancel = True
    End If
ElseIf e.Row("发货") = True Then
    If e.Col.Name = "发货"
        If User.name <> "开发者" Then
            e.Cancel = True
        End If
    End If
End If

目的为:
只有张三和李四才能审核订单
审核过的订单只能采购和发货,其他信息不能修改,开发者除外
只有张三和王五才能采购和发货
审核/采购/发货这三个按钮一旦选中就只有开发者才能取消

这段代码我写的可能不够简洁,但是能达到目的。

不过我给订单表加上录入窗口之后,问题就来了,在PrepareEdit表事件中设置的代码在这里没有用,审核过的订单依然可以修改,审核/采购/发货这三个按钮所有人都可能点。

我看了帮助学习到必须在录入窗口的Enter事件里加上代码,除此之外,是否有更好的办法?比如把表事件中的PrepareEdit里面的代码挪到其他地方?让它们对窗口里面也能生效,就像避免订单号重复的功能其实就可以在DataColChanging里面输入,然后同时限制表和窗口录入。

谢谢!

--  作者:Bin
--  发布时间:2015/6/15 11:20:00
--  
改写到DataColChanging里面去就可以

把e.row  e.col 改为 e.datarow  e.datacol

--  作者:guning007
--  发布时间:2015/6/15 11:38:00
--  
确实有用,真是省了我很多时间。

多谢Bin版!