Dim filter As String
Dim sts() As String = {"合同号", "客户名称", "业务员", "长度", "宽度", "厚度", "原料产地", "事业部"}
For Each st As String In sts
Dim val As String = e.Form.Controls(st).value
If val > "" Then
val = val.Replace("*", "[*]")
If filter = "" Then
filter = st & " like '%" & val & "%'"
Else
filter = filter & " and " & st & " like '%" & val & "%'"
End If
End If
Next
If e.Form.Controls("已完结").Checked = True Then' 如果付款状态选择了"已付"
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "合同完结 = 1"
End If
If e.Form.Controls("未完结").Checked = True Then' 如果付款状态选择了"未付"
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "(合同完结 = 0 Or 合同完结 Is Null)"
End If
With e.Form.Controls("实际交货期起始日")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 >= '" & .Value & "'"
End If
End With
With e.Form.Controls("实际交货期结束日")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "日期 <= '" & .Value & "'"
End If
End With
DataTables("销售合同基础表").LoadFilter = Filter
DataTables("销售合同基础表").load()