1、在一个单据编号下有一个品种,删除此单据,运行正常
2、在一个单据编号下有多个品种,删除此单据,库存量不对,不正常运行
3、库存计算:维一标识 “源单编号”
Dim tb1 As WinForm.Table = e.Form.Controls("Table1")
Dim r1 As Row
Dim Names As New List(Of String)
For i As Integer = vars("trow") To vars("brow")
r1 = tb1.Table.Rows(i)
If Names.Contains(r1("单据编号")) = False Then '判断集合是否包括"电视机"
Names.Add(r1("单据编号"))
End If
Next
Dim Result As DialogResult
Result = MessageBox.Show("您确定要删除" & names.Count & "条单据吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
For Each djbh As String In names
Dim dr As DataRow = DataTables("出入库主表").SQLFind("单据编号='" & djbh & "'")
If dr IsNot Nothing And dr("单据状态") = "计划" Then
Dim dr1 As DataRow = DataTables("出入库明细表").Find("源单编号='" & r1("源单编号") & "'")
If dr1 IsNot Nothing Then
dr1("库存数量") += r1("出库数量")
dr1.save
End If
DataTables("出入库主表").SQLDeleteFor("单据编号='" & djbh & "'")
DataTables("出入库明细表").SQLDeleteFor("单据编号='" & djbh & "'")
Else
MessageBox.Show("审核过单据不能审除")
End If
Next
End If
Dim cx As WinForm.Button = e.Form.Controls("查询")
cx.PerformClick