Dim dtp1 As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker1")
Dim dt1 As Date = dtp1.value
Dim dtp2 As WinForm.DateTimePicker = e.Form.Controls("DateTimePicker2")
Dim dt2 As Date = dtp2.value
Dim dtp3 As WinForm.combobox = e.Form.Controls("combobox1")
Dim name As String = dtp3.value
'加载数据表
DataTables("实时工序计算表").LoadFilter = ""
DataTables("实时工序计算表").Load
此主题相关图片如下:like.png
name = "'%" & name & "%'"
DataTables("实时工序计算表").LoadFilter = "发货日期 >= #" & dt1 & "# and 发货日期<=#" & dt2 & "# and 员工姓名 like " & name
DataTables("实时工序计算表").Load
Dim dtb As New DataTableBuilder("选员工实发工资计算表")
dtb.AddDef("客户", GetType(String), 16)
'dtb.AddDef("员工姓名", GetType(String), 12)
dtb.AddDef("产品类型", GetType(String), 26)
dtb.AddDef("工序名称", GetType(String), 26)
dtb.AddDef("合计金额", GetType(Double))
dtb.AddDef("重量kg_本期完成", GetType(Double))
dtb.AddDef("重量kg_本期耗时h", GetType(Double))
dtb.AddDef("重量kg_单价", GetType(Double))
dtb.AddDef("重量kg_金额", GetType(Double))
dtb.AddDef("数量件_本期完成", GetType(Double))
dtb.AddDef("数量件_单价", GetType(Double))
dtb.AddDef("数量件_本期耗时h", GetType(Double))
dtb.AddDef("数量件_金额", GetType(Double))
dtb.Build()
'以下是计算部分
Dim khs As New List(Of String)
Dim cps As New List(Of String)
Dim gxs As New List(Of String)
Dim khm, cplx, gxmc As String
For Each kkh As String In DataTables("实时工序计算表").GetValues("客户")
khs.Add(kkh)
Next
For Each cp As String In DataTables("实时工序计算表").GetValues("产品类型")
cps.Add(cp)
Next
For Each gx As String In DataTables("实时工序计算表").GetValues("工序名称")
gxs.Add(gx)
Next
Dim jsdj, jzdj As Double
For Each khm In khs
For Each cplx In cps
For Each gxmc In gxs
Dim dr As DataRow = DataTables("选员工实发工资计算表").AddNew()
Dim zzl As Double = DataTables("实时工序计算表").Compute("sum(重量)", " 客户='" & khm & "'and 产品类型='" & cplx & "' and 工序名称='" & gxmc & "'")
Dim zsl As Double = DataTables("实时工序计算表").Compute("sum(件数)", " 客户='" & khm & "'and 产品类型='" & cplx & "' and 工序名称='" & gxmc & "'")
Dim zlhs As Double = DataTables("实时工序计算表").Compute("sum(实际耗时)", "客户='" & khm & "'and 产品类型='" & cplx & "' and 工序名称='" & gxmc & "' and 结算单位='重量'")
Dim jshs As Double = DataTables("实时工序计算表").Compute("sum(实际耗时)", "客户='" & khm & "'and 产品类型='" & cplx & "' and 工序名称='" & gxmc & " 'and 结算单位='数量'")
dr("客户") = khm
dr("产品类型") = cplx
dr("工序名称") = gxmc
dr("数量件_本期完成") = zsl
dr("重量kg_本期完成") = zzl
dr("重量kg_本期耗时h") = zlhs / 60
dr("数量件_本期耗时h") = jshs / 60
Dim ur As DataRow = DataTables("计件定额表").find("客户='" & khm & "' and 产品类型='" & cplx & "' and 工序名称='" & gxmc & "'")
If ur IsNot Nothing Then
If ur("计价单位") = "kg" Then
jzdj = ur("定额单价")
dr("重量kg_单价") = jzdj
dr("重量kg_金额") = Round2(jzdj * zzl, 2)
Else If ur("计价单位") = "件" Then
jsdj = ur("定额单价")
dr("数量件_单价") = jsdj
dr("数量件_金额") = Round2(jsdj * zsl, 2)
End if
dr("合计金额") =Round2(jsdj * zsl + jzdj * zzl,2)
End If
Next
next
next
Tables("选员工实发工资计算表").Cols("数量件_本期完成").GrandTotal = True
Tables("选员工实发工资计算表").Cols("重量kg_本期完成").GrandTotal = True
Tables("选员工实发工资计算表").Cols("重量kg_本期耗时h").GrandTotal = True
Tables("选员工实发工资计算表").Cols("数量件_本期耗时h").GrandTotal = True
Tables("选员工实发工资计算表").Cols("重量kg_金额").GrandTotal = True
Tables("选员工实发工资计算表").Cols("数量件_金额").GrandTotal = True
Tables("选员工实发工资计算表").Cols("合计金额").GrandTotal = True
Tables("选员工实发工资计算表").GrandTotal = True '显示
MessageBox.Show("计算完毕!", "提示!")
Forms("员工实发计件工资计算").close
MainTable = Tables("选员工实发工资计算表")