有两段代码如下,烦请帮忙查看,能否帮忙简化一下,提高一下运算速度,谢谢!jin:
If Tables("原材料进仓主表").Current.IsNull("仓库名称") = True Then
MessageBox.Show("仓库名称不能为空!","提示")
Return
End If
DataTables("原材料进仓明细表盘").Loadfilter = "入库单据 = '"& forms("原材料进仓新增").controls("进仓单号").value &"'"
DataTables("原材料进仓明细表盘").load
For Each r As Row In Tables("原材料进仓新增_原材料进仓明细表盘")
If Forms("原材料进仓新增").Controls("仓库名称").value = "江门仓" OrElse Forms("原材料进仓新增").Controls("仓库名称").value = "新会仓" Then
Dim dr As DataRow '否则在产品表查找同名的进仓单号行,将找到的行赋值给变量dr
dr = DataTables("采购报价表").SQLFind("[物料代码] = '" & r("入库仓库")& "'")
If dr IsNot Nothing Then '如果找到了同名的进仓单号行,也就是dr不是Nothing
r("型号") = dr("型号")
r("规格") = dr("规格")
r("产地") = dr("产地")
r("等级") = dr("等级")
r("单价") = dr("单价")
r("单价1") = dr("单价1")
r("仓库名称") = Forms("原材料进仓新增").Controls("仓库名称").value
End If
Else
Dim dr1 As DataRow '否则在产品表查找同名的进仓单号行,将找到的行赋值给变量dr
dr1 = DataTables("物料信息表").SQLFind("[物料代码] = '" & r("入库仓库")& "'")
If dr1 IsNot Nothing Then '如果找到了同名的进仓单号行,也就是dr不是Nothing
r("型号") = dr1("型号")
r("规格") = dr1("规格")
r("产地") = dr1("产地")
r("等级") = dr1("等级")
r("仓库名称") = Forms("原材料进仓新增").Controls("仓库名称").value
End If
End If
Next
Dim r1 As Row = Tables("原材料进仓主表").Current
r1("总重量") = DataTables("原材料进仓明细表盘").Compute("sum(入库数量)","入库单据 = '"& forms("原材料进仓新增").controls("进仓单号").value &"'")
r1("总件数") = DataTables("原材料进仓明细表盘").Compute("count(条码)","入库单据 = '"& forms("原材料进仓新增").controls("进仓单号").value &"'")
chu:
DataTables("原材料出仓明细表盘").Loadfilter = "出库仓库 = '"& forms("原材料出仓新增").controls("生产单号").value &"'"
DataTables("原材料出仓明细表盘").load
For Each r As Row In Tables("原材料出仓新增_原材料出仓明细表盘").Rows
r("物料代码") = Tables("原材料出仓主表").Current("物料代码")
If e.Form.Controls("基材来源").value = "兆业膜" Then
Dim dr As DataRow = DataTables("采购报价表").SQLFind("[物料代码] = '" & r("物料代码")& "'")
If dr IsNot Nothing Then '如果找到了同名的进仓单号行,也就是dr不是Nothing
r("型号") = dr("型号")
r("规格") = dr("规格")
r("产地") = dr("产地")
r("等级") = dr("等级")
r("出仓单号") = Forms("原材料出仓新增").Controls("出仓单号").value
End If
Dim dr1 As DataRow = DataTables("原材料进仓明细表盘").SQLfind("条码 = '"& r("条码") &"' And 已出仓 = False ")
If dr1 IsNot Nothing Then
r("单件重量") = dr1("入库数量")
r("单价") = dr1("单价")
r("单价1") = dr1("单价1")
r("进仓单号") = dr1("入库单据")
End If
Else
Dim dr1 As DataRow = DataTables("物料信息表").SQLFind("[物料代码] = '" & r("物料代码")& "'")
If dr1 IsNot Nothing Then '如果找到了同名的进仓单号行,也就是dr不是Nothing
r("型号") = dr1("型号")
r("规格") = dr1("规格")
r("产地") = dr1("产地")
r("等级") = dr1("等级")
r("出仓单号") = Forms("原材料出仓新增").Controls("出仓单号").value
End If
End If
Next
Dim r1 As Row = Tables("原材料出仓主表").Current
r1("总重量") = DataTables("原材料出仓明细表盘").Compute("sum(单件重量)","出仓单号 = '"& forms("原材料出仓新增").controls("出仓单号").value &"'")
r1("总件数") = DataTables("原材料出仓明细表盘").Compute("count(条码)","出仓单号 = '"& forms("原材料出仓新增").controls("出仓单号").value &"'")