If e.DataCol.Name = "编号" Then
Dim nms() As String = {"客户id","户名","详细地址","电话号码","面积","到期日期","部门","预约","注意事项"}
If e.NewValue Is Nothing Then
For Each nm As String In nms
e.DataRow(nm) = Nothing
Next
Else
Dim dr As DataRow
dr = DataTables("成华客户资料").Find("[编号] = '" & 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
If e.DataCol.Name = "截止日期" AndAlso e.DataRow.IsNull(e.DataCol) = False Then
e.DataRow("日") = Right(Format(e.DataRow(e.DataCol),"yyyy-MM-dd"),2)
End If
If e.DataCol.Name = "截止日期" Then
If e.DataRow.IsNull("截止日期") Then
e.DataRow("日期") = Nothing
Else
e.DataRow("日期") = Format(e.DataRow("截止日期"),"yyyy-MM")
End If
End If
If e.DataCol.Name = "时间" Then
If e.DataRow.IsNull("时间") Then
e.DataRow("时段") = Nothing
Else
Dim d As Date
If Date.TryParse(e.NewValue, d) Then
Select Case d.Hour
Case 16
e.DataRow("时段") = "3三"
Case 18
e.DataRow("时段") = "3三"
Case 22
e.DataRow("时段") = "5取消"
Case Else
e.DataRow("时段") = iif(d.Hour>11, "2下午", "1上午")
End Select
Else
e.DataRow("时段") = Nothing
End If
End If
End If
Select Case e.DataCol.name
Case "截止日期","时段"
If e.DataRow.IsNull("工号") = False AndAlso e.DataRow.IsNull("截止日期") = False Then
Dim nstr As String = ""
Dim ls As List(Of String) = DataTables("列表数据").GetValues("请假人", "请假日期 = '" & e.DataRow("截止日期") & "'")
For Each yg As String In e.DataRow("工号").split(",")
If ls.Contains(yg) = False Then
nstr &= yg & ","
End If
Next
e.DataRow("工号") = nstr.trim(",")
End If
End Select
If e.DataCol.Name = "类型" OrElse e.DataCol.Name = "业务途径" Then
Dim dr As DataRow
dr = DataTables("列表数据").Find("[类型] = '" & e.DataRow("类型") & "' And [业务途径] = '" & e.DataRow("业务途径") & "'")
If dr IsNot Nothing Then
e.DataRow("付款方式") = dr("付款方式")
e.DataRow("转账银行") = dr("转账银行")
e.DataRow("业务人员") = dr("业务人员")
Else
e.DataRow("转账银行") = Nothing
e.DataRow("业务人员") = Nothing
End If
End If
If e.DataCol.Name = "是否" AndAlso e.DataRow("是否") = True Then
Dim count As Integer = DataTables("财务").compute("count(_Identify)", "[编号] = '" & e.DataRow("_Identify") & "' and 日期 = #" & e.DataRow("截止日期") & "# and 付款方式 = '" & e.DataRow("付款方式") & "'")
If count > 0 Then
msgbox("财务收款添加,不能新增!请核对!")
Return
End If
Dim nma() As String = {"派工id"} 'A表数据来源列
Dim nmb() As String = {"编号"} 'B表数据接收列
Dim dr As DataRow = DataTables("财务").AddNew
For i As Integer = 0 To nma.Length - 1
dr(nmb(i)) = e.DataRow(nma(i))
Next
End If
Select Case e.DataCol.name
Case "截止日期","付款方式","业务途径","时段"
Dim drs As List(Of DataRow) = DataTables("财务").Select("[编号] = '" & e.DataRow("_Identify") & "'")
If drs.count = 0 Then
Dim dr = DataTables("财务").addnew
dr("日期") = e.DataRow("截止日期")
dr("付款方式") = e.DataRow("付款方式")
dr("业务途径") = e.DataRow("业务途径")
dr("时段") = e.DataRow("时段")
Else
For Each dr As DataRow In drs
dr("日期") = e.DataRow("截止日期")
dr("业务途径") = e.DataRow("业务途径")
dr("时段") = e.DataRow("时段")
Next
End If
End Select
Dim dr As DataRow = e.DataRow
Select Case e.DataCol.Name
Case "计分金额","人数"
dr("人均值") = dr("计分金额")/dr("人数")
End Select