呵呵,长点但条理清晰些:
Dim sh,fh, ss,fs As string
Dim sk,fk As Boolean
dim dr1,dr2 as datarow
dim Dt as datatable = datatables("基本资料")
sk = e.datarow("收货_抵扣")
fk = e.datarow("发货_抵扣")
sh = e.datarow("收货_单位")
fh = e.datarow("发货_单位")
ss = e.datarow("收货_税号")
fs = e.datarow("发货_税号")
dr1 = Dt.find("[客户名称]= '" & sh & "'")
dr2 = Dt.find("[客户名称]= '" & fh & "'")
If e.DataCol.Name = "收货_单位" Then
if dr1 isNot nothing Then
e.datarow("收货_税号") = IIF(sk = true,"+","") & dr1("税号")
Else
e.datarow("收货_税号") = Nothing
e.datarow("收货_抵扣") = false
End if
Elseif e.DataCol.Name = "收货_抵扣" then
If sk = true then
e.datarow("发货_抵扣") = false
e.datarow("收货_税号") = IIF(ss.substring(0,1)="+","","+") & dr1("税号")
e.datarow("发货_税号") = dr2("税号").Replace("+","")
Else
e.datarow("收货_税号") = dr1("税号").Replace("+","")
End IF
ElseIf e.DataCol.Name = "发货_单位" Then
if dr2 isNot nothing Then
e.datarow("发货_税号") = IIF(fk = true,"+","") & dr2("税号")
Else
e.datarow("发货_税号") = Nothing
e.datarow("发货_抵扣") = false
End if
Elseif e.DataCol.Name = "发货_抵扣" then
If fk = true then
e.datarow("收货_抵扣") = false
e.datarow("发货_税号") = IIF(fs.substring(0,1)="+","","+") & dr2("税号")
e.datarow("收货_税号") = dr1("税号").Replace("+","")
Else
e.datarow("发货_税号") = dr2("税号").Replace("+","")
End IF
End IF
[此贴子已经被作者于2008-12-1 23:31:05编辑过]