Пример #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 dlgAttribute_SaveClick(object sender, EventArgs e)
        {
            Rock.Model.Attribute attribute = new Rock.Model.Attribute();
            edtAttributes.GetAttributeProperties(attribute);

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

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

            AttributesState.Add(attribute);

            ReOrderAttributes(AttributesState);

            BindAttributesGrid();

            HideDialog();
        }
Пример #2
0
        /// <summary>
        /// Handles the Delete event of the gAttributes 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 gAttributes_Delete(object sender, RowEventArgs e)
        {
            Guid attributeGuid = (Guid)e.RowKeyValue;

            AttributesState.RemoveEntity(attributeGuid);

            BindAttributesGrid();
        }
Пример #3
0
 /// <summary>
 /// Binds the group type attributes grid.
 /// </summary>
 private void BindAttributesGrid()
 {
     gAttributes.DataSource = AttributesState
                              .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();
     gAttributes.DataBind();
 }
Пример #4
0
        /// <summary>
        /// Shows the attribute edit.
        /// </summary>
        /// <param name="attributeGuid">The attribute unique identifier.</param>
        private void ShowAttributeEdit(Guid attributeGuid)
        {
            Attribute attribute;

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

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

            ShowDialog("Attributes");
        }