예제 #1
0
        public bool CheckControlSum(Pesel p)
        {
            // a+3b+7c+9d+e+3f+7g+9h+i+3j+k
            /* var controlSum =
                 (GetAnyNumber.GetAnyDigitFromPesel(p, 0, 1) +
                 3*GetAnyNumber.GetAnyDigitFromPesel(p, 1, 1) +
                 7*GetAnyNumber.GetAnyDigitFromPesel(p, 2, 1) +
                 9*GetAnyNumber.GetAnyDigitFromPesel(p, 3, 1) +
                 GetAnyNumber.GetAnyDigitFromPesel(p, 4, 1) +
                 3*GetAnyNumber.GetAnyDigitFromPesel(p, 5, 1) +
                 7*GetAnyNumber.GetAnyDigitFromPesel(p, 6, 1) +
                 9*GetAnyNumber.GetAnyDigitFromPesel(p, 7, 1) +
                 GetAnyNumber.GetAnyDigitFromPesel(p, 8, 1) +
                 3*GetAnyNumber.GetAnyDigitFromPesel(p, 9, 1) +
                 GetAnyNumber.GetAnyDigitFromPesel(p, 10, 1)); */

            if (
                (GetAnyNumber.GetAnyDigitFromPesel(p, 0, 1) +
                 3 * GetAnyNumber.GetAnyDigitFromPesel(p, 1, 1) +
                 7 * GetAnyNumber.GetAnyDigitFromPesel(p, 2, 1) +
                 9 * GetAnyNumber.GetAnyDigitFromPesel(p, 3, 1) +
                 GetAnyNumber.GetAnyDigitFromPesel(p, 4, 1) +
                 3 * GetAnyNumber.GetAnyDigitFromPesel(p, 5, 1) +
                 7 * GetAnyNumber.GetAnyDigitFromPesel(p, 6, 1) +
                 9 * GetAnyNumber.GetAnyDigitFromPesel(p, 7, 1) +
                 GetAnyNumber.GetAnyDigitFromPesel(p, 8, 1) +
                 3 * GetAnyNumber.GetAnyDigitFromPesel(p, 9, 1) +
                 GetAnyNumber.GetAnyDigitFromPesel(p, 10, 1))
                 % 10 == 0
                )
            {
                return true;
            }
            return false;
        }
예제 #2
0
 public bool CheckPesel(Pesel p)
 {
     if (CheckBirthDay(p) && CheckBirthMonth(p) && CheckControlSum(p))
     {
         return true;
     }
     return false;
 }
예제 #3
0
 public bool CheckBirthDay(Pesel p)
 {
     if (GetAnyNumber.GetBirthDay(p) <= 31)
     {
         return true;
     }
     return false;
 }
예제 #4
0
 public bool CheckBirthMonth(Pesel p)
 {
     if (GetAnyNumber.GetBirthMonth(p) <= 12)
     {
         return true;
     }
     if (GetAnyNumber.GetBirthMonth(p) <= 32)
     {
         if (GetAnyNumber.GetBirthYear(p) <= 15)
         {
             return true;
         }
         return false;
     }
     return false;
 }
예제 #5
0
 public static int GetAnyDigitFromPesel(Pesel p, int startingIndex, int lenghtIndex)
 {
     var peselString = p.PeselNumber.ToString();
     return Convert.ToInt32(peselString.Substring(startingIndex, lenghtIndex));
 }
예제 #6
0
        public static int GetBirthYear(Pesel p)
        {
            var peselString = p.PeselNumber.ToString();
            return Convert.ToInt32(peselString.Substring(0, 2));

        }