/// <summary>
        /// Gets the fee line item description.
        /// </summary>
        /// <param name="fee">The fee.</param>
        /// <param name="item">The item.</param>
        /// <param name="quantity">The quantity.</param>
        /// <returns></returns>
        private static string GetFeeLineItemDescription(RegistrationTemplateFee fee, RegistrationTemplateFeeItem item, int quantity)
        {
            var useFeeNameOnly = item.Name.IsNullOrWhiteSpace() || (fee.FeeType == RegistrationFeeType.Single && fee.Name == item.Name);
            var name           = useFeeNameOnly ? fee.Name : $"{fee.Name} - {item.Name}";
            var formattedCost  = item.Cost.FormatAsCurrency().Trim();
            var costDesc       = fee.AllowMultiple ? $"{quantity} @ {formattedCost}" : formattedCost;

            return($"{name} ({costDesc})");
        }
 /// <summary>
 /// Clones this RegistrationTemplateFee object to a new RegistrationTemplateFee object
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="deepCopy">if set to <c>true</c> a deep copy is made. If false, only the basic entity properties are copied.</param>
 /// <returns></returns>
 public static RegistrationTemplateFee Clone(this RegistrationTemplateFee source, bool deepCopy)
 {
     if (deepCopy)
     {
         return(source.Clone() as RegistrationTemplateFee);
     }
     else
     {
         var target = new RegistrationTemplateFee();
         target.CopyPropertiesFrom(source);
         return(target);
     }
 }
Пример #3
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 = feeItem.Cost == 0.0M ? feeItem.Name : $"{feeItem.Name} ({feeItem.Cost.FormatAsCurrency()})";

                    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);
            }
        }
        public List <string> GetParsedFeeOptionsWithoutCost(int registrationTemplateFeeId)
        {
            RegistrationTemplateFee registrationTemplateFee = this.Get(registrationTemplateFeeId);

            var options = new List <string>();

            string[] nameValues = registrationTemplateFee.CostValue.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string nameValue in nameValues)
            {
                string[] nameAndValue = nameValue.Split(new char[] { '^' }, StringSplitOptions.RemoveEmptyEntries);

                if (nameAndValue.Length == 2)
                {
                    options.Add(nameAndValue[0]);
                }
            }

            return(options);
        }
Пример #5
0
 /// <summary>
 /// Copies the properties from another RegistrationTemplateFee object to this RegistrationTemplateFee object
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="source">The source.</param>
 public static void CopyPropertiesFrom(this RegistrationTemplateFee target, RegistrationTemplateFee source)
 {
     target.Id                      = source.Id;
     target.AllowMultiple           = source.AllowMultiple;
     target.CostValue               = source.CostValue;
     target.DiscountApplies         = source.DiscountApplies;
     target.FeeType                 = source.FeeType;
     target.ForeignGuid             = source.ForeignGuid;
     target.ForeignKey              = source.ForeignKey;
     target.Name                    = source.Name;
     target.Order                   = source.Order;
     target.RegistrationTemplateId  = source.RegistrationTemplateId;
     target.CreatedDateTime         = source.CreatedDateTime;
     target.ModifiedDateTime        = source.ModifiedDateTime;
     target.CreatedByPersonAliasId  = source.CreatedByPersonAliasId;
     target.ModifiedByPersonAliasId = source.ModifiedByPersonAliasId;
     target.Guid                    = source.Guid;
     target.ForeignId               = source.ForeignId;
 }
        public Dictionary <string, string> GetParsedFeeOptionsWithNameAndValueString(int registrationTemplateFeeId)
        {
            RegistrationTemplateFee registrationTemplateFee = this.Get(registrationTemplateFeeId);

            var options = new Dictionary <string, string>();

            string[] nameValues = registrationTemplateFee.CostValue.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string nameValue in nameValues)
            {
                string[] nameAndValue = nameValue.Split(new char[] { '^' }, StringSplitOptions.RemoveEmptyEntries);
                if (nameAndValue.Length == 1)
                {
                    options.AddOrIgnore(nameAndValue[0], nameAndValue[0]);
                }
                else if (nameAndValue.Length == 2)
                {
                    options.AddOrIgnore(nameAndValue[0], string.Format("{0} ({1})", nameAndValue[0], nameAndValue[1].AsDecimal().FormatAsCurrency()));
                }
            }

            return(options);
        }
        public List <Tuple <string, decimal> > GetParsedFeeOptionsWithCostAsNumber(int registrationTemplateFeeId)
        {
            RegistrationTemplateFee registrationTemplateFee = this.Get(registrationTemplateFeeId);

            var options = new List <Tuple <string, decimal> >();

            string[] nameValues = registrationTemplateFee.CostValue.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string nameValue in nameValues)
            {
                string[] nameAndValue = nameValue.Split(new char[] { '^' }, StringSplitOptions.RemoveEmptyEntries);
                if (nameAndValue.Length == 1)
                {
                    options.Add(Tuple.Create <string, decimal>(nameAndValue[0], 0.00m));
                }
                else if (nameAndValue.Length == 2)
                {
                    options.Add(Tuple.Create <string, decimal>(nameAndValue[0], nameAndValue[1].AsDecimal()));
                }
            }

            return(options);
        }
