以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]工位ID根据条件动态填充(已解决)  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=86561)

--  作者:yyzlxc
--  发布时间:2016/6/20 15:48:00
--  [求助]工位ID根据条件动态填充(已解决)
扎包记录的工位ID列,根据采集序号列和工位模板的重复工位列的条件进行填充:
当采集序号为奇数时,工位ID为1、2、3、5、6、7、8、10,
当采集序号为偶数时,工位ID为1、2、4、5、6、7、9、10。
如何实现上述效果,请各位老师指教,谢谢!!


Dim cjxh As Integer = 5
If _cjxh >= cjxh Then
    _cjxh = 0
    DataTables("扎包记录").DataRows.Clear()
End If
_cjxh = _cjxh + 1
Dim f As New Filler
f.SourceTable = DataTables("工位模板") \'指定数据来源
f.SourceCols = "工序编号" \'指定数据来源列
f.DataTable = DataTables("扎包记录") \'指定数据接收表
f.DataCols = "工序编号" \'指定数据接收列
f.Fill()
For Each dr As DataRow In DataTables("扎包记录").DataRows
    If dr.IsNull("采集序号") Then
        Dim pr As DataRow = DataTables("工位模板").Find("工序编号 = \'" & dr("工序编号") & "\' and 重复工位 = False")
        If pr IsNot Nothing Then
            dr("采集序号") = _cjxh
            dr("工位ID") = pr("工位ID")
        End If
    End If
Next
DataTables("扎包记录").Save()
Tables("扎包记录").AutoSizeCols()
With Tables("扎包记录")
    .Position = .Rows.Count - 1
End With

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目23.foxdb



[此贴子已经被作者于2016/6/20 19:08:13编辑过]

--  作者:yyzlxc
--  发布时间:2016/6/20 19:01:00
--  
实现代码如下:

Dim cjxh As Integer = 5
If _cjxh >= cjxh Then
    _cjxh = 0
    DataTables("扎包记录").DataRows.Clear()
End If
_cjxh = _cjxh + 1
Dim f As New Filler
f.SourceTable = DataTables("工位模板") \'指定数据来源
f.SourceCols = "工序编号" \'指定数据来源列
f.DataTable = DataTables("扎包记录") \'指定数据接收表
f.DataCols = "工序编号" \'指定数据接收列
f.Fill()
For Each dr As DataRow In DataTables("扎包记录").DataRows
    If dr.IsNull("采集序号") Then
        Dim pr1 As DataRow = DataTables("工位模板").Find("工序编号 = \'" & dr("工序编号") & "\' and 重复工位 = False")
        Dim pr2 As DataRow = DataTables("工位模板").Find("工序编号 = \'" & dr("工序编号") & "\' And 重复工位 = True")
        If Right(CStr(_cjxh / 2 * 10),1) = 0 Then ’如果采集序号为偶数时
            If pr2 IsNot Nothing Then
                dr("采集序号") = _cjxh
                dr("工位ID") = pr2("工位ID")
            ElseIf pr1 IsNot Nothing Then
                dr("采集序号") = _cjxh
                dr("工位ID") = pr1("工位ID")
            End If
        ElseIf pr1 IsNot Nothing Then
            dr("采集序号") = _cjxh
            dr("工位ID") = pr1("工位ID")
        End If
    End If
Next
DataTables("扎包记录").Save()
Tables("扎包记录").AutoSizeCols()
With Tables("扎包记录")
    .Position = .Rows.Count - 1
End With
[此贴子已经被作者于2016/6/20 19:07:00编辑过]