Пример #1
0
 // returns string representation of patient object
 public override string ToString()
 {
     return(TitleName + "\t"
            + MaritalStatus + ""
            + " Age: " + Age + ",  "
            + "Expenses: " + Salary.ToString("C") + ". "
            + HomeAddress + ". "
            + HomePhone.ToString() + "/"
            + CellPhone.ToString() + "\t");
 } // end method ToString
Пример #2
0
 // returns string representation of reservation object
 public override string ToString()
 {
     return(GuestType + " "
            + TitleName + "\t"
            + HomeAddress + "\t"
            + HomePhone.ToString() + ", "
            + MobilePhone.ToString() + ", "
            + Nights + " nights, "
            + RoomTypeName + "\t"
            + "Discount: " + DiscountRate.ToString() + "%  "
            + "Room Charge: " + RoomCharge.ToString("C") + "  "
            + "Tax: " + Tax.ToString("C") + "  "
            + "Total: " + Total.ToString("C"));
 } // end method ToString
Пример #3
0
 public RadioStationWindow()
 {
     InitializeComponent();
     TextBlock.Text = hPhone.ToString();
 }
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (string.IsNullOrEmpty(FirstName))
            {
                yield return(new ValidationResult("First name cannot be empty"));
            }
            if (string.IsNullOrEmpty(LastName))
            {
                yield return(new ValidationResult("Last Name cannot be empty", new[] { nameof(LastName) }));
            }
            if (FirstName != null)
            {
                FirstName = FirstName.Trim();
            }
            if (LastName != null)
            {
                LastName = LastName.Trim();
            }
            if (Address != null)
            {
                Address = Address.Trim();
            }
            if (City != null)
            {
                City = City.Trim();
            }
            if (ProvinceCode != null)
            {
                ProvinceCode = ProvinceCode.ToUpper();
            }
            if (PostalCode != null)
            {
                PostalCode = PostalCode.ToUpper();
            }
            if (DateOfBirth != null)
            {
                if (DateOfBirth > DateTime.Now)
                {
                    yield return(new ValidationResult("DateOfBirth can not be in future"));
                }
                if (DateOfDeath != null)
                {
                    if (DateOfBirth > DateOfDeath)
                    {
                        yield return(new ValidationResult("DateOfDeath can not be before DateOfBirth"));
                    }
                    if (DateOfDeath > DateTime.Now)
                    {
                        yield return(new ValidationResult("DateOfDeath can not be in future"));
                    }
                    if (Deceased == false)
                    {
                        yield return(new ValidationResult("Deceased must be checked "));
                    }
                }
            }
            if (HomePhone != null)
            {
                if (HomePhone.Length != 10)
                {
                    yield return(new ValidationResult("Homephone numbe rshould be exactly 10 numbers"));
                }
                else
                {
                    HomePhone = Regex.Replace(HomePhone.ToString(), "[^0-9]+", string.Empty);
                    HomePhone = HomePhone.ToString().Insert(3, "-").Insert(7, "-");
                }
            }



            yield return(ValidationResult.Success);
        }