Select Case e.DataCol.name Case "是否结账" Dim dr As DataRow = e.DataRow If dr("发生年月").Length = 8 Then Dim d1 As Date = new Date(dr("发生年月").substring(0,4), dr("发生年月").substring(5,2), 1) Dim d2 As Date = d1.AddMonths(1) Dim s As String = Format(d2,"yyy年MM月") If dr("是否结账")="是" Then Dim drs1 As List (of DataRow)=DataTables("计划耗用结存").Select("发生年月='" & dr("发生年月") & "'") For Each dr1 As DataRow In drs1 If dr1("月末结余_投入数") <> 0 OrElse dr1("月末结余_计划数") <> 0 OrElse dr1("月末结余_应存数") <> 0 OrElse dr1("月末结余_盘点数") <> 0 Then Dim dr2 As DataRow =DataTables("计划耗用结存").find("发生年月= '" & s & " ' and 物料编码= ' " & dr1("物料编码") & "' and 部门= '" & dr1("部门") & "'") If dr2 Is Nothing Then Dim r As Row = Tables("计划耗用结存").Addnew() r("发生年月") = s r("物料编码")=dr1("物料编码") r("部门")=dr1("部门") r("月初结余_计划数")=dr1("月末结余_计划数") End If End If Next End If End If End Select
|