以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  说没有找到合同交期,为什么  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=144979)

--  作者:hongye
--  发布时间:2020/1/4 18:16: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
        Dim cmd As New SQLCommand
        Dim ds As DataTable
        Dim dds As DataTable
        Dim ddm As DataTable
        Dim dmd As DataTable
        Dim psb As DataTable
        Dim flb As DataTable
        Dim cmb As WinForm.ComboBox
        cmd.C
        cmd.CommandText = "SELECT * Fro m {订单主表}"
        ds = cmd.ExecuteReader(True)
        cmd.CommandText = "SELECT * Fro m {订单数量明细}"
        dds = cmd.ExecuteReader(True)
        cmd.CommandText = "SELECT * Fro m {订单面料明细}"
        ddm = cmd.ExecuteReader(True)
        cmd.CommandText = "SELECT * Fro m {面料委托表}"
        dmd= cmd.ExecuteReader(True)
        cmd.CommandText = "SELECT * Fro m {配色表}"
        psb = cmd.ExecuteReader(True)
        cmd.CommandText = "SELECT * Fro m {订单辅料明细}"
        flb = cmd.ExecuteReader(True)
If shk.text > "" And ddh.text > "" Then
    Dim filter As String = "合同号 = \'" & e.Form.Controls("合同号").Text & "\'And 款号 = \'" &  e.Form.Controls("款号").Text & "\'And 合同交期 = \'" & e.Form.Controls("合同交期").Value & "\' And 客户名称 = \'" & e.Form.Controls("客户名称").Text & "\' And 品名 = \'" & e.Form.Controls("品名").Text & "\'"
    Dim drZ As  List(Of DataRow) = ds.Select(filter)
    For Each r As DataRow In drZ
        r("合同交期") = e.Form.Controls("合同交期").Value
        r("二次加工") = e.Form.controls("ecjg").Text
        r("裁剪要求") = e.Form.controls("cjyq").Text
        r("包装要求") = e.Form.controls("bzyq").Text
        r("备注") = e.Form.controls("TB备注").Text
        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 = dds.find(temp)
                If fdr IsNot Nothing Then
                    fdr("数量") = dr
                Else
                    Dim Tea() As String ={"合同号","款号"}
                    Dim r As DataRow = dds.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
    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
            If shk.text > "" And ddh.text > "" Then
                Dim drs As List(Of DataRow) = ddm.Select(filter & " and 面料名称 = \'" & e.Form.controls("Tml_" & i1 & "_2" ).Text & "\' and 面料颜色 = \'" & e.Form.controls("Tml_" & i1 & "_1" ).Text & "\'")
                If drs.count = 0 Then
                    Dim dr As DataRow = ddm.AddNew
                    dr("合同号") = ddh.text
                    dr("款号") = shk.text
                    dr("面料名称") = e.Form.controls("Tml_" & i1 & "_2").Text
                    dr("面料规格") = e.Form.controls("Tml_" & i1 & "_3" ).Text
                    dr("面料颜色") = e.Form.controls("Tml_" & i1 & "_1" ).Text
                    dr("面料成份") = e.Form.controls("Tml_" & i1 & "_4").Text
                    dr("面料门幅") = e.Form.controls("Tml_" & i1 & "_6" ).Text
                    dr("面料单位") = e.Form.controls("Tml_" & i1 & "_5" ).Text
                    dr("面料单耗") = e.Form.controls("Tml_" & i1 & "_7").Text
                    dr("面料合计") = e.Form.controls("Tml_" & i1 & "_8" ).Text
                    dr("供应商") = e.Form.controls("Tml_" & i1 & "_9" ).Text
                Else
                    For ir As Integer = 0 To drs.count-1
                        drs(ir)("面料名称") = e.Form.controls("Tml_" & i1 & "_2").Text
                        drs(ir)("面料规格") = e.Form.controls("Tml_" & i1 & "_3" ).Text
                        drs(ir)("面料颜色") = e.Form.controls("Tml_" & i1 & "_1" ).Text
                        drs(ir)("面料成份") = e.Form.controls("Tml_" & i1 & "_4").Text
                        drs(ir)("面料门幅") = e.Form.controls("Tml_" & i1 & "_6" ).Text
                        drs(ir)("面料单位") = e.Form.controls("Tml_" & i1 & "_5" ).Text
                        drs(ir)("面料单耗") = e.Form.controls("Tml_" & i1 & "_7").Text
                        drs(ir)("面料合计") = e.Form.controls("Tml_" & i1 & "_8" ).Text
                        drs(ir)("供应商") = e.Form.controls("Tml_" & i1 & "_9" ).Text
                    Next
                    
                End If
            End If
        End If
    Next
    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
            If shk.text > "" And ddh.text > "" Then
                Dim drs As List(Of DataRow) = ddm.Select(filter & " and 面料名称 = \'" & e.Form.controls("Tml_" & i1 & "_2" ).Text & "\' and 颜色 = \'" & e.Form.controls("Tml_" & i1 & "_1" ).Text & "\'")
                If drs.count = 0 Then
                    Dim dr As DataRow = ddm.AddNew
                    dr("合同号") = ddh.text
                    dr("款号") = shk.text
                    dr("面料名称") = e.Form.controls("Tml_" & i1 & "_2").Text
                    dr("面料规格") = e.Form.controls("Tml_" & i1 & "_3" ).Text
                    dr("颜色") = e.Form.controls("Tml_" & i1 & "_1" ).Text
                    dr("面料成分") = e.Form.controls("Tml_" & i1 & "_4").Text
                    dr("面料门幅") = e.Form.controls("Tml_" & i1 & "_6" ).Text
                    dr("面料单位") = e.Form.controls("Tml_" & i1 & "_5" ).Text
                    dr("应耗数量") = e.Form.controls("Tml_" & i1 & "_8" ).Text
                Else
                    For ir As Integer = 0 To drs.count-1
                        drs(ir)("面料名称") = e.Form.controls("Tml_" & i1 & "_2").Text
                        drs(ir)("面料规格") = e.Form.controls("Tml_" & i1 & "_3" ).Text
                        drs(ir)("颜色") = e.Form.controls("Tml_" & i1 & "_1" ).Text
                        drs(ir)("面料成分") = e.Form.controls("Tml_" & i1 & "_4").Text
                        drs(ir)("面料门幅") = e.Form.controls("Tml_" & i1 & "_6" ).Text
                        drs(ir)("面料单位") = e.Form.controls("Tml_" & i1 & "_5" ).Text
                        drs(ir)("应耗数量") = e.Form.controls("Tml_" & i1 & "_8" ).Text
                    Next
                    
                End If
            End If
        End If
    Next
    For k As Integer = 1 To 7
        For l As Integer = 1 To 7
            Dim dr As String = e.Form.Controls("TBp_" & k & "_" & l).Text
            Dim dr2 As String = e.Form.Controls("TB_" & l).Text
            Dim dr3 As String = e.Form.Controls("TBs_" & k).Text
            If dr > "" And dr2 > "" And dr3 > ""  Then
                Dim temp As String = filter & " and 颜色 = \'" & dr3 & "\' and 配色名称 = \'" & dr2 & "\'"
                Dim fdr As DataRow = psb.find(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
    For i1 As Integer = 1 To 9
        Dim drm1 As String = e.Form.Controls("DBF_1_" & i1).text
        Dim drm2 As String = e.Form.Controls("DBF_4_" & i1 ).text
        Dim drm7 As String = e.Form.Controls("DBF_5_" & i1).text
        Dim drm8 As String = e.Form.Controls("DBF_6_" & i1).text
        If drm1 <> "" And drm2 <> "" And drm7<> ""  And drm8<> ""  Then
            If shk.text > "" And ddh.text > "" Then
                Dim drs As List(Of DataRow) = flb.Select(filter & " and 辅料名称 = \'" & e.Form.controls("DBF_1_" & i1 ).Text & "\' and 计量单位 = \'" & e.Form.controls("DBF_4_" & i1 ).Text & "\'")
                If drs.count = 0 Then
                    Dim dr As DataRow = flb.AddNew
                    dr("合同号") = ddh.text
                    dr("款号") = shk.text
                    dr("辅料名称") = e.Form.Controls("DBF_1_" & i1 ).Text
                    dr("辅料规格") = e.Form.Controls("DBF_2_" & i1 ).Text
                    dr("辅料颜色") = e.Form.Controls("DBF_3_" & i1).Text
                    dr("计量单位") = e.Form.Controls("DBF_4_" & i1 ).Text
                    dr("辅料单耗") = e.Form.Controls("DBF_5_" & i1 ).Text
                    dr("辅料合计") = e.Form.Controls("DBF_6_" & i1).Text
                    dr("供应商") = e.Form.Controls("DBF_7_" & i1).Text
                Else
                    For ir As Integer = 0 To drs.count-1
                        drs(ir)("辅料名称") = e.Form.Controls("DBF_1_" & i1 ).Text
                        drs(ir)("辅料规格") = e.Form.Controls("DBF_2_" & i1 ).Text
                        drs(ir)("辅料颜色") = e.Form.Controls("DBF_3_" & i1).Text
                        drs(ir)("计量单位") = e.Form.Controls("DBF_4_" & i1 ).Text
                        drs(ir)("辅料单耗") = e.Form.Controls("DBF_5_" & i1 ).Text
                        drs(ir)("辅料合计") = e.Form.Controls("DBF_6_" & i1).Text
                        drs(ir)("供应商") = e.Form.Controls("DBF_7_" & i1).Text
                    Next
                End If
            End If
        End If
    Next
    If ds.HasChanges Or dds.HasChanges Or flb.HasChanges Or ddm.HasChanges Or psb.HasChanges Then
        If MessageBox.Show("款号为" & shk.text & "的订单已经被修改,是否保存?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
            psb.Save()
            ddm.Save()
            flb.Save()
            dds.Save()
            ddm.Save()
            ds.Save()
            MessageBox.Show("订单更新完成,请打印!")
        End If
    End If
End If
e.Form.Controls("修改").Visible = False

--  作者:hongye
--  发布时间:2020/1/4 18:17:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:01.jpg
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2020/1/5 20:49:00
--  
提示很明显了,filter条件是所有表共用的,有表没有“合同交期”这个列