'ImportShippingList'INI Shipping List.xlsx,需要注意的是每月末将下月数据写入(手工更改到Query文件中)
Dim s1
As Date = Date.Now
Dim s2
As Date
Dim s3
As TimeSpan
Dim cg
As Boolean = True
Dim Yn
As Boolean = False
Dim
TableN As String = "INIShippingList"
If Not
DataTables.Contains("INIShippingList") Then
Yn = True
DataTables.Load("INIShippingList")
End If
DataTables(TableN).LoadFilter
= ""
DataTables(TableN).Load
'DataTables(TableN).StopRedraw '停止屏幕刷新
Dim fp
As String = "P:\General documents\Worktime Data\Fox Data\Query\"
Dim ff =
"INI Shipping List.xlsx" 'P:\General documents\Worktime Data\Fox
Data\Query\
Dim fpf
As String = fp & ff
Dim d As New Dictionary(Of String, DataRow) '当前ShippingList表中已经存在WO的行
If
filesys.FileExists(fpf) Then
Dim cn As String '列名称
Dim i As Integer
Dim App As New
MSExcel.Application
App.DisplayAlerts
= False
App.visible = True
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fpf)
Wb.RefreshAll
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Dim Rg As MSExcel.Range = Ws.UsedRange
Dim ary = Rg.value
Dim cs As Integer = Rg.Columns.Count
Dim c As Integer
Dim Dic_Ex As New Dictionary(Of String, DataRow)
'cs =5
Dim bh As Integer
Dim i1 As Integer = 0
Dim Filter As String
Dim d1s As New Dictionary(Of String, DataRow)
For Each dr As DataRow In DataTables(TableN).DataRows
Dim sowo As String = dr("ISOLineNo") &
dr("WO")
If Not Dic_Ex.ContainsKey(SOWO) Then
Dic_Ex.Add(sowo, dr)
Else
'Output.Show("重复行:"
& sowo)
dr("Repeatd") = 1
End If
'记录存在工单号的Iso行信息
If dr("WO") > "" Then
If Not
d.ContainsKey(dr("ISOLineNo")) Then
d.Add(dr("ISOLineNo"), dr)
End If
Else
If Not
d1s.ContainsKey(dr("ISOLineNo")) Then
d1s.Add(dr("ISOLineNo"), dr) '不存在工单的ISO 行
End If
End If
Next
If d1s.Keys.Count > 0 Then '不存在WO
的ISO行, 如果也同时存在ISO和WO的行,则不带WO的需要删除,同时定义为Dic_Ex存在该行
For Each ISO As String In d1s.Keys
Dim dr1s As DataRow = d1s(ISO)
If d.ContainsKey(ISO) Then
If Not Dic_Ex.ContainsKey(ISO)
Then
Dic_Ex.Add(ISO,
dr1s)
End If
'd1rs.Delete
dr1s("Repeatd") = 1
End If
Next
End If
'MessageBox.Show(1111)
Dim Lst_C As New List(Of String)
For Each dc As DataCol In DataTables(TableN).DataCols
If Not Lst_C.Contains(dc.Name) Then
Lst_C.Add(dc.Name) '字段名集合
End If
Next