有两张表 都是外部数据源 表一包含了几天的数据 假如已经把数据都填充到表二 在表中有一列订单编号是唯一值 不可重复填充
但有这么一个问题 假如表二不限制只显示哪一天数据的情况下 表一不可重复填充到表二 可是比如表一有三天的数据 这三天的数据都已经填充到表二 那在表二假如按日期刷新出当天数据后 前两天天的数据是可以再一次提交的 就好比代码只对比了表二当前是否有相同订单编号 我是想让代码去数据库的表二进行对比 可datatable("表名")不就是数据库表吗?
代码是:
Dim Cols1() As String = {"项目","下单日期","MK号","DO号","城市","客户","送货地址","物料代码","数量","体积","重量","承运商","司机","车牌","车数","车型","出车日期","车辆属性","备注","特殊要求","司机是否报销搬运费","跟车搬运","人数","订单编号"}
Dim Cols2() As String = {"项目","下单日期","MK号","DO号","城市","客户","送货地址","物料代码","数量","体积","重量","承运商","司机","车牌","车数","车型","出车日期","车辆属性","备注","特殊要求","司机是否报销搬运费","跟车搬运","人数","订单编号"}
Dim count As Integer = 0
Dim ls As new List(of Row)
Dim dic As new Dictionary (Of DataRow, Row)
systemready = False
For Each r As Row In Tables("配载订单").GetCheckedRows
If r.IsNull("订单编号") = False
Dim Filter = "[订单编号] = '" & r("订单编号") & "'"
Dim dr As DataRow = DataTables("客服跟单").find(filter)
If dr Is Nothing Then
ls.Add(r)
count += 1
Else
dic.add(dr, r)
End If
End If
Next
Dim p As WinForm.ProgressBar
p = e.Form.Controls("ProgressBar1")
If ls.count > 0 Then
p.Visible = True
p.Maximum = ls.Count - 1 '设置最大值
p.Minimum = 0 '设置最小值
p.Value = 0 '设置当前值
End If
Dim idx As Integer = 0
DataTables("配载订单").StopRedraw
For Each r As Row In ls
Dim dr As DataRow = DataTables("客服跟单").AddNew
For i As Integer = 0 To Cols1.Length -1
If r.IsNull(Cols1(i)) Then
dr(Cols2(i)) = Nothing
Else
dr(Cols2(i)) = r(Cols1(i))
End If
Next
idx += 1
p.Value = idx
Next
For Each key As DataRow In dic.Keys
Dim r As Row = dic(key)
Dim dr As DataRow = key
For i As Integer = 0 To Cols1.Length -1
If r.IsNull(Cols1(i)) Then
dr(Cols2(i)) = Nothing
Else
dr(Cols2(i)) = r(Cols1(i))
End If
Next
Next
DataTables("配载订单").ResumeRedraw
p.Visible = False
systemready = True
msgbox("共有 "& count &" 条数据提交" )
Tables("配载订单").save
Tables("配载订单").ClearCheckedRows