我的datagridview中有一个名为“Total”的列,此列需要执行计算。
我在datagridview中有这些列:
“...”中的名称是列的数据属性名称中的名称。
问题是我需要'total'来计算(hoursSpent * normalTimeRate或OverTimeRate)(因此,如果'working'列的值为'1',它将计算(hoursSpent * normalTimeRate))。
答案 0 :(得分:1)
您可以在SELECT语句中执行“Total”计算,如下所示:
sSQL = "SELECT B.laborHours_id, " & _
"A.labor_id, " & _
"A.first_name + ' ' + A.last_name as name, " & _
"B.project_id, " & _
"B.location_id, " & _
"B.dates, " & _
"B.worked, " & _
"B.hoursSpentOnDay, " & _
"B.normalTimeRate, " & _
"B.overTimeRate, " & _
"B.hoursSpentOnDay * IIf(B.worked = 1, B.normalTimeRate, B.overTimeRate) As Total" & _
"FROM tblLabor A, tblLaborHours B " & _
"WHERE A.labor_id = B.labor_id "