ASP.NET中数据库应用-身份证信息查询器
// Web版的身份证信息查询
//Default.aspx
UICulture = " zh-CN " Culture = " zh-CN " %>
<% @ Import Namespace = " System.Data " %>
<% @ Import Namespace = " System.Data.OleDb " %>
<! DOCTYPE html PUBLIC " -//W3C//DTD XHTML 1.0 Transitional//EN " " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >
< html xmlns = " http://www.w3.org/1999/xhtml " >
< head runat = " server " >
< title > 身份证查询 - Made by iceman </ title >
< script language = " C# " runat = " server " >
public string strIDCardNum;
public bool wrongFlag = false ;
private void Page_Load(Object sender, EventArgs e)
... {
TextIDNUM.Focus();
}
private void Submit_Click(Object sender, EventArgs e)
... {
wrongFlag = false;
TextAddr.Value = "";
TextBirth.Value = "";
TextSex.Value = "";
TextCheckInfor.Value = "";
Label6.Visible = false;
//textBoxAddr.Text = null;
//textBoxBirth.Text = null;
//textBoxSex.Text = null;
//textBoxCheckInfor.Text = null;
strIDCardNum = TextIDNUM.Value;
if (string.IsNullOrEmpty(strIDCardNum))
...{
//MessageBox.Show("请输入你要查询的身份证号码!");
TextCheckInfor.Value = "请输入你要查询的身份证号码!";
Label6.Visible = true;
TextIDNUM.Focus();
return;
}
else if (strIDCardNum.Length == 15)
...{
//MessageBox.Show("对不起,该软件暂不支持15位的身份证号码!");
TextCheckInfor.Value = "暂不支持15位的身份证号码!";
Label6.Visible = true;
TextIDNUM.Focus();
return;
}
else if (strIDCardNum.Length < 18)
...{
//MessageBox.Show("请检查你输入的身份证号码是否为18位!");
TextCheckInfor.Value = "请检查你输入的号码是否为18位!";
Label6.Visible = true;
TextIDNUM.Focus();
return;
}
else if (strIDCardNum.Substring(2, 2) == "00" || strIDCardNum.Substring(4, 2) == "00")
...{
//MessageBox.Show("请输入有效的身份证号码!");
TextCheckInfor.Value = "请输入有效的身份证号码!";
Label6.Visible = true;
TextIDNUM.Focus();
return;
}
else
...{
for (int i = 0; i <= 16; i++)
...{
if (strIDCardNum[i] < '0' || strIDCardNum[i] > '9')
...{
//MessageBox.Show("您输入的身份证号码中含有非法数字或字符,请检查!");
TextCheckInfor.Value = "号码中含有非法数字或字符,请检查!";
Label6.Visible = true;
TextIDNUM.Focus();
return;
}
}
if ((strIDCardNum[17] >= '0' && strIDCardNum[17] <= '9') || strIDCardNum[17] == 'x' || strIDCardNum[17] == 'X')
...{
GetAddr();
GetBirth();
GetSex();
GetCheckInfor();
}
}
}
private void GetAddr() // 从身份证号码中取出地址码(第1-第6位)
... {
string strAddr = null;
string strProvince, strCity, strTown;
strProvince = strIDCardNum.Substring(0, 2) + "0000";
strCity = strIDCardNum.Substring(0, 4) + "00";
strTown = strIDCardNum.Substring(0, 6);
ConnectionStringSettings settings;
settings = ConfigurationManager.ConnectionStrings["addrConnectionString"];
OleDbConnection conn = new OleDbConnection(settings.ConnectionString + ";Jet OLEDB:database password=icemanstudio2006");
DataSet ds = new DataSet();
conn.Open();
string SQLstr = "SELECT * FROM Province WHERE Code='" + strProvince + "'";
OleDbDataAdapter OleDbDA = new OleDbDataAdapter(SQLstr, conn);
OleDbDA.Fill(ds);
if (ds != null)
...{
DataRowCollection Rows = ds.Tables[0].Rows;
if (Rows.Count <= 0)
...{ //MessageBox.Show("没检索到此记录,请检查你的输入是否有误!");
TextCheckInfor.Value = "无此记录,请检查输入是否有误!";
Label6.Visible = true;
TextIDNUM.Focus();
wrongFlag = true;
return;
}
if (Rows.Count > 0)
...{
strAddr = Rows[0]["Address"].ToString(); //取出省
ds.Clear();
SQLstr = "SELECT * FROM City WHERE Code='" + strCity + "'";
OleDbDA = new OleDbDataAdapter(SQLstr, conn);
OleDbDA.Fill(ds);
if (ds != null)
...{
Rows = ds.Tables[0].Rows;
if (Rows.Count <= 0)
...{ //MessageBox.Show("没检索到此记录,请检查你的输入是否有误!");
TextCheckInfor.Value = "无此记录,请检查输入是否有误!";
Label6.Visible = true;
TextIDNUM.Focus();
wrongFlag = true;
return;
}
if (Rows.Count > 0)
...{
strAddr += Rows[0]["Address"].ToString(); //取出市
ds.Clear();
SQLstr = "SELECT * FROM Town WHERE Code='" + strTown + "'";
OleDbDA = new OleDbDataAdapter(SQLstr, conn);
OleDbDA.Fill(ds);
if (ds != null)
...{
Rows = ds.Tables[0].Rows;
if (Rows.Count <= 0)
...{ //MessageBox.Show("没检索到此记录,请检查你的输入是否有误!");
TextCheckInfor.Value = "无此记录,请检查输入是否有误!";
Label6.Visible = true;
TextIDNUM.Focus();
wrongFlag = true;
return;
}
if (Rows.Count > 0)
...{
string temp;
temp = Rows[0]["Address"].ToString();
strAddr += temp.Trim(' '); //取出省+市+县
ds.Clear();
conn.Close();
TextAddr.Value = strAddr;
}
}
}
}
}
}
}
private void GetBirth() // 从身份证号码中取出生日期码(第7-第14位)
... {
if (wrongFlag) return;
string strYear, strMonth, strDay;
strYear = strIDCardNum.Substring(6, 4);
strMonth = strIDCardNum.Substring(10, 2);
strDay = strIDCardNum.Substring(12, 2);
TextBirth.Value = strYear + "年" + strMonth + "月" + strDay + "日";
}
private void GetSex() // 从身份证号码中取顺序码(第15-第17位)从而判定性别
... {
if (wrongFlag) return;
string strSex;
strSex = strIDCardNum.Substring(16, 1);
if (System.Convert.ToInt16(strSex) % 2 == 0)
...{
TextSex.Value = "女";
}
else
...{
TextSex.Value = "男";
}
}
private void GetCheckInfor() // 从身份证号码中取校验码(第18位)从而判断该身份证号码是否合法
... {
if (wrongFlag) return;
string strCheck;
string[] strWi =...{ "7", "9", "10", "5", "8", "4", "2", "1", "6", "3", "7", "9", "10", "5", "8", "4", "2"};
int i, check = 0;
string strCheckFlag = null;
strCheck = strIDCardNum.Substring(17, 1);
if (strCheck == "X") strCheck = "x";
for (i = 0; i <= 16; i++)
...{
check += System.Convert.ToInt16(strIDCardNum.Substring(i, 1)) * System.Convert.ToInt16(strWi[i]);
check %= 11;
}
switch (check)
...{
case 0: strCheckFlag = "1"; break;
case 1: strCheckFlag = "0"; break;
case 2: strCheckFlag = "x"; break;
case 3: strCheckFlag = "9"; break;
case 4: strCheckFlag = "8"; break;
case 5: strCheckFlag = "7"; break;
case 6: strCheckFlag = "6"; break;
case 7: strCheckFlag = "5"; break;
case 8: strCheckFlag = "4"; break;
case 9: strCheckFlag = "3"; break;
case 10: strCheckFlag = "2"; break;
}
if (strCheck == strCheckFlag)
...{
TextCheckInfor.Value = "校验码正确!应该是合法身份证。";
}
else
...{
TextCheckInfor.Value = "校验码错误!可能是非法身份证。";
}
}
</ script >
</ head >
< body style = " font-size: 20px; " >
< form id = " form1 " runat = " server " >
< div align = " center " >
< table style = " width: 380px; background-color: #dfefef; " >
< tr >
< td >
< table style = " background-color: #d4e6ea " cellspacing = " 10 " cellpadding = " 10 " >
< tr >
< td style = " color: #ff0000; font-weight: bold; font-size: 25px; height: 46px; width: 354px; " >
一个简单的身份证查询程序 < br />
< hr style = " color: #ffffff " />
</ td >
</ tr >
< tr onmouseover = " this.style.backgroundColor='#d0e0ee' " onmouseout = " this.style.backgroundColor='#d4e6ea' " >
< td align = " left " style = " height: 46px; width: 354px; " >
< asp:Label ID = " Label1 " runat = " server " Text = " ID Num: " ></ asp:Label >
< input id = " TextIDNUM " type = " text " maxlength = " 18 " runat = " server " tabindex = " 1 " title = " Your ID number here "
style = " width: 127px " />
< input id = " Submit1 " type = " submit " value = " Search " runat = " server " onserverclick = " Submit_Click "
tabindex = " 2 " />
</ td >
</ tr >
< tr >
< td align = " left " style = " height: 40px; width: 354px; " >
< asp:Label ID = " Label2 " runat = " server " Text = " Address: " ></ asp:Label >
< input id = " TextAddr " type = " text " runat = " server " readonly = " readOnly " style = " width: 193px "
tabindex = " 3 " />
</ td >
</ tr >
< tr >
< td align = " left " style = " height: 40px; width: 354px; " >
< asp:Label ID = " Label3 " runat = " server " Text = " Birthday: " ></ asp:Label >
< input id = " TextBirth " type = " text " runat = " server " readonly = " readOnly " style = " width: 95px "
tabindex = " 4 " />
</ td >
</ tr >
< tr >
< td align = " left " style = " height: 40px; width: 354px; " >
& nbsp; & nbsp; & nbsp; & nbsp; & nbsp;
< asp:Label ID = " Label4 " runat = " server " Text = " Sex: " ></ asp:Label >& nbsp; < input id = " TextSex "
type = " text " runat = " server " readonly = " readOnly " style = " width: 15px " tabindex = " 5 " />
</ td >
</ tr >
< tr >
< td align = " left " style = " height: 40px; width: 354px; " >
& nbsp; & nbsp; & nbsp; & nbsp; < asp:Label ID = " Label5 " runat = " server " Text = " Infor: " ></ asp:Label >
< input id = " TextCheckInfor " type = " text " runat = " server " style = " width: 193px " readonly = " readOnly "
tabindex = " 6 " value = " 在ID NUM输入你要查询的号码! " />
< asp:Label ID = " Label6 " runat = " server " ForeColor = " Red " Text = " * " Visible = " False " ></ asp:Label ></ td >
</ tr >
</ table >
</ td >
</ tr >
</ table >
< br />
Copyright & copy; 2006 - 2007 iceman,All Rights Reserved < br />
< a href = " mailto:happyboylxl@yahoo.com.cn " > send E - mail to me </ a >
</ div >
</ form >
</ body >
</ html >
//Web.config
<!-- 注意: 除了手动编辑此文件以外,您还可以使用 Web 管理工具来
配置应用程序的设置。可以使用 Visual Studio 中的“网站”->“ASP.NET 配置”
选项。
设置和注释的完整列表在
machine.config.comments 中,该文件通常位于 WindowsMicrosoft.NETFrameworkv2.0.xxxxxConfig 中
-->
< configuration >
< appSettings />
< connectionStrings >
< add name ="addrConnectionString" connectionString ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|addr.mdb" providerName ="System.Data.OleDb" />
</ connectionStrings >
< system .web >
<!--
设置 compilation debug="true" 将调试符号插入已编译的页面中。
但由于这会影响性能,因此只在开发过程中将此值设置为 true。
-->
< compilation debug ="false" />
<!--
通过 <authentication> 节可以配置 ASP.NET 使用的
安全身份验证模式,以标识传入的用户。
-->
< authentication mode ="Windows" />
<!--
如果在执行请求的过程中出现未处理的错误,则通过 <customErrors> 节
可以配置相应的处理步骤。具体说来,开发人员通过该节可以
配置要显示的 html 错误页以代替错误堆栈跟踪。
-->
< customErrors mode ="RemoteOnly" defaultRedirect ="GenericErrorPage.htm" >
<!--
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
-->
</ customErrors >
<!--
完全限定客户端重定向的 URL
有些移动设备要求对客户端重定向的 URL 进行完全限定。
-->
< httpRuntime useFullyQualifiedRedirectUrl ="true" />
<!--
指定无 Cookie 的数据字典类型
这将使字典内容出现在本地请求 url 查询字符串中。
这是在无 Cookie 的设备上进行 Forms 身份验证所必需的。
-->
< mobileControls cookielessDataDictionaryType ="System.Web.Mobile.CookielessData" />
< deviceFilters >
< filter name ="isJPhone" compare ="Type" argument ="J-Phone" />
< filter name ="isHTML32" compare ="PreferredRenderingType" argument ="html32" />
< filter name ="isWML11" compare ="PreferredRenderingType" argument ="wml11" />
< filter name ="isCHTML10" compare ="PreferredRenderingType" argument ="chtml10" />
< filter name ="isGoAmerica" compare ="Browser" argument ="Go.Web" />
< filter name ="isMME" compare ="Browser" argument ="Microsoft Mobile Explorer" />
< filter name ="isMyPalm" compare ="Browser" argument ="MyPalm" />
< filter name ="isPocketIE" compare ="Browser" argument ="Pocket IE" />
< filter name ="isUP3x" compare ="Type" argument ="Phone.com 3.x Browser" />
< filter name ="isUP4x" compare ="Type" argument ="Phone.com 4.x Browser" />
< filter name ="isEricssonR380" compare ="Type" argument ="Ericsson R380" />
< filter name ="isNokia7110" compare ="Type" argument ="Nokia 7110" />
< filter name ="prefersGIF" compare ="PreferredImageMIME" argument ="image/gif" />
< filter name ="prefersWBMP" compare ="PreferredImageMIME" argument ="image/vnd.wap.wbmp" />
< filter name ="supportsColor" compare ="IsColor" argument ="true" />
< filter name ="supportsCookies" compare ="Cookies" argument ="true" />
< filter name ="supportsJavaScript" compare ="Javascript" argument ="true" />
< filter name ="supportsVoiceCalls" compare ="CanInitiateVoiceCall" argument ="true" />
</ deviceFilters >
<!--
<globalization requestEncoding="gb2312" responseEncoding="gb2312"/>
-->
</ system.web >
</ configuration >
ASP.NET中数据库应用-身份证信息查询器相关推荐
- C#中数据库应用-身份证信息查询器
//初学C#,写了个简单的身份证信息查询的小程序 //以下为部分源代码 //Visual Studio 2005下通过测试 //Form1.cs using System; using System. ...
- C语言身份证信息查询系统(可验证输入身份证是否合法)
利用C语言做的一个身份证信息查询系统. 原理很简单,也没什么技术难度,城市信息不是很多,就一并加入到了源代码中了. 关于身份证非法的判断还是很有用的,另外以下代码如有需要的可以直接使用或根据需要修改源 ...
- C语言身份证信息查询系统(可验证输入身份证是否合法)【已会】
利用C语言做的一个身份证信息查询系统. 原理很简单,也没什么技术难度,城市信息不是很多,就一并加入到了源代码中了. 关于身份证非法的判断还是很有用的,另外以下代码如有需要的可以直接使用或根据需要修改源 ...
- 如何使用python连接MYsql数据库,实现信息查询小案例
本文主要演示,在python中如何使用pymysql模块,链接MySQL数据库,实现多种条件,用户信息查询功能的小案例. 查询功能: 1.查询所有用户信息 2.查询所有用户姓名 3.查询单个用户工资 ...
- ASP.NET中数据库数据导入Excel并打印
众所周知,WEB上的打印是比较困难的,常见的WEB上打印的方法大概有三种: 1.直接利用IE的打印功能.一般来说,这种方法可以做些扩展,而不是单单的调用javascript:print()这样简单,比 ...
- asp.net中有关URL的信息
[说明]如果你已经熟悉了,请不必往下看,如果你还不熟悉,请做下参考,因为经常在asp.net中需要获取有关URL相关方面的信息,虽然msdn上列出了各种方法,无奈方法和属性太多,没办法一一记住,就做了 ...
- 【Android 逆向】x86 汇编 ( 参考资料 | Intel 官方的文档 | x86 汇编中文文档 | 汇编指令查询器 )
文章目录 一.x86 汇编参考文档 1.Intel 官方的文档 2.常用 x86 汇编文档 3.x86 汇编指令查询器 总结 一.x86 汇编参考文档 下面的所有资料 , 都可以在博客资源 https ...
- Android Api接口的简单实现----身份证信息查询
要实现这个功能,首先就要知道如何通过Http协议访问网络,向网络发送请求,其次了解如何解析JSON或者XML文件. 1.我的身份证查询接口是在聚合数据申请的,完成认证后,你会得到一个KEY,这在之后会 ...
- 在asp.net中读取XML文件信息的4种方法
方法一 :使用XML控件 <% @ Page Language="C#"%> <html> <body> <h3 ...
最新文章
- 历史有资产忘记折旧如何处理_紧急提醒! 500万以下固定资产一次性计入“管理费用”的,会计抓紧调账!...
- 深度复盘:AI 与脑科学的错位
- wdatepicker设置初始时间_滑动条的滑块的初始位置应该放在哪儿?
- android获取网络图片
- 前端学习(1606):数据请求与json-server
- TMS320VC5509片内ADC采集
- 1_统计学习方法概论
- idea打开hierarchy面板
- form表单中的enctype=multipart/form-data什么意思?
- Python程序打包exe文件(pyinstaller)
- php宝宝起名,宝宝在线起名取名大全
- linux/windows对应的软件
- java数据流编辑 kylo,kylo问题总结1
- 100~200以内素数
- Android中的传感器之---陀螺仪传感器
- PHP CURL 使用代理 获取国外资源
- Win7 C盘瘦身 微信文件夹太大WeChat Files
- 第十三届蓝桥杯大赛软件赛省赛(b组c语言)
- 软件企业认定的好处及条件
- 设置input[type=number]不显示箭头
热门文章
- 开创新纪元 筑梦新征程 华云数据南京研发中心乔迁新址
- 【等待事件】等待事件系列(5.1)--Enqueue(队列等待)
- js uniapp开发如何把分钟数转换为多少小时多少分钟
- Python在人工智能时代的作用
- 千禧入队问题(2023版)
- python教学课件PPT Java教学课件ppt以及代码
- java计算机毕业设计人才公寓管理系统源程序+mysql+系统+lw文档+远程调试
- java 去小数方法
- arcgis 合并名字相同的要素_ArcGIS中各种合并要素异同
- Donald Knuth(高德纳) 真的只是一个人么?