e.Form.Controls("Label6").Text = "正在进行专业筛选,请稍后..."
Application.DoEvents()
Dim timestart, timeend As Date
timestart = Date.now
Dim Filter As String
If e.Form.Controls("选择历史").Checked = True Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "首选科目 = '历史'"
End If
If e.Form.Controls("选择物理").Checked = True Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "首选科目 = '物理'"
End If
Dim s As String = e.Form.Controls("CheckedComboBox1").Text
Dim Xks() As String '考生选科集合
Xks = s.split(",")
Dim Jhxks As List(Of String) '招生计划中的选科
Jhxks = DataTables("基础数据").GetValues("次选科目")
Dim Xkmys As New List(Of String) '与我的选科匹配的选科集合
Xkmys.Add("不限")
Xkmys.Add(Xks(0) & "和" & Xks(1))
Xkmys.Add(Xks(1) & "和" & Xks(0))
''单科加"或"
For Index As Integer = 0 To Xks.Length - 1 '提示错误的位置在这里!
For Each Product As String In Jhxks
If (Product.contains(Xks(Index) & "或") Or Product.contains("或" & Xks(Index)) Or Product = Xks(Index)) And Xkmys.Contains(Product) = False Then
'filter=filter & "'" & Product & "'"
'Jhxks.Remove(Product)
Xkmys.Add(Product)
End If
Next
Next
'加组合,手动填加,
'开始生成筛选条件
Dim tj As String
For Each filter2 As String In Xkmys
tj = tj & "'" & filter2 & "',"
Next
tj = "[次选科目] In (" & tj.trim(",") & ")"
DataTables("基础数据").ReplaceFor("确定导入", False)
'添加分数区间条件
If Filter > "" Then
Filter = Filter & " and 确定导入=false"
End If
If tj > "" Then
Filter = Filter & " and " & tj
End If
If e.Form.Controls("CGF").text > "" Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "预估分 <= " & e.Form.Controls("CGF").text
End If
If e.Form.Controls("FS").text > "" Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "预估分 > " & e.Form.Controls("FS").text
End If
Tables("基础数据").Filter = Filter
Dim cnt As Integer = Tables("基础数据").Rows.Count
Dim nds As Integer = e.Form.Controls("CSL").text '要抽取的记录数
Tables("基础数据").StopRedraw()
Do
Dim idx As Integer = rand.Next(0, cnt)
Dim dr As Row = Tables("基础数据").Rows(idx)
dr("确定导入") = True
nds = nds - 1
Loop While nds > 0
Tables("基础数据").Filter = "[确定导入] = True"
Tables("基础数据").ResumeRedraw()
If e.Form.Controls("FS").text > "" Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "预估分 <= " & e.Form.Controls("FS").text
End If
If e.Form.Controls("WFS").text > "" Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "预估分 > " & e.Form.Controls("WFS").text
End If
Tables("基础数据").Filter = Filter
Dim wnt As Integer = Tables("基础数据").Rows.Count
Dim wds As Integer = e.Form.Controls("WSL").text '要抽取的记录数
Tables("基础数据").StopRedraw()
Do
Dim idx As Integer = rand.Next(0, wnt)
Dim dr As Row = Tables("基础数据").Rows(idx)
dr("确定导入") = True
wds = wds - 1
Loop While wds > 0
Tables("基础数据").Filter = "[确定导入] = True"
Tables("基础数据").ResumeRedraw()
If e.Form.Controls("WFS").text > "" Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "预估分 <= " & e.Form.Controls("WFS").text
End If
If e.Form.Controls("BDF").text > "" Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "预估分 >= " & e.Form.Controls("BDF").text
End If
Tables("基础数据").Filter = Filter
Dim bnt As Integer = Tables("基础数据").Rows.Count
Dim bds As Integer = e.Form.Controls("BSL").text '要抽取的记录数
Tables("基础数据").StopRedraw()
Do
Dim idx As Integer = rand.Next(0, bnt)
Dim dr As Row = Tables("基础数据").Rows(idx)
dr("确定导入") = True
bds = bds - 1
Loop While bds > 0
Tables("基础数据").Filter = "[确定导入] = True"
Tables("基础数据").ResumeRedraw()
Tables("基础数据").Sort = "预估分 DESC" '按"低分等效"列降序排列
e.Form.Controls("Label6").Text = "专业筛选完毕!."
timeend = Date.now
e.Form.Controls("Label6").text = "耗时" & (timeend - timestart).TotalSeconds & "秒"
Messagebox.show("按专业【预估分】分,筛选出符合条件的行,共" & (Tables("基础数据").rows.count) & "行", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
MainTable = Tables("基础数据")