Dim TotParts As Integer = 3
Dim SalesONX As String = "SO-009622"
If TotParts < 1 Then
messagebox.show("Can not proceed. Total parts must >= 1" , "Error", Messageboxbuttons.ok, MessageBoxIcon.warning)
Return 0
End If
Dim cmd As New SQLCo mmand
cmd.connectionname = _ConnectionName
cmd.Comma ndText = "SEL ECT * from {SalesOrdsForDispatch} where SalesON='" & SalesONX & "'"
Dim DTB As DataTable = cmd.Execu teReader(True)
Dim ExistTotParts As Integer = DTB.DataRows.count
If TotParts = ExistTotParts Then
messagebox.show("Can not proceed. Total parts = existing no. of parts" , "Error", Messageboxbuttons.ok, MessageBoxIcon.warning)
Return 0
End If
' ******************************************************************
If TotParts > ExistTotParts Then
'如果全部发货了,则不允许再次拆分
Dim tr As DataRow = dtb.find("DateDelivered is null")
If tr Is Nothing Then
messagebox.show("Can not proceed. All the parts have been delivered." , "Error", Messageboxbuttons.ok, MessageBoxIcon.warning)
Return 0
End If
'增加新的parts
Dim kr As DataRow = DTB.DataRows(0)
For i As Integer = ExistTotParts + 1 To TotParts
Dim nr As DataRow = DTB.addnew
For Each cl As DataCol In DTB.DataCols
Dim cname As String = cl.name
If Cname Like "SiteFeed*" = False Then
Select Case Cname
Case "Weight", "Status", "PartNo", "DateDelivered", "DispatchNo", "MaxLth", "Progress_Stock", "Printed"
Case Else
nr(Cname) = kr(Cname)
End Select
End If
Next
nr("PartNo") = i & "/" & TotParts
Next
Output.Show(dtb.DataRows.count)
DTB.save '(这句代码会报错) 新增行无法保存
messagebox.show("Successful. Order has been split into " & Totparts & " parts." , "Note", Messageboxbuttons.ok, MessageBoxIcon.Information)
Return 0
End If