以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 数量月结 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=177077) |
-- 作者:nuoyan89 -- 发布时间:2022/5/8 19:50:00 -- 数量月结 老师,我以下代码写在控件中的,我遇到一个问题,就是在做月结时如图那样为0的不显示也不保存到月结数据这个表中,但是有个问题,如果不显示也不保存就会影响我下次月结时没有显示的无法月结,请帮忙看看,谢谢 Dim dt As DataTable = DataTables("出入库明细") Dim str As String = e.Form.Controls("月").Text Dim kw As String = e.Form.Controls("库位1").Text Dim d As Date = new Date(str.SubString(0, 4), str.SubString(4,2), 1) Dim ls As new List(Of String) For Each dr As DataRow In dt.sqlSelect("月 = \'" & str & "\' and 库位 = \'" & kw & "\'") Dim s = dr("成品编码") & "|" & dr("库位") & "|" & dr("生产型号") If ls.Contains(s) = False Then ls.add(s) End If Next For Each dr As DataRow In DataTables("期初数据").sqlSelect("月 = \'" & Format(d.AddMonths(-1), "yyyyMM") & "\' and 库位 = \'" & kw & "\'") Dim s = dr("成品编码") & "|" & dr("库位") & "|" & dr("生产型号") If ls.Contains(s) = False Then ls.add(s) End If Next For Each cl As String In ls Dim cl1 = cl.split("|")(0) Dim cl2 = cl.split("|")(1) Dim cl3 = cl.split("|")(2) Dim dr As DataRow = DataTables("成品月结_月结").AddNew dr("月") = str dr("成品编码") = cl1 dr("库位") = cl2 dr("生产型号") = cl3 Dim Filter As String = "成品编码 = \'" & cl1 & "\' And 月 = \'" & str & "\' and 库位 = \'" & cl2 & "\'and 生产型号= \'" & cl3 & "\'" Dim dr1 As DataRow = DataTables("期初数据").SQLFind("成品编码=\'" & cl1 & "\' and 月 = \'" & Format(d.AddMonths(-1), "yyyyMM") & "\' and 库位 = \'" & cl2 & "\'and 生产型号 = \'" & cl3 & "\'") If dr1 IsNot Nothing Then dr("上月结存_A类") = dr1("期初数量_A类") dr("上月结存_B类") = dr1("期初数量_B类") End If dr("本月入库_A类") = dt.SQLCompute("Sum(入库数量)",Filter & " And 月 = \'" & dr("月") & "\'And 入库类型 = \'A类\' And 单据类型 = \'入库\'") dr("本月入库_B类") = dt.SQLCompute("Sum(入库数量)",Filter & " And 月 = \'" & dr("月") & "\'And 入库类型 = \'B类\' And 单据类型 = \'入库\'") dr("本月出库_A类") = dt.SQLCompute("Sum(出库数量)",Filter & " And 月 = \'" & dr("月") & "\'And 出库类型 = \'A类\' And 单据类型 = \'出库\'") dr("本月出库_B类") = dt.SQLCompute("Sum(出库数量)",Filter & " And 月 = \'" & dr("月") & "\'And 出库类型 = \'B类\' And 单据类型 = \'出库\'") dr("本月结存_A类") = dr("上月结存_A类") + dr("本月入库_A类") - dr("本月出库_A类") dr("本月结存_B类") = dr("上月结存_B类") + dr("本月入库_B类") - dr("本月出库_B类") Next [此贴子已经被作者于2022/5/8 19:59:30编辑过]
|
-- 作者:有点蓝 -- 发布时间:2022/5/8 21:40:00 -- 数据不是根据"出入库明细"进行统计的吗?没看出来和月结数据有没有显示有什么关系? |