以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  关键词查找  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=169061)

--  作者:ganlan
--  发布时间:2021/5/31 22:17:00
--  关键词查找
If e.DataCol.Name = "订单号" Then 
      If e.NewValue Is Nothing Then 
         e.DataRow("出游日") = Nothing 
         e.DataRow("手机号") = Nothing 
         e.DataRow("新订单号") = Nothing 
   Else 
   Dim cy As DataRow 
       cy = DataTables("新表").Find("[渠道订单号] Like \'%" & e.NewValue & "%\'")
   If cy IsNot Nothing Then 
            e.DataRow("出游日") = cy("开始日期") 
           e.DataRow("手机号") = cy("联系电话")  
           e.DataRow("新订单号") = cy("订单号") 
Else
          e.DataRow("出游日") = Nothing
         e.DataRow("手机号") = Nothing 
         e.DataRow("新订单号") = Nothing 

End If
End If
End If

想用这个代码,把“订单号”作为关键词在新表的“渠道订单号(规则是***-订单号)里面查找,找到就填入新表的“日期”,“联系电话”,“新订单号”。
但是点重置列,很卡
有没有比较好的可以优化,我之前用EXCEL,是在新表把渠道订单号的“-”后订单号提取出来,但是用狐表不知道怎么提取。


--  作者:有点蓝
--  发布时间:2021/5/31 22:35:00
--  
很卡应该和这个没有关系

1、当前表数据如果很多,重置列卡是正常的
2、当前表datacolchanged事件还有没有其它代码?把其它代码都注释掉测试卡不卡?

如果要提取数据可以这样,"新表"增加一个列【订单号】
"新表"datacolchanged事件
If e.DataCol.Name = "渠道订单号" andalso e.datarow.isnull("渠道订单号") = false Then 
dim ar() as string = e.datarow("渠道订单号").split("-")
if ar.length > 1 then e.datarow("订单号") = ar(1)
end if

--  作者:ganlan
--  发布时间:2021/5/31 23:09:00
--  
好的,刚在使用指南里面找到了Split,谢谢了
--  作者:ganlan
--  发布时间:2021/6/2 12:04:00
--  
再请教一下,
如果资料列是:李四(13000000000)这样的格式,我想在名字列提取名字,电话列提取电话
用上面的代码的时候,提示出错,请教一下是什么原因呀
If e.DataCol.Name = "资料" andalso e.datarow.isnull("资料") = false Then 
dim ar() as string = e.datarow("资料").split("(")
if ar.length > 1 then e.datarow("名字") = ar(0)
e.datarow("电话") = ar(1)
end if

--  作者:有点蓝
--  发布时间:2021/6/2 14:05:00
--  
提示什么错误?
If e.DataCol.Name = "资料" andalso e.datarow.isnull("资料") = false Then 
dim ar() as string = e.datarow("资料").split("(")
e.datarow("名字") = ar(0)
if ar.length > 1 then e.datarow("电话") = ar(1).trim(")")
end if

--  作者:ganlan
--  发布时间:2021/6/2 15:48:00
--  
.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2021.5.27.1
错误所在事件:表,报销, DataColChanged
详细错误信息:
Exception has been thrown by the target of an invocation.
Conversion from string "李四(13000000000)" to type \'Double\' is not valid.
Input string was not in a correct format.

--  作者:有点蓝
--  发布时间:2021/6/2 15:52:00
--  
"电话"列是双精度类型?改为字符型
--  作者:ganlan
--  发布时间:2021/6/2 17:12:00
--  
好的,谢谢,可以了