[求助]进销存入库窗口点审核条件填充代码不知道怎么写?
当点击审核的时候,
把入库表明细表中和窗口的是入库单号相等的行,填充到库存明细表中。
填充条件是:入库表明细表中的仓位和型号都和库存明细表已经存在的行的仓位和型号同时相等的时候,数量和小计要加总(这个代码已经会写),如果仓位和型号不都相等,则把 仓位,类型,型号,单位,数量,币别,单价,小计这些列的数据行增行填充到库存明细表。
下面是我写的一段代码。但实现不了。
Dim str As String
str = Forms("窗口3").controls("TextBox1").value
'加载指定期数的数据
For Each dr1 As DataRow In DataTables("入库表明细").Select("[入库单号] = '"& str & "'")
dr1("审核") =True
Next
Dim n As Integer = Tables("库存明细").Rows.Count
Select Case n
Case 0
Dim h As New Filler
h.SourceTable = DataTables("入库表明细")
h.SourceCols = "仓位,类型,型号,单位,数量,币别,单价,小计"
h.DataTable = DataTables("库存明细")
h.DataCols = "仓位,类型,型号,单位,数量,币别,单价,小计"
h.Filter = "[入库单号] = '"& str & "'"
h.ExcludeExistValue = True
h.Fill()
For Each dr2 As DataRow In DataTables("入库表").Select("[入库单号] = '"& str & "'")
dr2("审核") =True
Next
Case Else
For r As Integer = 0 To n-1
Dim drr1 As DataRow
drr1 = DataTables("库存明细").DataRows(r)
Dim drr2 As DataRow = DataTables("入库表明细").Find("[入库单号] = '"& str & "' And [仓位] = '" & drr1("仓位") & "' And [型号] = '"& drr1("型号") &"'")
If drr2 IsNot Nothing Then
drr1("数量") = drr1("数量") +drr2("数量")
drr1("小计") = drr1("小计") +drr2("数量")
End If
Next
For rr As Integer = 0 To n-1
Dim drr5 As DataRow
drr5 = DataTables("库存明细").DataRows(rr)
Dim Cols1() As String = {"仓位","类型","型号","单位","数量","币别","单价","小计"}
Dim Cols2() As String = {"仓位","类型","型号","单位","数量","币别","单价","小计"}
For Each drr3 As DataRow In DataTables("入库表明细").Select("[入库单号] = '"& str & "' And (([仓位] = '" & drr5("仓位") & "' or [型号] = '"& drr5("型号") &"') Or ([仓位] <> '" & drr5("仓位") & "' AND [型号] <> '"& drr5("型号") &"')) ")
Dim drr4 As DataRow = DataTables("库存明细").AddNew()
For i As Integer = 0 To Cols1.Length -1
drr4(Cols2(i)) = drr3(Cols1(i))
Next
Next
For Each dr3 As DataRow In DataTables("入库表").Select("[入库单号] = '"& str & "'")
dr3("审核") =True
Next
Next
End Select
此主题相关图片如下:1.jpg
[此贴子已经被作者于2011-6-30 20:01:39编辑过]