/// <summary> /// Button OK click event handler. /// </summary> protected void btnOk_Click(object sender, EventArgs e) { if (modifyAccountContact) { string resultMessage = string.Empty; Action action = (Action)ValidationHelper.GetInteger(drpAction.SelectedItem.Value, 0); What what = (What)ValidationHelper.GetInteger(drpWhat.SelectedItem.Value, 0); string where = string.Empty; switch (what) { // All items case What.All: where = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, gridElem.WhereClause); where = string.Format("AccountID={0} AND ContactID IN (SELECT ContactID FROM View_OM_AccountContact_ContactJoined WHERE {1})", ai.AccountID, where); break; // Selected items case What.Selected: where = SqlHelperClass.GetWhereCondition <int>("AccountContactID", ContactHelper.GetSafeArray(gridElem.SelectedItems), false); break; default: return; } switch (action) { // Action 'Remove' case Action.Remove: // Reset account's main contact IDs if any of the contacts was set as primary or secondary contact AccountContactInfoProvider.ResetAccountMainContacts(ai.AccountID, 0, where); // Delete the relations between account and contacts AccountContactInfoProvider.DeleteAllAccountContacts(where); resultMessage = GetString("om.contact.massaction.removed"); break; // Action 'Select role' case Action.SelectRole: // Get selected role ID from hidden field int roleId = ValidationHelper.GetInteger(hdnValue.Value, -1); if (roleId >= 0) { AccountContactInfoProvider.UpdateContactRole(roleId, where); resultMessage = GetString("om.contact.massaction.roleassigned"); } break; default: return; } if (!string.IsNullOrEmpty(resultMessage)) { lblInfo.Text = resultMessage; lblInfo.Visible = true; } // Reload unigrid gridElem.ClearSelectedItems(); gridElem.ReloadData(); pnlUpdate.Update(); } // No permission modify else { if (this.SiteID > 0) { CMSPage.RedirectToCMSDeskAccessDenied("CMS.ContactManagement", "ModifyAccounts"); } else { CMSPage.RedirectToCMSDeskAccessDenied("CMS.ContactManagement", "ModifyGlobalAccounts"); } } }
protected void btnOk_Click(object sender, EventArgs e) { if (mModifyAccountContact) { Action action = (Action)ValidationHelper.GetInteger(drpAction.SelectedItem.Value, 0); What what = (What)ValidationHelper.GetInteger(drpWhat.SelectedItem.Value, 0); string where = string.Empty; switch (what) { // All items case What.All: where = SqlHelper.AddWhereCondition(gridElem.WhereCondition, gridElem.WhereClause); where = string.Format("ContactID={0} AND AccountID IN (SELECT AccountID FROM View_OM_AccountContact_AccountJoined WHERE {1})", mContactInfo.ContactID, where); break; // Selected items case What.Selected: where = SqlHelper.GetWhereCondition <int>("AccountContactID", gridElem.SelectedItems, false); break; default: return; } switch (action) { // Action 'Remove' case Action.Remove: // Reset accounts' main contact IDs if the contact was set as primary or secondary contact AccountContactInfoProvider.ResetAccountMainContacts(0, mContactInfo.ContactID, where); // Delete the relations between contact and accounts AccountContactInfoProvider.DeleteAllAccountContacts(where); // Show result message if (what == What.Selected) { ShowConfirmation(GetString("om.account.massaction.removed")); } else { ShowConfirmation(GetString("om.account.massaction.removedall")); } break; // Action 'Select role' case Action.SelectRole: // Get selected role ID from hidden field int roleId = ValidationHelper.GetInteger(hdnValue.Value, -1); if (roleId >= 0 && mModifyAccountContact) { AccountContactInfoProvider.UpdateContactRole(roleId, where); ShowConfirmation(GetString("om.contact.massaction.roleassigned")); } break; default: return; } // Reload unigrid gridElem.ResetSelection(); gridElem.ReloadData(); pnlUpdate.Update(); } // No permission modify else { CMSPage.RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "Modify"); } }