把计算备注和表事件分开
DataColChanged事件
Select Case e.DataCol.name
Case "产品名称规格", "工序"
Dim fdr As DataRow = DataTables("价格表").find("产品名称 = '" & e.DataRow("产品名称规格").replace("'", "''") & "' and 工序 = '" & e.DataRow("工序") & "'")
If fdr IsNot Nothing
e.DataRow("单价") = fdr("单价")
End If
End Select
Select Case e.DataCol.name
Case "日期","姓名","职位","系数"
Dim d As Date = e.DataRow("日期")
d = new Date(d.year, d.month, 1)
Dim fdr As DataRow = DataTables("姓名").find("姓名 = '" & e.DataRow("姓名") & "' and 日期 >= #" & Format(d,"yyyy-MM-dd") & "# and 日期 < #" & Format(d.AddMonths(1),"yyyy -MM-dd") & "#", "日期 desc")
If fdr IsNot Nothing
e.DataRow("职位") = fdr("职位")
If e.DataTable.GetValues("日期|生产形式", "日期 is not null and 生产形式 <> '个人'").Count > 1 Then
If e.DataRow("职位") Like "*拉长*" Then
e.DataRow("系数") = 1 + (fdr("系数") - 1)/ 2
Else
e.DataRow("系数") = fdr("系数")
End If
Else
e.DataRow("职位") = Nothing
e.DataRow("系数") = Nothing
End If
End If
End Select
按钮事件
For Each ary() As String In DataTables("包装车间工资表").GetValues("日期|生产形式", "日期 is not null and 生产形式 <> '个人'")
Dim drs As List(Of DataRow) = DataTables("包装车间工资表").Select("日期=#" & ary(0) & "# And 生产形式='" & ary(1).Replace("'","''") & "'")
Dim count As Integer = 0
Dim ls As new List(Of String)
If DataTables("包装车间工资表").DataCols.Contains("备注1") = False Then
DataTables("包装车间工资表").DataCols.add("备注1", Gettype(String))
End If
For Each dr As DataRow In drs
Dim str As String = dr("生产形式")
If ls.Contains(str) = False Then
count + = 1
ls.add(str)
dr("备注1") = dr("备注1").replace("重复", Nothing)
Else
dr("备注1") = "重复" & dr("备注1").replace("重复", Nothing)
End If
Next
Next