Select Case e.DataCol.Name Case "数量" Dim dr As DataRow = DataTables("fa piao库存").find(" 名称 = '" & e.DataRow("名称") & "' and 规格 = '" & e.DataRow("规格") & "' and 单位 = '" & e.DataRow("单位") & "' ") Dim drs As List(Of DataRow) = DataTables("fa piao主表").Select(" 业务类型 = '收进fa piao' ") Dim Values As new List(of String ) For Each dr2 As DataRow In drs Values.Add( CStr(dr2("autoid"))) Next Dim str As String = String.Join("','",Values.ToArray) Dim drs1 As List(Of DataRow) = DataTables("fa piao主表").Select(" 业务类型 = '开出fa piao' ") Dim Values1 As new List(of String) For Each dr1 As DataRow In drs1 Values1.Add( CStr(dr1("autoid"))) Next Dim str1 As String = String.Join("','",Values1.ToArray) If dr Is Nothing Then Dim n As Integer = DataTables("fa piao库存").SQLCompute(" max(autoid) ") +1 Dim dd As Row = Tables("fa piao库存").AddNew() dd("AutoID") = n dd("名称") = e.DataRow("名称") dd("规格") = e.DataRow("规格") dd("单位") = e.DataRow("单位") dd("单价") = e.DataRow("单价") dd("含税单价") = e.DataRow("含税单价") dd.save End If dr("入库数量") = DataTables("fa piao内容明细表").SQLCompute("sum(数量)"," 名称 = '" & e.DataRow("名称") & "' and 规格 = '" & e.DataRow("规格") & "' and 单位 = '" & e.DataRow("单位") & "' and MainID in (' " & str & "') ") dr("出库数量") = DataTables("fa piao内容明细表").SQLCompute("sum(数量)"," 名称 = '" & e.DataRow("名称") & "' and 规格 = '" & e.DataRow("规格") & "' and 单位 = '" & e.DataRow("单位") & "' and MainID in (' " & str1 & "') ") dr.save End Select
|