Dim t As Table = CurrentTable
If t.Current Is Nothing Then Return False
If t.TopPosition < 0 Then Return False '如果选定区域不包括数据行
Dim json As String = t.Current("SYS_Note")
Dim jo As JObject = JObject.Parse(json)
'messagebox.show(jo(CurrentTable.Cols(CurrentTable.ColSel).Name))
If t.Current.IsNull("SYS_Note") = True Or t.Current("SYS_Note") = Nothing Then
Return False
Else
'messagebox.show(json)
Dim it As Win.Data.ITable = SYS.Tables(t.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("SYS_Note") = True Or r("SYS_Note") = Nothing Then
Dim jo1 As New JObject
jo1(CurrentTable.Cols(CurrentTable.ColSel).Name) = jo(CurrentTable.Cols(CurrentTable.ColSel).Name)
'Output.Show(jo1.ToString)
r("SYS_Note") = jo1.ToString
r.Save
Dim fdr As DataRow = t.DataTable.Find("_Identify = " & r("_Identify"))
If fdr IsNot Nothing Then
fdr.Load
End If
'r.load
Else
If r("SYS_Note").Contains(CurrentTable.Cols(CurrentTable.ColSel).Name) = True Then
'接下来需要处理的地方,如何向json中修改当前列名对应的值,先生成json,再将json赋值给r("SYS_Note")
Dim json1 As String = r("SYS_Note")
Dim jo2 As JObject = JObject.Parse(json1)
jo2(CurrentTable.Cols(CurrentTable.ColSel).Name) = jo(CurrentTable.Cols(CurrentTable.ColSel).Name)
r("SYS_Note") = jo2.Tostring
r.Save
Dim fdr As DataRow = t.DataTable.Find("_Identify = " & r("_Identify"))
If fdr IsNot Nothing Then
fdr.Load
End If
'r.load
'output.show(r("SYS_Note"))
'判断遍历的列名在json中是否存在,如果存在直接替换,如何不存在,新建json
Else
'待加代码
'messagebox.show("不存在")
Dim json1 As String = r("SYS_Note")
Dim jo2 As JObject = JObject.Parse(json1)
jo2(CurrentTable.Cols(CurrentTable.ColSel).Name) = New JObject
jo2(CurrentTable.Cols(CurrentTable.ColSel).Name) = jo(CurrentTable.Cols(CurrentTable.ColSel).Name)
r("SYS_Note") = jo2.Tostring
r.Save
Dim fdr As DataRow = t.DataTable.Find("_Identify = " & r("_Identify"))
If fdr IsNot Nothing Then
fdr.Load
End If
'r.load
'output.show(r("SYS_Note"))
End If
End If
Next
End If