Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共3 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]请高手帮精简优化代码

1楼
号子 发表于:2008/12/1 18:20:00
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:汽车管理系统.table

请帮我优化开piao记录的datacolchanged事件代码。合并更好,谢谢先
2楼
ybil 发表于:2008/12/1 23:29:00

呵呵,长点但条理清晰些:

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编辑过]
3楼
号子 发表于:2008/12/3 8:44:00
授人鱼不如授人以渔,加点注释好吗,麻烦你了,有些看的懂,有些还不清楚。
[此贴子已经被作者于2008-12-3 8:44:18编辑过]
共3 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .01953 s, 3 queries.