예제 #1
0
        /// <summary>
        /// Marks invalid/valid feilds by calling their Mark(In)Valid functions
        /// returns true if all fields contain valid data, false otherwise.
        /// </summary>
        /// <returns></returns>
        private bool ValidateFields()
        {
            bool allValid = true;

            if (FirstName.TextField.Text == FirstName.Hint)
            {
                FirstName.MarkInvalid();
                allValid = false;
            }
            else
            {
                FirstName.MarkValid();
            }

            if (LastName.TextField.Text == LastName.Hint)
            {
                LastName.MarkInvalid();
                allValid = false;
            }
            else
            {
                LastName.MarkValid();
            }

            if (!IsHealthcareIDValid() || HealthID.TextField.Text == HealthID.Hint)
            {
                HealthID.MarkInvalid();
                allValid = false;
            }
            else
            {
                HealthID.MarkValid();
            }

            if (!Birthdate.DateSelected.HasValue)
            {
                Birthdate.InputText.MarkInvalid();
                allValid = false;
            }
            else
            {
                Birthdate.InputText.MarkValid();
            }

            if (Address.TextField.Text == Address.Hint)
            {
                Address.MarkInvalid();
                allValid = false;
            }
            else
            {
                Address.MarkValid();
            }

            if (City.TextField.Text == City.Hint)
            {
                City.MarkInvalid();
                allValid = false;
            }
            else
            {
                City.MarkValid();
            }

            if (!IsPostalCodeValid())
            {
                PostalCode.MarkInvalid();
                allValid = false;
            }
            else
            {
                PostalCode.MarkValid();
            }

            if (!IsPhoneNumberValid(HomePhone))
            {
                HomePhone.MarkInvalid();
                allValid = false;
            }
            else
            {
                HomePhone.MarkValid();
            }

            //Optional Business Phone, if it is filled in, ensure it is at least a 10 digit number
            if (BusinessPhone.TextField.Text != BusinessPhone.Hint && BusinessPhone.TextField.Text.Length < 14)
            {
                BusinessPhone.MarkInvalid();
                allValid = false;
            }
            else
            {
                BusinessPhone.MarkValid();
            }

            //Optional Cell Phone, if it is filled in, ensure it is at least a 10 digit number
            if (CellPhone.TextField.Text != CellPhone.Hint && CellPhone.TextField.Text.Length < 14)
            {
                CellPhone.MarkInvalid();
                allValid = false;
            }
            else
            {
                CellPhone.MarkValid();
            }

            if (ContactName.TextField.Text == ContactName.Hint)
            {
                ContactName.MarkInvalid();
                allValid = false;
            }
            else
            {
                ContactName.MarkValid();
            }

            if (ContactRelation.TextField.Text == ContactRelation.Hint)
            {
                ContactRelation.MarkInvalid();
                allValid = false;
            }
            else
            {
                ContactRelation.MarkValid();
            }

            if (!IsPhoneNumberValid(ContactPhone))
            {
                ContactPhone.MarkInvalid();
                allValid = false;
            }
            else
            {
                ContactPhone.MarkValid();
            }

            return(allValid);
        }