以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 请求计算 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=122042) |
||||
-- 作者:xusuyang -- 发布时间:2018/7/17 22:42:00 -- 请求计算 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元,为啥在“货款状态_欠款金额”不显示5000.00元
|
||||
-- 作者:有点蓝 -- 发布时间:2018/7/17 23:31:00 -- http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=122039&skin=0 |