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("出行行程")
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
Dim drr As DataRow = DataTables("计调操作表").Find("订单编号 = '" & e.DataRow("订单编号") & "'")
If drr IsNot Nothing Then
drr.Delete()
End If
'根据订单表客人信息,自动计算出订单总人数
If e.DataCol.name = "客人姓名" Then
If e.NewValue = Nothing Then
e.DataRow("订单人数") = 0
Else
e.DataRow("订单人数") = e.newvalue.split(",").length
End If
End If
'根据出团时间自动生成订单编号(以后看下中间的-能不能去掉)
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,3)) + 1 '获得最大编号的后三位顺序号,并加1
Else
idx = 1 '否则顺序号等于1
End If
e.DataRow("订单编号") = bh & "-" & Format(idx,"000")
End If
End If
End If