private void ChangeStatus(What what) { int statusId = ValidationHelper.GetInteger(hdnIdentifier.Value, -1); string where = null; switch (what) { case What.All: where = "ContactID IN (SELECT ContactGroupMemberRelatedID FROM OM_ContactGroupMember WHERE ContactGroupMemberContactGroupID = " + cgi.ContactGroupID + ")"; break; case What.Selected: where = SqlHelper.GetWhereCondition <int>("ContactID", gridElem.SelectedItems, false); break; } ContactInfoProvider.UpdateContactStatus(statusId, where); ShowConfirmation(GetString("om.contact.massaction.statuschanged")); }
/// <summary> /// Mass operation button "OK" click. /// </summary> protected void btnOk_Click(object sender, EventArgs e) { string resultMessage = string.Empty; // Get where condition depending on mass action selection string where; List <string> contactIds = null; What what = (What)ValidationHelper.GetInteger(drpWhat.SelectedValue, 0); switch (what) { // All items case What.All: // Get all contacts with scores based on filter condition var contacts = GetContactsWithScore(); if (!DataHelper.DataSourceIsEmpty(contacts)) { // Get array list with IDs contactIds = DataHelper.GetUniqueValues(contacts.Tables[0], "ContactID", true); } break; // Selected items case What.Selected: // Get selected IDs from unigrid contactIds = gridElem.SelectedItems; break; } // Prepare where condition if ((contactIds != null) && (contactIds.Count > 0)) { where = SqlHelper.GetWhereCondition <int>("ContactID", contactIds, false); } else { where = "0=1"; } Action action = (Action)ValidationHelper.GetInteger(drpAction.SelectedItem.Value, 0); switch (action) { // Action 'Change status' case Action.ChangeStatus: // Get selected status ID from hidden field int statusId = ValidationHelper.GetInteger(hdnIdentifier.Value, -1); // If status ID is 0, the status will be removed if (statusId >= 0) { ContactInfoProvider.UpdateContactStatus(statusId, where); resultMessage = GetString("om.contact.massaction.statuschanged"); } break; // Action 'Add to contact group' case Action.AddToGroup: // Get contact group ID from hidden field int groupId = ValidationHelper.GetInteger(hdnIdentifier.Value, 0); if ((groupId > 0) && (contactIds != null)) { // Add each selected contact to the contact group, skip contacts that are already members of the group foreach (string item in contactIds) { int contactId = ValidationHelper.GetInteger(item, 0); if (contactId > 0) { ContactGroupMemberInfoProvider.SetContactGroupMemberInfo(groupId, contactId, ContactGroupMemberTypeEnum.Contact, MemberAddedHowEnum.Manual); } } // Get contact group to show result message with its display name ContactGroupInfo group = ContactGroupInfoProvider.GetContactGroupInfo(groupId); if (group != null) { resultMessage = String.Format(GetString("om.contact.massaction.addedtogroup"), group.ContactGroupDisplayName); } } break; default: return; } if (!string.IsNullOrEmpty(resultMessage)) { lblInfo.Text = resultMessage; lblInfo.Visible = true; } // Reload unigrid gridElem.ClearSelectedItems(); gridElem.ReloadData(); pnlUpdate.Update(); }
/// <summary> /// Mass operation button "OK" click. /// </summary> protected void btnOk_Click(object sender, EventArgs e) { // Get where condition depending on mass action selection string where = null; What what = (What)ValidationHelper.GetInteger(drpWhat.SelectedValue, 0); switch (what) { // All items case What.All: where = SqlHelper.AddWhereCondition(gridElem.WhereCondition, gridElem.WhereClause); break; // Selected items case What.Selected: where = SqlHelper.GetWhereCondition <int>("ContactID", gridElem.SelectedItems, false); break; } Action action = (Action)ValidationHelper.GetInteger(drpAction.SelectedItem.Value, 0); switch (action) { // Action 'Change status' case Action.ChangeStatus: // Get selected status ID from hidden field int statusId = ValidationHelper.GetInteger(hdnIdentifier.Value, -1); // If status ID is 0, the status will be removed if (statusId >= 0) { ContactInfoProvider.UpdateContactStatus(statusId, where); ShowConfirmation(GetString("om.contact.massaction.statuschanged")); } break; // Action 'Add to contact group' case Action.AddToGroup: // Get contact group ID from hidden field int groupId = ValidationHelper.GetInteger(hdnIdentifier.Value, 0); if (groupId > 0) { var contactGroup = ContactGroupInfoProvider.GetContactGroupInfo(groupId); if (contactGroup == null) { RedirectToAccessDenied(GetString("general.invalidparameters")); return; } if (contactGroup.ContactGroupSiteID != CurrentSite.SiteID) { RedirectToAccessDenied(GetString("general.invalidparameters")); return; } IEnumerable <string> contactIds = null; switch (what) { // All items case What.All: // Get selected IDs based on where condition DataSet contacts = ContactInfoProvider.GetContacts().Where(where).Column("ContactID"); if (!DataHelper.DataSourceIsEmpty(contacts)) { // Get array list with IDs contactIds = DataHelper.GetUniqueValues(contacts.Tables[0], "ContactID", true); } break; // Selected items case What.Selected: // Get selected IDs from unigrid contactIds = gridElem.SelectedItems; break; } if (contactIds != null) { // Add each selected contact to the contact group, skip contacts that are already members of the group foreach (string item in contactIds) { int contactId = item.ToInteger(0); if (contactId > 0) { ContactGroupMemberInfoProvider.SetContactGroupMemberInfo(groupId, contactId, ContactGroupMemberTypeEnum.Contact, MemberAddedHowEnum.Manual); } } // Show result message with contact group's display name ShowConfirmation(String.Format(GetString("om.contact.massaction.addedtogroup"), ResHelper.LocalizeString(contactGroup.ContactGroupDisplayName))); } } break; // Merge click case Action.Merge: DataSet selectedContacts = ContactHelper.GetContactListInfos(null, where, null, -1, null); if (!DataHelper.DataSourceIsEmpty(selectedContacts)) { // Get selected contact ID from hidden field int contactID = ValidationHelper.GetInteger(hdnIdentifier.Value, -1); // If contact ID is 0 then new contact must be created if (contactID == 0) { int siteID; if (filter.DisplaySiteSelector || filter.DisplayGlobalOrSiteSelector) { siteID = filter.SelectedSiteID; } else { siteID = SiteID; } SetDialogParameters(selectedContacts, ContactHelper.GetNewContact(ContactHelper.MERGED, true, siteID)); } // Selected contact to be merged into else if (contactID > 0) { SetDialogParameters(selectedContacts, ContactInfoProvider.GetContactInfo(contactID)); } OpenWindow(); } break; default: return; } // Reload unigrid gridElem.ResetSelection(); gridElem.ReloadData(); pnlUpdate.Update(); }
/// <summary> /// Mass operation button "OK" click. /// </summary> protected void btnOk_Click(object sender, EventArgs e) { string resultMessage = string.Empty; // Get where condition depending on mass action selection string where = null; What what = (What)ValidationHelper.GetInteger(drpWhat.SelectedValue, 0); switch (what) { // All items case What.All: where = gridElem.WhereCondition; break; // Selected items case What.Selected: where = SqlHelperClass.GetWhereCondition <int>("ContactID", (string[])gridElem.SelectedItems.ToArray(typeof(string)), false); break; } Action action = (Action)ValidationHelper.GetInteger(drpAction.SelectedItem.Value, 0); switch (action) { // Action 'Change status' case Action.ChangeStatus: // Get selected status ID from hidden field int statusId = ValidationHelper.GetInteger(hdnIdentificator.Value, -1); // If status ID is 0, the status will be removed if (statusId >= 0) { ContactInfoProvider.UpdateContactStatus(statusId, where); resultMessage = GetString("om.contact.massaction.statuschanged"); } break; // Action 'Add to contact group' case Action.AddToGroup: // Get contact group ID from hidden field int groupId = ValidationHelper.GetInteger(hdnIdentificator.Value, 0); if (groupId > 0) { ArrayList contactIds = null; switch (what) { // All items case What.All: // Get selected IDs based on where condition DataSet contacts = ContactInfoProvider.GetContacts(where, null, 0, "ContactID"); if (!DataHelper.DataSourceIsEmpty(contacts)) { // Get array list with IDs contactIds = DataHelper.GetUniqueValues(contacts.Tables[0], "ContactID", true); } break; // Selected items case What.Selected: // Get selected IDs from unigrid contactIds = gridElem.SelectedItems; break; } if (contactIds != null) { int contactId = 0; // Add each selected contact to the contact group, skip contacts that are already members of the group foreach (string item in contactIds) { contactId = ValidationHelper.GetInteger(item, 0); if (contactId > 0) { ContactGroupMemberInfoProvider.SetContactGroupMemberInfo(groupId, contactId, ContactGroupMemberTypeEnum.Contact, MemberAddedHowEnum.Manual); } } // Get contact group to show result message with its display name ContactGroupInfo group = ContactGroupInfoProvider.GetContactGroupInfo(groupId); if (group != null) { resultMessage = String.Format(GetString("om.contact.massaction.addedtogroup"), group.ContactGroupDisplayName); } } } break; // Merge click case Action.Merge: DataSet selectedContacts = ContactHelper.GetContactListInfos(null, where, null, -1, null); if (!DataHelper.DataSourceIsEmpty(selectedContacts)) { // Get selected contact ID from hidden field int contactID = ValidationHelper.GetInteger(hdnIdentificator.Value, -1); // If contact ID is 0 then new contact must be created if (contactID == 0) { int siteID; if (filter.DisplaySiteSelector || filter.DisplayGlobalOrSiteSelector) { siteID = filter.SelectedSiteID; } else { siteID = SiteID; } SetDialogParameters(selectedContacts, ContactHelper.GetNewContact(ContactHelper.MERGED, true, siteID)); } // Selected contact to be merged into else if (contactID > 0) { SetDialogParameters(selectedContacts, ContactInfoProvider.GetContactInfo(contactID)); } OpenWindow(); } break; default: return; } if (!string.IsNullOrEmpty(resultMessage)) { lblInfo.Text = resultMessage; lblInfo.Visible = true; } // Reload unigrid gridElem.ClearSelectedItems(); gridElem.ReloadData(); pnlUpdate.Update(); }