请问老师“材料库库存表”中
1.如何实现“材料名称”加“材料规格”自动生成材料编码,如“材料名称”是语文书,“材料规格”为25*15,自动生成材料编码“YWS2515” ?
2.“材料库库存表”中如何实现自动计算出结余?如上年结余1500,今年1月1日入库500,今年1月8日出库300,库存结余1700?
If e.DataCol.Name = "配件名称" Then
If e.DataRow.IsNull("配件名称") Then
e.DataRow("配件编码") = Nothing
Else
e.DataRow("产品编码") = GetPy(e.DataRow("产品名称"), 1)
End If
End If
Select Case e.DataCol.Name
Case "配件信息_配件名称","出入库信息_入库数量","出入库信息_出库数量"
Dim drs As List(of DataRow)
Dim Filter As String
Filter = "[_SortKey] >= " & e.DataRow("_SortKey") & " And [配件信息_配件名称] = '" & e.DataRow("配件信息_配件名称") & "'"
drs = e.DataTable.Select(Filter)
For Each dr As DataRow In drs
Filter = "[_SortKey] <= " & dr("_SortKey") & " And [配件信息_配件名称] = '" & dr("配件信息_配件名称") & "'"
Dim Val1 As Double = e.DataTable.Compute("Sum(出入库信息_入库数量)",Filter)
Dim Val2 As Double = e.DataTable.Compute("Sum(出入库信息_出库数量)",Filter)
dr("库存结余") = Val1 - Val2
Next
If e.DataCol.Name = "配件信息_配件名称" AndAlso e.OldValue IsNot Nothing AndAlso e.OldValue <> e.NewValue Then
Filter = "[_SortKey] > " & e.DataRow("_SortKey") & " And [配件信息_配件名称] = '" & e.OldValue & "'"
drs = e.DataTable.Select(Filter)
For Each dr As DataRow In drs
Filter = "[_SortKey] <= " & dr("_SortKey") & " And [配件信息_配件名称] = '" & dr("配件信息_配件名称") & "'"
Dim Val1 As Double = e.DataTable.Compute("Sum(库存结余)",Filter)
Dim Val2 As Double = e.DataTable.Compute("Sum(出入库信息_出库数量)",Filter)
dr("库存结余") = Val1 - Val2
Next
End If
End Select 为啥配件编码不能显示?