Foxtable(狐表)用户栏目专家坐堂 → 按顺序操作问题


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

主题:按顺序操作问题

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


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

1、上传具体实例测试;

 

2、循环为正数的单元格,然后依次从后面递减。


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


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

Dim dic_kc As new Dictionary(Of String ,String)  '可用库存
Dim dic_aqkc As new Dictionary(Of String ,String)          '安全库存
Dim dic_bhxq As new Dictionary(Of String ,String)   '补货需求

Dim t As Table = Tables("调拨操作表")
For Each c2 As Col In t.Cols
    If c2.Caption.Contains("可用库存_") And c2.Caption.Contains("店仓名称") = False Then
        Dim v  = c2.Caption.Replace("可用库存_","")
        dic_kc.add(v, c2.name)
    End If
   
    If c2.Caption.Contains("安全库存_") And c2.Caption.Contains("店仓名称") = False Then
        Dim v  = c2.Caption.Replace("安全库存_","")
        dic_aqkc.add(v, c2.name)
    End If
   
    If c2.caption.Contains("补货需求_")  Then
        Dim v  = c2.caption.Replace("补货需求_","")
        dic_bhxq.add(v, c2.name)
    End If
Next
For Each r2 As Row In t.Rows
    For Each key As String In dic_aqkc.Keys
        If r2(dic_aqkc(key)) > 0 Then '
            r2(dic_bhxq(key)) = r2(dic_aqkc(key)) - r2(dic_kc(key))  '算出的补货需求
        End If
    Next
Next

Dim r1 As Row = t.Rows(0)
For i As Integer = 1 To t.Rows.count-1
    For Each key As String In dic_bhxq.Keys
        Dim kcname As String = dic_kc(key)
        Dim bhname As String = dic_bhxq(key)
        If val(t.rows(i)(bhname)) > 0 Then
            Dim count = val(t.Rows(i)(bhname))
            If val(r1(kcname)) > 0 Then
                If val(r1(kcname)) >= val(t.Rows(i)(bhname)) Then
                    Dim ndr As DataRow = DataTables("调拨单据").AddNew
                    ndr("创建时间") = Date.now
                    ndr("调出门店") = r1("店仓ID")
                    ndr("商品款号") = r1("商品款号")
                    ndr("颜色") = r1("颜色")
                    ndr("调入门店") = t.Rows(i)("店仓id")
                    ndr(key) = count
                    'r1(kcname) -= count
                    count = 0
                Else
                    Dim ndr As DataRow = DataTables("调拨单据").AddNew
                    ndr("创建时间") = Date.now
                    ndr("调出门店") = r1("店仓ID")
                    ndr("商品款号") = r1("商品款号")
                    ndr("颜色") = r1("颜色")
                    ndr("调入门店") = t.Rows(i)("店仓id")
                    ndr(key) = r1(kcname)
                    'r1(kcname) = 0
                    count -= r1(kcname)
                End If
                Return i  '调试代码
            End If
           
            If count > 0 Then
                For j As Integer = t.Rows.count-1 To i Step -1
                    Dim r As Row = t.Rows(j)
                    If r(kcname) > 0 Then
                        If r(kcname) >= count Then
                            Dim ndr As DataRow = DataTables("调拨单据").AddNew
                            ndr("创建时间") = Date.now
                            ndr("调出门店") = r("店仓ID")
                            ndr("商品款号") = r("商品款号")
                            ndr("颜色") = r("颜色")
                            ndr("调入门店") = t.Rows(i)("店仓id")
                            ndr(key) = count
                            'r(kcname) -= count
                            count = 0
                        Else
                            Dim ndr As DataRow = DataTables("调拨单据").AddNew
                            ndr("创建时间") = Date.now
                            ndr("调出门店") = r("店仓ID")
                            ndr("商品款号") = r("商品款号")
                            ndr("颜色") = r("颜色")
                            ndr("调入门店") = t.Rows(i)("店仓id")
                            ndr(key) = r(kcname)
                            count -= r(kcname)
                            'r(kcname) = 0
                        End If
                    End If
                    If count = 0 Then Exit For
                Next
            End If
        End If
    Next
Next


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


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

请,直接使用4楼的例子测试。

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


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

请贴出开发者密码。

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


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

参考

 

Dim dic_kc As new Dictionary(Of String ,String)  '可用库存
Dim dic_aqkc As new Dictionary(Of String ,String)          '安全库存
Dim dic_bhxq As new Dictionary(Of String ,String)   '补货需求

