Select Case e.DataCol.Name
Case "产品详细信息_产品名称","产品详细信息_产品规格","产品详细信息_产品配置要求"
If e.DataRow.IsNull(e.DataCol.Name)= False Then
Dim Oldstr As String =e.DataRow("产品详细信息_产品配置要求")
Dim Newstr As String
For Each s As String In Oldstr
If Char.IsDigit(s) = True Then
Newstr = newstr & "," & s
End If
Next
e.DataRow("产品详细信息_产品编码") = GetPinYin(e.DataRow("产品详细信息_产品名称"), 1).Tostring.ToUpper() & "/" & e.DataRow("产品详细信息_产品规格") & "/" & Newstr.TrimStart(",")
End If
End Select
Select Case e.DataCol.Name
Case "购货客户详细信息_订货日期","购货客户详细信息_省市","购货客户详细信息_地区","购货客户详细信息_公司简称","产品详细信息_产品编码","购货客户详细信息_订货人"
If e.DataRow.IsNull(e.DataCol.Name)= False Then
Dim Oldstr As String =Format(e.DataRow("购货客户详细信息_订货日期"),"yyyMMdd")
Dim Newstr As String =GetPinYin(e.DataRow("购货客户详细信息_省市"), 1).Tostring.ToUpper()
Dim Newstr1 As String =GetPinYin(e.DataRow("购货客户详细信息_地区"), 1).Tostring.ToUpper()
Dim Newstr2 As String =GetPinYin(e.DataRow("购货客户详细信息_公司简称"), 1).Tostring.ToUpper()
Dim Newstr3 As String =GetPinYin(e.DataRow("购货客户详细信息_订货人"), 1).Tostring.ToUpper()
e.DataRow("购货客户详细信息_订货单编码") = Oldstr & "/" & newstr & "/" & Newstr1 & "/" & Newstr2 & "/" & Newstr3 & "/" & e.DataRow("产品详细信息_产品编码")
End If
End Select
If e.DataCol.Name = "购货客户详细信息_省市" OrElse e.DataCol.name = "购货客户详细信息_地区" OrElse e.DataCol.Name = "购货客户详细信息_公司简称" OrElse e.DataCol.name = "购货客户详细信息_订货人" Then
If e.DataRow.isnull("购货客户详细信息_省市") OrElse e.DataRow.isnull("购货客户详细信息_地区") OrElse e.DataRow.isnull("购货客户详细信息_公司简称") OrElse e.DataRow.Isnull("购货客户详细信息_订货人") Then
e.DataRow("购货客户详细信息_客户编码") = Nothing
Else
e.DataRow("购货客户详细信息_客户编码") = e.DataRow("购货客户详细信息_省市") &"-" & GetPy(e.DataRow("购货客户详细信息_地区"), 1).ToUpper & "-" & e.DataRow("购货客户详细信息_公司简称") & "-" & e.DataRow("购货客户详细信息_订货人")
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)
Dim Val3 As Double = e.DataTable.Compute("Sum(货款状态_欠款金额)",Filter & " And 产品详细信息_总金额 Is null And 货款状态_预收金额 Is null")
dr("货款状态_欠款金额") = Val1 - Val2 + val3
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)
Dim Val3 As Double = e.DataTable.Compute("Sum(货款状态_欠款金额)",Filter & " and 产品详细信息_总金额 is null and 货款状态_预收金额 Is null")
dr("货款状态_欠款金额") = Val1 - Val2 + val3
Next
End If
End Select
请教如何自动计算出同一“客购货客户详细信息_客户编码“的”货款状态_欠款金额“?如“客购货客户详细信息_客户编码“的”产品详细信息_总金额“为5000.00元,已收“货款状态_预收金额”3000.00元,如何自动计算出“货款状态_欠款金额”为2000.00元
?