我在订单表中的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里面输入,然后同时限制表和窗口录入。
谢谢!