以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]订单明细表中导入TXT文件时,要求相同商品的数量汇总导入 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=85357) |
||||
-- 作者:99473593 -- 发布时间:2016/5/24 4:22:00 -- [求助]订单明细表中导入TXT文件时,要求相同商品的数量汇总导入
|
||||
-- 作者:Hyphen -- 发布时间:2016/5/24 9:07:00 -- \'导入TXT文件,其文件格式必须为"条码号,数量",在导入的时候,相同条码的数量可以累加 Dim strs As String = FileSys.ReadAllText(e.Form.Controls("ComboBox1").Text,Encoding.Default) strs = strs.Replace(vblf,"") Dim rs() As String = strs.Split(vbcr) Tables("订单.订单明细").StopRedraw() For i As Integer = 0 To rs.Length - 1 Dim cs() As String = rs(i).Split(",") \'以","为记号将每行的内容拆分为两部分 If cs.Length = 2 Then Dim tm As String = cs(0) Dim sl As Integer = cs(1) Dim er As Row Dim idx As Integer = Tables("订单.订单明细").Find(tm,0,"条码号",False,True,False) If idx > -1 Then Tables("订单.订单明细").Rows(idx)("数量") += sl Else er = Tables("订单.订单明细").AddNew er("条码号")= tm er("数量")= sl End If End If Next Tables("订单.订单明细").ResumeRedraw e.Form.Close() \'关闭本窗口
|
||||
-- 作者:大红袍 -- 发布时间:2016/5/24 9:20:00 -- Dim strs As String = FileSys.ReadAllText(e.Form.Controls("ComboBox1").Text,Encoding.Default) strs = strs.Replace(vblf,"") Dim rs() As String = strs.Split(vbcr) Tables("订单.订单明细").StopRedraw() For i As Integer = 0 To rs.Length - 1 Dim cs() As String = rs(i).Split(",") \'以","为记号将每行的内容拆分为两部分 If cs.Length = 2 Then Dim tm As String = cs(0) Dim sl As Integer = cs(1) Dim er As Row = Nothing For Each r As Row In Tables("订单.订单明细").Rows \'判断是否存在这行 If r("条码号")= tm Then er = r er("数量") = er("数量") + cs(1) End If Next If er Is Nothing Then \'不存在就增加 er = Tables("订单.订单明细").AddNew er("条码号")= tm er("数量")= sl End If End If Next Tables("订单.订单明细").ResumeRedraw e.Form.Close() \'关闭本窗口 |
||||
-- 作者:99473593 -- 发布时间:2016/5/28 11:18:00 -- 不错,完美解决了,谢谢两位老师! |