zoukankan      html  css  js  c++  java
  • 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;
    
                }
  • 相关阅读:
    haproxy常用配置
    分区命令(大于2TB的分区)
    css基础-2 div布局
    css基础-1
    2.HTML5基本标签
    1.HTML基本结构、头部、注释
    AWK数组
    nginx rewrite 基础
    nginx location详解
    Linux命令练习.ziw
  • 原文地址:https://www.cnblogs.com/adozheng/p/12128477.html
Copyright © 2011-2022 走看看