Dim t As Table = Tables("调拨操作表")
For Each c2 As Col In t.Cols
    If c2.Caption.Contains("可用库存_") And c2.Caption.Contains("店仓名称") = False Then
        Dim v  = c2.Caption.Replace("可用库存_","")
        dic_kc.add(v, c2.name)
    End If
   
    If c2.Caption.Contains("安全库存_") And c2.Caption.Contains("店仓名称") = False Then
        Dim v  = c2.Caption.Replace("安全库存_","")
        dic_aqkc.add(v, c2.name)
    End If
   
    If c2.caption.Contains("补货需求_")  Then
        Dim v  = c2.caption.Replace("补货需求_","")
        dic_bhxq.add(v, c2.name)
    End If
Next
For Each r2 As Row In t.Rows
    For Each key As String In dic_aqkc.Keys
        If r2(dic_aqkc(key)) > 0 Then '
            r2(dic_bhxq(key)) = r2(dic_aqkc(key)) - r2(dic_kc(key))  '算出的补货需求
        End If
    Next
Next

Dim r1 As Row = t.Rows(0)
For Each zh As String In t.DataTable.GetValues("组合", "组合 is not null")
    Dim drs As List(Of DataRow) = t.DataTable.Select("组合 = '" & zh & "'", "排名")
    For i As Integer = 1 To drs.count-1
        For Each key As String In dic_bhxq.Keys
            If dic_kc.ContainsKey(key) = False Then Continue For
            Dim kcname As String = dic_kc(key)
            Dim bhname As String = dic_bhxq(key)
            If val(drs(i)(bhname)) > 0 Then
               
                Dim count = val(drs(i)(bhname))
                If val(r1(kcname)) > 0 Then
                    If val(r1(kcname)) >= val(drs(i)(bhname)) Then
                        Dim ndr As DataRow = DataTables("调拨单据").AddNew
                        ndr("创建时间") = Date.now
                        ndr("调出门店") = r1("店仓ID")
                        ndr("商品款号") = r1("商品款号")
                        ndr("颜色") = drs(i)("颜色")
                        ndr("调入门店") = drs(i)("店仓id")
                        ndr("调拨数量_" & key) = count
                        'r1(kcname) -= count
                        count = 0
                    Else
                        Dim ndr As DataRow = DataTables("调拨单据").AddNew
                        ndr("创建时间") = Date.now
                        ndr("调出门店") = r1("店仓ID")
                        ndr("商品款号") = r1("商品款号")
                        ndr("颜色") = drs(i)("颜色")
                        ndr("调入门店") = drs(i)("店仓id")
                        ndr("调拨数量_" & key) = r1(kcname)
                        'r1(kcname) = 0
                        count -= r1(kcname)
                    End If
                    Return i '调试代码
                End If
               
                If count > 0 Then
                    For j As Integer = drs.count-1 To i Step -1
                        Dim r As DataRow = drs(j)
                        If r(kcname) > 0 Then
                            If r(kcname) >= count Then
                                Dim ndr As DataRow = DataTables("调拨单据").AddNew
                                ndr("创建时间") = Date.now
                                ndr("调出门店") = r("店仓ID")
                                ndr("商品款号") = r("商品款号")
                                ndr("颜色") = drs(i)("颜色")
                                ndr("调入门店") = drs(i)("店仓id")
                                ndr("调拨数量_" & key) = count
                                'r(kcname) -= count
                                count = 0
                            Else
                                Dim ndr As DataRow = DataTables("调拨单据").AddNew
                                ndr("创建时间") = Date.now
                                ndr("调出门店") = r("店仓ID")
                                ndr("商品款号") = r("商品款号")
                                ndr("颜色") = drs(i)("颜色")
                                ndr("调入门店") = drs(i)("店仓id")
                                ndr("调拨数量_" & key) = r(kcname)
                                count -= r(kcname)
                                'r(kcname) = 0
                            End If
                        End If
                        If count = 0 Then Exit For
                    Next
                End If
            End If
        Next
    Next
Next


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


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

Dim r1 As DataRow = t.DataTable.Find("店仓id=1")

For Each zh As String In t.DataTable.GetValues("组合", "组合 is not null")
    Dim drs As List(Of DataRow) = t.DataTable.Select("组合 = '" & zh & "' and 店仓id<>1", "排名")

 

 


 回到顶部