Exemplo n.º 1
0
        /// <summary>
        /// Handles when a person is selected from the re-print label button.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        protected void rReprintLabelPersonResults_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            // Get the person Id
            int personId = e.CommandArgument.ToString().AsInteger();

            hfSelectedPersonId.Value = personId.ToStringSafe();

            // Get the attendanceIds
            var hfAttendanceIds = e.Item.FindControl("hfAttendanceIds") as HiddenField;

            if (hfAttendanceIds == null)
            {
                return;
            }

            // save the attendance ids for later use.
            hfSelectedAttendanceIds.Value = hfAttendanceIds.Value;

            // hide the reprint person select results, then show the selected labels to pick from
            pnlReprintLabels.Visible = false;
            pnlManager.Visible       = false;
            pnlReprintSearchPersonResults.Visible  = false;
            pnlReprintSelectedPersonLabels.Visible = true;

            // bind all possible tags to reprint
            var possibleLabels = ZebraPrint.GetLabelTypesForPerson(personId, hfSelectedAttendanceIds.Value.SplitDelimitedValues().AsIntegerList());

            if (possibleLabels.Count != 0)
            {
                lbReprintSelectLabelTypes.Visible = true;
            }
            else
            {
                lbReprintSelectLabelTypes.Visible = false;
                maNoLabelsFound.Show("No labels were found for that selection.", ModalAlertType.Alert);
            }

            rReprintLabelTypeSelection.DataSource = possibleLabels;
            rReprintLabelTypeSelection.DataBind();
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnReprintLabels_Click(object sender, EventArgs e)
        {
            nbReprintMessage.Visible = false;

            Guid?personGuid = PageParameter(PERSON_GUID_PAGE_QUERY_KEY).AsGuidOrNull();

            if (personGuid == null || !personGuid.HasValue)
            {
                maNoLabelsFound.Show("No person was found.", ModalAlertType.Alert);
                return;
            }

            if (string.IsNullOrEmpty(hfCurrentAttendanceIds.Value))
            {
                maNoLabelsFound.Show("No labels were found for re-printing.", ModalAlertType.Alert);
                return;
            }

            var rockContext = new RockContext();

            var attendanceIds = hfCurrentAttendanceIds.Value.SplitDelimitedValues().AsIntegerList();

            // Get the person Id from the Guid in the page parameter
            var personId = new PersonService(rockContext).Queryable().Where(p => p.Guid == personGuid.Value).Select(p => p.Id).FirstOrDefault();

            hfPersonId.Value = personId.ToString();

            var possibleLabels = ZebraPrint.GetLabelTypesForPerson(personId, attendanceIds);

            if (possibleLabels != null && possibleLabels.Count != 0)
            {
                cblLabels.DataSource = possibleLabels;
                cblLabels.DataBind();
            }
            else
            {
                maNoLabelsFound.Show("No labels were found for re-printing.", ModalAlertType.Alert);
                return;
            }

            cblLabels.DataSource = ZebraPrint.GetLabelTypesForPerson(personId, attendanceIds).OrderBy(l => l.Name);
            cblLabels.DataBind();

            // Bind the printers list
            var printers = new DeviceService(rockContext)
                           .GetByDeviceTypeGuid(new Guid(Rock.SystemGuid.DefinedValue.DEVICE_TYPE_PRINTER))
                           .OrderBy(d => d.Name)
                           .ToList();

            if (printers == null || printers.Count == 0)
            {
                maNoLabelsFound.Show("Due to browser limitations, only server based printers are supported and none are defined on this server.", ModalAlertType.Information);
                return;
            }

            ddlPrinter.Items.Clear();
            ddlPrinter.DataSource = printers;
            ddlPrinter.DataBind();
            ddlPrinter.Items.Insert(0, new ListItem(None.Text, None.IdValue));

            nbReprintLabelMessages.Text = string.Empty;
            mdReprintLabels.Show();
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnReprintLabels_Click(object sender, EventArgs e)
        {
            nbReprintMessage.Visible = false;

            Guid personGuid = GetPersonGuid();

            if (personGuid == Guid.Empty)
            {
                maNoLabelsFound.Show("No person was found.", ModalAlertType.Alert);
                return;
            }

            if (string.IsNullOrEmpty(hfCurrentAttendanceIds.Value))
            {
                maNoLabelsFound.Show("No labels were found for re-printing.", ModalAlertType.Alert);
                return;
            }

            var rockContext = new RockContext();

            var attendanceIds = hfCurrentAttendanceIds.Value.SplitDelimitedValues().AsIntegerList();

            // Get the person Id from the PersonId page parameter, or look it up based on the Person Guid page parameter.
            int?personIdParam = PageParameter(PageParameterKey.PersonId).AsIntegerOrNull();
            int personId      = personIdParam.HasValue
                ? personIdParam.Value
                : new PersonService(rockContext).GetId(personGuid).GetValueOrDefault();

            hfPersonId.Value = personId.ToString();

            var possibleLabels = ZebraPrint.GetLabelTypesForPerson(personId, attendanceIds);

            if (possibleLabels != null && possibleLabels.Count != 0)
            {
                cblLabels.DataSource = possibleLabels;
                cblLabels.DataBind();
            }
            else
            {
                maNoLabelsFound.Show("No labels were found for re-printing.", ModalAlertType.Alert);
                return;
            }

            cblLabels.DataSource = ZebraPrint.GetLabelTypesForPerson(personId, attendanceIds).OrderBy(l => l.Name);
            cblLabels.DataBind();

            // Get the printers list.
            var printerList = new DeviceService(rockContext)
                              .GetByDeviceTypeGuid(new Guid(Rock.SystemGuid.DefinedValue.DEVICE_TYPE_PRINTER))
                              .OrderBy(d => d.Name)
                              .Select(a => new { a.Name, a.Guid })
                              .ToList();

            ddlPrinter.Items.Clear();
            ddlPrinter.Items.Add(new ListItem());

            if (hfHasClientPrinter.Value.AsBoolean())
            {
                ddlPrinter.Items.Add(new ListItem("local printer", Guid.Empty.ToString()));
            }

            foreach (var printer in printerList)
            {
                ddlPrinter.Items.Add(new ListItem(printer.Name, printer.Guid.ToString()));
            }

            var labelPrinterGuid = CheckinManagerHelper.GetCheckinManagerConfigurationFromCookie().LabelPrinterGuid;

            ddlPrinter.SetValue(labelPrinterGuid);

            nbReprintLabelMessages.Text = string.Empty;
            mdReprintLabels.Show();
        }