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;
    
                }
  • 相关阅读:
    Oracle学习笔记<5>
    Oracle学习笔记<4>
    fabric动态获取远程目录列表
    fabric查看本地与远程主机信息
    fabric安装使用
    pexpect实现远程操作
    pexpect的pxssh类实现远程操作
    Most Distant Point from the Sea
    Art Gallery
    Rotating Scoreboard(半平面交模板题)
  • 原文地址:https://www.cnblogs.com/adozheng/p/12128477.html
Copyright © 2011-2022 走看看