Foxtable(狐表)用户栏目专家坐堂 → [已解决]仓库结转问题


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

主题:[已解决]仓库结转问题

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


加好友 发短信
等级:八尾狐 帖子:1812 积分:12999 威望:0 精华:14 注册:2008/10/11 18:07:00
  发帖心情 Post By:2013/6/26 16:52:00 [显示全部帖子]


Dim t1 As Table = Tables("仓库总表")
Dim dt1,dt2 As DataTable
Dim dr,dr1,dr2 As DataRow
Dim drs As List(of DataRow)
Dim flt,s1 As String
Dim Date1,Date2 As Date
Date1 = Tables("月末结账").Current("结账期_起")
Date2 = Tables("月末结账").Current("结账期_讫")
dt1 = DataTables("采购入库单明细表")
dt2 = DataTables("生产入库单明细表")
Dim dts As DataTable() ={dt1,dt2}
s1 = "[日期] >= #" & Date1 & "# And [日期]<= #" & Date2 & "#"
flt ="[期间] = '" & Date1.Month & "'"
t1.StopRedraw
For Each dt As DataTable In dts
    drs = dt.Select(s1)
    For Each dr  In drs
        dr1=t1.DataTable.Find(flt & " and [品号] = '" & dr("品号") & " 'and [仓库] = '" & dr("仓库") &  "'")
        If dr1 Is Nothing Then
            dr2 = t1.DataTable.AddNew
            dr2("期间") = Date1.Month
            dr2("仓库") = dr("仓库")
            dr2("品号") = dr("品号")
        End If
    Next
Next


t1.Filter = flt
For Each r2 As Row In t1.Rows
    flt = s1 & " and [品号] = '" & r2("品号") & " 'and [仓库] = '" & r2("仓库") &  "'"
    r2("入库数量") = dt1.Compute("Sum(数量)",flt) + dt2.Compute("Sum(数量)",flt)
    r2("入库金额") = dt1.Compute("Sum(金额)",flt) + dt2.Compute("Sum(金额)",flt)
Next
t1.ResumeRedraw
t1.DataTable.save

 回到顶部