Example #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (field != null && field.CustomFieldId > -1)
                {
                    ContentLanguage.DeleteByContent(field.Guid);
                    ProductProperty.DeleteByCustomField(field.CustomFieldId);
                    CustomFieldOption.DeleteCustomField(field.CustomFieldId);
                    CustomField.Delete(field.CustomFieldId);

                    LogActivity.Write("Delete custom field", field.Name);

                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "DeleteSuccessMessage");
                }

                WebUtils.SetupRedirect(this, SiteRoot + "/Product/AdminCP/CustomFields.aspx");
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Example #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                int iRecordDeleted = 0;
                foreach (Telerik.Web.UI.GridDataItem data in grid.SelectedItems)
                {
                    int customFieldId = Convert.ToInt32(data.GetDataKeyValue("CustomFieldId"));

                    CustomField field = new CustomField(customFieldId);
                    if (field != null && field.CustomFieldId != -1)
                    {
                        ContentLanguage.DeleteByContent(field.Guid);
                        ProductProperty.DeleteByCustomField(field.CustomFieldId);
                        CustomFieldOption.DeleteCustomField(field.CustomFieldId);
                        CustomField.Delete(field.CustomFieldId);

                        LogActivity.Write("Delete custom field", field.Name);

                        iRecordDeleted += 1;
                    }
                }

                if (iRecordDeleted > 0)
                {
                    //LogActivity.Write("Delete " + iRecordDeleted.ToString() + " item(s)", "Custom field");
                    message.SuccessMessage = ResourceHelper.GetResourceString("Resource", "DeleteSuccessMessage");

                    grid.Rebind();
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }