Systemready = False
Tables("库存管理界面_table29").AddNew()
Dim App As New MSExcel.Application
try
Dim tsxx As WinForm.Label = e.Form.Controls("Label73")
tsxx.text = "正在导入OEM IN 直销序列号请耐心等待!"
Dim Wb As MSExcel.Workbook = App.WorkBooks.Open("D:\直销序列号.xls")
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Tables("库存管理界面_table29").DataTable.StopRedraw()
'注意以下数组中列名称的顺序,必须和Excel表中的列顺序一致
msgbox(1)-----'正常弹出1
Dim ra = ws.Usenrange
msgbox(2)-----'奇怪的是2怎么不弹出呢?
Dim nms() As String = {"采购订单号","存货编码","存货名称","SN","MAC","物流信息"}
Dim wlxx As String = ws.cells(2,6).Value
'注意下面的循环变量从1开始,而不是从0开始,因为Excel表的第一行是标题
msgbox(wlxx)
For n As Integer = 2 To ra.Rows.Count -1
Dim xlh As String = ws.cells(n,4).Text '序列号----SN,xlh
If DataTables("库存明细表").SQLFind("SN = '" & xlh & "'") Is Nothing Then '如果不存在同编号的计划表
Dim r As Row = Tables("库存管理界面_table29").AddNew()
r("工单行号") = 0
r("订单行号") = "0"
r("库位类别") = "30"
r("数量") = 1
r("订单号") = ws.cells(n,1).Value
r("生产订单号码") = "ZX" & r("订单号")
r("物料编码") = ws.cells(n,2).Value
r("物料名称") = ws.cells(n,3).Value
r("SN") = ws.cells(n,4).Value
r("MAC") = ws.cells(n,5).Value
r("出库完成时间") = Date.Today
r("货运单号") = wlxx
r.Save
Dim dr As DataRow = DataTables("可用数量表").SQLFind("生产订单号码 = '" & r("生产订单号码") & "' and 工单行号 = '0' and 物料编码 = '" & r("物料编码") & "'")
If dr Is Nothing Then
Dim nr As DataRow = DataTables("可用数量表").AddNew()
nr("生产订单号码") = r("生产订单号码")
nr("工单行号") = "0"
nr("物料编码") = r("物料编码")
nr("物料名称") = r("物料名称")
nr("博达物料编码") = r("物料编码")
nr("博达物料名称") = r("物料名称")
nr("库位类别") = "30"
nr("订单号") = r("订单号")
nr("订单行号") = "0"
nr("在库数量") = 1
nr("数量") = 1
nr("入库时间") = Date.now
nr.save
Else
dr("在库数量") = dr("在库数量") + 1
dr("数量") = dr("在库数量")
dr.save
End If
End If
Next
Tables("库存管理界面_table29").DataTable.ResumeRedraw()
DataTables("库存明细表").SQLDeleteFor("SN is null")
DataTables("库存明细表").RemoveFor("SN is null")
tsxx.text = "请导入OEM IN 直销序列号!"
MessageBox.show("OEM IN直销序列号已导入完成","导入完成",MessageBoxButtons.OK,MessageBoxIcon.Information)
catch ex As exception
finally
app.quit
End try
Systemready = True