以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  身份证审核  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=96479)

--  作者:ayiken
--  发布时间:2017/2/21 18:13:00
--  身份证审核
1.各位狐表专家!我用的这些代码虽然准确运作,但是顺序有点乱,本人水平有限,整理不了,请帮忙整理下
2.我想这些代码执行之前能审核身份证号是否正确的代码,正确执行,则不执行,要求充填、修改

If e.DataCol.Name = "身份证号码" Then \'是身份证号码发生变化吗?
    If e.DataRow.IsNull("身份证号码") Then \'身份证号码是否为空
        e.DataRow("出生日期") = Nothing \'如果为空,则清除出生日期
    Else
        \'否则从身份证号码列中提取出生日期
        e.DataRow("出生日期") = ReadBirthday(e.DataRow("身份证号码"))
    End If
ElseIf e.DataCol.name = "出生日期" Then
    If e.newvalue <> Nothing Then
        Dim y As Integer = e.NewValue.year
        If format(e.newvalue, "MMdd") <= Format(Date.Today, "MMdd") Then
            e.DataRow("年龄") = Date.Today.Year - y
        Else
            e.DataRow("年龄") = Date.Today.Year - y -1
        End If
    Else
        e.DataRow("年龄") = Nothing
    End If
End If

Select Case e.DataCol.name
    Case "身份证号码"
        If e.DataRow.IsNull("身份证号码") Then
            e.DataRow("出生地点") = Nothing
            e.DataRow("籍贯") = Nothing
            e.DataRow("国籍") = Nothing
        Else
            Dim szd As String = e.DataRow("身份证号码").SubString(0,6)
            Dim jg As String = e.DataRow("身份证号码").SubString(0,2)
            Dim gj As String = e.DataRow("身份证号码").SubString(0,1)
            Dim dr As DataRow = DataTables("身份证籍贯编码").Find("籍贯编码 = \'" & szd & "\'")
            Dim dc As DataRow = DataTables("身份证籍贯编码").Find("籍贯编码 = \'" & jg & "\'")
            Dim dt As DataRow = DataTables("身份证籍贯编码").Find("籍贯编码 = \'" & gj & "\'")
            If dr  IsNot Nothing Then
                e.DataRow("出生地点") = dr("哈文名称")
                e.DataRow("籍贯") = dc("哈文名称")
                e.DataRow("国籍") = dt("哈文名称")
                
            End If
        End If
End Select
Dim rq As DataRow = e.DataRow
Dim t As TimeSpan
If e.DataCol.Name = "出院日期" Then
    If rq.IsNull("入院日期") OrElse rq.IsNull("入院日期") Then
        rq("住院天数") = Nothing
    Else
        t = rq("出院日期")-rq("入院日期")
        rq("住院天数") = t.Days
    End If
End If


帮忙一下

--  作者:ayiken
--  发布时间:2017/2/21 18:14:00
--  
1.各位狐表专家!我用的这些代码虽然准确运作,但是顺序有点乱,本人水平有限,整理不了,请帮忙整理下
2.我想这些代码执行之前能审核身份证号是否正确的代码,正确执行,则不执行,要求充填、修改

If e.DataCol.Name = "身份证号码" Then \'是身份证号码发生变化吗?
    If e.DataRow.IsNull("身份证号码") Then \'身份证号码是否为空
        e.DataRow("出生日期") = Nothing \'如果为空,则清除出生日期
    Else
        \'否则从身份证号码列中提取出生日期
        e.DataRow("出生日期") = ReadBirthday(e.DataRow("身份证号码"))
    End If
ElseIf e.DataCol.name = "出生日期" Then
    If e.newvalue <> Nothing Then
        Dim y As Integer = e.NewValue.year
        If format(e.newvalue, "MMdd") <= Format(Date.Today, "MMdd") Then
            e.DataRow("年龄") = Date.Today.Year - y
        Else
            e.DataRow("年龄") = Date.Today.Year - y -1
        End If
    Else
        e.DataRow("年龄") = Nothing
    End If
End If

Select Case e.DataCol.name
    Case "身份证号码"
        If e.DataRow.IsNull("身份证号码") Then
            e.DataRow("出生地点") = Nothing
            e.DataRow("籍贯") = Nothing
            e.DataRow("国籍") = Nothing
        Else
            Dim szd As String = e.DataRow("身份证号码").SubString(0,6)
            Dim jg As String = e.DataRow("身份证号码").SubString(0,2)
            Dim gj As String = e.DataRow("身份证号码").SubString(0,1)
            Dim dr As DataRow = DataTables("身份证籍贯编码").Find("籍贯编码 = \'" & szd & "\'")
            Dim dc As DataRow = DataTables("身份证籍贯编码").Find("籍贯编码 = \'" & jg & "\'")
            Dim dt As DataRow = DataTables("身份证籍贯编码").Find("籍贯编码 = \'" & gj & "\'")
            If dr  IsNot Nothing Then
                e.DataRow("出生地点") = dr("哈文名称")
                e.DataRow("籍贯") = dc("哈文名称")
                e.DataRow("国籍") = dt("哈文名称")
                
            End If
        End If
