老师,以下是我整个完整的代码
Select Case e.DataCol.Name
Case "毛坯编码"
Dim dr As DataRow = e.DataRow
Dim pr As DataRow
If dr.IsNull("毛坯编码") Then
dr("生产批次") = Nothing
dr("批次序号") = Nothing
dr("成品编码") = Nothing
Else
Dim filter As String
filter = "毛坯编码= '" & dr("毛坯编码") & "' and 加工内容='喷油入库'"
pr = DataTables("工序跟踪表").SQLFind(filter)
If pr IsNot Nothing Then
dr("生产批次") = pr("生产批次")
dr("批次序号") = pr("批次序号")
dr("成品编码") = pr("成品编码")
End If
End If
End Select
If e.DataRow("成品编码") = "0103001" OrElse e.DataRow("成品编码") = "0103020" Then
e.DataRow("成品流水号") = e.DataRow("毛坯编码")
Else
Select Case e.DataCol.Name
Case "成品流水号"
Dim dr As DataRow = e.DataRow
Dim pr As DataRow
If dr.IsNull("毛坯编码") Then
dr("成品流水号") = Nothing
Else
Dim filter As String
filter = "Barcode= '" & dr("毛坯编码") & "'"
pr = DataTables("T_Produce_No").SQLFind(filter)
If pr IsNot Nothing Then
dr("成品流水号") = pr("Produce_No")
End If
End If
End Select
End If
If e.DataCol.Name = "毛坯编码" Then
Dim nms() As String = {"产地编码","规格型号"}
If e.NewValue = Nothing Then
For Each nm As String In nms
e.DataRow(nm) = Nothing
Next
Else
Dim dr As DataRow
dr = DataTables("条码基础数据").sqlFind("[毛坯编码] = '" & e.NewValue & "'")
If dr IsNot Nothing
For Each nm As String In nms
e.DataRow(nm) = dr(nm)
Next
End If
End If
End If
Select Case e.DataCol.Name
Case "成品编码"
Dim dr As DataRow = e.DataRow
Dim pr As DataRow
If dr.IsNull("成品编码") Then
dr("成品描述") = Nothing
dr("毛坯产地") = Nothing
dr("规格型号") = Nothing
Else
Dim filter As String
filter = "成品编码= '" & dr("成品编码") & "'"
pr = DataTables("产品基础数据").SQLFind(filter)
If pr IsNot Nothing Then
dr("成品描述") = pr("成品描述")
dr("毛坯产地") = pr("毛坯产地")
dr("规格型号") = pr("规格型号")
End If
End If
End Select
If e.DataCol.Name = "单据日期" Then
If e.DataRow.IsNull("单据日期") Then
e.DataRow("年") = Nothing
Else
e.DataRow("年") = Format(e.DataRow("单据日期"),"yyyy")
End If
End If
If e.DataCol.Name = "单据日期" Then
If e.DataRow.IsNull("单据日期") Then
e.DataRow("月") = Nothing
Else
e.DataRow("月") = Format(e.DataRow("单据日期"),"yyyyMM")
End If
End If
If e.DataCol.Name = "单据日期" Then
If e.DataRow.IsNull("单据日期") Then
e.DataRow("日") = Nothing
Else
e.DataRow("日") = Format(e.DataRow("单据日期"),"yyyyMMdd")
End If
End If
Select Case e.DataCol.name
Case "毛坯编码","成品流水号","成品编码"
Dim dr As DataRow = e.DataRow
If dr.IsNull("毛坯编码") = False AndAlso dr.IsNull("成品流水号") = False AndAlso dr.IsNull("成品编码") = False Then
If DataTables("产成品入库_录入").Compute("Count([_Identify])","毛坯编码 = '" & dr("毛坯编码") & "' And 成品流水号 = '" & dr("成品流水号") & "' And 成品编码 = '" & dr("成品编码") & "'") > 1 Then
MessageBox.Show("成品流水号重复,重新输入!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.DataRow(e.DataCol.Name) = e.OldValue '取消输入
ElseIf DataTables("出入库明细").sqlCompute("Count([_Identify])","毛坯编码 = '" & dr("毛坯编码") & "' And 成品流水号 = '" & dr("成品流水号") & "' And 成品编码 = '" & dr("成品编码") & "'") > 0 Then
MessageBox.Show("成品流水号重复,重新输入!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.DataRow(e.DataCol.Name) = e.OldValue '取消输入
End If
End If
End Select