老师,我上面说的错误计算跟下面我标出的代码有关联吗?
Dim ck As DataRow = e.DataRow
Dim rk = DataTables("入库明细").Find("入库单编号明细 = '" & e.DataRow("入库批次号") & "'")
If rk IsNot Nothing Then
Dim sum = e.DataTable.compute("sum(出库_数量)", "入库批次号 = '" & e.DataRow("入库批次号") & "' and _Identify <= " & e.DataRow("_Identify"))
ck("最后库存") = rk("入库_数量") - sum
End If
'MessageBox.Show(8)
'=================================================================================================================
Select Case e.DataCol.Name
Case "出库_数量"
SystemReady = False
If e.DataRow.isnull("出库_数量") = False Then
If e.DataRow.IsNull("出库_价税合计") Then
e.DataRow("出库_价税合计") = e.DataRow("出库_价税合计") * e.DataRow("出库_数量")
ElseIf e.DataRow.isnull("出库_售价") Then
e.DataRow("出库_售价") = e.DataRow("出库_价税合计") / e.DataRow("出库_数量")
Else
e.DataRow("出库_价税合计") = e.DataRow("出库_售价") * e.DataRow("出库_数量")
End If
End If
SystemReady = True
Case "出库_售价"
SystemReady = False
If e.DataRow.isnull("出库_售价") = False Then
If e.DataRow.IsNull("出库_价税合计") Then
e.DataRow("出库_价税合计") = e.DataRow("出库_售价") * e.DataRow("出库_数量")
ElseIf e.DataRow.isnull("出库_数量") Then
e.DataRow("出库_数量") = e.DataRow("出库_价税合计") / e.DataRow("出库_售价")
Else
e.DataRow("出库_价税合计") = e.DataRow("出库_售价") * e.DataRow("出库_数量")
End If
End If
SystemReady = True
Case "出库_价税合计"
SystemReady = False
If e.DataRow.isnull("出库_价税合计") = False Then
If e.DataRow.IsNull("出库_售价") Then
If e.DataRow.IsNull("出库_数量") = False Then
e.DataRow("出库_售价") = e.DataRow("出库_价税合计") / e.DataRow("出库_数量")
End If
ElseIf e.DataRow.isnull("出库_数量") Then
If e.DataRow.IsNull("出库_售价") = False Then
e.DataRow("出库_数量") = e.DataRow("出库_价税合计") / e.DataRow("出库_售价")
End If
Else
If e.DataRow.IsNull("出库_数量") = False Then
e.DataRow("出库_售价") = e.DataRow("出库_价税合计") / e.DataRow("出库_数量")
End If
End If
End If
SystemReady = True
End Select
'--------------------------------------------------------------------------------------
Select Case e.DataCol.Name
Case "出库_税率"
SystemReady = False
If e.DataRow("出库_税率") > 0 Then
e.DataRow("出库_金额") = e.DataRow("出库_价税合计") / e.DataRow("出库_税率")
e.DataRow("出库_税金") = e.DataRow("出库_价税合计") - e.DataRow("出库_金额")
End If
SystemReady = True
Case "出库_税金"
SystemReady = False
If e.DataRow.isnull("出库_税金") = False Then
e.DataRow("出库_金额") = e.DataRow("出库_价税合计") - e.DataRow("出库_税金")
If e.DataRow("出库_金额") > 0 Then
e.DataRow("出库_税率") = e.DataRow("出库_价税合计") / e.DataRow("出库_金额")
End If
End If
SystemReady = True
Case "出库_金额"
SystemReady = False
If e.DataRow.isnull("出库_金额") = False Then
e.DataRow("出库_税金") = e.DataRow("出库_价税合计") - e.DataRow("出库_金额")
If e.DataRow("出库_金额") > 0 Then
e.DataRow("出库_税率") = e.DataRow("出库_价税合计") / e.DataRow("出库_金额")
End If
End If
SystemReady = True
End Select