以文本方式查看主题

-  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=121972)

--  作者:湛江智
--  发布时间:2018/7/16 17:59:00
--  [求助]窗口文本框权限
下面代码 只对 第一列 设置权限,如果有很多列,下列代码怎么修改呢?
If _UserGroup <> "经理" Or _UserGroup <> "总裁" Then
    If e.DataCol.Name = "第一列" Then
        If e.OldValue = "已完成" Then
            If e.NewValue <> "已完成" Then
                MessageBox.Show("经理已经确定此任务:已完成,如有问题请沟通经理", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                e.Cancel = True \'则取消更改
                Return
            End If
        Else
            If e.OldValue <> "已完成" Then
                If e.NewValue = "已完成" Then
                    MessageBox.Show("经理才可以确定此任务:已完成,可以录入:已完成了或已完成+完成日期  最好再截图通知经理已完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    e.Cancel = True \'则取消更改
                End If
                Return
            End If
        End If
    End If
End If

--  作者:有点甜
--  发布时间:2018/7/16 18:36:00
--  

 If e.DataCol.Name = "第一列" Then

 

改成

 

 If e.DataCol.Name = "第一列" OrElse e.datacol.name = "第二列" OrElse e.DataCol.Name = "第三列" Then


--  作者:湛江智
--  发布时间:2018/7/16 23:46:00
--  回复:(有点甜) If e.DataCol.Name = "第一列"...
 Select Case e.DataCol.name
    Case "第一列","第二列"
        If e.DataCol.Name= "第一列" Then
            
            If User.Group <> "经理" Then
                If e.DataCol.Name = "第一列" Then
                    If e.OldValue = "已完成" Then
                        If e.NewValue <> "已完成" Then
                            MessageBox.Show("经理已经确定此任务:已完成,如有问题请沟通经理", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                            e.Cancel = True \'则取消更改
                            Return
                        End If
                    Else
                        If e.OldValue <> "已完成" Then
                            If e.NewValue = "已完成" Then
                                MessageBox.Show("经理才可以确定此任务:已完成,可以录入:已完成了或已完成+完成日期  最好再截图通知经理已完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                                e.Cancel = True \'则取消更改
                            End If
                            Return
                        End If
                    End If
                End If
            End If
        End If
        
        If e.DataCol.Name= "第二列" Then
            
            If User.Group <> "经理" Then
                If e.DataCol.Name = "第二列" Then
                    If e.OldValue = "已完成" Then
                        If e.NewValue <> "已完成" Then
                            MessageBox.Show("经理已经确定此任务:已完成,如有问题请沟通经理", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                            e.Cancel = True \'则取消更改
                            Return
                        End If
                    Else
                        If e.OldValue <> "已完成" Then
                            If e.NewValue = "已完成" Then
                                MessageBox.Show("经理才可以确定此任务:已完成,可以录入:已完成了或已完成+完成日期  最好再截图通知经理已完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                                e.Cancel = True \'则取消更改
                            End If
                            Return
                        End If
                    End If
                End If
            End If
        End If
        
End Select


因为有十几列,可以怎么优化呢?
case 函数怎么简化呢?

--  作者:有点甜
--  发布时间:2018/7/17 8:56:00
--  
Select Case e.DataCol.name
    Case "第一列","第二列"
        If User.Group <> "经理" Then
            If e.OldValue = "已完成" Then
                If e.NewValue <> "已完成" Then
                    MessageBox.Show("经理已经确定此任务:已完成,如有问题请沟通经理", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                    e.Cancel = True \'则取消更改
                    Return
                End If
            Else
                If e.OldValue <> "已完成" Then
                    If e.NewValue = "已完成" Then
                        MessageBox.Show("经理才可以确定此任务:已完成,可以录入:已完成了或已完成+完成日期  最好再截图通知经理已完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
                        e.Cancel = True \'则取消更改
                    End If
                    Return
                End If
            End If
        End If
End Select