以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 月结时同一编码重复出现 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=171353) |
-- 作者:nuoyan89 -- 发布时间:2021/8/27 11:07:00 -- 月结时同一编码重复出现 老师,我做月结时发现一个问题,就是同一个编码出现多次,如图1,请帮忙看看,谢谢 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("库位") 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("库位") 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 dr As DataRow = DataTables("成品月结_月结").AddNew dr("月") = str dr("成品编码") = cl1 dr("库位") = cl2 Dim Filter As String = "成品编码 = \'" & cl1 & "\' And 月 = \'" & str & "\' and 库位 = \'" & cl2 & "\'" Dim dr1 As DataRow = DataTables("期初数据").SQLFind("成品编码=\'" & cl1 & "\' and 月 = \'" & Format(d.AddMonths(-1), "yyyyMM") & "\' and 库位 = \'" & cl2 & "\'") 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
|
-- 作者:有点蓝 -- 发布时间:2021/8/27 11:25:00 -- For Each dr As DataRow In dt.sqlSelect("月 = \'" & str & "\' and 库位 = \'" & kw & "\'") Dim s = 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("库位") If ls.Contains(s) = False Then ls.add(s) End If Next for each s as string in ls output.show(s) next 可能数据有空格,遍历集合,看看是不是有重复的
|
-- 作者:nuoyan89 -- 发布时间:2021/9/11 10:27:00 -- 老师,以下代码我是放在保存控件上的,点击后,数据没有保存到指定的表中,请帮忙看看,谢谢 Dim Cols1() As String = {"成品编码","年","月","本月结存_A类","本月结存_B类","成品描述","规格型号","库位"} |
-- 作者:有点蓝 -- 发布时间:2021/9/11 11:03:00 -- 操作的是DataTables("期初数据"),却保存的是DataTables("成品月结_月结"),和DataTables("成品月结_月结")有什么关系? |
-- 作者:nuoyan89 -- 发布时间:2021/9/11 11:08:00 -- 最开始是保存的是期初数据这表,因为保存不上,也没有提示,所以我就改成了成品月结_月结这张表 |
-- 作者:有点蓝 -- 发布时间:2021/9/11 11:23:00 -- 操作哪个表就保存那个表。买了A房跑去B房装修合适吗 如果保存不了,要么这个表是查询表,或者没有权限保存
|