以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]复制  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=189484)

--  作者:风声
--  发布时间:2023/12/5 8:31:00
--  [求助]复制
老师好,在下面的代码中进一步设置当表A退勾后后面三个表的数据也能同时删除,另外表A重置审核列时不重复复制数据到三个表中。谢谢老师.
    
If e.DataCol.Name = "审核" AndAlso e.DataRow("审核") = True Then
    Dim nma() As String = {"项目","项目ID","抄表日期","时段","年","月份"} \'A表数据来源列
    Dim nmb() As String = {"项目","项目ID","抄表日期","时段","年","月份"} \'原材料数据接收列
    Dim nmc() As String = {"项目","项目ID","抄表日期","时段","年","月份"} \'原材料数据接收列
    Dim nmd() As String = {"项目","项目ID","抄表日期","时段","年","月份"} \'原材料数据接收列

    Dim dr3 As DataRow = DataTables("一号楼").AddNew
    Dim dr1 As DataRow = DataTables("二号楼").AddNew
    Dim dr2 As DataRow = DataTables("三号楼").AddNew

    For i As Integer = 0 To nma.Length - 1
        dr3(nmb(i)) = e.DataRow(nma(i))
        dr1(nmc(i)) = e.DataRow(nma(i))
        dr2(nmd(i)) = e.DataRow(nma(i))
    Next
End If





--  作者:有点蓝
--  发布时间:2023/12/5 8:38:00
--  
If e.DataCol.Name = "审核" 
if e.DataRow("审核") = True Then
Dim dr3 As DataRow = DataTables("一号楼").find("项目ID=" & e.DataRow("项目ID") & "\'")
    if dr3 is nothing then
    Dim nma() As String = {"项目","项目ID","抄表日期","时段","年","月份"} \'A表数据来源列
    Dim nmb() As String = {"项目","项目ID","抄表日期","时段","年","月份"} \'原材料数据接收列
    Dim nmc() As String = {"项目","项目ID","抄表日期","时段","年","月份"} \'原材料数据接收列
    Dim nmd() As String = {"项目","项目ID","抄表日期","时段","年","月份"} \'原材料数据接收列

    dr3  = DataTables("一号楼").AddNew
    Dim dr1 As DataRow = DataTables("二号楼").AddNew
    Dim dr2 As DataRow = DataTables("三号楼").AddNew

    For i As Integer = 0 To nma.Length - 1
        dr3(nmb(i)) = e.DataRow(nma(i))
        dr1(nmc(i)) = e.DataRow(nma(i))
        dr2(nmd(i)) = e.DataRow(nma(i))
    Next
    end if
else
DataTables("一号楼").deletefor("项目ID=" & e.DataRow("项目ID") & "\'")
DataTables("二号楼").deletefor("项目ID=" & e.DataRow("项目ID") & "\'")
end if
End If

--  作者:风声
--  发布时间:2023/12/5 9:10:00
--  
老师,上面代码报错。




.NET Framework 版本:2.0.50727.9174
Foxtable 版本:2017.4.22.1
错误所在事件:表,电气费用记录,DataColChanged
详细错误信息:
调用的目标发生了异常。
表达式包含无效的字符串常量: \'。

--  作者:有点蓝
--  发布时间:2023/12/5 9:23:00
--  
打少一个单引号

("项目ID=\'" & e.DataRow("项目ID") & "\'")

--  作者:风声
--  发布时间:2023/12/5 9:31:00
--  
谢谢老师
--  作者:风声
--  发布时间:2023/12/6 8:06:00
--  
老师好,下面代码重置“审核”列后复制的三张表数据都删除了,我的意思是要对重置命令失效。谢谢



以下是引用有点蓝在2023/12/5 8:38:00的发言:
If e.DataCol.Name = "审核" 
if e.DataRow("审核") = True Then
Dim dr3 As DataRow = DataTables("一号楼").find("项目ID=" & e.DataRow("项目ID") & "\'")
    if dr3 is nothing then
    Dim nma() As String = {"项目","项目ID","抄表日期","时段","年","月份"} \'A表数据来源列
    Dim nmb() As String = {"项目","项目ID","抄表日期","时段","年","月份"} \'原材料数据接收列
    Dim nmc() As String = {"项目","项目ID","抄表日期","时段","年","月份"} \'原材料数据接收列
    Dim nmd() As String = {"项目","项目ID","抄表日期","时段","年","月份"} \'原材料数据接收列

    dr3  = DataTables("一号楼").AddNew
    Dim dr1 As DataRow = DataTables("二号楼").AddNew
    Dim dr2 As DataRow = DataTables("三号楼").AddNew

    For i As Integer = 0 To nma.Length - 1
        dr3(nmb(i)) = e.DataRow(nma(i))
        dr1(nmc(i)) = e.DataRow(nma(i))
        dr2(nmd(i)) = e.DataRow(nma(i))
    Next
    end if
else
DataTables("一号楼").deletefor("项目ID=" & e.DataRow("项目ID") & "\'")
DataTables("二号楼").deletefor("项目ID=" & e.DataRow("项目ID") & "\'")
end if
End If


--  作者:有点蓝
--  发布时间:2023/12/6 8:33:00
--  
首先,没有办法判断是重置的还是录入的。可以先把删除的代码先去掉,重置后再加回来。

其次,1楼不是说【当表A退勾后后面三个表的数据也能同时删除】,数据被删除,说明审核没有被勾选呀,不是符合预期么?

--  作者:风声
--  发布时间:2023/12/6 8:56:00
--  
老师,原则上是不会重置也不会重复勾选就怕误操作。
--  作者:有点蓝
--  发布时间:2023/12/6 9:06:00
--  
怕误操作就增加一个对话框,提示用户:http://www.foxtable.com/webhelp/topics/0326.htm