'-----------------------------------------------------------------------------------------------------------------------
' 当输入入库存日期后, 自动获得相应的工时,成本汇总
If e.DataCol.Name = "入库日期" Then
'If e.DataRow.IsNull("入库日期") Then
' e.DataRow("总工时")= Nothing
' e.DataRow("生产成本")= Nothing
' e.DataRow("入库数量")= Nothing
Dim str = User.ExtendedValues("账套")
'msgbox(str)
Dim Total11 As Single
Dim Total12 As Single
Dim Total13 As Single
Dim Total14 As Single
Dim Total15 As Single
Dim Total16 As Single
Dim Total17 As Single
Dim Total18 As Single
Dim Total19 As Single
Dim Total110 As Single
Dim Total111 As Single
Dim Total112 As Single
Total11=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= '"& e.DataRow("零件ID") & "'and 年份=" & str & " and 月份=1")
e.DataRow("JAN")= Total11
Total12=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= '"& e.DataRow("零件ID") & "'and 年份=" & str & " and 月份=2")
e.DataRow("FEB")= Total12
Total13=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= '"& e.DataRow("零件ID") & "'and 年份=" & str & " and 月份=3")
e.DataRow("MAR")= Total13
Total14=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= '"& e.DataRow("零件ID") & "'and 年份=" & str & " and 月份=4")
e.DataRow("APR")= Total14
Total15=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= '"& e.DataRow("零件ID") & "'and 年份=" & str & " and 月份=5")
e.DataRow("MAY")= Total15
Total16=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= '"& e.DataRow("零件ID") & "'and 年份=" & str & " and 月份=6")
e.DataRow("JUN")= Total16
Total17=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= '"& e.DataRow("零件ID") & "'and 年份=" & str & " and 月份=7")
e.DataRow("JUL")= Total17
Total18=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= '"& e.DataRow("零件ID") & "'and 年份=" & str & " and 月份=8")
e.DataRow("AUG")= Total18
Total19=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= '"& e.DataRow("零件ID") & "'and 年份=" & str & " and 月份=9")
e.DataRow("SEP")= Total19
Total110=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= '"& e.DataRow("零件ID") & "'and 年份=" & str & " and 月份=10")
e.DataRow("OCT")= Total110
Total111=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= '"& e.DataRow("零件ID") & "'and 年份=" & str & " and 月份=11")
e.DataRow("NOV")= Total111
Total112=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= '"& e.DataRow("零件ID") & "'and 年份=" & str & " and 月份=12")
e.DataRow("DEC")= Total112
' Else
Dim Total1 As Single
Dim Total2 As Single
Total1=DataTables("生产记录").Compute("Sum(工时小计)","零件ID= '"& e.DataRow("零件ID") & "'")
Total2=DataTables("生产记录").Compute("Sum(成本小计)","零件ID= '"& e.DataRow("零件ID") & "'")
e.DataRow("总工时")= Total1
e.DataRow("生产成本")= Total2
e.DataRow("单位成本")= Total2 / e.DataRow("入库数量")
' End If
End If
'-------------------------------------------------------------------------------------------------------------------------
' 自动根据入库日期获得入库月及锁行
If e.DataCol.Name = "入库日期" Then
If e.DataRow.IsNull("入库日期") Then
e.DataRow("入库月份")= ""
e.DataRow.Locked = False
Else
e.DataRow.Locked = True
e.DataRow("入库月份")= e.DataRow("入库日期").year & "-" & e.DataRow("入库日期").month
End If
End If
'-----------------------------------------------------------------------------------------------------------------------
'材料自动分类
If e.DataCol.Name = "材料名称" Then '当输入材料名称时
Dim dr As DataRow
dr = DataTables("材料细目").Find("材料名称 = '" & e.DataRow("材料名称") & "'" ) '找到对应材料.
If dr IsNot Nothing '如果找到, 则设置各列内容
e.DataRow("材料类别")= dr("材料类别")
End If
End If