Dim Cols1() As String = {"T28CT","T28UT","T28DL","T28UserId","T28DeptId","T28PointId","F390","F391","F392","F394","F395","F396","F397","F398","F399","F400","F401","F402","F403","F404","F405","F406","F407","F408","F409","F410","F411","F412","F413","F414","F415","F416","F417","F418","F419","F420","F421","F422","F4367","F4368","F4370","F4371","F4372","F4373","F4374","F4375","F4376","F4377","F4378","F4379","F4380","F4381","F4382","F5140","F5221","F5222","F5223","F5224","F5225","F5226","F5299","F5308","F5310","F5311","F5312","F5313"}
Dim Cols2() As String = {"T246CT","T246UT","T246DL","T246UserId","T246DeptId","T246PointId","F4362","F4363","F4364","F4366","F4383","F4384","F4385","F4386","F4387","F4388","F4389","F4390","F4391","F4392","F4393","F4394","F4395","F4396","F4397","F4398","F4399","F4400","F4401","F4402","F4403","F4404","F4405","F4406","F4407","F4408","F4409","F4410","F4411","F4412","F4414","F4415","F4416","F4417","F4418","F4419","F4420","F4421","F4422","F4423","F4424","F4425","F4426","F5265","F5293","F5294","F5295","F5296","F5297","F5298","F5300","F5315","F5317","F5318","F5319","F5320"}
For Each dr1 As DataRow In DataTables("T28").Select("")
Dim filter As String = "1=1"
For i As Integer = 0 To cols1.length-1
Dim dc As DataCol = DataTables("T246").datacols(cols2(i))
If dr1.IsNull(cols1(i)) Then
If dc.IsNumeric Then
filter &= " and " & dc.name & " = " & dr1(cols1(i))
Else
filter &= " and " & cols2(i) & " is null"
End If
Else
If dc.IsString Then
filter &= " and " & dc.name & " = '" & dr1(cols1(i)) & "'"
ElseIf dc.IsBoolean Then
filter &= " and " & dc.name & " = " & dr1(cols1(i))
ElseIf dc.IsNumeric Then
filter &= " and " & dc.name & " = " & dr1(cols1(i))
ElseIf dc.IsDate Then
filter &= " and " & dc.name & " = #" & dr1(cols1(i)) & "#"
End If
End If
Next
Dim dr2 As DataRow = DataTables("T246").find(filter)
If dr2 Is Nothing Then
dr2 = DataTables("T246").AddNew()
End If
For i As Integer = 0 To Cols1.Length -1
dr2(Cols2(i)) = dr1(Cols1(i))
Next
Next
DataTables("T246").Save()