//Web版的身份证信息查询
//Default.aspx
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default"
UICulture="zh-CN"Culture="zh-CN"%>

<%@ImportNamespace="System.Data"%>
<%@ImportNamespace="System.Data.OleDb"%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>身份证查询-Madebyiceman</title>

<scriptlanguage="C#"runat="server">
publicstringstrIDCardNum;
publicboolwrongFlag=false;
privatevoidPage_Load(Objectsender,EventArgse)

...{
TextIDNUM.Focus();
}
privatevoidSubmit_Click(Objectsender,EventArgse)

...{
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;
}
elseif(strIDCardNum.Length==15)

...{
//MessageBox.Show("对不起,该软件暂不支持15位的身份证号码!");
TextCheckInfor.Value="暂不支持15位的身份证号码!";
Label6.Visible=true;
TextIDNUM.Focus();
return;
}
elseif(strIDCardNum.Length<18)

...{
//MessageBox.Show("请检查你输入的身份证号码是否为18位!");
TextCheckInfor.Value="请检查你输入的号码是否为18位!";
Label6.Visible=true;
TextIDNUM.Focus();
return;
}
elseif(strIDCardNum.Substring(2,2)=="00"||strIDCardNum.Substring(4,2)=="00")

...{
//MessageBox.Show("请输入有效的身份证号码!");
TextCheckInfor.Value="请输入有效的身份证号码!";
Label6.Visible=true;
TextIDNUM.Focus();
return;
}
else

...{
for(inti=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();
}
}
}
privatevoidGetAddr()//从身份证号码中取出地址码(第1-第6位)

...{
stringstrAddr=null;
stringstrProvince,strCity,strTown;

strProvince=strIDCardNum.Substring(0,2)+"0000";
strCity=strIDCardNum.Substring(0,4)+"00";
strTown=strIDCardNum.Substring(0,6);

ConnectionStringSettingssettings;
settings=ConfigurationManager.ConnectionStrings["addrConnectionString"];
OleDbConnectionconn=newOleDbConnection(settings.ConnectionString+";JetOLEDB:databasepassword=icemanstudio2006");
DataSetds=newDataSet();

conn.Open();

stringSQLstr="SELECT*FROMProvinceWHERECode='"+strProvince+"'";
OleDbDataAdapterOleDbDA=newOleDbDataAdapter(SQLstr,conn);
OleDbDA.Fill(ds);

if(ds!=null)

...{
DataRowCollectionRows=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*FROMCityWHERECode='"+strCity+"'";
OleDbDA=newOleDbDataAdapter(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*FROMTownWHERECode='"+strTown+"'";
OleDbDA=newOleDbDataAdapter(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)

...{
stringtemp;
temp=Rows[0]["Address"].ToString();
strAddr+=temp.Trim('');//取出省+市+县
ds.Clear();
conn.Close();

TextAddr.Value=strAddr;
}
}
}
}
}
}
}

privatevoidGetBirth()//从身份证号码中取出生日期码(第7-第14位)

...{
if(wrongFlag)return;

stringstrYear,strMonth,strDay;

strYear=strIDCardNum.Substring(6,4);
strMonth=strIDCardNum.Substring(10,2);
strDay=strIDCardNum.Substring(12,2);
TextBirth.Value=strYear+"年"+strMonth+"月"+strDay+"日";
}

privatevoidGetSex()//从身份证号码中取顺序码(第15-第17位)从而判定性别

...{
if(wrongFlag)return;

stringstrSex;

strSex=strIDCardNum.Substring(16,1);
if(System.Convert.ToInt16(strSex)%2==0)

...{
TextSex.Value="女";
}
else

...{
TextSex.Value="男";
}
}

privatevoidGetCheckInfor()//从身份证号码中取校验码(第18位)从而判断该身份证号码是否合法

...{
if(wrongFlag)return;

stringstrCheck;

string[]strWi=...{"7","9","10","5","8","4","2","1","6","3","7","9","10","5","8","4","2","1"};
inti,check=0;
stringstrCheckFlag=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)

