以文本方式查看主题

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

--  作者:wusim
--  发布时间:2021/7/24 7:37:00
--  怎样根据不合格项目的内容,填写相应字段的内容?
怎样根据不合格项目的内容,填写相应字段的内容? 如不合格项目内容:使用登记,安全管理人员,安全管理制度,标志,则相应字段这填写“X”,其他字段填写“√”。
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:wsm.table

[此贴子已经被作者于2021/7/24 7:38:15编辑过]

--  作者:有点蓝
--  发布时间:2021/7/24 9:24:00
--  
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:wsm.zip


--  作者:wusim
--  发布时间:2021/7/24 10:21:00
--  

If e.DataCol.Name = "不合格项目"  Then

    If e.DataRow.IsNull("不合格项目") Then

        For Each dc As DataCol In e.DataTable.DataCols

            If dc.Name <> "不合格项目" Then

                e.DataRow(dc.Name) = Nothing

            End If

        Next

    Else

        Dim lst As new List(of String)

        lst.AddRange(e.DataRow("不合格项目").split(","))

        For Each dc As DataCol In e.DataTable.DataCols

            If dc.Name <> "不合格项目" Then

                If lst.Contains(dc.Name) Then

                    e.DataRow(dc.Name) = "X"

                Else

                    e.DataRow(dc.Name) = "√"

                End If

            End If

        Next

    End  If

End  If

 

 

如果不合格项目不包含“实时监控”且字段“是否公共场所”为“否”

字段“实时监控”应为“/ ,怎样增加判断语句?


--  作者:有点蓝
--  发布时间:2021/7/24 10:35:00
--  
……

    Else

        Dim lst As new List(of String)

        lst.AddRange(e.DataRow("不合格项目").split(","))

        For Each dc As DataCol In e.DataTable.DataCols

            If dc.Name <> "不合格项目" Then

                If lst.Contains(dc.NameThen

                    e.DataRow(dc.Name) = "X"

                Else

                    e.DataRow(dc.Name) = "√"

                End If

            End If

        Next

if lst.Contains(“实时监控”)=false andalso e.DataRow(“是否公共场所”) = ""

e.DataRow(“实时监控”) = "/"

endif

    End  If

End  If


--  作者:wusim
--  发布时间:2021/7/24 11:42:00
--  
有点问题,记录内容有变化时,会把字段“是否公共场所”改为“”,应该排除该字段。
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:wsm.table


--  作者:有点蓝
--  发布时间:2021/7/24 11:54:00
--  
自行参考上面的代码。里面有排除的方法
--  作者:wusim
--  发布时间:2021/7/24 13:31:00
--  
If e.DataCol.Name = "不合格项目"  Then
    If e.DataRow.IsNull("不合格项目") Then
        For Each dc As DataCol In e.DataTable.DataCols
            If dc.Name <> "不合格项目" Then
                e.DataRow(dc.Name) = Nothing
            End If
        Next
    Else
        Dim lst As new List(of String)
        lst.AddRange(e.DataRow("不合格项目").split(","))
        For Each dc As DataCol In e.DataTable.DataCols
            If dc.Name <> "不合格项目" Then
                If lst.Contains(dc.Name) Then
                    e.DataRow("使用登记") = "X"
                    e.DataRow("安全管理人员") = "X"
                    e.DataRow("安全管理制度") = "X"
                    e.DataRow("标志") = "X"
                    e.DataRow("紧急报警") = "X"
                    e.DataRow("实时监控") = "X"
                    e.DataRow("层门") = "X"
                    
                Else
                    e.DataRow("使用登记") = "√"
                    e.DataRow("安全管理人员") = "√"
                    e.DataRow("安全管理制度") = "√"
                    e.DataRow("标志") = "√"
                    e.DataRow("紧急报警") = "√"
                    e.DataRow("实时监控") = "√"
                    e.DataRow("层门") = "√"
                    
                End If
            End If
        Next
        If e.DataRow("是否公共场所") = "否" Then
            e.DataRow("实时监控") = "/"
            
        End If
    End  If
End  If

已经可以排除其他字段,但是“不合格项目”字段非空时,相应字段不会打“X”,相应字段全打“√”,不知公式哪里错?

[此贴子已经被作者于2021/7/24 13:34:38编辑过]

--  作者:有点蓝
--  发布时间:2021/7/24 13:37:00
--  

        For Each dc As DataCol In e.DataTable.DataCols

            If dc.Name <> "不合格项目" andalso dc.Name <> "是否公共场所" Then

                If lst.Contains(dc.NameThen

                    e.DataRow(dc.Name) = "X"

                Else

                    e.DataRow(dc.Name) = "√"

                End If

            End If

        Next


--  作者:wusim
--  发布时间:2021/7/24 14:05:00
--  
If dc.Name <> "不合格项目" andalso dc.Name <> "是否公共场所" andalso dc.Name <> "出厂编号"Then   
现在可以实现功能了,但是如果排除的字段比较多,用这个公式比较长,有没有其他办法

--  作者:有点蓝
--  发布时间:2021/7/24 14:19:00
--  
很多方法,要学会思考

2、把和项目有关的列,改名统一加上一个前缀,比如:项目_使用登记、项目_安全管理人员、......然后判断是"项目_"开头的列在处理
3、把项目放到一个数组里使用,例如
Dim Cols1() As String = {"使用登记","安全管理人员",....}然后遍历这个数组,而不是遍历所有列