以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  帮忙优化代码,应用的时候感觉卡卡的  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=16998)

--  作者:bm
--  发布时间:2012/2/29 19:24:00
--  帮忙优化代码,应用的时候感觉卡卡的

If e.form.controls("ComboBox1").value = "" Then
 messagebox.show("请输入或选择来源例.")
Return
ElseIf e.form.controls("ComboBox2").value = "" Then
 messagebox.show("请输入或选条件例.")
Return
End If

Dim Result As DialogResult
Result = MessageBox.Show("确认对账吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
  Dim s1 As Object = e.Form.Controls("ComboBox1").Value
  Dim s2 As Object = e.Form.Controls("ComboBox2").Value
  Dim sum As Double = Tables("支出明细").Compute("Sum(金额)",s1 & " = \'" & s2 & "\'")
  Dim r As Row = Tables("应付运费").AddNew
  r("应付金额") = sum
  r("录入日期") = Date.now
  Dim F As Object
  If Tables("支出明细").Filter <> ""  Then
      F = "(" & Tables("支出明细").Filter & ") And "
  End If
  f  = f & F & s1 & " = \'" & s2 & "\'"
  Dim drs As List(Of DataRow) = DataTables("支出明细").Select(f)
  For Each dr As DataRow In drs
  r("收款人") = dr("收款人")
  r.Locked = True
  r.Save()
  dr("支出账户")="已对账"
  dr("日期") = Date.now
  dr("流水号") = r("应付流水")
  dr.Save()
  Next
  e.Form.close()
Else
    Return
End If


--  作者:狐狸爸爸
--  发布时间:2012/2/29 21:57:00
--  

   For Each dr As DataRow In drs
        r("收款人") = dr("收款人")
        r.Locked = True
        r.Save()
        dr("支出账户")="已对账"
        dr("日期") = Date.now
        dr("流水号") = r("应付流水")
        dr.Save()
    Next

 

改为:

 

   For Each dr As DataRow In drs
        r("收款人") = dr("收款人")
        r.Locked = True
        r.Save()
        dr("支出账户")="已对账"
        dr("日期") = Date.now
        dr("流水号") = r("应付流水")
    Next

    DataTables("支出明细").Save()