以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]表事件DataColChanged请教 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=140036) |
||||
-- 作者:lhfu -- 发布时间:2019/8/28 11:16:00 -- [求助]表事件DataColChanged请教 各位老师,我在表A里用表事件DataColChanged进行了自动编号及同步表的代码写入,前三行的时候,自动编号和同步信息都正常,但新增到第四行的时候,它会出现这样的提示 然后表A的数据就不能同步表B的了,请各位老师帮我查看一下代码没有输错,谢谢! If e.DataCol.Name = "日期" Then If e.DataRow.IsNull("日期") Then e.DataRow("序号") = Nothing Else Dim bh As String = Format(e.DataRow("日期"),"yyyyMMdd") \'取得编号的8位前缀 If e.DataRow("序号").StartsWith(bh) = False \'如果编号的前8位不符 Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(序号)","日期 = #" & e.DataRow("日期") & "# And [_Identify] <> " & e.DataRow("_Identify")) \'取得该天的最大编号 If max > "" Then \'如果存在最大编号 idx = CInt(max.Substring(9,4)) + 1 \'获得最大编号的后四位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("序号") = bh & "-" & Format(idx,"0000") End If End If End If Select Case e.DataCol.name Case "日期" \' Dim dr As DataRow = DataTables("查询").Find("日期 = \'" & e.OldValue & "\'") If dr Is Nothing Then dr = DataTables("查询").AddNew() dr("日期") = e.DataRow("日期") dr("序号") = e.DataRow("序号") dr("材料名称") = e.DataRow("材料名称") dr("规格型号") = e.DataRow("规格型号") dr("工序") = e.DataRow("工序") dr("数量") = e.DataRow("数量") dr("员工") = e.DataRow("员工") dr("备注") = e.DataRow("备注") Else dr("日期") = e.DataRow("日期") End If Case "日期","序号","材料名称","规格型号","工序","数量","员工","备注" Dim dr As DataRow = DataTables("查询").Find("日期 = \'" & e.DataRow("日期") & "\'") If dr IsNot Nothing Then dr(e.DataCol.Name) = e.DataRow(e.DataCol.Name) End If End Select [此贴子已经被作者于2019/8/28 11:16:56编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2019/8/28 11:32:00 -- Select Case e.DataCol.name Case "日期" \' if e.OldValue <> nothing Dim dr As DataRow = DataTables("查询").Find("日期 = #" & e.OldValue & "#") If dr Is Nothing Then dr = DataTables("查询").AddNew() dr("日期") = e.DataRow("日期") dr("序号") = e.DataRow("序号") dr("材料名称") = e.DataRow("材料名称") dr("规格型号") = e.DataRow("规格型号") dr("工序") = e.DataRow("工序") dr("数量") = e.DataRow("数量") dr("员工") = e.DataRow("员工") dr("备注") = e.DataRow("备注") Else dr("日期") = e.DataRow("日期") End If endif Case "序号","材料名称","规格型号","工序","数量","员工","备注" Dim dr As DataRow = DataTables("查询").Find("日期 = #" & e.DataRow("日期") & "#") If dr IsNot Nothing Then dr(e.DataCol.Name) = e.DataRow(e.DataCol.Name) End If End Select
[此贴子已经被作者于2019/8/28 11:32:01编辑过]
|
||||
-- 作者:lhfu -- 发布时间:2019/8/28 12:00:00 -- 蓝老师,修改过后,发现不能“一车间毛坯流水帐”的数据不能同步到“查询”表里去了
麻烦帮我看一下,哪里出错了 [此贴子已经被作者于2019/8/28 12:01:07编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2019/8/28 13:44:00 -- Select Case e.DataCol.Name Case "日期" If e.DataRow.IsNull("日期") Then e.DataRow("序号") = Nothing Else \' Dim dr As DataRow = DataTables("查询").Find("日期 = #" & e.NewValue & "#") If dr Is Nothing Then dr = DataTables("查询").AddNew() dr("日期") = e.DataRow("日期") dr("序号") = e.DataRow("序号") dr("材料名称") = e.DataRow("材料名称") dr("规格型号") = e.DataRow("规格型号") dr("工序") = e.DataRow("工序") dr("数量") = e.DataRow("数量") dr("员工") = e.DataRow("员工") dr("备注") = e.DataRow("备注") Else dr("日期") = e.DataRow("日期") End If Dim bh As String = Format(e.DataRow("日期"),"yyyyMMdd") \'取得编号的8位前缀 If e.DataRow("序号").StartsWith(bh) = False \'如果编号的前8位不符 Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(序号)","日期 = #" & e.DataRow("日期") & "# And [_Identify] <> " & e.DataRow("_Identify")) \'取得该天的最大编号 If max > "" Then \'如果存在最大编号 idx = CInt(max.Substring(9,4)) + 1 \'获得最大编号的后四位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("序号") = bh & "-" & Format(idx,"0000") End If End If Case "序号","材料名称","规格型号","工序","数量","员工","备注" If e.DataRow.IsNull("日期") = False Then Dim dr As DataRow = DataTables("查询").Find("日期 = #" & e.DataRow("日期") & "#") If dr IsNot Nothing Then dr(e.DataCol.Name) = e.DataRow(e.DataCol.Name) End If End If End Select
|
||||
-- 作者:lhfu -- 发布时间:2019/8/28 14:53:00 -- 蓝老师,这个又引出别一个问题:如果在按“一车间毛坯流水帐”里,同一天在日期新增几行内容的话,哪么“查询”只默认同步一行的内容,哪么又如何设置的呢,请指导一下,谢谢! |
||||
-- 作者:有点蓝 -- 发布时间:2019/8/28 15:37:00 -- 同步多行内容?参考:http://www.foxtable.com/webhelp/topics/0400.htm |
||||
-- 作者:lhfu -- 发布时间:2019/8/28 16:21:00 -- 蓝老师,我的问题是在“一车间毛坯流水帐”这个表里面,通过日期的自编编号,想按同一天(以日期为例,新增多条信息 但发现“查询”表里的话,它日期同步的话,只得一条信息了 表的DataColChanged事件代码设置为 Select Case e.DataCol.Name Case "日期" If e.DataRow.IsNull("日期") Then e.DataRow("序号") = Nothing Else \' Dim dr As DataRow = DataTables("查询").Find("日期 = #" & e.NewValue & "#") If dr Is Nothing Then dr = DataTables("查询").AddNew() dr("日期") = e.DataRow("日期") dr("序号") = e.DataRow("序号") dr("材料名称") = e.DataRow("材料名称") dr("规格型号") = e.DataRow("规格型号") dr("工序") = e.DataRow("工序") dr("数量") = e.DataRow("数量") dr("员工") = e.DataRow("员工") dr("备注") = e.DataRow("备注") Else dr("日期") = e.DataRow("日期") End If Dim bh As String = Format(e.DataRow("日期"),"yyyyMMdd") \'取得编号的8位前缀 If e.DataRow("序号").StartsWith(bh) = False \'如果编号的前8位不符 Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(序号)","日期 = #" & e.DataRow("日期") & "# And [_Identify] <> " & e.DataRow("_Identify")) \'取得该天的最大编号 If max > "" Then \'如果存在最大编号 idx = CInt(max.Substring(9,4)) + 1 \'获得最大编号的后四位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("序号") = bh & "-" & Format(idx,"0000") End If End If Case "序号","材料名称","规格型号","工序","数量","员工","备注" If e.DataRow.IsNull("日期") = False Then Dim dr As DataRow = DataTables("查询").Find("日期 = #" & e.DataRow("日期") & "#") If dr IsNot Nothing Then dr(e.DataCol.Name) = e.DataRow(e.DataCol.Name) End If End If End Select 表的DataRowDeleting事件代码设置为 Dim dr As DataRow = DataTables("查询").Find("日期 = \'" & e.DataRow("日期") & "\'") If dr IsNot Nothing Then dr.Delete() End If 我还未啃透帮助文件,请蓝老师指导一下,我这应该怎么修改,谢谢 |
||||
-- 作者:有点蓝 -- 发布时间:2019/8/28 16:26:00 -- Case "序号","材料名称","规格型号","工序","数量","员工","备注" If e.DataRow.IsNull("日期") = False Then for each dr As DataRow in DataTables("查询").select("日期 = #" & e.DataRow("日期") & "#") dr(e.DataCol.Name) = e.DataRow(e.DataCol.Name) next End If
|
||||
-- 作者:lhfu -- 发布时间:2019/8/28 16:56:00 -- Select Case e.DataCol.name Case "日期" \' Dim dr As DataRow = DataTables("查询").Find("日期 = \'" & e.OldValue & "\'") If dr Is Nothing Then dr = DataTables("查询").AddNew() dr("日期") = e.DataRow("日期") dr("序号") = e.DataRow("序号") dr("材料名称") = e.DataRow("材料名称") dr("规格型号") = e.DataRow("规格型号") dr("工序") = e.DataRow("工序") dr("数量") = e.DataRow("数量") dr("员工") = e.DataRow("员工") dr("备注") = e.DataRow("备注") Else dr("日期") = e.DataRow("日期") End If Case "序号","材料名称","规格型号","工序","数量","员工","备注" If e.DataRow.IsNull("日期") = False Then For Each dr As DataRow In DataTables("查询").Select("日期 = #" & e.DataRow("日期") & "#") dr(e.DataCol.Name) = e.DataRow(e.DataCol.Name) Next End If End Select If e.DataCol.Name = "日期" Then If e.DataRow.IsNull("日期") Then e.DataRow("序号") = Nothing Else Dim bh As String = Format(e.DataRow("日期"),"yyyyMMdd") \'取得编号的8位前缀 If e.DataRow("序号").StartsWith(bh) = False \'如果编号的前8位不符 Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(序号)","日期 = #" & e.DataRow("日期") & "# And [_Identify] <> " & e.DataRow("_Identify")) \'取得该天的最大编号 If max > "" Then \'如果存在最大编号 idx = CInt(max.Substring(9,4)) + 1 \'获得最大编号的后四位顺序号,并加1 Else idx = 1 \'否则顺序号等于1 End If e.DataRow("序号") = bh & "-" & Format(idx,"0000") End If End If End If 它又显示这个出来了
[此贴子已经被作者于2019/8/28 17:09:13编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2019/8/28 17:51:00 -- Dim dr As DataRow = DataTables("查询").Find("日期 = #" & e.NewValue & "#") |