以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 代码整合问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=93147) |
||||
-- 作者:hongyefor -- 发布时间:2016/11/21 20:14:00 -- 代码整合问题 查询修改代码 新增代码
|
||||
-- 作者:hongyefor -- 发布时间:2016/11/21 20:55:00 -- 能不能帮我改一下呢 |
||||
-- 作者:有点蓝 -- 发布时间:2016/11/21 20:57:00 -- 最好上例子测试 Dim i As Integer = DataTables("订单数量明细").GetValues("规格", filter ,"规格 desc").Count Dim j As Integer = DataTables("订单数量明细").GetValues("颜色", filter,"_Identify").Count For k As Integer = 1 To j-1 For l As Integer = 1 To i-1 Dim temp As String = filter & " and 颜色 = \'" & e.Form.controls("Tsy_" & k).Text & "\' and 规格 = \'" & e.Form.controls("Tg_" & l).Text & "\'" Dim fdr As DataRow = DataTables("订单数量明细").find(temp) If fdr IsNot Nothing Then fdr("数量") = e.Form.controls("Ts_" & k & "_" & l).Text Else Dim dr As String = e.Form.Controls("Ts_" & l & "_" & k).text Dim dr2 As String = e.Form.Controls("Tg_" & k).text Dim dr3 As String = e.Form.Controls("Tsy_" & l).text If dr > "" And dr2 > "" And dr3 > "" Then Dim Tea() As String ={"合同号","款号"} Dim r As Row = Tables("订单数量明细").AddNew For Each TTL As String In Tea r(TTL) = e.Form.Controls(TTL).text Next r("颜色") = e.Form.Controls("Tsy_" & l).Value r("规格") = e.Form.Controls("Tg_" & k).Value r("数量") = e.Form.Controls("Ts_" & l & "_" & k).Value End If End If Next Next |
||||
-- 作者:hongyefor -- 发布时间:2016/11/22 13:54:00 -- 上面的代码试过了,不行
|
||||
-- 作者:有点青 -- 发布时间:2016/11/22 14:26:00 -- Dim ddh As WinForm.TextBox = e.Form.Controls("合同号") Dim shk As WinForm.TextBox = e.Form.Controls("款号") Dim dtr5 As String = e.Form.Controls("Ts_8_8").text If shk.text > "" And ddh.text > "" Then Dim filter As String = "合同号 = \'" & ddh.Text & "\'And 款号 = \'" & shk.Text & "\' " Dim drZ As List(Of DataRow) = DataTables("订单主表").Select(filter) For Each r As DataRow In drZ Dim Parts() As String = dtr5.Split("+") r("数量") = Parts(0) Next For k As Integer = 1 To 7 For l As Integer = 1 To 7 Dim dr As String = e.Form.Controls("Ts_" & l & "_" & k).text Dim dr2 As String = e.Form.Controls("Tg_" & k).text Dim dr3 As String = e.Form.Controls("Tsy_" & l).text If dr > "" And dr2 > "" And dr3 > "" Then Dim temp As String = filter & " and 颜色 = \'" & dr3 & "\' and 规格 = \'" & dr2 & "\'" Dim fdr As DataRow = DataTables("订单数量明细").find(temp) msgbox(temp) If fdr IsNot Nothing Then fdr("数量") = dr Else Dim Tea() As String ={"合同号","款号"} Dim r As Row = Tables("订单数量明细").AddNew For Each TTL As String In Tea r(TTL) = e.Form.Controls(TTL).text Next r("颜色") = dr3 r("规格") = dr2 r("数量") = dr End If End If Next Next If DataTables("订单主表").HasChanges Or DataTables("订单数量明细").HasChanges Then If MessageBox.Show("款号为" & shk.text & "的订单已经被修改,是否保存?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then DataTables("订单数量明细").Save() DataTables("订单主表").Save() MessageBox.Show("订单更新完成,请打印!") End If End If End If |
||||
-- 作者:hongyefor -- 发布时间:2016/11/22 21:29:00 -- Dim drs As List(Of DataRow) = DataTables("订单面料明细").Select(filter) For ir As Integer = 0 To drs.count-1 drs(ir)("面料名称") = e.Form.controls("Tml_" & ir+1 & "_2").Text drs(ir)("面料规格") = e.Form.controls("Tml_" & ir+1 & "_3" ).Text drs(ir)("面料颜色") = e.Form.controls("Tml_" & ir+1 & "_1" ).Text drs(ir)("面料成份") = e.Form.controls("Tml_" & ir+1 & "_4").Text drs(ir)("面料门幅") = e.Form.controls("Tml_" & ir+1 & "_6" ).Text drs(ir)("面料单位") = e.Form.controls("Tml_" & ir+1 & "_5" ).Text drs(ir)("面料单耗") = e.Form.controls("Tml_" & ir+1 & "_7").Text drs(ir)("面料合计") = e.Form.controls("Tml_" & ir+1 & "_8" ).Text drs(ir)("供应商") = e.Form.controls("Tml_" & ir+1 & "_9" ).Text Next 那这个代码怎么写呢 |
||||
-- 作者:有点蓝 -- 发布时间:2016/11/22 21:55:00 -- 什么意思? |
||||
-- 作者:hongyefor -- 发布时间:2016/11/23 10:22:00 -- 现在我想按照上面的代码把下面两个代码也整合在一起,请问怎么改啊 代码1 Dim drs As List(Of DataRow) = DataTables("订单面料明细").Select(filter) For ir As Integer = 0 To drs.count-1 drs(ir)("面料名称") = e.Form.controls("Tml_" & ir+1 & "_2").Text drs(ir)("面料规格") = e.Form.controls("Tml_" & ir+1 & "_3" ).Text drs(ir)("面料颜色") = e.Form.controls("Tml_" & ir+1 & "_1" ).Text drs(ir)("面料成份") = e.Form.controls("Tml_" & ir+1 & "_4").Text drs(ir)("面料门幅") = e.Form.controls("Tml_" & ir+1 & "_6" ).Text drs(ir)("面料单位") = e.Form.controls("Tml_" & ir+1 & "_5" ).Text drs(ir)("面料单耗") = e.Form.controls("Tml_" & ir+1 & "_7").Text drs(ir)("面料合计") = e.Form.controls("Tml_" & ir+1 & "_8" ).Text drs(ir)("供应商") = e.Form.controls("Tml_" & ir+1 & "_9" ).Text Next Dim drw As List(Of DataRow) = DataTables("面料明细表").Select(filter) For ir As Integer = 0 To drs.count-1 drw(ir)("面料名称") = e.Form.controls("Tml_" & ir+1 & "_2").Text drw(ir)("面料规格") = e.Form.controls("Tml_" & ir+1 & "_3" ).Text drw(ir)("颜色") = e.Form.controls("Tml_" & ir+1 & "_1" ).Text drw(ir)("面料成分") = e.Form.controls("Tml_" & ir+1 & "_4").Text drw(ir)("面料门幅") = e.Form.controls("Tml_" & ir+1 & "_6" ).Text drw(ir)("面料单位") = e.Form.controls("Tml_" & ir+1 & "_5" ).Text drw(ir)("应耗数量") = e.Form.controls("Tml_" & ir+1 & "_8" ).Text Next 代码2 For i1 As Integer = 1 To 9
Dim drm1 As String = e.Form.Controls("Tml_" & i1 & "_1" ).text Dim drm2 As String = e.Form.Controls("Tml_" & i1 & "_2" ).text Dim drm7 As String = e.Form.Controls("Tml_" & i1 & "_7" ).text Dim drm8 As String = e.Form.Controls("Tml_" & i1 & "_8" ).text If drm1 <> "" And drm2 <> "" And drm7<> "" And drm8<> "" Then Dim Tea() As String ={"合同号","款号"} Dim r As Row = Tables("订单面料明细").AddNew Dim r1 As Row = Tables("面料明细表").AddNew For Each TTL As String In Tea r(TTL) = e.Form.Controls(TTL).text r1(TTL) = e.Form.Controls(TTL).text r("面料名称") = e.Form.Controls("Tml_" & i1 & "_2" ).Value r1("面料名称") = e.Form.Controls("Tml_" & i1 & "_2" ).Value r("面料规格") = e.Form.Controls("Tml_" & i1 & "_3" ).Value r1("面料规格") = e.Form.Controls("Tml_" & i1 & "_3" ).Value r("面料成份") = e.Form.Controls("Tml_" & i1 & "_4" ).Value r1("面料成分") = e.Form.Controls("Tml_" & i1 & "_4" ).Value r("面料门幅") = e.Form.Controls("Tml_" & i1 & "_6" ).Value r1("面料门幅") = e.Form.Controls("Tml_" & i1 & "_6" ).Value r("面料单位") = e.Form.Controls("Tml_" & i1 & "_5" ).Value r1("面料单位") = e.Form.Controls("Tml_" & i1 & "_5" ).Value r("面料单耗") = e.Form.Controls("Tml_" & i1 & "_7" ).Value r("面料合计") = e.Form.Controls("Tml_" & i1 & "_8" ).Value r1("应耗数量") = e.Form.Controls("Tml_" & i1 & "_8" ).Value * 1.03 r("面料颜色") = e.Form.Controls("Tml_" & i1 & "_1" ).Value r1("颜色") = e.Form.Controls("Tml_" & i1 & "_1" ).Value r("供应商") = e.Form.Controls("Tml_" & i1 & "_9" ).Value Next End If Next |
||||
-- 作者:有点蓝 -- 发布时间:2016/11/23 10:35:00 -- 除非2个表Select返回的行数是一样的,不然没有办法整合到一起 |
||||
-- 作者:hongyefor -- 发布时间:2016/11/24 10:37:00 --
帮我看看吧 |