以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]身份证号码 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=137417) |
-- 作者:江南小镇 -- 发布时间:2019/7/5 13:53:00 -- [求助]身份证号码 老师,籍贯怎样提取出来。 If e.DataCol.Name = "个人基本资料_身份证号码" Then \'如果更改的是身份证号码列 If e.DataRow.IsNull("个人基本资料_身份证号码") Then \'身份证号码是否为空 e.DataRow("个人基本资料_出生年月") = Nothing \'如果为空,则清除出生日期 e.DataRow("个人基本资料_性别") = Nothing \'如果为空,则清除出生日期 e.DataRow("个人基本资料_籍贯") = Nothing \'如果为空,则清除出生日期 e.DataRow("个人基本资料_年龄") = Nothing \'如果为空,则清除出生日期 Else \'否则从身份证号码列中提取出生日期 e.DataRow("个人基本资料_出生年月") = ReadBirthday(e.DataRow("个人基本资料_身份证号码")) e.DataRow("个人基本资料_性别") = ReadSex(e.DataRow("个人基本资料_身份证号码")) e.DataRow("个人基本资料_年龄") =Functions.Execute("服务器时间").Year - e.DataRow("个人基本资
|
-- 作者:jjjeyes -- 发布时间:2019/7/5 14:14:00 -- 参考:http://www.foxtable.com/webhelp/topics/2625.htm |
-- 作者:江南小镇 -- 发布时间:2019/7/5 21:50:00 -- 老师好,下面身份号码证验证代码是狐表论坛上的,现在我要把代码设置到窗口表中。“身份证地区编码表”是外部数据表。谢谢老师帮我修改。(标出的地方想引用外部数据表)。 If e.DataCol.name = "证件号码" If e.DataRow.isnull("证件号码") = False Dim sum,ai,n As Integer If len(e.DataRow("证件号码")) > 15 If len(e.DataRow("证件号码")) = 18 If IsNumeric(e.DataRow("证件号码")) = True OrElse IsNumeric(left(e.DataRow("证件号码"),17)) = True And right(e.DataRow("证件号码"),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("证件号码").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("证件号码"),1) Dim y,m,d As Integer y = e.DataRow("证件号码").SubString(6,4) m = e.DataRow("证件号码").SubString(10,2) d = e.DataRow("证件号码").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("出生日期") = 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("证件号码").SubString(16,1) Mod 2 If n = 1 e.DataRow("性别") = "男" Else e.DataRow("性别") = "女" End If Dim s As String = e.DataRow("证件号码").SubString(0,2) & "0000" Dim dq As String Dim dr As DataRow dr = DataTables("身份证地区编码").find("编码 = " & s) If dr IsNot Nothing dq = dr("县级以上地区名称") End If s = e.DataRow("证件号码").SubString(0,4) & "00" dr = DataTables("身份证地区编码").find("编码 = " & s) If dr IsNot Nothing dq = dq & dr("县级以上地区名称") Else s = e.DataRow("证件号码").SubString(0,3) & "000" dr = DataTables("身份证地区编码").find("编码 = " & s) If dr IsNot Nothing dq = dq & dr("县级以上地区名称") End If End If s = e.DataRow("证件号码").SubString(0,5) & "0" dr = DataTables("身份证地区编码").find("编码 = " & s) If dr IsNot Nothing dq = dq & dr("县级以上地区名称") End If s = e.DataRow("证件号码").SubString(0,6) dr = DataTables("身份证地区编码").find("编码 = " & s) If dr IsNot Nothing dq = dq & dr("县级以上地区名称") End If e.DataRow("籍贯") = dq 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("证件号码")) < 15 MessageBox.show("对不起,身份证号码长度不合法,请重新输入!","系统提示",MessageBoxButtons.OK, MessageBoxIcon.Information) Else Dim y,m,d As Integer y = e.DataRow("证件号码").SubString(6,2) y = 1900 + y m = e.DataRow("证件号码").SubString(8,2) d = e.DataRow("证件号码").SubString(10,2) If m > 0 And m < 13 If d > 0 And d <= Date.DaysInMonth(y,m) e.DataRow("出生日期") = 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("证件号码").SubString(14,1) Mod 2 If n = 1 e.DataRow("性别") = "男" Else e.DataRow("性别") = "女" End If Dim s As String = e.DataRow("证件号码").SubString(0,2) & "0000" Dim dq As String Dim dr As DataRow dr = DataTables("身份证地区编码").find("编码 = " & s) If dr IsNot Nothing dq = dr("县级以上地区名称") End If s = e.DataRow("证件号码").SubString(0,4) & "00" dr = DataTables("身份证地区编码").find("编码 = " & s) If dr IsNot Nothing dq = dq & dr("县级以上地区名称") Else s = e.DataRow("证件号码").SubString(0,3) & "000" dr = DataTables("身份证地区编码").find("编码 = " & s) If dr IsNot Nothing dq = dq & dr("县级以上地区名称") End If End If s = e.DataRow("证件号码").SubString(0,5) & "0" dr = DataTables("身份证地区编码").find("编码 = " & s) If dr IsNot Nothing dq = dq & dr("县级以上地区名称") End If s = e.DataRow("证件号码").SubString(0,6) dr = DataTables("身份证地区编码").find("编码 = " & s) If dr IsNot Nothing dq = dq & dr("县级以上地区名称") End If e.DataRow("籍贯") = dq End If End If Else e.DataRow("性别") = Nothing e.DataRow("出生日期") = Nothing e.DataRow("籍贯") = Nothing End If End If If e.DataCol.name = "出生日期" If e.DataRow.isnull("出生日期") = False Dim tp As TimeSpan = Date.today - CDate(e.DataRow("出生日期")) e.DataRow("年龄") = Math.Round(tp.TotalDays / 365.2422,2) Else e.DataRow("年龄") = Nothing End If End If [此贴子已经被作者于2019/7/6 8:03:39编辑过]
|
-- 作者:江南小镇 -- 发布时间:2019/7/6 15:37:00 -- 老师好,标出的代码我想改成引用外部数据表。 dr = DataTables("身份证地区编码").find("编码 = " & s) If dr IsNot Nothing dq = dr("县级以上地区名称")
|
-- 作者:有点蓝 -- 发布时间:2019/7/6 16:14:00 -- find改为使用sqlfind |
-- 作者:江南小镇 -- 发布时间:2019/7/6 16:43:00 -- Dim cmd As New SQLCommand cmd.C cmd.CommandText = " Select * F rom {身份证籍贯编码}" sfzxgbm = cmd.ExecuteReader(True) 老师,我想通过项目事件来引用。标出的代码不会改。(老师可以这样做吗?) dr = DataTables("身份证地区编码").find("编码 = " & s) If dr IsNot Nothing dq = dr("县级以上地区名称")
[此贴子已经被作者于2019/7/6 16:43:27编辑过]
|
-- 作者:有点蓝 -- 发布时间:2019/7/6 17:03:00 -- 如果"身份证地区编码"表已经加载,直接使用sqlfind 就行了,搞那么多花样干啥。 一些字典类的数据,比如"身份证地区编码"表这种的,一般数据相对固定,也不算多,并且是常用的,建议直接加载完整数据使用即可。业务数据才考虑动态加载和使用。 如果要使用SQLCommand,dr = DataTables("身份证地区编码").find("编码 = " & s) 改为 dr = sfzxgbm .find("编码 = " & s)
|