Exemple #1
0
        public static bool IsValid(string nip)
        {
            if ((nip = Normalize(nip)) == null)
            {
                return(false);
            }

            string cc  = nip.Substring(0, 2).ToUpper();
            string num = nip.Substring(2).ToUpper();

            if (!map.ContainsKey(cc))
            {
                return(false);
            }

            Regex re = new Regex(map[cc]);

            if (!re.IsMatch(nip))
            {
                return(false);
            }

            if (cc.Equals("PL"))
            {
                return(NIP.IsValid(num));
            }

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Pobranie sufiksu ścieżki
        /// </summary>
        /// <param name="type">typ numeru identyfikującego firmę</param>
        /// <param name="number">numer określonego typu</param>
        /// <returns>fragment ścieżki lub null</returns>
        private string GetPathSuffix(Number type, string number)
        {
            string path = "";

            if (type.Equals(Number.NIP))
            {
                if (!NIP.IsValid(number))
                {
                    LastError = "Numer NIP jest nieprawidłowy";
                    return(null);
                }

                path = "nip/" + NIP.Normalize(number);
            }
            else if (type.Equals(Number.REGON))
            {
                if (!REGON.IsValid(number))
                {
                    LastError = "Numer REGON jest nieprawidłowy";
                    return(null);
                }

                path = "regon/" + REGON.Normalize(number);
            }
            else if (type.Equals(Number.KRS))
            {
                if (!KRS.IsValid(number))
                {
                    LastError = "Numer KRS jest nieprawidłowy";
                    return(null);
                }

                path = "krs/" + KRS.Normalize(number);
            }
            else if (type.Equals(Number.EUVAT))
            {
                if (!EUVAT.IsValid(number))
                {
                    LastError = "Numer EU VAT ID jest nieprawidłowy";
                    return(null);
                }

                path = "euvat/" + EUVAT.Normalize(number);
            }
            else
            {
                LastError = "Nieprawidłowy typ numeru";
                return(null);
            }

            return(path);
        }
        public static bool IsValid(string nip)
        {
            if ((nip = Normalize(nip)) == null)
            {
                return(false);
            }

            string cc  = nip.Substring(0, 2).ToUpper();
            string num = nip.Substring(2).ToUpper();

            if (cc.Equals("PL"))
            {
                return(NIP.IsValid(num));
            }

            return(true);
        }