Esempio n. 1
0
        /// <summary>
        /// Adds the fee control.
        /// </summary>
        /// <param name="phFees">The ph fees.</param>
        /// <param name="registrationInstance">The registration instance.</param>
        /// <param name="setValues">if set to <c>true</c> [set values].</param>
        /// <param name="feeValues">The fee values.</param>
        /// <param name="otherRegistrants">The other registrants that have been registered so far in this registration. Set to NULL if editing a single registrant.</param>
        public void AddFeeControl(PlaceHolder phFees, RegistrationInstance registrationInstance, bool setValues, List <FeeInfo> feeValues, List <RegistrantInfo> otherRegistrants)
        {
            RegistrationTemplateFee fee = this;
            Control feeControl          = null;

            if (fee.FeeType == RegistrationFeeType.Single)
            {
                var feeItem = fee.FeeItems.FirstOrDefault();
                if (feeItem != null)
                {
                    int?usageCountRemaining = feeItem.GetUsageCountRemaining(registrationInstance, otherRegistrants);

                    string controlLabel;

                    if (feeItem.Cost != 0.0M)
                    {
                        controlLabel = $"{feeItem.Name} ({feeItem.Cost.FormatAsCurrency()})";
                    }
                    else
                    {
                        controlLabel = feeItem.Name;
                    }

                    if (fee.AllowMultiple)
                    {
                        feeControl = GetFeeSingleOptionMultipleQuantityControl(setValues, controlLabel, feeValues, usageCountRemaining);
                    }
                    else
                    {
                        feeControl = GetFeeSingleOptionSingleQuantityControl(setValues, controlLabel, feeValues, usageCountRemaining);
                    }
                }
            }
            else
            {
                if (fee.AllowMultiple)
                {
                    feeControl = GetFeeMultipleOptionMultipleQuantityControl(setValues, feeValues, registrationInstance, otherRegistrants);
                }
                else
                {
                    feeControl = GetFeeMultipleOptionSingleQuantityControl(setValues, feeValues, registrationInstance, otherRegistrants);
                }
            }

            if (feeControl != null)
            {
                if (feeControl is IHasValidationGroup hasValidationGroup)
                {
                    hasValidationGroup.ValidationGroup = phFees.RockBlock()?.BlockValidationGroup;
                }

                phFees.Controls.Add(feeControl);
            }
        }