以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 查找指定条件的后台数据所在位置 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=170885) |
-- 作者:采菊东篱下 -- 发布时间:2021/8/10 15:03:00 -- 查找指定条件的后台数据所在位置 查找指定条件的后台数据所在位置,如果r存在,删除借方的行,再在贷方行前插入一行,否则在贷方行前插入一行。 Dim r As DataRow = DataTables("财务数据源").SQLFind("[字号] = \'" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "\' And [凭证号] = \'" & e.Form.Controls("dh").text & "\' And [安日期生成单号辅助列] = \'" & e.Form.Controls("dh1").text & "\' And [借或贷] = \'借\'") If r IsNot Nothing Then DataTables("财务数据源").SQLDeleteFor("[字号] = \'" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "\' And [凭证号] = \'" & e.Form.Controls("dh").text & "\' And [安日期生成单号辅助列] = \'" & e.Form.Controls("dh1").Value & "\' And [借或贷] = \'借\'") Dim r1 As DataRow = DataTables("财务数据源").SQLFind("[字号] = \'" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "\' And [凭证号] = \'" & e.Form.Controls("dh").text & "\' And [安日期生成单号辅助列] = \'" & e.Form.Controls("dh1").text & "\' And [借或贷] = \'贷\'") If r1 IsNot Nothing Then Dim wz As Integer = Tables("财务数据源").FindRow(r1) If wz = 0 Then Tables("财务数据源").Position = wz + 1 End If End If r =Tables("财务数据源").InsertNew (注这样写报错,改为:Tables("财务数据源").InsertNew不报错,但我要的是借方行插入一行) Else r = Tables("财务数据源").AddNew (注这样写报错,改为:Tables("财务数据源").InsertNew不报错,但我要的是借方行插入一行) End If 这样写不无法定位后台数据。 |
-- 作者:有点蓝 -- 发布时间:2021/8/10 15:09:00 -- 后台数据没有办法定位。只能定位已经加载的数据 Dim r As DataRow = DataTables("财务数据源").SQLFind("[字号] = \'" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "\' And [凭证号] = \'" & e.Form.Controls("dh").text & "\' And [安日期生成单号辅助列] = \'" & e.Form.Controls("dh1").text & "\' And [借或贷] = \'借\'") If r IsNot Nothing Then DataTables("财务数据源").SQLDeleteFor("[字号] = \'" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "\' And [凭证号] = \'" & e.Form.Controls("dh").text & "\' And [安日期生成单号辅助列] = \'" & e.Form.Controls("dh1").Value & "\' And [借或贷] = \'借\'") Dim r1 As DataRow = DataTables("财务数据源").SQLFind("[字号] = \'" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "\' And [凭证号] = \'" & e.Form.Controls("dh").text & "\' And [安日期生成单号辅助列] = \'" & e.Form.Controls("dh1").text & "\' And [借或贷] = \'贷\'") If r1 IsNot Nothing Then r =dataTables("财务数据源").AddNew r("_sortkey") = r1("_sortkey") - 0.0001 End If Else r = dataTables("财务数据源").AddNew End If [此贴子已经被作者于2021/8/10 15:09:25编辑过]
|
-- 作者:采菊东篱下 -- 发布时间:2021/8/10 19:35:00 -- r1可能有多行,这r("_sortkey") = r1("_sortkey") - 0.0001岂不是多值?要求只在r1第一行插入一行。 [此贴子已经被作者于2021/8/10 20:08:33编辑过]
|
-- 作者:采菊东篱下 -- 发布时间:2021/8/10 20:07:00 -- 这样写吗? Dim r As DataRow = DataTables("财务数据源").SQLFind("[字号] = \'" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "\' And [凭证号] = \'" & e.Form.Controls("dh").text & "\' And [安日期生成单号辅助列] = \'" & e.Form.Controls("dh1").text & "\' And [借或贷] = \'借\'") If r IsNot Nothing Then DataTables("财务数据源").SQLDeleteFor("[字号] = \'" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "\' And [凭证号] = \'" & e.Form.Controls("dh").text & "\' And [安日期生成单号辅助列] = \'" & e.Form.Controls("dh1").Value & "\' And [借或贷] = \'借\'") Dim r1s As List(Of DataRow) = DataTables("财务数据源").SQLSelect("[字号] = \'" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "\' And [凭证号] = \'" & e.Form.Controls("dh").text & "\' And [安日期生成单号辅助列] = \'" & e.Form.Controls("dh1").text & "\' And [借或贷] = \'贷\'") If r1s IsNot Nothing Then r = DataTables("财务数据源").AddNew r("_sortkey") = r1s(0)("_sortkey") - 0.0001 End If Else r = DataTables("财务数据源").AddNew End If |
-- 作者:有点蓝 -- 发布时间:2021/8/10 20:25:00 -- Dim r1 As DataRow = DataTables("财务数据源").SQLFind("[字号] = \'" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "\' And [凭证号] = \'" & e.Form.Controls("dh").text & "\' And [安日期生成单号辅助列] = \'" & e.Form.Controls("dh1").text & "\' And [借或贷] = \'贷\'","_sortkey")
|
-- 作者:采菊东篱下 -- 发布时间:2021/8/10 20:30:00 -- 或者写成这样: Dim r As DataRow = DataTables("财务数据源").SQLFind("[字号] = \'" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "\' And [凭证号] = \'" & e.Form.Controls("dh").text & "\' And [安日期生成单号辅助列] = \'" & e.Form.Controls("dh1").text & "\' And [借或贷] = \'借\'") If r IsNot Nothing Then DataTables("财务数据源").SQLDeleteFor("[字号] = \'" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "\' And [凭证号] = \'" & e.Form.Controls("dh").text & "\' And [安日期生成单号辅助列] = \'" & e.Form.Controls("dh1").Value & "\' And [借或贷] = \'借\'") Dim r1s As List(Of DataRow) = DataTables("财务数据源").SQLSelect("[字号] = \'" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "\' And [凭证号] = \'" & e.Form.Controls("dh").text & "\' And [安日期生成单号辅助列] = \'" & e.Form.Controls("dh1").text & "\' And [借或贷] = \'贷\'",1) If r1s IsNot Nothing Then r = DataTables("财务数据源").AddNew r("_sortkey") = r1s(0)("_sortkey") - 0.0001 End If Else r = DataTables("财务数据源").AddNew End If |
-- 作者:有点蓝 -- 发布时间:2021/8/10 21:12:00 -- 也可以 |
-- 作者:采菊东篱下 -- 发布时间:2021/8/10 21:39:00 -- Dim r1s As List(Of DataRow) = DataTables("财务数据源").SQLSelect("[字号] = \'" & (e.Form.Controls("TextBox2").text).SubString(0,2) & "\' And [凭证号] = \'" & e.Form.Controls("dh").text & "\' And [安日期生成单号辅助列] = \'" & e.Form.Controls("dh1").text & "\' And [借或贷] = \'贷\'",0) 第一行应该是0吧?
|
-- 作者:有点蓝 -- 发布时间:2021/8/10 22:04:00 -- 还是没有理解帮助:http://www.foxtable.com/webhelp/topics/2900.htm SQLSelect(Filter,Top,Sort) Filter: 查询条件,采用的是SQL语法,和常规表达式的语法有所不同,请参考:SQL表达式的语法差异。 是返回多少行数据,而不是第几行 |
-- 作者:采菊东篱下 -- 发布时间:2021/8/10 22:20:00 -- 哦,明白了,谢谢。 |