Exemplo n.º 1
0
        public static DateTime ConvertNullToDatetime(string date)
        {
            DateTime date_new;

            DateTime.TryParse(date, out date_new);
            if (date_new.Year == 0001 && !ValueConverters.IsStringEmpty(date))
            {
                //var culture = System.Globalization.CultureInfo.CurrentCulture;
                var culture = System.Globalization.CultureInfo.InvariantCulture;
                date_new = DateTime.ParseExact(date, "d/M/yyyy", culture);
            }
            if (date_new.Year == 0001)
            {
                date_new = new DateTime(1900, 01, 01);
            }

            return(date_new);
        }
Exemplo n.º 2
0
        public static bool ValidatePhoneNumber(string phoneNo)
        {
            bool validNumber;

            validNumber = false;
            phoneNo     = ValueConverters.ConvertNullToEmptyString(phoneNo);
            if (phoneNo.Trim().Length == 10)
            {
                // check if user entered a duplicated number throughout
                validNumber = true;
                for (int i = 0; i < 9; i++)
                {
                    string j = PADLeft(6, i.ToString(), (char)i);
                    if (j == Right(phoneNo, 6))
                    {
                        validNumber = false;
                        break;
                    }
                }
            }
            return(validNumber);
        }