Foxtable(狐表)用户栏目专家坐堂 → 请教关于窗口录入权限的问题


  共有2240人关注过本帖树形打印复制链接

主题:请教关于窗口录入权限的问题

帅哥哟,离线,有人找我吗?
guning007
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:89 积分:720 威望:0 精华:0 注册:2015/4/28 10:09:00
请教关于窗口录入权限的问题  发帖心情 Post By: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
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:35433 积分:178524 威望:0 精华:3 注册:2013/3/30 16:36:00
  发帖心情 Post By:2015/6/15 11:20:00 [只看该作者]

改写到DataColChanging里面去就可以

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

 回到顶部
帅哥哟,离线,有人找我吗?
guning007
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:婴狐 帖子:89 积分:720 威望:0 精华:0 注册:2015/4/28 10:09:00
  发帖心情 Post By:2015/6/15 11:38:00 [只看该作者]

确实有用,真是省了我很多时间。

多谢Bin版!

 回到顶部