Foxtable(狐表)用户栏目专家坐堂 → 身份证


  共有5629人关注过本帖树形打印复制链接

主题:身份证

帅哥哟,离线,有人找我吗?
rgbjwjb
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:638 积分:6477 威望:0 精华:0 注册:2016/12/27 21:05:00
身份证  发帖心情 Post By:2022/7/12 10:43:00 [只看该作者]

我想把15位的身份证转换位18位的身份证,可否实现?请指教,谢谢!

 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107136 积分:544923 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2022/7/12 11:01:00 [只看该作者]


 回到顶部
帅哥哟,离线,有人找我吗?
jygyyl
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:463 积分:4163 威望:0 精华:0 注册:2011/4/5 16:54:00
回复:(rgbjwjb)身份证  发帖心情 Post By:2022/7/12 11:34:00 [只看该作者]

If e.DataCol.name = "GB011"
    If e.DataRow.isnull("GB011") = False
        Dim sum,ai,n As Integer
        If len(e.DataRow("GB011")) > 15
            If len(e.DataRow("GB011")) = 18
                If IsNumeric(e.DataRow("GB011")) = True OrElse IsNumeric(left(e.DataRow("GB011"),17)) = True And right(e.DataRow("GB011"),1) = "X"
                    Dim wi() As Integer = {7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2}
                    For i As Integer = 0 To 16
                        ai = e.DataRow("GB011").SubString(i,1)
                        sum = sum + ai*wi(i)
                    Next
                    n = sum Mod 11
                    Dim jym() As String = {"1","0","X","9","8","7","6","5","4","3","2"}
                    If jym(n) = right(e.DataRow("GB011"),1)
                        Dim y,m,d As Integer
                        y = e.DataRow("GB011").SubString(6,4)
                        m = e.DataRow("GB011").SubString(10,2)
                        d = e.DataRow("GB011").SubString(12,2)
                        If y > 1900 And y < 2100 And m > 0 And m < 13
                            If d > 0 And d <= Date.DaysInMonth(y,m)
                                e.DataRow("GB012") = new Date(y,m,d)
                            Else
                                MessageBox.show("对不起,检测到该身份证号码持有人的出生日期的日数据不合法,请检查!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                                Return
                            End If
                        Else
                            MessageBox.show("对不起,检测到该身份证号码持有人的出生日期的月数据不合法,请检查!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                            Return
                        End If
                        n = e.DataRow("GB011").SubString(16,1) Mod 2
                        If n = 1
                            e.DataRow("HGB002") = "男"
                        Else
                            e.DataRow("HGB002") = "女"
                        End If
                    Else
                        MessageBox.show("对不起,该身份证号码无法通过验证,请检查!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                    End If
                Else
                    MessageBox.show("对不起,身份证号码字符格式不合法,请重新输入!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                End If
            Else
                MessageBox.show("对不起,身份证号码长度不合法,请重新输入!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
            End If
        Else
            If len(e.DataRow("GB011")) < 15
                MessageBox.show("对不起,身份证号码长度不合法,请重新输入!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
            Else
                Dim y,m,d As Integer
                y = e.DataRow("GB011").SubString(6,2)
                y = 1900 + y
                m = e.DataRow("GB011").SubString(8,2)
                d = e.DataRow("GB011").SubString(10,2)
                If m > 0 And m < 13
                    If d > 0 And d <= Date.DaysInMonth(y,m)
                        e.DataRow("GB012") = new Date(y,m,d)
                    Else
                        MessageBox.show("对不起,检测到该身份证号码持有人的出生日期的日数据不合法,请检查!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                        Return
                    End If
                Else
                    MessageBox.show("对不起,检测到该身份证号码持有人的出生日期的月数据不合法,请检查!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information)
                    Return
                End If
                n = e.DataRow("GB011").SubString(14,1) Mod 2
                If n = 1
                    e.DataRow("HGB002") = "男"
                Else
                    e.DataRow("HGB002") = "女"
                End If
            End If
        End If
    Else
        e.DataRow("HGB002") = Nothing
        e.DataRow("GB012") = Nothing
        e.DataRow("籍贯") = Nothing
    End If
End If
If e.DataCol.name = "GB012"
    If e.DataRow.isnull("GB012") = False
        Dim tp As TimeSpan = Date.today - CDate(e.DataRow("GB012"))
        e.DataRow("年龄") = Math.Round(tp.TotalDays / 365.2422,2)
    Else
        e.DataRow("年龄") = Nothing
    End If
End If

Select Case e.DataCol.name
    Case "GB011"
        If e.DataRow.IsNull("GB011") Then
            e.DataRow("籍贯") = Nothing
        Else
            Dim bm As String = e.DataRow("GB011").SubString(0,6)
            Dim dr As DataRow = DataTables("ybsj").SQLFind("代码 = '" & bm & "'")
            If dr IsNot Nothing Then
                e.DataRow("籍贯") = dr("地址") 
            End If
        End If
End Select



 回到顶部
帅哥哟,离线,有人找我吗?
rgbjwjb
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:638 积分:6477 威望:0 精华:0 注册:2016/12/27 21:05:00
  发帖心情 Post By:2022/7/12 14:58:00 [只看该作者]

谢谢!


 回到顶部