/// <summary> /// Handles the RowCommand event of the grdResponses control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewCommandEventArgs"/> instance containing the event data.</param> protected void grdResponses_RowCommand(object sender, GridViewCommandEventArgs e) { ITargetResponse targetResponse; string responseId = String.Empty; try { int rowIndex = Convert.ToInt32(e.CommandArgument); responseId = grdResponses.DataKeys[rowIndex].Values[0].ToString(); if (String.IsNullOrEmpty(responseId)) { return; } targetResponse = EntityFactory.GetRepository <ITargetResponse>().Get(responseId); if (targetResponse == null) { return; } } catch { return; } switch (e.CommandName.ToUpper()) { case "EDIT": ShowResponseView(targetResponse); break; case "DELETE": if (targetResponse != null) { ICampaignTarget campaignTarget = targetResponse.CampaignTarget; if (campaignTarget != null) { campaignTarget.Status = GetLocalResourceObject("TargetStatus_Removed").ToString(); campaignTarget.TargetResponses.Remove(targetResponse); } targetResponse.Delete(); LoadResponses(); } PanelRefresh.RefreshTabWorkspace(); break; case "SORT": break; } }
/// <summary> /// Handles the RowCommand event of the AccountMarketing control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewCommandEventArgs"/> instance containing the event data.</param> protected void AccountMarketing_RowCommand(object sender, GridViewCommandEventArgs e) { ITargetResponse targetResponse = null; ICampaignTarget campaignTarget = null; string targetId = String.Empty; string responseId = String.Empty; try { int rowIndex = Convert.ToInt32(e.CommandArgument); targetId = grdAccountMarketing.DataKeys[rowIndex].Values[0].ToString(); responseId = grdAccountMarketing.DataKeys[rowIndex].Values[1].ToString(); if (!string.IsNullOrEmpty(responseId)) { targetResponse = EntityFactory.GetRepository <ITargetResponse>().Get(responseId); campaignTarget = targetResponse.CampaignTarget; } else if (!string.IsNullOrEmpty(targetId)) { campaignTarget = EntityFactory.GetRepository <ICampaignTarget>().Get(targetId); } } catch { } switch (e.CommandName.ToUpper()) { case "ADD": if (targetResponse == null || targetResponse.Id != null) { targetResponse = EntityFactory.Create <ITargetResponse>(); targetResponse.Campaign = campaignTarget.Campaign; targetResponse.Contact = EntityFactory.GetRepository <IContact>().Get(campaignTarget.EntityId); targetResponse.CampaignTarget = campaignTarget; ShowResponseView(targetResponse); } else { ShowResponseView(targetResponse); } break; case "EDIT": if (String.IsNullOrEmpty(targetId)) { AddResponseAndTarget(); } else { if (targetResponse == null) { targetResponse = EntityFactory.Create <ITargetResponse>(); targetResponse.Campaign = campaignTarget.Campaign; targetResponse.CampaignTarget = campaignTarget; targetResponse.Contact = EntityFactory.GetRepository <IContact>().Get(campaignTarget.EntityId); } ShowResponseView(targetResponse); } break; case "DELETE": if (targetResponse != null) { if (campaignTarget.TargetResponses.Count <= 1) { campaignTarget.Status = GetLocalResourceObject("TargetStatus_Removed").ToString(); } campaignTarget.TargetResponses.Remove(targetResponse); targetResponse.Delete(); LoadMarketing(); } else { RemoveTargetAssociation(targetId); } PanelRefresh.RefreshTabWorkspace(); break; case "REMOVE": RemoveTargetAssociation(targetId); break; case "SORT": break; } }
/// <summary> /// Handles the OnClick event of the cmdClose control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void cmdClose_OnClick(object sender, EventArgs e) { DialogService.CloseEventHappened(sender, e); PanelRefresh.RefreshTabWorkspace(); }