验证二代身份证真假
来源:互联网 发布:网络优化课程 编辑:程序博客网 时间:2024/04/28 01:58
看了几天的视频,做了一个小程序,查询你的二代身份证是否是真的
源代码如下:
namespace 验证身份证算法
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnview_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox1.ToString()))
{
MessageBox.Show("号码不能为空");
textBox1.Focus();
return;
}
if (textBox1.TextLength !=18 )
{
MessageBox.Show("输入的号码长度为18位");
return;
}
int sum = 0;
string checkwei = "10x98765432";
string ID = textBox1.Text;
string number17 = ID.Substring(0, 17);
string number18 = ID.Substring(17);
int[] Wquan = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
for (int i = 0; i < 17; i++)
{
sum = sum + Wquan[i] * Convert.ToInt32(number17[i].ToString());
}
string result = checkwei[sum % 11].ToString();
if (result.Equals(number18,StringComparison.OrdinalIgnoreCase))
{
MessageBox.Show("身份证合法");
this.pic朱逢娅.Visible = true;
}
else
{
MessageBox.Show("身份证不合法");
}
int 年龄 = Convert.ToInt32(textBox1.Text.Substring(6,4 ));
int year = DateTime.Now.Year - 年龄;
if (year <18)
{
this.pic朱逢娅.Visible = false;
MessageBox.Show("年龄太小回家看动画片吧");
}
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar < '0' || e.KeyChar > '9')
{
e.Handled = true;
}
if (e.KeyChar ==8)
{
e.Handled = false;
}
//440524188001010014
//4405,2418,8001,0100,14
}
private void btnExit_Click(object sender, EventArgs e)
{
this.Close();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
pic朱逢娅.Visible = false;
}
- 验证二代身份证真假
- PHP验证二代身份证
- Js 二代身份证验证
- php不用正则验证真假身份证 身份证号码验证
- C#读取二代身份证
- C#读取二代身份证
- .net读取二代身份证
- 读取二代身份证
- 简易二代身份证校验
- 关于二代身份证照片回执
- 二代身份证的尺寸大小
- 二代身份证读取操作类
- 二代身份证读卡器的二次开发
- 六盘水购买二代身份证x
- asp.net读取二代身份证
- Android 二代身份证精确校验
- 二代身份证上的信息
- C# 国腾 二代身份证 扫描身份证信息
- sql server远程访问设置
- Linux mount/umount
- 快速排序
- ioremap_nocache函数说明
- (10) 使用Spring的注解方式实现AOP入门 以及 细节
- 验证二代身份证真假
- tar解压与压缩
- zip 和 unzip
- C#中实现三层架构
- rar 的用法
- js中var的作用
- chcon应用举例
- Android实现程序前后台切换效果
- argc 和 argv 详解