S e l e c t Case e.DataCol.Name
Case "油费", "通行费", "罚款", "交车费", "停车费", "其他费用"
e.DataRow("费用合计") = e.DataRow("油费") + e.DataRow("通行费") + e.DataRow("罚款") + e.DataRow("交车费") + e.DataRow("停车费") + e.DataRow("其他费用")
Dim val As Double = Tables("自营车辆结算管理_Table1").Compute("Sum(费用合计)", "调度单号 = '" & e.DataRow("调度单号") & "'")
Dim val1 As Double = Tables("自营车辆结算管理_Table1").Compute("Sum(台数)", "调度单号 = '" & e.DataRow("调度单号") & "'")
Dim cmd As New SQLCommand
cmd.C
cmd.CommandText = "UP DATE {调度管理} SET [下游金额] =" & val & " WH ERE [调度单号] = '" & e.DataRow("调度单号") & "'"
cmd.ExecuteNonQuery()
Dim cmd6 As New SQLCommand
cmd6.C
cmd6.CommandText = "UP DATE {调度管理} SET [下游余额] = iif([下游金额] is null,0,[下游金额]) + iif([下游调整] is null,0,[下游调整]) - iif([下游考核] is null,0,[下游考核]) + iif([预借合计] is null,0,[预借合计]) W H E R E [调度单号] = '" & e.DataRow("调度单号") & "'"
cmd6.ExecuteNonQuery()
If val1 > 0 Then
Dim cmd2 As New SQLCommand
cmd2.C
cmd2.CommandText = "UP DATE {运单管理} SET 下游单价 = " & val / val1 & " WH ERE [调度单号] = '" & e.DataRow("调度单号") & "'"
cmd2.ExecuteNonQuery()
Dim cmd3 As New SQLCommand
cmd3.C
cmd3.CommandText = "UP DATE {运单管理} SET 下游运费金额 = 下游台数*下游单价 WH ERE [调度单号] = '" & e.DataRow("调度单号") & "'"
cmd3.ExecuteNonQuery()
Dim cmd4 As New SQLCommand
cmd4.C
cmd4.CommandText = "UP DATE {运单管理} SET 下游运费余额 = iif([下游运费金额] is null,0,[下游运费金额]) + iif([下游调整金额] is null,0,[下游调整金额]) - iif([下游考核金额] is null,0,[下游考核金额]) - iif([下游借款金额] is null,0,[下游借款金额]) WH ERE [调度单号] = '" & e.DataRow("调度单号") & "'"
cmd4.ExecuteNonQuery()
End If
Dim cmd5 As New SQLCommand
cmd5.C
cmd5.CommandText = "UP DATE {运单管理} SET 下游结算 = true, 结算单号 = '" & e.DataRow("结算单号") & "', 下游结算日期 = '" & Tables("自营车辆结算").Current ("结算日期") & "', 下游结算员= '" & Tables("自营车辆结算").Current ("结算员") & "' WH ERE [调度单号] = '" & e.DataRow("调度单号") & "'"
cmd5.ExecuteNonQuery()
End Select
If e.Col.name = "删除" Then
e.StartDraw
If e.MouseHover = False Then'如果鼠标不在此单元格
e.Graphics.DrawImage(D2, e.x + 10, e.y + 3) '绘制第一个图标
Else '如果鼠标在此单元格
e.Graphics.DrawImage(D1, e.x + 11, e.y + 2) '绘制第二个图标
End If
e.EndDraw
End If