/// <summary> /// Event handler for the Datagrid custom control. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void reminderCheckList_ViewEvent(object sender, CollectionViewEventArgs e) { string speedCode = SiteMap.CurrentNode.Description; string keyName = BCC.Core.BCCUIHelper.Constants.REM_CHK_LIST_KEY; StringCollection stringCollection = null; // this is sweet code. loved it. if (e.OperationCode == "Add" || e.OperationCode == "AddOnEmpty") { BCCModuleProperty props = Profile.ControlCenterProfile.ModuleFilter[speedCode]; if (props != null) { if (e.KeyName != string.Empty) { stringCollection = props.ModuleDictionary[keyName]; } } if (stringCollection != null) { stringCollection.Add(e.ItemName); } } else if (e.OperationCode == "Remove") { BCCModuleProperty props = Profile.ControlCenterProfile.ModuleFilter[speedCode]; if (props != null) { if (e.KeyName != string.Empty) { stringCollection = props.ModuleDictionary[keyName]; } } if (stringCollection != null) { stringCollection.Remove(e.ItemName); } } BindModuleConfiguration(speedCode, keyName); }
protected void collectionView_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Add") { TextBox tbCollectionItem = collectionView.FooterRow.FindControl("tbCollectionItem") as TextBox; if (tbCollectionItem != null) { // Generate an event with // ItemName, KeyName, OperationCode (Add, Remove) if (CollectionViewEvent != null) { CollectionViewEventArgs args = new CollectionViewEventArgs(KeyName, tbCollectionItem.Text, "Add"); CollectionViewEvent(this, args); } } } else if (e.CommandName == "Remove") { GridViewRow selectedRow = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer); if (selectedRow != null) { Label lblCollectionItem = selectedRow.FindControl("lblCollectionItem") as Label; if (lblCollectionItem != null) { CollectionViewEventArgs args = new CollectionViewEventArgs(KeyName, lblCollectionItem.Text, "Remove"); CollectionViewEvent(this, args); } } } else if (e.CommandName == "AddOnEmpty") { TextBox tbEmptyInsert = collectionView.Controls[0].Controls[0].FindControl("tbEmptyInsert") as TextBox; if (tbEmptyInsert != null) { if (CollectionViewEvent != null) { CollectionViewEventArgs args = new CollectionViewEventArgs(KeyName, tbEmptyInsert.Text, "AddOnEmpty"); CollectionViewEvent(this, args); } } } }
/// <summary> /// Event handler for the Datagrid custom control. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void moduleConfiguration_CollectionViewEvent(object sender, CollectionViewEventArgs e) { string speedCode = ddlModule.SelectedValue; string keyName = e.KeyName; StringCollection stringCollection = null; // this is sweet code. loved it. if (e.OperationCode == "Add" || e.OperationCode == "AddOnEmpty") { BCCModuleProperty props = Profile.ControlCenterProfile.ModuleFilter[speedCode]; if (props != null) { if (e.KeyName != string.Empty) { stringCollection = props.ModuleDictionary[keyName]; } } if (stringCollection != null) { stringCollection.Add(e.ItemName); BindModuleConfiguration(speedCode, keyName); new ActivityHelper().RaiseAuditEvent(this, lblCaption.Text, string.Format("added items to key '{0}' for speedcode {1}", keyName, speedCode), 603); } } else if (e.OperationCode == "Remove") { BCCModuleProperty props = Profile.ControlCenterProfile.ModuleFilter[speedCode]; if (props != null) { if (e.KeyName != string.Empty) { stringCollection = props.ModuleDictionary[keyName]; } } if (stringCollection != null) { stringCollection.Remove(e.ItemName); BindModuleConfiguration(speedCode, keyName); new ActivityHelper().RaiseAuditEvent(this, lblCaption.Text, string.Format("removed items from key '{0}' for speedcode {1}", keyName, speedCode), 603); } } }