End Select


--  作者:ayiken
--  发布时间:2017/2/21 18:14:00
--  
希望参考二楼


--  作者:有点色
--  发布时间:2017/2/21 18:28:00
--  
If e.DataCol.Name = "身份证号码" Then \'是身份证号码发生变化吗?
    If e.DataRow.IsNull("身份证号码") Then \'身份证号码是否为空
        e.DataRow("出生日期") = Nothing \'如果为空,则清除出生日期
        e.DataRow("出生地点") = Nothing
        e.DataRow("籍贯") = Nothing
        e.DataRow("国籍") = Nothing
    Else
        If ValidPIN(e.DataRow("身份证号码")) Then
            \'否则从身份证号码列中提取出生日期
            e.DataRow("出生日期") = ReadBirthday(e.DataRow("身份证号码"))
            Dim szd As String = e.DataRow("身份证号码").SubString(0,6)
            Dim jg As String = e.DataRow("身份证号码").SubString(0,2)
            Dim gj As String = e.DataRow("身份证号码").SubString(0,1)
            Dim dr As DataRow = DataTables("身份证籍贯编码").Find("籍贯编码 = \'" & szd & "\'")
            Dim dc As DataRow = DataTables("身份证籍贯编码").Find("籍贯编码 = \'" & jg & "\'")
            Dim dt As DataRow = DataTables("身份证籍贯编码").Find("籍贯编码 = \'" & gj & "\'")
            If dr  IsNot Nothing Then
                e.DataRow("出生地点") = dr("哈文名称")
                e.DataRow("籍贯") = dc("哈文名称")
                e.DataRow("国籍") = dt("哈文名称")
               
            End If
        End If
    end if
ElseIf e.DataCol.name = "出生日期" Then
    If e.newvalue <> Nothing Then
        Dim y As Integer = e.NewValue.year
        If format(e.newvalue, "MMdd") <= Format(Date.Today, "MMdd") Then
            e.DataRow("年龄") = Date.Today.Year - y
        Else
            e.DataRow("年龄") = Date.Today.Year - y -1
        End If
    Else
        e.DataRow("年龄") = Nothing
    End If
End If

--  作者:ayiken
--  发布时间:2017/2/21 18:38:00
--  
请问怎样判断首身份证号码的准确性?
--  作者:ayiken
--  发布时间:2017/2/21 18:40:00
--  
四楼代码前面怎么加判断身份证号码的准确性?准确执行,则不执行的代码?



--  作者:ayiken
--  发布时间:2017/2/21 19:29:00
--  
帅哥,在线噢!
有点色 老师
四楼代码有误吗?执行无反应,二楼代码执行还是有效,请六楼的问题帮一下忙!!!!

--  作者:有点蓝
--  发布时间:2017/2/21 20:08:00
--  
If ValidPIN(e.DataRow("身份证号码")) Then

这一句就是判断身份证的有效性的

--  作者:有点蓝
--  发布时间:2017/2/21 20:08:00
--  
或者参考:

Select Case e.DataCol.name
    Case "身份证号码"
        If e.DataRow.IsNull("身份证号码") Then
            e.DataRow("出生地点") = Nothing
            e.DataRow("籍贯") = Nothing
            e.DataRow("国籍") = Nothing
            e.DataRow("出生日期") = Nothing
        ElseIf ValidPIN(e.NewValue)
            e.DataRow("出生日期") = ReadBirthday(e.NewValue)
            Dim szd As String = e.DataRow("身份证号码").SubString(0,6)
            Dim jg As String = e.DataRow("身份证号码").SubString(0,2)
            Dim gj As String = e.DataRow("身份证号码").SubString(0,1)
            Dim dr As DataRow = DataTables("身份证籍贯编码").Find("籍贯编码 = \'" & szd & "\'")
            Dim dc As DataRow = DataTables("身份证籍贯编码").Find("籍贯编码 = \'" & jg & "\'")
            Dim dt As DataRow = DataTables("身份证籍贯编码").Find("籍贯编码 = \'" & gj & "\'")
            If dr  IsNot Nothing Then
                e.DataRow("出生地点") = dr("哈文名称")
                e.DataRow("籍贯") = dc("哈文名称")
                e.DataRow("国籍") = dt("哈文名称")
            End If
        End If
    Case "出生日期"
        If e.newvalue <> Nothing Then
            Dim y As Integer = e.NewValue.year
            If format(e.newvalue, "MMdd") <= Format(Date.Today, "MMdd") Then
                e.DataRow("年龄") = Date.Today.Year - y
            Else
                e.DataRow("年龄") = Date.Today.Year - y -1
            End If
        Else
            e.DataRow("年龄") = Nothing
        End If
    Case "出院日期","入院日期"
        Dim rq As DataRow = e.DataRow
        Dim t As TimeSpan
        If rq.IsNull("入院日期") OrElse rq.IsNull("入院日期") Then
            rq("住院天数") = Nothing
        Else
            t = rq("出院日期")-rq("入院日期")
            rq("住院天数") = t.Days
        End If
End Select