Пример #8
0
 /// <summary>
 /// Copies the properties from another RegistrationTemplateFee object to this RegistrationTemplateFee object
 /// </summary>
 /// <param name="target">The target.</param>
 /// <param name="source">The source.</param>
 public static void CopyPropertiesFrom(this RegistrationTemplateFee target, RegistrationTemplateFee source)
 {
     target.Id            = source.Id;
     target.AllowMultiple = source.AllowMultiple;
     #pragma warning disable 612, 618
     target.CostValue = source.CostValue;
     #pragma warning restore 612, 618
     target.DiscountApplies       = source.DiscountApplies;
     target.FeeType               = source.FeeType;
     target.ForeignGuid           = source.ForeignGuid;
     target.ForeignKey            = source.ForeignKey;
     target.HideWhenNoneRemaining = source.HideWhenNoneRemaining;
     target.IsActive              = source.IsActive;
     target.IsRequired            = source.IsRequired;
     target.Name  = source.Name;
     target.Order = source.Order;
     target.RegistrationTemplateId  = source.RegistrationTemplateId;
     target.CreatedDateTime         = source.CreatedDateTime;
     target.ModifiedDateTime        = source.ModifiedDateTime;
     target.CreatedByPersonAliasId  = source.CreatedByPersonAliasId;
     target.ModifiedByPersonAliasId = source.ModifiedByPersonAliasId;
     target.Guid      = source.Guid;
     target.ForeignId = source.ForeignId;
 }
Пример #9
0
        /// <summary>
        /// Gets the fee information from controls.
        /// </summary>
        /// <param name="phFees">The ph fees.</param>
        /// <returns></returns>
        public List <FeeInfo> GetFeeInfoFromControls(PlaceHolder phFees)
        {
            RegistrationTemplateFee fee = this;

            string fieldId = string.Format("fee_{0}", fee.Id);

            if (fee.FeeType == RegistrationFeeType.Single)
            {
                var singleFeeItem = fee.FeeItems.FirstOrDefault();
                if (fee.AllowMultiple)
                {
                    // Single Option, Multi Quantity
                    var numUpDown = phFees.FindControl(fieldId) as NumberUpDown;
                    if (numUpDown != null && numUpDown.Value > 0)
                    {
                        return(new List <FeeInfo> {
                            new FeeInfo(singleFeeItem, numUpDown.Value, singleFeeItem.Cost)
                        });
                    }
                }
                else
                {
                    // Single Option, Single Quantity
                    var cb = phFees.FindControl(fieldId) as RockCheckBox;
                    if (cb != null && cb.Checked)
                    {
                        return(new List <FeeInfo> {
                            new FeeInfo(singleFeeItem, 1, singleFeeItem.Cost)
                        });
                    }
                }
            }
            else
            {
                if (fee.AllowMultiple)
                {
                    // Multi Option, Multi Quantity
                    var result = new List <FeeInfo>();

                    foreach (var feeItem in fee.FeeItems)
                    {
                        string optionFieldId   = $"feeItem_{feeItem.Guid.ToString( "N" )}";
                        var    numUpDownGroups = phFees.ControlsOfTypeRecursive <NumberUpDownGroup>();

                        foreach (NumberUpDownGroup numberUpDownGroup in numUpDownGroups)
                        {
                            foreach (NumberUpDown numberUpDown in numberUpDownGroup.NumberUpDownControls)
                            {
                                if (numberUpDown.ID == optionFieldId && numberUpDown.Value > 0)
                                {
                                    result.Add(new FeeInfo(feeItem, numberUpDown.Value, feeItem.Cost));
                                }
                            }
                        }
                    }

                    if (result.Any())
                    {
                        return(result);
                    }
                }
                else
                {
                    // Multi Option, Single Quantity
                    var ddl = phFees.FindControl(fieldId) as RockDropDownList;
                    if (ddl != null && ddl.SelectedValue != string.Empty)
                    {
                        var feeItemId = ddl.SelectedValue.AsInteger();
                        var feeItem   = fee.FeeItems.FirstOrDefault(a => a.Id == feeItemId);
                        if (feeItem != null)
                        {
                            return(new List <FeeInfo> {
                                new FeeInfo(feeItem, 1, feeItem.Cost)
                            });
                        }
                    }
                }
            }

            return(null);
        }