以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 库存统计 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=128378) |
-- 作者:outcat -- 发布时间:2018/12/4 23:16:00 -- 库存统计 Dim s As String = e.Form.Controls("月份").Value If s <> "" Then Tables("库存明细表").StopRedraw() \'停止重绘 DataTables("库存明细表").DataRows.Clear Dim dt_in As List(Of DataRow) dt_in = DataTables("进货单明细表").Select("商品编号 is not null", "品牌名称,系列名称,商品类别,商品编号,商品名称,规格,型号,单位,方向,色号,月份") \'排序取出 入仓 全部数据 Dim r As Row Dim sum_curr_count, sum_prev_count As Integer r = Tables("库存明细表").AddNew r("品牌名称") = dt_in(0)("品牌名称") r("系列名称") = dt_in(0)("系列名称") r("商品类别") = dt_in(0)("商品类别") r("商品编号") = dt_in(0)("商品编号") r("商品名称") = dt_in(0)("商品名称") r("规格") = dt_in(0)("规格") r("型号") = dt_in(0)("型号") r("方向") = dt_in(0)("方向") r("单位") = dt_in(0)("单位") r("色号") = dt_in(0)("色号") If dt_in(0)("月份") < s Then \'之前月 sum_prev_count = sum_prev_count + dt_in(0)("数量") Else If dt_in(0)("月份") = s Then \'本月份 sum_curr_count = sum_curr_count + dt_in(0)("数量") End If For i As Integer = 1 To dt_in.Count - 1 \'写入型号和规格,同时统计入仓数量和金额 If dt_in(i)("商品编号") <> dt_in(i-1)("商品编号") Then \'不同产品 r("本月_进货数量") = sum_curr_count r("期初_结存数量") = sum_prev_count \'暂存 r = Tables("库存明细表").AddNew \'插入新数据 r("品牌名称") = dt_in(i)("品牌名称") r("系列名称") = dt_in(i)("系列名称") r("商品类别") = dt_in(i)("商品类别") r("商品编号") = dt_in(i)("商品编号") r("商品名称") = dt_in(i)("商品名称") r("型号") = dt_in(i)("型号") r("规格") = dt_in(i)("规格") r("单位") = dt_in(i)("单位") r("方向") = dt_in(i)("方向") r("色号") = dt_in(i)("色号") sum_curr_count = 0 sum_prev_count = 0 End If If dt_in(i)("月份") < s Then \'之前月 sum_prev_count = sum_prev_count + dt_in(i)("数量") Else If dt_in(i)("月份") = s Then \'本月份 sum_curr_count = sum_curr_count + dt_in(i)("数量") End If Next r("本月_进货数量") = sum_curr_count r("期初_结存数量") = sum_prev_count \'暂存 For Each dr As DataRow In DataTables("库存明细表").DataRows \'填充统计数据 sum_curr_count = 0 \'累计本月出仓数量 sum_prev_count = 0 \'累计之前出仓数量 Dim drs_out As List(Of DataRow) Dim filter As String = "品牌名称 = \'" & dr("品牌名称") & "\' And 系列名称 = \'" & dr("系列名称") & "\'And 商品类别 = \'" & dr("商品类别") & "\'And 商品编号 = \'" & dr("商品编号") & "\'And 商品名称 = \'" & dr("商品名称") & "\'And 规格 = \'" & dr("规格") & "\'And 型号 = \'" & dr("型号") & "\'And 单位 = \'" & dr("单位") & "\'And 方向 = \'" & dr("方向") & "\'And 色号 = \'" & dr("色号") & "\'" drs_out = DataTables("出货单明细表").Select(filter, "月份") \'排序取出 出仓 全部数据 For Each dr_out As DataRow In drs_out If dr_out("月份") < s Then sum_prev_count = sum_prev_count + dr_out("出货数量") Else If dr_out("月份") = s Then sum_curr_count = sum_curr_count + dr_out("出货数量") Else Exit For End If Next Dim sum_in_prev_count As Integer = dr("期初_结存数量") \'从表中取出暂存数据 dr("本月_出货数量") = sum_curr_count dr("期初_结存数量") = sum_in_prev_count - sum_prev_count dr("期末_结存数量") = dr("期初_结存数量") + dr("本月_进货数量") - dr("本月_出货数量") Next Tables("库存明细表").ResumeRedraw() End If 老师,麻烦给看一下,我这个本月的出货数量填充不到库存明细表里
|
-- 作者:有点甜 -- 发布时间:2018/12/5 9:10:00 -- 1、加入msgbox,弹出各个阶段的值,看哪个时候开始出错;
2、具体实例发上来测试,说明测试步骤和测试所需结果。 |