C#--添加对象前
来源:互联网 发布:天津二手房成交量数据 编辑:程序博客网 时间:2024/05/21 17:31
验证是否符合通用验证类的要求
调用通用验证类
通过数据验证
验证身份证号是否存在SQL
如果SQL有了身份证信息新增的身份证号不能是重复的
编写查询身份证方法
/// <summary> /// 查询身份证是否已经存在 /// </summary> /// <param name="idcard"></param> /// <returns></returns> public bool IsIdCardExisted(string idcard) { string sql = "Select count(*) from Students where StudentIdNo={0}"; 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)) { MessageBox.Show("身份证号和出生日期不匹配", "验证提示"); this.txtStuIdNo.Focus(); this.txtStuIdNo.SelectAll(); return; }
阅读全文
0 0
- C#--添加对象前
- C#--添加对象之前的数据验证
- effective c++(04)之对象使用前初始化
- 确定对象试用前已经初始化(Effective C++_4)
- Effective C++,rule 4,确保对象使用前被初始化
- 字符串数字前添加*
- android 添加前景色
- object-c编程tips-给类对象添加属性
- Objective-C 给分类添加属性——关联对象
- 《Effective C++》学习笔记条款04 确定对象被使用前被初始化
- 《Effect C++》学习------条款04:确定对象被使用前以先被初始化
- (c#)AutoCAD二次开发,运行时,出现“对象的当前状态使该操作无效”
- combobox绑定前添加一项
- VC菜单前添加图标
- c++-前向声明
- 【C++】前记
- C-0-课前
- 定义一个StringBuffer类对象,然后通过append()方法想对象中添加26个小写字母,要求每次只添加一次,共添加26次,然后按照逆序的方式输出,并且可以删除前5个字符。
- 多个css合在一起写
- SpringMVC+FreeMarker的使用
- HBase-HMaster源码分析
- 实现随机10个20至200之间的随机数
- KMP(2)-KMP算法原理与匹配部分.
- C#--添加对象前
- 【Cocos2d-x】开发实战-Cococs2d-x中的菜单
- 手机归属地查询----自学了这么久总算可以不copy他人代码写出一款APP了 虽然有点丑
- shiro_spring.xml
- 位运算符
- 最完整的Windows下React Native开发环境搭建与第一个程序HelloWorld
- shiro_web.xml
- shiro+spring.pom
- shiro+spring认证