Пример #1
0
        /// <summary>
        /// Handles the SaveClick event of the dlgAttribute control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void dlgEventAttribute_SaveClick(object sender, EventArgs e)
        {
            Rock.Model.Attribute attribute = new Rock.Model.Attribute();
            edtEventAttributes.GetAttributeProperties(attribute);

            // Controls will show warnings
            if (!attribute.IsValid)
            {
                return;
            }

            if (EventAttributesState.Any(a => a.Guid.Equals(attribute.Guid)))
            {
                attribute.Order = EventAttributesState.Where(a => a.Guid.Equals(attribute.Guid)).FirstOrDefault().Order;
                EventAttributesState.RemoveEntity(attribute.Guid);
            }
            else
            {
                attribute.Order = EventAttributesState.Any() ? EventAttributesState.Max(a => a.Order) + 1 : 0;
            }

            EventAttributesState.Add(attribute);

            ReOrderEventAttributes(EventAttributesState);

            BindEventAttributesGrid();

            HideDialog();
        }
Пример #2
0
        /// <summary>
        /// Handles the Delete event of the gEventAttributes control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        protected void gEventAttributes_Delete(object sender, RowEventArgs e)
        {
            Guid attributeGuid = ( Guid )e.RowKeyValue;

            EventAttributesState.RemoveEntity(attributeGuid);

            BindEventAttributesGrid();
        }
Пример #3
0
 /// <summary>
 /// Binds the event attributes grid.
 /// </summary>
 private void BindEventAttributesGrid()
 {
     gEventAttributes.DataSource = EventAttributesState
                                   .OrderBy(a => a.Order)
                                   .ThenBy(a => a.Name)
                                   .ToList();
     gEventAttributes.DataBind();
 }
Пример #4
0
 /// <summary>
 /// Binds the event attributes grid.
 /// </summary>
 private void BindEventAttributesGrid()
 {
     gEventAttributes.DataSource = EventAttributesState
                                   .OrderBy(a => a.Order)
                                   .ThenBy(a => a.Name)
                                   .Select(a => new
     {
         a.Id,
         a.Guid,
         a.Name,
         a.Description,
         FieldType = FieldTypeCache.GetName(a.FieldTypeId),
         a.IsRequired,
         a.IsGridColumn,
         a.AllowSearch
     })
                                   .ToList();
     gEventAttributes.DataBind();
 }
Пример #5
0
        /// <summary>
        /// Shows the attribute edit.
        /// </summary>
        /// <param name="attributeGuid">The attribute unique identifier.</param>
        private void ShowEventAttributeEdit(Guid attributeGuid)
        {
            Attribute attribute;

            if (attributeGuid.Equals(Guid.Empty))
            {
                attribute             = new Attribute();
                attribute.FieldTypeId = FieldTypeCache.Get(Rock.SystemGuid.FieldType.TEXT).Id;
            }
            else
            {
                attribute = EventAttributesState.First(a => a.Guid.Equals(attributeGuid));
            }

            edtEventAttributes.ReservedKeyNames   = EventAttributesState.Where(a => !a.Guid.Equals(attributeGuid)).Select(a => a.Key).ToList();
            edtEventAttributes.AllowSearchVisible = true;
            edtEventAttributes.SetAttributeProperties(attribute, typeof(EventCalendar));

            ShowDialog("EventAttributes");
        }