-- 关于GetCheckedRows用法问题的求助
基本环境:我有一装箱表的管理窗口,窗口中分主表和下表(是明细表),每打开一份装箱表,只显示这一个单号的装箱表(包括上表及下表);问题:如果用户想从单号一的下表中选择一部份行复制到另一单号二的下表中,理论上新复制的行是排在最后的,但为什么测试中发现新增的行排在单号二已存在是明细行的前面?
选择复制行按钮的代码:
If Tables("pkl2").AllowAddNew = True Then
Dim s As String = e.Form.Controls("ComboBox1").Value
If s = "复制到其他装箱表的单号" Or s = "" Then
MessageBox.Show("你还未选出需其他装箱表的单号!")
Else
Dim s1 As String = "现在正准备将你选择的数据复制到其他装箱表中,确定吗?"
Dim Result As DialogResult
Result = MessageBox.Show(s1, "注意!", MessageBoxButtons.YesNo,MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
Dim tbl As Table = Tables("pkl2")
For Each r1 As Row In tbl.GetCheckedRows
Dim r As DataRow = DataTables("pkl2").AddNew()
If s <> "" And s <> "复制到其他装箱表的单号" Then
r("pksheet_no") = s
End If
r("part_no") = r1("part_no")
r("sheet_type") = r1("sheet_type")
r("delivery_addr") = r1("delivery_addr")
r("osal_no") = r1("osal_no")
r("cuord_no") = r1("cuord_no")
r("sheet_date") = r1("sheet_date")
r("kt_no1") = r1("kt_no1")
r("kt_no2") = r1("kt_no2")
r("kb_no1") = r1("kb_no1")
r("kb_no2") = r1("kb_no2")
r("zsl") = r1("zsl")
r("mhsl") = r1("mhsl")
r("item_no") = r1("item_no")
r("part_name") = r1("part_name")
r("part_spec") = r1("part_spec")
r("part_dw") = r1("part_dw")
r("cu_part_no") = r1("cu_part_no")
r("wf_eanno") = r1("wf_eanno")
r("ktjz") = r1("ktjz")
r("ktmz") = r1("ktmz")
r("kbjz") = r1("kbjz")
r("kbmz") = r1("kbmz")
r("kbcc_c") = r1("kbcc_c")
r("kbcc_k") = r1("kbcc_k")
r("pcs") = r1("pcs")
r("org_no") = r1("org_no")
r("osal_ddsl") = r1("osal_ddsl")
r("osal_jhno") = r1("osal_jhno")
r("osal_sheet_lot") = r1("osal_sheet_lot")
r("pksm") = r1("pksm")
r("wlwjhpj") = r1("wlwjhpj")
r("abus_ord_no") = r1("abus_ord_no")
Next
DataTables("pkl2").Save
DataTables("pkl2").LoadFilter = "pksheet_no = \'" & s & "\'"
DataTables("pkl2").Load()
Dim drs1 As List(of DataRow) = DataTables("pkl2").Select("[pksheet_no] = \'" & s & "\'")
For Each rd21 As DataRow In drs1 \'遍历所有行
rd21("pksheet_no")=Nothing
Next
For Each rd21 As DataRow In drs1 \'遍历所有行
rd21("pksheet_no")= s
Next
DataTables("pkl2").Save
e.Form.Close()
DataTables("pkl1").LoadFilter = "pksheet_no = \'" & s & "\'"
DataTables("pkl1").Load()
DataTables("pkl2").LoadFilter = "pksheet_no = \'" & s & "\'"
DataTables("pkl2").Load()
MessageBox.Show("复制完成!")
tbl.ShowCheckBox = False
Else
Return
End If
End If
Else
MessageBox.Show("你该权限还未开通!请联系管理员!")
End If