C 新增物件前 身份證號的驗證

2021-08-07 08:18:22 字數 2028 閱讀 5808

呼叫通用驗證類

通過資料驗證

如果sql有了身份證資訊新增的身份證號不能是重複的

編寫查詢身份證方法

/// 查詢身份證是否已經存在

//////

///public

bool

isidcardexisted(string idcard)

";sql = string.format(sql, idcard);

int count = convert.toint32(sqlhelper.getsingleresult(sql));

if (count == 1) return

true;

else

return

false;

}通過資料驗證

sql已經有了存在的身份證號,新增的身份證號重複不通過

//驗證身份證號是否和出生日期吻合

string month = string.empty

; string day = string.empty

; if(convert.todatetime(this.txtbirthday

.text).month

<10)

month = "0" + convert.todatetime(this.txtbirthday

.text).month

.tostring();

else

month = convert.todatetime(this.txtbirthday

.text).month

.tostring();

if (convert.todatetime(this.txtbirthday

.text).day

< 10)

day = "0" + convert.todatetime(this.txtbirthday

.text).day

.tostring();

else

day = convert.todatetime(this.txtbirthday

.text).day

.tostring();

string birthday = convert.todatetime(this.txtbirthday

.text).year

.tostring() + month + day;

if(!this.txtstuidno

.text

.trim().contains(birthday))

C 身份證號驗證

c 身份證號驗證 由於專案需要,在網上的例子大多數都是c 的,所以新增了這個身份證號的驗證的c 程式 實現身份證生成和校驗 bool cid card no generatedlg idnumberverify cstring stridnumber byte uccoefficient 17 tc...

身份證號驗證

原文 身份證號驗證 public static boolean isidnumber string idnumber 定義判別使用者身份證號的正規表示式 15位或者18位,最後一位可以為字母 string regularexpression 1 9 d 18 19 20 d 0 1 9 10 11 ...

身份證號驗證

身份證號組成 17位數字 1位校驗碼 位址碼 前六位 出生日期碼 第七位至第十位 順序碼 第十五位至十七位 對同年同月同日生的人便定的順序號,順序號奇數為男生,偶數為女生 檢驗碼 第十八位 0 9 x var acity function iscarid sid d x i.test sid ret...