If Forms("产品编辑1").Opened() Then
For Each r1 As Row In Tables("工序库维护选择_Table1").GetCheckedRows
If r1("配色") < 2 Then
Dim r2 As Row = Tables("产品编辑1_Table4").AddNew
r2("组件名称") = r1("部件名称")
r2("产品工序规格") = r1("产品工序规格")
cmd2.commandText = "S elect * From {工序表} where 工序编号 = '" & r1("工序编码") & "'"
dt2 = cmd2.ExecuteReader(True)
Dim cmd1 As New SQLCommand
S elect * From {工序表新} where 工序编号 = '" & r1("工序编码") & "'"
dt1 = cmd1.ExecuteReader(True)
If dt1.DataRows.Count = 0 Then
Dim r As DataRow = dt1.addnew
r("工序编号") = dt2.DataRows(0) ("工序编号")
r("工序名称") = dt2.DataRows(0)("工序名称")
r("工序规格") = dt2.DataRows(0)("工序规格")
r("工序说明") = dt2.DataRows(0)("工序说明")
dt1.save
End If
cmd.commandText = "Se lect * From {工序价格} where 厂内单价 = '" & r1("厂内单价") & "' and 修改定额 = '" & r1("修改定额") & "' "
dt = cmd.ExecuteReader(True)
If dt.DataRows.Count = 0 Then
rr("修改定额") = dt2.DataRows(0)("修改定额")
rr("工段标准") = dt2.DataRows(0)("工段标准")
Dim cmd3 As New SQLCommand
Dim Key As Integer
cmd3.C
cmd3.commandText = "S elect [顺序号] From {编号} Where [前缀] = 'JG'"
Do
Key = cmd3.ExecuteScalar() '从后台获得顺序号
cmd3.commandText = "U pdate [编号] Set [顺序号] = " & (Key + 1) & " Where [顺序号] = " & Key & " And [前缀] = 'JG'"
If cmd3.ExecuteNonQuery() > 0 Then '更新顺序号
Exit Do '更新成功则退出循环
End If
Loop
rr("价格编号") = "JG" & Format(Key,"0000000000")
r2("价格编号") = "JG" & Format(Key,"0000000000")
dt.save
Else
r2("价格编号") = dt.DataRows(0)("价格编号")
End If
e.Form.Close()
Tables("产品编辑1_Table4").save()
End If