Esempio n. 1
0
        public static bool IsValidEan(string Value, BarcodeEanType EanType, out string ErrMsgIs)
        {
            ErrMsgIs = "";

            int FixedLength = 0;

            if (EanType == BarcodeEanType.Ean8)
            {
                FixedLength = 8;
            }
            else if (EanType == BarcodeEanType.Ean13)
            {
                FixedLength = 13;
            }
            else
            {
                ErrMsgIs = string.Format("잘못된 EanType:{0}입니다.", EanType);
                return(false);
            }

            if (Value.Length != FixedLength)
            {
                ErrMsgIs = string.Format("길이는 {0}자리만 허용됩니다.", FixedLength);
                return(false);
            }

            string ValueWithoutCheck = Value.Substring(0, FixedLength - 1);

            string CheckDigitRight = CValid.GetBarcodeCheckDigit(ValueWithoutCheck, out ErrMsgIs);

            if (string.IsNullOrEmpty(CheckDigitRight))
            {
                return(false);
            }

            string CheckDigit = Value.Substring(FixedLength - 1, 1);

            if (CheckDigitRight != CheckDigit)
            {
                ErrMsgIs = string.Format("잘못된 검증번호:{0}", CheckDigit);
                return(false);
            }


            return(true);
        }
Esempio n. 2
0
        public static bool IsBarcode(string Value)
        {
            if (string.IsNullOrEmpty(Value))
            {
                return(false);
            }

            string ValueExcept = Value.Substring(0, Value.Length - 1);
            string CheckDigit  = Value[Value.Length - 1].ToString();

            string ErrMsgIs;
            string CheckDigitRight = CValid.GetBarcodeCheckDigit(ValueExcept, out ErrMsgIs);

            if (string.IsNullOrEmpty(CheckDigitRight))
            {
                return(false);
            }

            return(CheckDigit == CheckDigitRight.ToString());
        }