以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  为何这两组代码同时放在一起不执行  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=24890)

--  作者:lyfxybc
--  发布时间:2012/10/25 20:15:00
--  为何这两组代码同时放在一起不执行

为何这两组代码同时放在一起不执行(DataColChanged)

 

 

Dim dr As DataRow =e.DataRow
Select e.DataCol.Name
    Case "日期","序号"
        If dr.IsNull("日期") OrElse dr.isnull("序号") Then
            dr("编号") = Nothing
        Else
            Dim drs As List(of DataRow) =e.DataTable.Select("日期 =#" & dr("日期") & "# and 序号 =\'" & dr("序号") & "\'" ,"_Identify")
            Dim i As Integer
            For Each tr As DataRow In drs
                Dim d As Date = tr("日期")
                Dim xh As Integer =tr("序号")
                Dim bh As String =  Format(d,"yyyyMMdd")  & format(xh,"000") \'生成编号的前缀
                i =i+1
                tr("编号") = bh & format(i,"000")
            Next
        End If
End Select

 

 

If e.DataCol.Name = "机号"
    If e.DataRow.IsNull("机号") = False
        For Each dr As DataRow In e.DataTable.Select("[机号] Is null And [_Identify] < " & e.DataRow("_Identify"))
            dr("机号") = e.NewValue
        Next
    End If
End If

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1.table

[此贴子已经被作者于2012-10-25 20:25:55编辑过]

--  作者:szp2012
--  发布时间:2012/10/25 23:23:00
--  

没有机号列


--  作者:wjl-se
--  发布时间:2012/10/26 10:39:00
--  

楼主传错附件了:

推测了你的逻辑可能是这样的:

 

Dim dr As DataRow =e.DataRow
Select e.DataCol.Name
    Case "日期","序号"
        If dr.IsNull("日期") OrElse dr.isnull("序号") Then
            dr("编号") = Nothing
        Else
            Dim drs As List(of DataRow) =e.DataTable.Select("日期 =#" & dr("日期") & "# and 序号 =\'" & dr("序号") & "\'" ,"_Identify")
            Dim i As Integer
            For Each tr As DataRow In drs
                Dim d As Date = tr("日期")
                Dim xh As Integer =tr("序号")
                Dim bh As String =  Format(d,"yyyyMMdd")  & format(xh,"000") \'生成编号的前缀
                i =i+1
                tr("编号") = bh & format(i,"000")
            Next
        End If
    Case "机号"
        If dr.IsNull("机号") = False Then
            Dim drs As List (of DataRow) = e.DataTable.Select("[机号] Is null And [ID] < " & e.DataRow("ID") & "")
            For Each dr1 As DataRow In drs
                dr1("机号") = e.NewValue
            Next
        End If
End Select

[此贴子已经被作者于2012-10-26 10:56:42编辑过]

--  作者:lyfxybc
--  发布时间:2012/10/26 20:42:00
--  

非常谢谢您给我的答案,根据您的答案我已解决:

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1(1).table

 

 

其中:编号为字符,序号为整数,[id]为[_Identify]

[此贴子已经被作者于2012-10-26 20:43:48编辑过]