protected override void TypeOneRecord(Cell c, object rec) { // cast generic object to specific type // appropriate to this label type: FamiliesAndKids fk = (FamiliesAndKids)rec; c.MarginTop = 0; Paragraph p = c.Paragraphs.First(); // Xceed.Words.NET should initialize Cells with one // paragraph. But, in the unlikeley case // that that paragraph isn't there, add one. if (p == null) { p = c.InsertParagraph(); } string zip = Utils.TextUtils.CanonicalPostalCode(fk.dao.postal_code); p.SpacingBefore(0); p.SpacingAfter(0); p.Append(fk.dao.head_of_household).FontSize(24).Bold() .AppendLine(fk.dao.phone).FontSize(18).Bold() .AppendLine(fk.dao.address).FontSize(16) .AppendLine(fk.dao.city + ", " + fk.dao.state_or_province + " " + zip).FontSize(16) .AppendLine("Gift Cards: " + fk.gift_card_count.ToString()).FontSize(16) .AppendLine("Number of Bags: ___").FontSize(16) .AppendLine("") // Another blank line before children's names .AppendLine("Children: " + fk.kids).FontSize(16); }
/// <summary> /// For each ServicesHouseholdEnrollment object, if there /// are corresponding GiftLabelInfo objects for this writer's /// year: /// For each such GiftLabelInfo object, make a FamiliesAndKids /// object, fill its fields, and add it to our ItemList. /// </summary> protected override void SetItemList() { List <object> fkl = new List <object>(); ServicesHouseholdEnrollment_DAO[] participant_array = this.context.HoEnrList.Select(h => h.dao).Where(h => h.year == this.Year).ToArray(); foreach (ServicesHouseholdEnrollment_DAO participant in participant_array) { var gli_array = this.context.GliList.Where(g => (g.year == this.Year && g.family_id == participant.family_id)).ToArray(); if (gli_array.Count() > 0) { FamiliesAndKids fak = new FamiliesAndKids(); fak.dao = participant; string[] sa = gli_array.Select(g => g.child_name).Distinct().ToArray(); fak.kids = string.Join(", ", sa); fak.gift_card_count = gli_array.Where(g => g.donor_name == "Gift Cards").Count(); fkl.Add(fak); } } this.ItemList = fkl; }