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


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

主题:按顺序操作问题

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


加好友 发短信
等级:九尾狐 帖子:2355 积分:16187 威望:0 精华:0 注册:2013/9/1 8:09:00
  发帖心情 Post By:2017/11/21 9:24:00 [只看该作者]

不好意思,甜老师,昨晚太晚了,没注意。。。
密码  888
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:调拨测试.foxdb



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


加好友 发短信
等级:九尾狐 帖子:2355 积分:16187 威望:0 精华:0 注册:2013/9/1 8:09:00
  发帖心情 Post By:2017/11/21 10:52:00 [只看该作者]

甜老师,就是补货需求的列名格式不一样,怎么就不对哈。我改来改去也没改好。。

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  13楼 | 信息 | 搜索 | 邮箱 | 主页 | 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


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


加好友 发短信
等级:九尾狐 帖子:2355 积分:16187 威望:0 精华:0 注册:2013/9/1 8:09:00
  发帖心情 Post By:2017/11/22 0:14:00 [只看该作者]

老师,终于大概可以理解了。

那如果去掉 先以第一行(其实实际不能是第一行(表里的第一行是合计数,不参与调拨),而是总仓,ID=1)条件,
而是完全由排名来调,排名最后依次向排名最前的调。最后一名调完了,轮到倒数第二名调出。
最后一名是 总仓,ID=1 。不同款的商品都有总仓数量。
Dim r1 As Row = t.Rows(0)
这个要怎么改掉呢。。。
[此贴子已经被作者于2017/11/22 0:15:58编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  15楼 | 信息 | 搜索 | 邮箱 | 主页 | 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", "排名")

 

 


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