• C#--添加对象前


    验证是否符合通用验证类的要求

    调用通用验证类
    这里写图片描述


    通过数据验证
    这里写图片描述

    这里写图片描述


    验证身份证号是否存在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;
    
                }
  • 相关阅读:
    HTML DOM clearInterval() 方法
    clone() 方法
    Java EE 6体系结构的变革
    我们看人的眼光
    NetBeans 时事通讯(刊号 # 44 Feb 10, 2009)
    jBPM 与项目的适用性探讨
    Java EE 6体系结构的变革
    jBPM 与项目的适用性探讨
    系分又挂了 :)
    NetBeans 时事通讯(刊号 # 44 Feb 10, 2009)
  • 原文地址:https://www.cnblogs.com/adozheng/p/12128477.html
Copyright © 2020-2023  润新知