Foxtable(狐表)用户栏目专家坐堂 → 组装共通品合并加工


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

主题:组装共通品合并加工

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/6/30 11:19:00 [显示全部帖子]

剔除重复值,参考

 

Dim idx As String = "-1,"
Dim idx_temp As String = ""
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
Dim cs As String = "第一列,第二列,第三列"
For Each dr As DataRow In DataTables("表A").Select("", cs)
   
    Dim flag As Boolean = False
    If pdr IsNot Nothing Then
        For Each c As String In cs.split(",")
            If pdr(c) <> dr(c) Then
                flag = True
                Exit For
            End If
        Next
    End If
    If flag Then
        If count > 1 Then
            idx &= idx_temp
        End If
        count = 1
        idx_temp = ""
    Else
        count += 1
        idx_temp &= dr("_Identify") & ","
    End If
   
    pdr = dr
Next

If count > 1 Then
    idx &= idx_temp
End If

Tables("表A").filter = "_Identify not in (" & idx.trim(",") & ")"

'DataTables("表A").deletefor("_Identify not in (" & idx.trim(",") & ")")

 


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/6/30 11:21:00 [显示全部帖子]

 看懂2楼代码,如果要合计良品数,微调代码即可。

 

 具体问题,做个小例子上来测试。


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/6/30 14:55:00 [显示全部帖子]

类似代码

 

Dim idx As String = "-1,"
Dim idx_temp As String = ""
Dim pdr As DataRow = Nothing
Dim count As Integer = 0
Dim cs As String = "部品id"
For Each dr As DataRow In DataTables("加工排产").Select("类别 = '计划'", cs)
   
    Dim flag As Boolean = False
    If pdr IsNot Nothing Then
        For Each c As String In cs.split(",")
            If pdr(c) <> dr(c) Then
                flag = True
                Exit For
            End If
        Next
    End If
    If flag Then
        If count > 1 Then
            idx &= idx_temp
        End If
        count = 1
        idx_temp = ""
    Else
        count += 1
        idx_temp &= dr("_Identify") & ","
    End If
   
    pdr = dr
Next

If count > 1 Then
    idx &= idx_temp
End If

count = 0
For Each dr As DataRow In DataTables("加工排产").Select("类别 = '实际'", cs)
   
    Dim flag As Boolean = False
    If pdr IsNot Nothing Then
        For Each c As String In cs.split(",")
            If pdr(c) <> dr(c) Then
                flag = True
                Exit For
            End If
        Next
    End If
    If flag Then
        If count > 1 Then
            idx &= idx_temp
        End If
        count = 1
        idx_temp = ""
    Else
        count += 1
        idx_temp &= dr("_Identify") & ","
    End If
   
    pdr = dr
Next

If count > 1 Then
    idx &= idx_temp
End If

Tables("加工排产").filter = "_Identify not in (" & idx.trim(",") & ")"
'DataTables("表A").deletefor("_Identify not in (" & idx.trim(",") & ")")


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/3 9:48:00 [显示全部帖子]

Dim t As Table = Tables("加工排产")
Dim dic As new Dictionary(of String, String)
For i As Integer = 0 To t.Rows.count - 1 Step 2
    Dim r1 As Row = t.Rows(i)
    Dim r2 As Row = t.Rows(i+1)
    Dim key As String = r1("部品id") & "|" & r1("调度")
    If dic.ContainsKey(key) = False Then
        dic.Add(key, r1("_Identify") & "," & r2("_Identify"))
    End If
Next
Dim idxs As String = ""
For Each key As String In dic.Keys
    idxs &= dic(key) & ","
Next
'msgbox(idxs)
t.filter = "_Identify in (" & idxs.trim(",") & ")"
[此贴子已经被作者于2017/7/3 9:48:30编辑过]

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/3 14:08:00 [显示全部帖子]

Dim t As Table = Tables("加工排产")
Dim dic As new Dictionary(of String, String)
For i As Integer = 0 To t.Rows.count - 1 Step 2
    Dim r1 As Row = t.Rows(i)
    Dim r2 As Row = t.Rows(i+1)
    Dim key As String = r1("部品id") & "|" & r1("调度")
    If dic.ContainsKey(key) = False Then
        dic.Add(key, r1("_Identify") & "," & r2("_Identify"))
        r1("良品数") = t.compute("sum(良品数)", "部品id = '" & r1("部品id") & "' and 调度 = '" & r1("调度") & "'")
    End If
Next
Dim idxs As String = ""
For Each key As String In dic.Keys
    idxs &= dic(key) & ","
Next
'msgbox(idxs)
t.filter = "_Identify in (" & idxs.trim(",") & ")"

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/3 16:10:00 [显示全部帖子]

这个代码没问题,肯定能统计得出结果。

 

 r1("最终良品数") = t.compute("sum(最终良品数)", "部品id = '" & r1("部品id") & "' and 调度 = '" & r1("调度") & "'")


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/4 11:40:00 [显示全部帖子]

以下是引用zhangning在2017/7/4 11:28:00的发言:
现有的过滤代码是:filter1 = "商品名 in ('" & e.form.controls("CheckedComboBox1").Text.replace(",", "','") & "')  
如要准确导入(跟CheckedComboBox1内容完全一样的才能导入)的话,请问老师,怎么改呢?

 

你根据【部组名】查询表数据赋值的,你短床有对应数据,自然就会赋值。

 

你可以再加上限制代码,如

 

    For Each pr In DataTables("加工用製品构成").Select("部组名 = '" & bz & "' and " & filter1, "优先级")


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/4 14:04:00 [显示全部帖子]

 请消化10楼代码,代码很简单的。

 

 贴出你写的代码说明。

[此贴子已经被作者于2017/7/4 14:05:12编辑过]

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/4 14:12:00 [显示全部帖子]

测试了一下,代码没问题,请做实例说明。

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2017/7/4 14:37:00 [显示全部帖子]

Dim t As Table = Tables("加工排产")
Dim dic As new Dictionary(of String, String)
For i As Integer = 0 To t.Rows.count - 1 Step 2
    Dim r1 As Row = t.Rows(i)
    Dim r2 As Row = t.Rows(i+1)
    Dim key As String = r1("部组名") & "|" & r1("部品id") & "|" & r1("调度")
    If dic.ContainsKey(key) = False Then
        dic.Add(key, r1("_Identify") & "," & r2("_Identify"))
    End If
Next
Dim idxs As String = ""
For Each key As String In dic.Keys
    idxs &= dic(key) & ","
Next
'msgbox(idxs)
t.filter = "_Identify in (" & idxs.trim(",") & ")"

 回到顶部
总数 15 1 2 下一页