...{
case0:strCheckFlag="1";break;
case1:strCheckFlag="0";break;
case2:strCheckFlag="x";break;
case3:strCheckFlag="9";break;
case4:strCheckFlag="8";break;
case5:strCheckFlag="7";break;
case6:strCheckFlag="6";break;
case7:strCheckFlag="5";break;
case8:strCheckFlag="4";break;
case9:strCheckFlag="3";break;
case10:strCheckFlag="2";break;
}
if(strCheck==strCheckFlag)

...{
TextCheckInfor.Value="校验码正确!应该是合法身份证。";
}
else

...{
TextCheckInfor.Value="校验码错误!可能是非法身份证。";
}
}
</script>

</head>
<bodystyle="font-size:20px;">
<formid="form1"runat="server">
<divalign="center">
<tablestyle="width:380px;background-color:#dfefef;">
<tr>
<td>
<tablestyle="background-color:#d4e6ea"cellspacing="10"cellpadding="10">
<tr>
<tdstyle="color:#ff0000;font-weight:bold;font-size:25px;height:46px;width:354px;">
一个简单的身份证查询程序<br/>
<hrstyle="color:#ffffff"/>
</td>
</tr>
<tronmouseover="this.style.backgroundColor='#d0e0ee'"onmouseout="this.style.backgroundColor='#d4e6ea'">
<tdalign="left"style="height:46px;width:354px;">
<asp:LabelID="Label1"runat="server"Text="IDNum:"></asp:Label>
<inputid="TextIDNUM"type="text"maxlength="18"runat="server"tabindex="1"title="YourIDnumberhere"
style="width:127px"/>
<inputid="Submit1"type="submit"value="Search"runat="server"onserverclick="Submit_Click"
tabindex="2"/>
</td>
</tr>
<tr>
<tdalign="left"style="height:40px;width:354px;">
<asp:LabelID="Label2"runat="server"Text="Address:"></asp:Label>
<inputid="TextAddr"type="text"runat="server"readonly="readOnly"style="width:193px"
tabindex="3"/>
</td>
</tr>
<tr>
<tdalign="left"style="height:40px;width:354px;">
<asp:LabelID="Label3"runat="server"Text="Birthday:"></asp:Label>
<inputid="TextBirth"type="text"runat="server"readonly="readOnly"style="width:95px"
tabindex="4"/>
</td>
</tr>
<tr>
<tdalign="left"style="height:40px;width:354px;">
<asp:LabelID="Label4"runat="server"Text="Sex:"></asp:Label> <inputid="TextSex"
type="text"runat="server"readonly="readOnly"style="width:15px"tabindex="5"/>
</td>
</tr>
<tr>
<tdalign="left"style="height:40px;width:354px;">
<asp:LabelID="Label5"runat="server"Text="Infor:"></asp:Label>
<inputid="TextCheckInfor"type="text"runat="server"style="width:193px"readonly="readOnly"
tabindex="6"value="在IDNUM输入你要查询的号码!"/>
<asp:LabelID="Label6"runat="server"ForeColor="Red"Text="*"Visible="False"></asp:Label></td>
</tr>
</table>
</td>
</tr>
</table>
<br/>
Copyright©2006-2007iceman,AllRightsReserved<br/>
<ahref="mailto:happyboylxl@yahoo.com.cn">sendE-mailtome</a>
</div>
</form>
</body>
</html>
//Web.config
<?xmlversion="1.0"encoding="utf-8"?>

<!--注意:除了手动编辑此文件以外,您还可以使用Web管理工具来
配置应用程序的设置。可以使用VisualStudio中的“网站”->“ASP.NET配置”
选项。
设置和注释的完整列表在
machine.config.comments中,该文件通常位于WindowsMicrosoft.NETFrameworkv2.0.xxxxxConfig中
-->

<configuration>

<appSettings/>
<connectionStrings>
<addname="addrConnectionString"connectionString="Provider=Microsoft.Jet.OLEDB.4.0;DataSource=|DataDirectory|addr.mdb"providerName="System.Data.OleDb"/>
</connectionStrings>

<system.web>

<!--
设置compilationdebug="true"将调试符号插入已编译的页面中。
但由于这会影响性能,因此只在开发过程中将此值设置为true。
-->
<compilationdebug="false"/>


