/// <summary> /// Handles the UpdateCommand event of the grdSelectionValues control. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.DataGridCommandEventArgs"/> instance containing the event data.</param> protected void grdSelectionValues_Update(object source, DataGridCommandEventArgs e) { lblError.Text = String.Empty; if (ListItemType.EditItem == e.Item.ItemType) { var selectionName = (TextBox)e.Item.FindControl("txtEditSelectionName"); var txtValue = (TextBox)e.Item.FindControl("txtEditSelectionValue"); if (selectionName != null && txtValue != null) { var customFieldSelectionId = (int)((DataGrid)source).DataKeys[e.Item.ItemIndex]; UserCustomFieldSelection cfs = UserCustomFieldSelectionManager.GetById(customFieldSelectionId); cfs.Name = selectionName.Text.Trim(); cfs.Value = txtValue.Text.Trim(); UserCustomFieldSelectionManager.SaveOrUpdate(cfs); lblError.Text = String.Empty; foreach (DataGridItem item in grdCustomFields.Items) { var grdSelectionValues = (DataGrid)item.FindControl("grdSelectionValues"); if (null == grdSelectionValues) { continue; } grdSelectionValues.ShowFooter = true; grdSelectionValues.EditItemIndex = -1; BindCustomFieldSelections(); } } ViewState["EditingSubGrid"] = null; BindCustomFields(); } }
/// <summary> /// Handles the ItemCommand event of the grdSelectionValues control. /// </summary> /// <param name="source">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.DataGridCommandEventArgs"/> instance containing the event data.</param> protected void grdSelectionValues_ItemCommand(object source, DataGridCommandEventArgs e) { UserCustomFieldSelection cfs; var itemIndex = e.Item.ItemIndex; int itemId; var grid = source as DataGrid; switch (e.CommandName) { case "up": //move row up if (itemIndex == 0) { return; } itemId = Convert.ToInt32(grid.DataKeys[itemIndex]); cfs = UserCustomFieldSelectionManager.GetById(itemId); cfs.SortOrder -= 1; UserCustomFieldSelectionManager.SaveOrUpdate(cfs); break; case "down": //move row down if (itemIndex == grid.Items.Count - 1) { return; } itemId = Convert.ToInt32(grid.DataKeys[itemIndex]); cfs = UserCustomFieldSelectionManager.GetById(itemId); cfs.SortOrder += 1; UserCustomFieldSelectionManager.SaveOrUpdate(cfs); break; case "add": if (Page.IsValid) { var txtAddSelectionName = (TextBox)e.Item.FindControl("txtAddSelectionName"); var txtAddSelectionValue = (TextBox)e.Item.FindControl("txtAddSelectionValue"); cfs = new UserCustomFieldSelection { CustomFieldId = Convert.ToInt32(e.CommandArgument), Name = txtAddSelectionName.Text.Trim(), Value = txtAddSelectionValue.Text.Trim() }; UserCustomFieldSelectionManager.SaveOrUpdate(cfs); } break; } BindCustomFieldSelections(); }
/// <summary> /// Saves this instance. /// </summary> /// <param name="entity">The custom field selection to save.</param> /// <returns></returns> public static bool SaveOrUpdate(UserCustomFieldSelection entity) { if (entity.Id > Globals.NEW_ID) { return(DataProviderManager.Provider.UpdateUserCustomFieldSelection(entity)); } var tempId = DataProviderManager.Provider.CreateNewUserCustomFieldSelection(entity); if (tempId <= 0) { return(false); } entity.Id = tempId; return(true); }
public abstract bool UpdateUserCustomFieldSelection(UserCustomFieldSelection customFieldSelectionToUpdate);
// User Custom Field Selections public abstract int CreateNewUserCustomFieldSelection(UserCustomFieldSelection newCustomFieldSelection);