예제 #1
0
        private static Label getLabel(AttendanceCacheSet cacheSet, LabelFormat format, Attendance attendance, List <AttendanceGroup> groups)
        {
            Label label = new Label();

            foreach (LabelFormatEntry formatEntry in format.entries)
            {
                if (formatEntry.repeat > 1)
                {
                    for (int iX = 0; iX < formatEntry.repeat; iX++)
                    {
                        if (groups.Count <= iX)
                        {
                            break;
                        }

                        LabelEntry entry = new LabelEntry(cacheSet, formatEntry, attendance, groups[iX], iX);

                        label.entries.Add(entry);
                    }
                }
                else
                {
                    label.entries.Add(new LabelEntry(cacheSet, formatEntry, attendance, groups[0]));
                }
            }

            // remove shaded box entries without data -- this means they are behind a blank field
            label.entries.RemoveAll(e => e.typeID == 6 && e.data == "");
            return(label);
        }
예제 #2
0
        public List <Label> createLabelData(CMSDataContext dataContext)
        {
            List <Label> labels = new List <Label>();

            using (var db = new SqlConnection(Util.ConnectionString)) {
                AttendanceCacheSet cacheSet = new AttendanceCacheSet {
                    dataContext    = dataContext,
                    formats        = LabelFormat.forSize(db, labelSize),
                    securityLabels = securityLabels,
                    securityCode   = dataContext.NextSecurityCode().Select(c => c.Code).Single().Trim(),
                    guestLabels    = guestLabels,
                    locationLabels = locationLabels,
                    nameTagAge     = nameTagAge
                };

                foreach (Attendance attendance in attendances)
                {
                    labels.AddRange(attendance.getLabels(cacheSet));
                }

                if (labels.Count > 0 && attendances.Count > 0 && securityLabels == Attendance.SECURITY_LABELS_PER_FAMILY)
                {
                    labels.AddRange(attendances[0].getSecurityLabel(cacheSet));
                }
            }

            return(labels);
        }
예제 #3
0
        private static Label getLabel(LabelFormat format, Attendance attendance, List <AttendanceGroup> groups)
        {
            Label label = new Label();

            foreach (LabelFormatEntry formatEntry in format.entries)
            {
                if (formatEntry.repeat > 1)
                {
                    for (int iX = 0; iX < formatEntry.repeat; iX++)
                    {
                        if (groups.Count <= iX)
                        {
                            break;
                        }

                        LabelEntry entry = new LabelEntry(formatEntry, attendance, groups[iX], iX);

                        label.entries.Add(entry);
                    }
                }
                else
                {
                    label.entries.Add(new LabelEntry(formatEntry, attendance, groups[0]));
                }
            }

            return(label);
        }
예제 #4
0
        public List <Label> createLabelData(CMSDataContext dataContext)
        {
            List <Label> labels = new List <Label>();
            bool         printingForChildren = false;
            bool         needsSecurityLabel  = false;

            using (var db = new SqlConnection(Util.ConnectionString)) {
                AttendanceCacheSet cacheSet = new AttendanceCacheSet {
                    dataContext    = dataContext,
                    formats        = LabelFormat.forSize(db, labelSize),
                    securityLabels = securityLabels,
                    securityCode   = dataContext.NextSecurityCode().Select(c => c.Code).Single().Trim(),
                    guestLabels    = guestLabels,
                    locationLabels = locationLabels,
                    nameTagAge     = nameTagAge
                };

                foreach (Attendance attendance in attendances)
                {
                    attendance.populateSubgroups(db, cacheSet);
                    labels.AddRange(attendance.getLabels(cacheSet));
                    CmsData.Person person = cacheSet.getPerson(attendance.peopleID);
                    if (securityLabels == Attendance.SECURITY_LABELS_PER_FAMILY)
                    {
                        // we only add a security label if we are printing for children in orgs with a security label needed; do those checks now
                        if ((person.Age ?? 0) < cacheSet.nameTagAge)
                        {
                            printingForChildren = true;
                        }
                        foreach (AttendanceGroup group in attendance.groups)
                        {
                            Organization org = cacheSet.getOrganization(group.groupID);
                            if (org != null && org.NoSecurityLabel != true && org.NumCheckInLabels > 0 && group.present)
                            {
                                needsSecurityLabel = true;
                            }
                        }
                    }
                }
                if (printingForChildren && needsSecurityLabel && labels.Count > 0)
                {
                    labels.AddRange(attendances[0].getSecurityLabel(cacheSet));
                }
            }

            return(labels);
        }
예제 #5
0
        public static List <Label> generate(AttendanceCacheSet cacheSet, Type type, Attendance attendance, List <AttendanceGroup> groups)
        {
            List <Label> labels = new List <Label>();
            LabelFormat  format = cacheSet.formats[(int)type];

            List <AttendanceGroup> groupsCopy = new List <AttendanceGroup>(groups);

            if (format.canRepeat)
            {
                do
                {
                    labels.Add(getLabel(cacheSet, format, attendance, nextGroups(groupsCopy, format.maxRepeat())));
                } while(groupsCopy.Any());
            }
            else
            {
                labels.Add(getLabel(cacheSet, format, attendance, nextGroups(groupsCopy, 1)));
            }

            return(labels);
        }
예제 #6
0
        public static Dictionary <int, LabelFormat> forSize(SqlConnection db, int size)
        {
            Dictionary <int, LabelFormat> formats = new Dictionary <int, LabelFormat>();
            DataTable table = new DataTable();

            const string qFormats = @"SELECT
													label.id AS id,
													label.name AS name,
													label.typeID AS typeID,
													type.name AS type,
													minimum,
													maximum,
													type.canRepeat AS canRepeat
												FROM CheckInLabel AS label
													LEFT JOIN CheckInLabelType AS type ON type.id = label.typeID
												WHERE @size BETWEEN minimum AND maximum
                                                AND active = 1";

            using (SqlCommand cmd = new SqlCommand(qFormats, db)) {
                SqlParameter sizeParameter = new SqlParameter("size", size);

                cmd.Parameters.Add(sizeParameter);

                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                adapter.Fill(table);
            }

            foreach (DataRow row in table.Rows)
            {
                LabelFormat format = new LabelFormat();
                format.populate(row);
                format.loadEntries(db);

                formats.Add(format.typeID, format);
            }

            return(formats);
        }