1、代码改成这样,你按照需要删减你afterload事件的代码
If e.Form.Width> 0 AndAlso e.Form.height > 0 Then
vars("width") = e.Form.width
vars("height") = e.Form.height
End If
msgbox(1)
Dim cmd As new SQLCommand
cmd.ConnectionName = "条码扫描系统数据库"
cmd.CommandText = " Select year(开始日期) as 年, month(开始日期) as 月,成品描述,count(*) as 毛坯编码 from {工序跟踪表} group by year(开始日期), month(开始日期),成品描述"
Dim dt As DataTable = cmd.ExecuteReader
msgbox(2)
Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1")
trv.BuildTree(dt, "年|月|成品描述")
trv.StopRedraw
For Each nd As WinForm.TreeNode In trv.AllNodes
Dim Year As Integer = nd.DataRow("年")
Dim Month As Integer = nd.DataRow("月")
Dim Product As String = nd.DataRow("成品描述")
Select Case nd.Level
Case 0
nd.Text = nd.text & "年("& dt.Compute("Sum(毛坯编码)","年 = " & Year) & "条)"
Case 1
nd.Text = nd.text & "月("& dt.Compute("Sum(毛坯编码)","年 = " & Year & " And 月 = " & Month) & "条)"
Case 2
nd.Text = nd.text & "("& nd.DataRow("毛坯编码") & ")"
End Select
Next
trv.Nodes.Insert("加载所有行","加载所有行("& dt.Compute("Sum(毛坯编码)") & "条)", 0)
trv.ResumeRedraw
msgbox(3)
For Each dr As DataRow In DataTables("权限设置").Select("用户名 = '" & _username & "' And 窗口名 = '" & e.form.Name & "'")
Dim c = e.form.Controls(dr("按钮权限"))
If typeof c Is winform.Table Then
c.visible = Not dr("不可见")
c.Table.allowEdit = Not dr("不可编辑")
Else
c.Visible = Not dr("不可见")
c.Enabled = Not dr("不可编辑")
End If
Next
msgbox(4)
With DataTables("生产报工查询_生产报工查询表")
.LoadFilter = "" '一定要清除加载条件
.LoadTop = 50
.LoadPage = 0
.Load()
e.Form.Controls("TextBox1").Value = 1 &"/" & .TotalPages
End With
msgbox(5)
2、这段代码比较耗时,建议你分别写到各个控件的enter事件。或者是做个按钮获取
Dim cmf As WinForm.ComboBox = e.form.Controls("加工工序1")
cmf.ComboList = DataTables("工序跟踪表").SQLGetComboListString("加工工序")
Dim cfm As WinForm.ComboBox = e.form.Controls("使用设备1")
cfm.ComboList = DataTables("工序跟踪表").SQLGetComboListString("使用设备")
Dim cma As WinForm.ComboBox = e.form.Controls("生产批次1")
cma.ComboList = DataTables("工序跟踪表").SQLGetComboListString("生产批次")
Dim cms As WinForm.ComboBox = e.form.Controls("姓名1")
cms.ComboList = DataTables("工序跟踪表").SQLGetComboListString("姓名")
Dim cmd As WinForm.ComboBox = e.form.Controls("班次1")
cmd.ComboList = DataTables("工序跟踪表").SQLGetComboListString("班次")
Dim cmv As WinForm.ComboBox = e.form.Controls("成品编码1")
cmv.ComboList = DataTables("工序跟踪表").SQLGetComboListString("成品编码")
Dim cmw As WinForm.ComboBox = e.form.Controls("毛坯编码1")
cmw.ComboList = DataTables("工序跟踪表").SQLGetComboListString("毛坯编码")
Dim cmg As WinForm.ComboBox = e.form.Controls("批次序号1")
cmg.ComboList = DataTables("工序跟踪表").SQLGetComboListString("批次序号")