以文本方式查看主题
- Foxtable(狐表) (http://foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2)
---- [求助]请大神帮忙修该下代码了 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=30581)
|
-- 作者:sadfox
-- 发布时间:2013/3/30 17:25:00
-- [求助]请大神帮忙修该下代码了
1、如何让考核序号自动增加到第18时,出现提示,注意,你的考核序号已经增加到18条
Select e.DataCol.Name Case "文档号" If e.DataRow.IsNull("文档号") Then e.DataRow("考核序号") = Nothing Else Dim lb As String = e.DataRow("文档号") If e.DataRow("考核序号").StartsWith(lb) = False Dim max As String Dim idx As Integer max = e.DataTable.Compute("Max(考核序号)","文档号 = \'" & lb & "\'") If max > "" Then \' idx = CInt(max.Substring(5,3)) + 1 Else idx = 1 End If e.DataRow("考核序号") = lb & Format(idx,"000") End If End If End Select
2、如何根据考核序号判断,不再填入已经存在的内容。
Dim f As New Filler f.SourceTable = DataTables("出勤表") f.SourceCols = "时间,考核事实,依据,加扣分值,考核序号"
f.DataTable = DataTables("文档号")
f.DataCols = "时间,考核事实,依据,加扣分值,考核序号"
f.Fill() \'
求大神帮忙啦
|
-- 作者:sadfox
-- 发布时间:2013/3/30 17:37:00
--
2、如何根据考核序号判断,不再填入已经存在的内容。
Dim f As New Filler f.SourceTable = DataTables("出勤表") f.SourceCols = "时间,考核事实,依据,加扣分值,考核序号"
f.DataTable = DataTables("文档号")
f.DataCols = "时间,考核事实,依据,加扣分值,考核序号"
f.Filter = "编号 = 55526"
f.Fill() \'
开少了个编号条件,现在是,执行一次,就填一次,再执行,就把先前已经重复的内容又填充进去,能不能加个语句在填充时,自动根据考核序号判断已经存在的内容不在填充,求大神帮忙啦
|
-- 作者:sadfox
-- 发布时间:2013/3/30 18:11:00
--
以下是引用muhua在2013-3-30 17:44:00的发言:
参考这个做吧:
Dim nma() As String = {"A1","A2","A3","A4"} \'A表数据来源列 Dim nmb() As String = {"B1","B2","B3","B4"}\'B表数据接收列 For dr As DataRow In DataTables("表A").DataRows Dim dr2 As DataRow = DataTables("表B").Find("A2=\'" & dr("B2") & "\'") If dr2 Is Nothing Then For i As Integer = 0 To nma.Length - 1 dr2(nmb(i)) = dr(nma(i)) Next End If Next
此主题相关图片如下:未命22222名.jpg

[此贴子已经被作者于2013-3-30 18:11:10编辑过]
|
-- 作者:狐狸爸爸
-- 发布时间:2013/3/30 18:30:00
--
Dim nma() As String = {"A1","A2","A3","A4"} \'A表数据来源列 Dim nmb() As String = {"B1","B2","B3","B4"}\'B表数据接收列 For Each dr As DataRow In DataTables("表A").DataRows Dim dr2 As DataRow = DataTables("表B").Find("A2=\'" & dr("B2") & "\'") If dr2 Is Nothing Then For i As Integer = 0 To nma.Length - 1 dr2(nmb(i)) = dr(nma(i)) Next End If Next
|
-- 作者:sadfox
-- 发布时间:2013/3/30 18:44:00
--
晕,搞昏头头了,删行居然删成表了,晕啊!
|
-- 作者:sadfox
-- 发布时间:2013/3/30 19:24:00
--
以下是引用狐狸爸爸在2013-3-30 18:30:00的发言:
Dim nma() As String = {"A1","A2","A3","A4"} \'A表数据来源列 Dim nmb() As String = {"B1","B2","B3","B4"}\'B表数据接收列 For Each dr As DataRow In DataTables("表A").DataRows Dim dr2 As DataRow = DataTables("表B").Find("A2=\'" & dr("B2") & "\'") If dr2 Is Nothing Then For i As Integer = 0 To nma.Length - 1 dr2(nmb(i)) = dr(nma(i)) Next End If Next
测试时,提示错误:System.Reflection.TargetInvocationException: 调用的目标发生了异常。 ---> System.NullReferenceException: 未将对象引用设置到对象的实例。
|
-- 作者:狐狸爸爸
-- 发布时间:2013/3/30 20:15:00
--
Dim nma() As String = {"A1","A2","A3","A4"} \'A表数据来源列 Dim nmb() As String = {"B1","B2","B3","B4"}\'B表数据接收列 For Each dr As DataRow In DataTables("表A").DataRows Dim dr2 As DataRow = DataTables("表B").Find("A2=\'" & dr("B2") & "\'") If dr2 Is Nothing Then dr2 = DataTables("表B").AddNew() For i As Integer = 0 To nma.Length - 1 dr2(nmb(i)) = dr(nma(i)) Next End If Next
|
-- 作者:sadfox
-- 发布时间:2013/3/30 21:14:00
--
以下是引用狐狸爸爸在2013-3-30 20:15:00的发言:
Dim nma() As String = {"A1","A2","A3","A4"} \'A表数据来源列 Dim nmb() As String = {"B1","B2","B3","B4"}\'B表数据接收列 For Each dr As DataRow In DataTables("表A").DataRows Dim dr2 As DataRow = DataTables("表B").Find("A2=\'" & dr("B2") & "\'") If dr2 Is Nothing Then dr2 = DataTables("表B").AddNew() For i As Integer = 0 To nma.Length - 1 dr2(nmb(i)) = dr(nma(i)) Next End If Next
测试结果:由于Nothing Then对数值列空值的判断会返回零,所以每次执行就会把表A的空值行不断导入表B,并在数值列显示0,如何解决,不让空值行导入表B?知道原因,不知道方法!
|