<!--
通过<authentication>节可以配置ASP.NET使用的
安全身份验证模式,以标识传入的用户。
-->
<authenticationmode="Windows"/>


<!--
如果在执行请求的过程中出现未处理的错误,则通过<customErrors>节
可以配置相应的处理步骤。具体说来,开发人员通过该节可以
配置要显示的html错误页以代替错误堆栈跟踪。
-->
<customErrorsmode="RemoteOnly"defaultRedirect="GenericErrorPage.htm">
<!--
<errorstatusCode="403"redirect="NoAccess.htm"/>
<errorstatusCode="404"redirect="FileNotFound.htm"/>
-->
</customErrors>


<!--
完全限定客户端重定向的URL
有些移动设备要求对客户端重定向的URL进行完全限定。
-->
<httpRuntimeuseFullyQualifiedRedirectUrl="true"/>


<!--
指定无Cookie的数据字典类型
这将使字典内容出现在本地请求url查询字符串中。
这是在无Cookie的设备上进行Forms身份验证所必需的。
-->
<mobileControlscookielessDataDictionaryType="System.Web.Mobile.CookielessData"/>


<deviceFilters>
<filtername="isJPhone"compare="Type"argument="J-Phone"/>
<filtername="isHTML32"compare="PreferredRenderingType"argument="html32"/>
<filtername="isWML11"compare="PreferredRenderingType"argument="wml11"/>
<filtername="isCHTML10"compare="PreferredRenderingType"argument="chtml10"/>
<filtername="isGoAmerica"compare="Browser"argument="Go.Web"/>
<filtername="isMME"compare="Browser"argument="MicrosoftMobileExplorer"/>
<filtername="isMyPalm"compare="Browser"argument="MyPalm"/>
<filtername="isPocketIE"compare="Browser"argument="PocketIE"/>
<filtername="isUP3x"compare="Type"argument="Phone.com3.xBrowser"/>
<filtername="isUP4x"compare="Type"argument="Phone.com4.xBrowser"/>
<filtername="isEricssonR380"compare="Type"argument="EricssonR380"/>
<filtername="isNokia7110"compare="Type"argument="Nokia7110"/>
<filtername="prefersGIF"compare="PreferredImageMIME"argument="image/gif"/>
<filtername="prefersWBMP"compare="PreferredImageMIME"argument="image/vnd.wap.wbmp"/>
<filtername="supportsColor"compare="IsColor"argument="true"/>
<filtername="supportsCookies"compare="Cookies"argument="true"/>
<filtername="supportsJavaScript"compare="Javascript"argument="true"/>
<filtername="supportsVoiceCalls"compare="CanInitiateVoiceCall"argument="true"/>
</deviceFilters>
<!--
<globalizationrequestEncoding="gb2312"responseEncoding="gb2312"/>

-->

