If e.DataCol.Name = "日期" Then
If e.DataRow.IsNull("日期") Then
e.DataRow("序号") = Nothing
Else
Dim bh As String = Format(e.DataRow("日期"),"yyyyMMdd") '取得编号的8位前缀
If e.DataRow("序号").StartsWith(bh) = False '如果编号的前8位不符
Dim max As String
Dim idx As Integer
max = e.DataTable.Compute("Max(序号)","日期 = #" & e.DataRow("日期") & "# And [_Identify] <> " & e.DataRow("_Identify")) '取得该天的最大编号
If max > "" Then '如果存在最大编号
idx = CInt(max.Substring(9,4)) + 1 '获得最大编号的后四位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("序号") = bh & "-" & Format(idx,"0000")
End If
End If
End If
Select Case e.DataCol.name
Case "日期" '
Dim dr As DataRow = DataTables("查询").Find("日期 = '" & e.OldValue & "'")
If dr Is Nothing Then
dr = DataTables("查询").AddNew()
dr("日期") = e.DataRow("日期")
dr("序号") = e.DataRow("序号")
dr("材料名称") = e.DataRow("材料名称")
dr("规格型号") = e.DataRow("规格型号")
dr("工序") = e.DataRow("工序")
dr("数量") = e.DataRow("数量")
dr("员工") = e.DataRow("员工")
dr("备注") = e.DataRow("备注")
Else
dr("日期") = e.DataRow("日期")
End If
Case "日期","序号","材料名称","规格型号","工序","数量","员工","备注"
Dim dr As DataRow = DataTables("查询").Find("日期 = '" & e.DataRow("日期") & "'")
If dr IsNot Nothing Then
dr(e.DataCol.Name) = e.DataRow(e.DataCol.Name)
End If
End Select