1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
Function valid_NID(&NID) Returns boolean; Local string &strNID = &NID; Local string &strMonth, &strDay, &strIdBirth; Local string &strSex = " "; Local number &numNIDSex, &i; Local array of number &Wnum = CreateArray(7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1); Local array of string &Cstr = CreateArray("1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"); Local number &numResult = 0; If All(&strNID) Then &numNIDlen = Len(&strNID); rem 验证省份; SQLExec("select 'Y' from dual where :1 in ('11','12','13','14','15','21','22','23','31','32','33','34','35','36','37','41','42','43','44','45','46','50','51','52','53','54','61','62','63','64','65','71','81','82','91')", Substring(&strNID, 1, 2), &flag1); If &flag1 <> "Y" Then Return False; End-If; SQLExec("select 'Y' from dual where :1 in ('01','02','03','04','05','06','07','08','09','10','11','12')", Substring(&strNID, 11, 2), &flag2); If &flag2 <> "Y" Then Return False; End-If; If Substring(&strNID, 11, 2) = "01" Or Substring(&strNID, 11, 2) = "03" Or Substring(&strNID, 11, 2) = "05" Or Substring(&strNID, 11, 2) = "07" Or Substring(&strNID, 11, 2) = "08" Or Substring(&strNID, 11, 2) = "10" Or Substring(&strNID, 11, 2) = "12" Then SQLExec(" select 'Y' from dual where to_number(substr(:1,13,2)) between 1 and 31", &strNID, &flag31); If &flag31 <> "Y" Then Return False; End-If; End-If; If Substring(&strNID, 11, 2) = "04" Or Substring(&strNID, 11, 2) = "06" Or Substring(&strNID, 11, 2) = "09" Or Substring(&strNID, 11, 2) = "11" Then SQLExec(" select 'Y' from dual where to_number(substr(:1,13,2)) between 1 and 30", &strNID, &flag32); If &flag32 <> "Y" Then Return False; End-If; End-If; If Substring(&strNID, 11, 2) = "02" Then SQLExec("select MOD(to_number(:1), 4) from dual", Substring(&strNID, 7, 4), &num); If &num = 0 Then SQLExec(" select 'Y' from dual where to_number(substr(:1,13,2)) between 1 and 29", &strNID, &flag33); If &flag33 <> "Y" Then Return False; End-If; Else SQLExec(" select 'Y' from dual where to_number(substr(:1,13,2)) between 1 and 28", &strNID, &flag34); If &flag34 <> "Y" Then Return False; End-If; End-If; End-If;
SQLExec("select 'Y' from dual where to_date(substr(:1,7,8) ,'yyyymmdd') > to_date('19000101','yyyymmdd') and to_date(substr(:1,7,8) ,'yyyymmdd')<=sysdate", &strNID, &flag4); If &flag4 <> "Y" Then Return False; End-If;
If &numNIDlen = 18 Then For &i = 1 To 17 &numResult = &numResult + &Wnum [&i] * Value(Substring(&strNID, &i, 1)) End-For; &numResult = Mod(&numResult, 11); If &Cstr [&numResult + 1] <> Right(&strNID, 1) Then Return False; End-If; End-If; End-If; Return True; End-Function;
|