</system.web>
</configuration>
分享到:
相关推荐
5-3 ASP.NET如何结合数据库 5-3-1关于ADO.NET 5-3-2与数据库无关的DataSet DataSet的内容 DateSet的来源(自行建立) DateSet的来源(取用数据库) 控制项结合DataSet 回存至来源 5-3-3...
ASP.NET作为微软开发的Web应用程序框架,提供了强大的开发工具和丰富的库资源,使得开发学籍信息管理系统变得更加高效和便捷。该系统采用MVC(Model-View-Controller)架构模式,使得代码结构清晰,易于维护和扩展。...
asp.net,数据库sqlserver,开发工具用Microsoft Visual Studio 通过对用户需求的分析,本系统的功能主要包括两块,前台用户操作及后台管理。各个功能的具体描述如下: 前台用户操作界面功能主要有:专家查询、预约...
在标题提到的"asp.net缓存应用实例"中,我们可以看到一系列实用功能的实现,如天气预报、IP地址查询、手机号码归属地查询、邮编查询、身份证查询以及北京公交和全国火车时刻表查询。这些功能的实现都充分利用了ASP...
【ASP.NET 图书信息管理系统】是一个基于C#编程语言,利用ASP.NET技术和SQL Server 2005数据库的三层架构实现的图书管理平台。该系统主要用于处理图书馆的日常借阅和管理工作,为管理员和读者提供便捷的信息服务。 ...
查询结果部分,系统可能采用了数据库查询技术,比如SQL语言,根据用户输入的条件(如姓名、身份证号等)从后台数据库检索相关信息,然后使用ASP.NET的数据绑定技术将结果显示在网页上。此外,可能还涉及到分页、排序...
在这个系统中,Access数据库用于存储学生信息、缴费记录等数据,与ASP.NET应用程序进行交互,实现数据的增删改查操作。 系统可能采用以下技术架构: 1. **ASP.NET MVC(Model-View-Controller)**:这是一种设计...
这个“ASP.NET (C#) 课件”很可能是为了帮助学习者深入理解和掌握ASP.NET平台以及C#编程语言在Web开发中的应用。 1. ASP.NET概述:ASP.NET是.NET Framework的一部分,它提供了多种服务,如页面生命周期管理、状态...
通过分析和理解这个身份证验证示例源码,开发者可以学习到如何在 ASP.NET 中进行数据验证、用户输入处理以及错误处理等重要技能,这对于构建更安全、更可靠的Web应用至关重要。同时,这也可以作为一个基础,进一步...
1. ASP.NET框架:ASP.NET是微软提供的一个用于构建Web应用程序的开发框架,它包含了丰富的服务器控件、事件驱动模型和自动页面生命周期管理,使得开发者能够快速、高效地创建动态网站和Web应用,如本例中的人事管理...
ASP.NET学籍管理系统是一款利用微软的ASP.NET技术与SQL Server数据库相结合开发的高效、稳定的学生信息管理平台。这个系统旨在简化学校对学生学籍信息的管理,提高数据处理效率,确保数据的安全性和准确性。 首先,...
【ASP.NET运动员档案管理系统】 ASP.NET是微软推出的一种用于构建Web应用程序的开发框架,...它结合了数据库操作、用户认证、数据呈现和用户体验优化等多个方面的知识,展示了ASP.NET在实际业务场景中的强大应用能力。
【VB+ASP.NET图书管理系统】是一个综合性的信息系统,主要用于实现图书馆内部的自动化管理。这个系统结合了两种编程语言——Visual Basic (VB) 和 ASP.NET,它们都是微软开发的编程工具,用于构建高效、用户友好的...
在"电信缴费系统"这个场景中,ASP.NET 技术被用来实现一系列与电信服务相关的功能,包括新客户登记、客户缴费、话费清单查询、交费清单记录以及模拟消费等。 1. **新客户登记**: 新客户登记模块是系统的基础部分...
ASP.NET某店POS积分管理系统是基于.NET框架的Web应用程序,主要目标是实现商店销售点(Point of Sale, POS)的积分管理功能,并且包括会员信息的创建与管理。这个系统适用于零售业,可以帮助商家有效跟踪顾客消费,...
2. 学习ASP.NET MVC和ASP.NET Core MVC,理解模型-视图-控制器的设计模式。 3. 掌握ASP.NET中的依赖注入,提升代码的可测试性和可维护性。 4. 学习使用Visual Studio或Visual Studio Code等IDE,提升开发效率。 5. ...
总的来说,图书馆管理系统ASP.NET结合了ASP.NET的高效开发环境和数据库的强大功能,实现了图书馆管理的信息化、自动化,极大地提升了图书管理的效率。对于开发者来说,掌握ASP.NET技术并应用于图书馆管理系统开发,...
在这个"asp.net图书管理系统"项目中,我们可以深入探讨ASP.NET在实际应用场景中的运用。 1. **系统架构** 图书管理系统通常采用三层架构设计,包括表现层(UI)、业务逻辑层(BLL)和数据访问层(DAL)。表现层...
表示层(PL):为客户提供用于交互的应用服务图形界面,帮助用户理解和高效地定位应用服务,呈现业务逻辑层中传递的数据,用ASP.NET 页面来实现。 二、ASP.NET 三层架构应用实现 使用 ASP.NET 可以方便地构建 B/S ...
本例展示了如何在ASP.NET中实现从Excel文件导入数据到数据库的过程。主要涉及到了以下技术点: - 使用`FileUpload`控件让用户上传Excel文件。 - 使用ADO.NET中的`OleDbConnection`和`OleDbDataAdapter`等组件读取...