以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]填充不重复行 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=102244) |
-- 作者:huhuyq -- 发布时间:2017/6/15 22:45:00 -- [求助]填充不重复行 各位大神,我想从员工表中已经“onduty”或者“vacation”的人员自动填充到通讯录中,但同一个人即同一个名字的不再填充,我分别指表属性beforeload 和 datarowadding中写了如下代码,但是实现不了,名字相同其他内容如Department不同的还是填充了。 beforeLoad事件: Dim f As New Filler f.SourceTable = DataTables("员工") \'指定数据来源 f.SourceCols = "Chinese_Name,English_Name,Personnel_Classify_Department,Personnel_Classify_Position,Company" \'指定数据来源列 f.DataTable = DataTables("通讯录") \'指定数据接收表 f.DataCols = "Chinese_Name,English_Name,Department,Position,Company" \'指定数据接收列 f.filter="Pers And Status=\'Onduty\' or Status=\'Vacation\' " f.ExcludeExistValue=True f.Fill() \'填充数据 datarowadding事件: Dim dr As DataRow = e.DataRow Dim dr1 As DataRow If dr("Chinese_Name" ) IsNot Nothing Then If e.DataTable.Compute("Count([_Identify])","Chinese_Name = \'" & dr("Chinese_Name") & "\'") > 1 Then dr1 = e.DataTable.Find("Chinese_Name= \'" &dr("Chinese_Name")& "\'") If dr1 IsNot Nothing Then dr1.Delete() End If End If End If |
-- 作者:有点色 -- 发布时间:2017/6/16 0:05:00 -- 不能用filler填充。
改成这样增加 http://www.foxtable.com/webhelp/scr/1533.htm
在增加的代码上,加上判断,就好了。 |
-- 作者:huhuyq -- 发布时间:2017/6/17 12:28:00 -- 跟原“通讯录表“中’“Chinese_Name"不重复的条件怎么写啊? |
-- 作者:huhuyq -- 发布时间:2017/6/17 13:10:00 -- 我用下面的代码,添加的是一样行数的空白行,为什么呢。 Dim Cols1() As String = {"Chinese_Name","English_Name","Personnel_Classify_Department","Personnel_Classify_Position","Company"} Dim Cols2() As String = {"Chinese_Name","English_Name","Department","Position","Company"} For Each dr1 As DataRow In DataTables("员工").Select("[Personnel_Classify_Category] = \'间接\' And [Status] = \'Onduty\'") Dim dr2 As DataRow = DataTables("通讯录").AddNew() For i As Integer = 0 To Cols1.Length -1 dr2(Cols2(i)) = dr1(Cols1(i)) Next Next |
-- 作者:有点蓝 -- 发布时间:2017/6/17 14:56:00 -- Dim Cols1() As String = {"Chinese_Name","English_Name","Personnel_Classify_Department","Personnel_Classify_Position","Company"} Dim Cols2() As String = {"Chinese_Name","English_Name","Department","Position","Company"} Dim lst1 As new List(of DataRow) Dim lstname As new List(of String) For Each dr1 As DataRow In DataTables("员工").Select("[Personnel_Classify_Category] = \'间接\' And [Status] = \'Onduty\'") If DataTables("通讯录").Find("Chinese_Name=\'" & dr1("Chinese_Name") & "\'") Is Nothing AndAlso lstname.Contains(dr1("Chinese_Name")) = False lst1.Add(dr1) lstname.Add(dr1("Chinese_Name")) End If Next For Each dr As DataRow In lst1 Dim dr2 As DataRow = DataTables("通讯录").AddNew() For i As Integer = 0 To Cols1.Length -1 dr2(Cols2(i)) = dr(Cols1(i)) Next Next
|
-- 作者:huhuyq -- 发布时间:2017/6/17 20:36:00 -- 添加的符合条件相同数量的是空白行,这是为什么呀? |
-- 作者:有点色 -- 发布时间:2017/6/18 17:43:00 -- 上传实例说明问题。 |