以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]查询与赋值新增行并存的问题 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=125329) |
-- 作者:积水成渊 -- 发布时间:2018/9/26 14:30:00 -- [求助]查询与赋值新增行并存的问题 想弄一个功能,选中表中的几行,然后新增这几行,最后将选中行的内容赋值给新增的几行中,但是我写完代码执行后,发现效率低的可怜,在论坛也找了一些案例看了下,还是没有把问题解决好,请老师们帮我看下代码该如何改进: Dim Result As DialogResult Result = MessageBox.Show("是否要执行此操作", "提示", MessageBoxButtons.YesNo) If Result = DialogResult.No Then Return Else Dim t1 As Table = Tables("A") Dim mdbm As String If InputValue(mdbm, "编码输入","可以输入多个编码,用逗号进行分隔如:1001,1005,1008") Then Dim Parts() As String = mdbm.Split(",") If t1.Current Is Nothing Then Return If t1.TopPosition < 0 Then Return \'如果选定区域不包括数据行 Dim it As Win.Data.ITable = SYS.Tables(t1.Name) For i As Integer = it.TopRow To it.BottomRow Dim r As Win.Data.IRow = it.Rows(i) If r.Visible = False Then Continue For If r.IsNull("月份")= True Then Continue For For Each nm As String In Parts Dim dr1 As Row = t1.AddNew For Each c As Col In t1.Cols If c.name = "任务一_完成率" orelse c.name = "名称" Then Continue For dr1(c.name) = r(c.name) \'messagebox.show(r(c.name)) dr1("编码") = nm dr1("取值结果") = nothing dr1("计算结果") = nothing Next Next Next End If End If MessageBox.Show("执行完毕,请检查是否有错误!", "提示") |
-- 作者:有点甜 -- 发布时间:2018/9/26 14:40:00 -- 你这个和查询赋值无关。具体做一个实例发上来测试,说明你要做什么。 |
-- 作者:积水成渊 -- 发布时间:2018/9/26 15:14:00 -- 好的 |
-- 作者:积水成渊 -- 发布时间:2018/9/26 15:19:00 -- 说明 |
-- 作者:积水成渊 -- 发布时间:2018/9/26 15:21:00 -- 代码就一段 Dim t1 As Table = Tables("SPM_合同清单表") Dim mdbm As String If InputValue(mdbm, "编码输入","可以输入多个编码,用逗号进行分隔如:1001,1005,1008") Then Dim Parts() As String = mdbm.Split(",") If t1.Current Is Nothing Then Return If t1.TopPosition < 0 Then Return \'如果选定区域不包括数据行 For i As Integer = t1.TopPosition To t1.BottomPosition Dim r As Row = t1.Rows(i) For Each nm As String In Parts Dim dr1 As Row = t1.AddNew For Each c As Col In t1.Cols If c.name = "任务一_完成率" OrElse c.name = "部门名称" Then Continue For dr1(c.name) = r(c.name) dr1("创建人") = nm Next Next Next End If MessageBox.Show("执行完毕,请检查是否有错误!", "提示") |
-- 作者:有点甜 -- 发布时间:2018/9/26 15:25:00 -- 选择了200行,填入了5个值,也就是1000行数据,测试2、3秒左右
Dim t1 As Table = Tables("SPM_合同清单表") |
-- 作者:积水成渊 -- 发布时间:2018/9/26 15:32:00 -- 太感谢,厉害 |