Exemplo n.º 1
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            string res = "0";

            try
            {
                switch ((EIdType)int.Parse(values[0].ToString()))
                {
                case EIdType.SFZ:
                    if (!RuleHelper.IsID(EIdType.SFZ, values[1]))
                    {
                        res = "1";
                    }
                    break;

                case EIdType.GATSFZ:
                    if (!RuleHelper.IsID(EIdType.GATSFZ, values[1]))
                    {
                        res = "2";
                    }
                    break;

                case EIdType.HZ:
                    if (!RuleHelper.IsID(EIdType.HZ, values[1]))
                    {
                        res = "3";
                    }
                    break;

                case EIdType.HKB:
                    if (!RuleHelper.IsID(EIdType.HKB, values[1]))
                    {
                        res = "4";
                    }
                    break;

                case EIdType.JGZ:
                    if (!RuleHelper.IsID(EIdType.JGZ, values[1]))
                    {
                        res = "5";
                    }
                    break;

                case EIdType.ZZJGDM:
                    if (!RuleHelper.IsID(EIdType.ZZJGDM, values[1]))
                    {
                        res = "6";
                    }
                    break;

                case EIdType.YYZZ:
                    if (!RuleHelper.IsID(EIdType.YYZZ, values[1]))
                    {
                        res = "7";
                    }
                    break;

                case EIdType.QT:
                    if (!RuleHelper.IsID(EIdType.QT, values[1]))
                    {
                        res = "99";
                    }
                    break;

                default:
                    break;
                }
            }
            catch (Exception)
            {
            }
            return(res);
        }
        private void CheckId(String table, String id, String zjlx, String zjh, String name)
        {
            bool IsSuccess = true;

            switch ((EIdType)int.Parse(zjlx))
            {
            case EIdType.SFZ:
                if (!RuleHelper.IsID(EIdType.SFZ, zjh))
                {
                    IsSuccess = false;
                }
                break;

            case EIdType.GATSFZ:
                if (!RuleHelper.IsID(EIdType.GATSFZ, zjh))
                {
                    IsSuccess = false;
                }
                break;

            case EIdType.HZ:
                if (!RuleHelper.IsID(EIdType.HZ, zjh))
                {
                    IsSuccess = false;
                }
                break;

            case EIdType.HKB:
                if (!RuleHelper.IsID(EIdType.HKB, zjh))
                {
                    IsSuccess = false;
                }
                break;

            case EIdType.JGZ:
                if (!RuleHelper.IsID(EIdType.JGZ, zjh))
                {
                    IsSuccess = false;
                }
                break;

            case EIdType.ZZJGDM:
                if (!RuleHelper.IsID(EIdType.ZZJGDM, zjh))
                {
                    IsSuccess = false;
                }
                break;

            case EIdType.YYZZ:
                if (!RuleHelper.IsID(EIdType.YYZZ, zjh))
                {
                    IsSuccess = false;
                }
                break;

            case EIdType.QT:
                if (!RuleHelper.IsID(EIdType.QT, zjh))
                {
                    IsSuccess = false;
                }
                break;

            default:
                break;
            }

            if (!IsSuccess)
            {
                ErrorMsg.Add(table + "表中," + id + "的" + name + "证件类型与证件号格式错误");
            }
        }
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            // 非空验证
            NotEmptyValidationRule notEmptyValidation = new NotEmptyValidationRule();

            if (!notEmptyValidation.Validate(value, cultureInfo).IsValid)
            {
                return(notEmptyValidation.Validate(value, cultureInfo));
            }

            //if (value.ToString() == "0") return ValidationResult.ValidResult;
            ValidationResult validationResult = new ValidationResult(true, null);

            switch ((EIdType)int.Parse(Params.Data.ToString()))
            {
            case EIdType.SFZ:
                if (!RuleHelper.IsID(EIdType.SFZ, value))
                {
                    validationResult = new ValidationResult(false, "身份证号格式错误");
                }
                break;

            case EIdType.GATSFZ:
                if (!RuleHelper.IsID(EIdType.GATSFZ, value))
                {
                    validationResult = new ValidationResult(false, "港澳台身份证号格式错误");
                }
                break;

            case EIdType.HZ:
                if (!RuleHelper.IsID(EIdType.HZ, value))
                {
                    validationResult = new ValidationResult(false, "护照格式错误");
                }
                break;

            case EIdType.HKB:
                if (!RuleHelper.IsID(EIdType.HKB, value))
                {
                    validationResult = new ValidationResult(false, "户口簿格式错误");
                }
                break;

            case EIdType.JGZ:
                if (!RuleHelper.IsID(EIdType.JGZ, value))
                {
                    validationResult = new ValidationResult(false, "军官证(士兵证)号格式错误");
                }
                break;

            case EIdType.ZZJGDM:
                if (!RuleHelper.IsID(EIdType.ZZJGDM, value))
                {
                    validationResult = new ValidationResult(false, "组织机构代码格式错误");
                }
                break;

            case EIdType.YYZZ:
                if (!RuleHelper.IsID(EIdType.YYZZ, value))
                {
                    validationResult = new ValidationResult(false, "营业执照格式错误");
                }
                break;

            case EIdType.QT:
                if (!RuleHelper.IsID(EIdType.QT, value))
                {
                    validationResult = new ValidationResult(false, "其它号码格式错误");
                }
                break;

            default:
                break;
            }
            return(validationResult);
        }