Example #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            string   cardNo = textBox1.Text.Trim();
            DateTime?birth  = IdCardHelper.GetBirthDay(cardNo);
            double   age    = IdCardHelper.GetAge(cardNo);
            var      sex    = IdCardHelper.GetGender(cardNo);

            textBox2.Text = $"{birth:yyyy-MM-dd},{age},{sex}";
        }
Example #2
0
        public void GetIdCardModelTest()
        {
            var model = IdCardHelper.GetIdCardModel("230606198812310574");

            model.ShouldNotBeNull();
            model.Sex.ShouldBe((sbyte)1);
            model.Birthday.AddYears(model.Age).ShouldBeLessThanOrEqualTo(DateTime.Today);
            model.IdCard.ShouldBe("230606198812310574");
            model = IdCardHelper.GetIdCardModel("341321199808080383");
            model.ShouldBeNull();
        }
Example #3
0
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         string cardNo = textBox1.Text.Trim();
         textBox2.Text = IdCardHelper.TransFToS(cardNo);
     }
     catch (Exception ex)
     {
         textBox2.Text = ex.Message;
     }
 }
Example #4
0
 protected override ValidationResult IsValid(object value, ValidationContext validationContext)
 {
     if ((string)value != string.Empty)
     {
         var isValid = IdCardHelper.CheckIDCard(value.ToString());
         if (!isValid)
         {
             var formatErrorMessage = FormatErrorMessage(validationContext.DisplayName);
             var memberNames        = new List <string> {
                 validationContext.MemberName
             };
             return(new ValidationResult(formatErrorMessage, memberNames));
         }
     }
     return(ValidationResult.Success);
 }
Example #5
0
 private void button4_Click(object sender, EventArgs e)
 {
     textBox2.Text = "" + IdCardHelper.IsIdCard(textBox1.Text.Trim());
 }
Example #6
0
        /// <summary>
        /// 合伙人信息完善
        /// </summary>
        /// <param name="model"></param>
        /// <param name="Code"></param>
        /// <returns></returns>
        public ActionResult SubmitUser(Ho_PartnerUser nmodel, string Code)
        {
            string realCode = DESEncrypt.Decrypt(CookieHelper.GetCookie("WebCode"));

            if (StringHelper.IsNullOrEmpty(Code) || Code != realCode)
            {
                return(Content(new JsonMessage {
                    Success = false, Code = "0", Message = "验证码不正确"
                }.ToString()));
            }
            if (StringHelper.IsNullOrEmpty(nmodel.CardCode) || !IdCardHelper.CheckIDCard(nmodel.CardCode))
            {
                return(Content(new JsonMessage {
                    Success = false, Code = "0", Message = "身份证号码不正确"
                }.ToString()));
            }
            //验证手机号码和身份证的唯一
            IDatabase database  = DataFactory.Database();
            int       codecount = database.FindCount <Ho_PartnerUser>(" and CardCode = '" + nmodel.CardCode + "'");

            if (codecount > 0)
            {
                return(Content(new JsonMessage {
                    Success = false, Code = "0", Message = "身份证号码已存在"
                }.ToString()));
            }
            int Mobile = database.FindCount <Ho_PartnerUser>(" and Mobile = '" + nmodel.Mobile + "'");

            if (Mobile > 0)
            {
                return(Content(new JsonMessage {
                    Success = false, Code = "0", Message = "手机号码已存在"
                }.ToString()));
            }
            WebData wbll  = new WebData();
            var     model = wbll.GetUserInfo(Request);

            model.Birthday   = Convert.ToDateTime(IdCardHelper.GetBrithdayFromIdCard(nmodel.CardCode));
            model.Sex        = IdCardHelper.GetSexFromIdCard(nmodel.CardCode);
            model.CardCode   = nmodel.CardCode;
            model.CodeImg1   = nmodel.CodeImg1;
            model.CodeImg2   = nmodel.CodeImg2;
            model.Mobile     = nmodel.Mobile;
            model.ModifyTime = DateTime.Now;
            model.Name       = nmodel.Name;
            model.Status     = 2;
            model.StatusStr  = "未认证";
            model.CreatTime  = DateTime.Now; //正式申请成为合伙人
            model.Modify(model.Number);

            int result = database.Update(model);

            if (result > 0)
            {
                return(Content(new JsonMessage {
                    Success = true, Code = "1", Message = "提交成功"
                }.ToString()));
            }
            else
            {
                return(Content(new JsonMessage {
                    Success = false, Code = "0", Message = "提交失败"
                }.ToString()));
            }
        }