public LabelEntry(AttendanceCacheSet cacheSet, LabelFormatEntry formatEntry, Attendance attendance, AttendanceGroup group = null, int index = 0) { bool conditionalRemovedEntry = false; typeID = formatEntry.typeID; if (formatEntry.orgEV.HasValue()) { Organization org = cacheSet.getOrganization(group.groupID); if (org != null) { var ev = org.OrganizationExtras.SingleOrDefault(e => e.Field == formatEntry.orgEV); if (ev == null) { conditionalRemovedEntry = true; } } else { conditionalRemovedEntry = true; } } if (formatEntry.personFlag.HasValue() && conditionalRemovedEntry == false) { CmsData.Person person = cacheSet.getPerson(attendance.peopleID); if (person != null) { var sf = cacheSet.dataContext.ViewAllStatusFlags.SingleOrDefault(f => f.Flag == formatEntry.personFlag && f.PeopleId == person.PeopleId); if (sf == null) { conditionalRemovedEntry = true; } } else { conditionalRemovedEntry = true; } } switch (formatEntry.typeID) { case 1: try { data = getField(cacheSet, (LabelField)formatEntry.fieldID, formatEntry.fieldFormat, attendance, group); } catch (Exception) { data = "Format Exception"; } break; case 4: case 5: data = formatEntry.fieldFormat; break; case 6: // populate box data so that it is printed if data is present // later we remove box entries if they are behind a blank field by querying this data prop try { if (formatEntry.invert && formatEntry.fieldID != 0) { data = getField(cacheSet, (LabelField)formatEntry.fieldID, formatEntry.fieldFormat, attendance, group); } else { data = "print"; } } catch (Exception) { data = "Format Exception"; } break; default: data = ""; break; } font = formatEntry.font; fontSize = formatEntry.fontSize; start.x = formatEntry.startX; start.y = formatEntry.startY + (formatEntry.offset * index); align.x = formatEntry.alignX; align.y = formatEntry.alignY; end.x = formatEntry.endX; end.y = formatEntry.endY + (formatEntry.offset * index); size.x = formatEntry.width; size.y = formatEntry.height; invert = formatEntry.invert; order = formatEntry.order; if (conditionalRemovedEntry) { data = "ConditionalRemovedEntry"; } }
private string getPersonField(AttendanceCacheSet cacheSet, LabelField field, string format, Attendance attendance) { CmsData.Person person = cacheSet.getPerson(attendance.peopleID); if (person == null) { return(""); } switch (field) { case LabelField.PERSON_SECURITY_CODE: return(string.Format(format, cacheSet.securityCode)); case LabelField.PERSON_FIRST_NAME: string firstname = person.PreferredName; return(string.Format(format, firstname)); case LabelField.PERSON_LAST_NAME: return(string.Format(format, person.LastName)); case LabelField.PERSON_ALLERGIES: return(string.Format(format, person.GetRecReg().MedicalDescription)); case LabelField.PERSON_INFO: string allergies = person.GetRecReg().MedicalDescription.IsEmpty() ? "" : "A"; string custody = person.CustodyIssue.HasValue && person.CustodyIssue.Value ? "C" : ""; string transport = person.OkTransport.HasValue && person.OkTransport.Value ? "T" : ""; return(string.Format(format, allergies, custody, transport)); case LabelField.PERSON_MEMBER_GUEST: string member = person.MemberStatus.Member ? "Member" : ""; string guest = person.MemberStatus.Member ? "" : "Guest"; return(string.Format(format, member, guest)); case LabelField.PERSON_FULL_NAME: return(string.Format(format, person.PreferredName, person.LastName)); case LabelField.PERSON_DOB: return(string.Format(format, person.BirthDate)); case LabelField.PERSON_EMERGENCY_NAME: return(string.Format(format, person.GetRecReg().Emcontact)); case LabelField.PERSON_EMERGENCY_PHONE: return(string.Format(format, person.GetRecReg().Emphone.FmtFone())); case LabelField.PERSON_SCHOOL: return(string.Format(format, person.SchoolOther)); case LabelField.PERSON_GRADE: return(string.Format(format, person.Grade)); default: return(""); } }
private string getParentsField(AttendanceCacheSet cacheSet, LabelField field, string format, Attendance attendance) { CmsData.Person person = cacheSet.getPerson(attendance.peopleID); if (person == null) { return(""); } CmsData.Family family = cacheSet.getFamily(person.FamilyId); if (family == null) { return(""); } CmsData.Person head = cacheSet.getPerson(family.HeadOfHouseholdId ?? 0); CmsData.Person spouse = cacheSet.getPerson(family.HeadOfHouseholdSpouseId ?? 0); if (head == null && spouse == null) { return(""); } switch (field) { case LabelField.PARENTS_NAME: List <string> names = new List <string>(); if (head != null) { names.Add(head.FirstName); } if (spouse != null) { names.Add(spouse.FirstName); } return(string.Format(format, string.Join(", ", names))); case LabelField.PARENTS_PHONE: List <string> phones = new List <string>(); if (head != null && !head.CellPhone.IsEmpty()) { phones.Add(head.FirstName + ": " + head.CellPhone); } if (spouse != null && !spouse.CellPhone.IsEmpty()) { phones.Add(spouse.FirstName + ": " + spouse.CellPhone); } return(string.Format(format, string.Join(", ", phones))); default: return(""); } }
public string getField(AttendanceCacheSet cacheSet, LabelField field, string format, Attendance attendance, AttendanceGroup group) { switch (field.category()) { case LabelFieldAttribute.CATEGORY_UNUSED: return(""); case LabelFieldAttribute.CATEGORY_PERSON: return(getPersonField(cacheSet, field, format, attendance)); case LabelFieldAttribute.CATEGORY_PARENTS: return(getParentsField(cacheSet, field, format, attendance)); case LabelFieldAttribute.CATEGORY_GROUP: return(getGroupField(cacheSet, field, format, group)); default: return(""); } }