-- 作者:liuxianjie1980
-- 发布时间:2015/11/18 15:26:00
--
另外有一段代码现在让我感到很难受啊!!
写在采购合同表的currentchanged事件
If Forms("采购窗口").Opened Then If e.Table.current IsNot Nothing Then Forms("采购窗口").Controls("Table2").Table.Filter = "合同编号 = \'" & e.Table.current("合同编号") & "\'" Forms("采购窗口").Controls("Table3").Table.Filter = "对应合同编号 = \'" & e.Table.current("合同编号") & "\'" Else Forms("采购窗口").Controls("Table2").Table.Filter = "1=2" Forms("采购窗口").Controls("Table3").Table.Filter = "1=2" End If End If
本意是:在有采购合同 表的窗口中选择不同的行,另外两个表也跟着变动,显示跟该条记录有关的信息。table2和table3分别在一个页面集合中得不同页面
窗口打开时,默认的是table2(页面集合的第一页)
当从其他表格返回采购合同表的这个窗口时,老是提示:找不到控件table3!!
|
-- 作者:liuxianjie1980
-- 发布时间:2015/11/18 16:15:00
--
这个采购单元,还有一个问题,保存按钮里的代码执行错误。
本意是:保存时,再执行一次treeview
代码如下:
DataTables("采购合同表").save() DataTables("采购明细表").save() Dim cmd As New SQLCommand Dim dt As DataTable cmd.Connectionname=“contract” Dim b As New GroupTableBuilder("统计表2",DataTables("采购明细表")) b.Groups.AddDef("产品名称") b.Groups.AddDef("产品规格") dt = b.Build(False) \'参数设置为False,生成一个临时表,不在主界面显示 \'然后根据统计表生成目录树 Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") Dim v As String = "产品名称" Dim h As String = "产品规格" Dim md As WinForm.TreeNode For Each f As String In dt.GetValues(v, v & " Is not null") Dim gd As WinForm.TreeNode =md.Nodes.Add(f) For Each g As String In dt.GetValues(h, "[产品名称]= \'" & f & "\'And [产品规格] Is not null ") Dim kd As WinForm.TreeNode =gd.Nodes.Add(g) Next Next Dim c As String = "到货完结" Dim nd As WinForm.TreeNode For Each s As String In DataTables("采购明细表").GetValues(c, c & " is not null") nd.Nodes.Add(s) Next trv.ResumeRedraw Audio.play(ProjectPath & "Windows Exclamation.wav", AudioPlayMode.Background) MessageBox.show("数据已保存完毕!","提示")
执行时出现的问题提示为:
.NET Framework 版本:2.0.50727.4984 Foxtable 版本:2015.11.2.1 错误所在事件:窗口,采购窗口,Button4,Click 详细错误信息: System.NullReferenceException: 未将对象引用设置到对象的实例。 在 UserCode.ADwHxplO1Z2WXi3T5(ControlEventArgs e)
采购主页面的afterload的代码如下:
Tables("采购合同表.采购明细表").Visible = False Tables("采购合同表.原材料到货表").Visible = False DataTables("采购合同表").SysStyles("EmptyArea").BackColor = Color.White Dim cmd As New SQLCommand Dim dt As DataTable cmd.Connectionname=“contract” Dim b As New GroupTableBuilder("统计表1",DataTables("采购明细表")) b.Groups.AddDef("产品名称") b.Groups.AddDef("产品规格") dt = b.Build(False) \'参数设置为False,生成一个临时表,不在主界面显示 \'然后根据统计表生成目录树 Dim trv As WinForm.TreeView = e.Form.Controls("TreeView1") Dim v As String = "产品名称" Dim h As String = "产品规格" Dim md As WinForm.TreeNode = trv.nodes.Add("按"&v) For Each f As String In dt.GetValues(v, v & " Is not null") Dim gd As WinForm.TreeNode =md.Nodes.Add(f) For Each g As String In dt.GetValues(h, "[产品名称]= \'" & f & "\'And [产品规格] Is not null ") Dim kd As WinForm.TreeNode =gd.Nodes.Add(g) Next Next Dim c As String = "到货完结" Dim nd As WinForm.TreeNode = trv.nodes.Add("按"&c) For Each s As String In DataTables("采购明细表").GetValues(c, c & " is not null") nd.Nodes.Add(s) Next trv.Nodes.Insert("显示全部",0) trv.ResumeRedraw
[此贴子已经被作者于2015/11/18 16:19:26编辑过]
|