protected void Page_Load(object sender, EventArgs e) { modifyPermission = AccountHelper.AuthorizedModifyAccount(this.SiteID, false); if (this.SiteID == UniSelector.US_GLOBAL_OR_SITE_RECORD) { modifyGlobal = AccountHelper.AuthorizedModifyAccount(UniSelector.US_GLOBAL_RECORD, false); modifySite = AccountHelper.AuthorizedModifyAccount(CMSContext.CurrentSiteID, false); } filter.ShowGlobalStatuses = ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false); // Setup unigrid gridElem.OnBeforeDataReload += new OnBeforeDataReload(gridElem_OnBeforeDataReload); gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound); gridElem.WhereCondition = filter.WhereCondition; gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, this.WhereCondition); gridElem.EditActionUrl = "Frameset.aspx?accountId={0}&siteId=" + this.SiteID; gridElem.ZeroRowsText = GetString("om.account.noaccountsfound"); if (ContactHelper.IsSiteManager) { gridElem.EditActionUrl = URLHelper.AddParameterToUrl(gridElem.EditActionUrl, "issitemanager", "1"); } // Initialize dropdown lists if (!RequestHelper.IsPostBack()) { drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString())); if ((modifyPermission || ContactGroupHelper.AuthorizedModifyContactGroup(this.SiteID, false)) && ContactGroupHelper.AuthorizedReadContactGroup(this.SiteID, false)) { drpAction.Items.Add(new ListItem(GetString("om.account." + Action.AddToGroup), Convert.ToInt32(Action.AddToGroup).ToString())); } if (modifyPermission) { drpAction.Items.Add(new ListItem(GetString("general.delete"), Convert.ToInt32(Action.Delete).ToString())); drpAction.Items.Add(new ListItem(GetString("om.account." + Action.Merge), Convert.ToInt32(Action.Merge).ToString())); if (SiteID >= 0) { drpAction.Items.Add(new ListItem(GetString("om.account." + Action.ChangeStatus), Convert.ToInt32(Action.ChangeStatus).ToString())); } } drpWhat.Items.Add(new ListItem(GetString("om.account." + What.Selected), Convert.ToInt32(What.Selected).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.account." + What.All), Convert.ToInt32(What.All).ToString())); } else { if (RequestHelper.CausedPostback(btnOk)) { // Set delayed reload for unigrid if mass action is performed gridElem.DelayedReload = true; } } if (Request.Params["__EVENTARGUMENT"] == ACCOUNTS_MERGED) { lblInfo.Text = GetString("om.account.merginglist"); } // Register JS scripts RegisterScripts(); }
/// <summary> /// Actions handler. /// </summary> protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e) { // Check permission AccountHelper.AuthorizedModifyAccount(SiteID, true); switch (e.CommandName.ToLowerCSafe()) { // Save account case "save": if (EditForm.SaveData(null)) { SetButtonsVisibility(); } break; // Split from parent account case "split": var mergedAccount = (AccountInfo)UIContext.EditedObject; List <AccountInfo> mergedAccountList = new List <AccountInfo>(1) { mergedAccount }; AccountHelper.Split(parentAccount, mergedAccountList, false, false, false); SetButtonsVisibility(); ShowConfirmation(GetString("om.account.splitted")); ScriptHelper.RefreshTabHeader(Page, mergedAccount.AccountDescriptiveName); break; } }
protected void btnOK_Click(object sender, EventArgs e) { // Check permissions if (AccountHelper.AuthorizedModifyAccount(accountSiteId, true)) { EnsureAsyncLog(); RunAsyncDelete(); } }
protected void Page_Load(object sender, EventArgs e) { // Ensure, that it is going to be rendered pnlRole.Visible = true; ScriptHelper.RegisterWOpenerScript(Page); ScriptHelper.RegisterJQuery(Page); // Try to get parameters string identifier = QueryHelper.GetString("params", null); Hashtable parameters = (Hashtable)WindowHelper.GetItem(identifier); // Validate hash if ((QueryHelper.ValidateHash("hash", "selectedvalue")) && (parameters != null)) { int siteID = ValidationHelper.GetInteger(parameters["SiteID"], -1); if (siteID != -1) { // Check permissions ContactHelper.AuthorizedReadContact(siteID, true); if (AccountHelper.AuthorizedModifyAccount(siteID, false) || ContactHelper.AuthorizedModifyContact(siteID, false)) { contactRoleSelector.SiteID = siteID; contactRoleSelector.IsLiveSite = false; contactRoleSelector.UniSelector.DialogWindowName = "SelectContactRole"; contactRoleSelector.IsSiteManager = ValidationHelper.GetBoolean(parameters["IsSiteManager"], false); selectionDialog.LocalizeItems = QueryHelper.GetBoolean("localize", true); // Load resource prefix string resourcePrefix = ValidationHelper.GetString(parameters["ResourcePrefix"], "general"); // Set the page title string titleText = GetString(resourcePrefix + ".selectitem|general.selectitem"); // Validity group text lblAddAccounts.ResourceString = resourcePrefix + ".contactsrole"; pnlRoleHeading.Visible = true; PageTitle.TitleText = titleText; Page.Title = titleText; } // No permission modify else { RedirectToAccessDenied(ModuleName.CONTACTMANAGEMENT, "ModifyAccount"); } } else { // Redirect to error page URLHelper.Redirect(ResolveUrl("~/CMSMessages/Error.aspx?title=" + ResHelper.GetString("dialogs.badhashtitle") + "&text=" + ResHelper.GetString("dialogs.badhashtext"))); } } CurrentMaster.PanelContent.RemoveCssClass("dialog-content"); }
protected void Page_Load(object sender, EventArgs e) { // Get edited object if (CMSContext.EditedObject != null) { ai = (AccountInfo)CMSContext.EditedObject; SiteID = ai.AccountSiteID; // Setup unigrid gridElem.GridOptions.ShowSelection = (ai.AccountMergedWithAccountID == 0); gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, "(AccountID = " + ai.AccountID + ") AND ((ContactMergedWithContactID IS NULL AND ContactSiteID > 0) OR (ContactGlobalContactID IS NULL AND ContactSiteID IS NULL))"); gridElem.OnAction += new OnActionEventHandler(gridElem_OnAction); gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound); gridElem.ZeroRowsText = GetString("om.account.nocontacts"); // Initialize dropdown lists if (!RequestHelper.IsPostBack()) { drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString())); drpAction.Items.Add(new ListItem(GetString("general.remove"), Convert.ToInt32(Action.Remove).ToString())); drpAction.Items.Add(new ListItem(GetString("om.contactrole.select"), Convert.ToInt32(Action.SelectRole).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.contact." + What.Selected), Convert.ToInt32(What.Selected).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.contact." + What.All), Convert.ToInt32(What.All).ToString())); } else { if (RequestHelper.CausedPostback(btnOk)) { // Set delayed reload for unigrid if mass action is performed gridElem.DelayedReload = true; } } // Initialize contact selector contactSelector.UniSelector.ButtonImage = GetImageUrl("/Objects/OM_Contact/add.png"); contactSelector.UniSelector.DialogImage.CssClass = "NewItemImage"; contactSelector.UniSelector.DialogLink.CssClass = "MenuItemEdit"; contactSelector.UniSelector.OnItemsSelected += new EventHandler(UniSelector_OnItemsSelected); contactSelector.UniSelector.SelectionMode = SelectionModeEnum.MultipleButton; contactSelector.UniSelector.SelectItemPageUrl = "~/CMSModules/ContactManagement/Pages/Tools/Account/Add_Contact_Dialog.aspx"; contactSelector.UniSelector.SetValue("SiteID", SiteID); contactSelector.UniSelector.SetValue("IsLiveSite", false); contactSelector.UniSelector.FilterControl = "~/CMSModules/ContactManagement/Filters/ContactFilter.ascx"; contactSelector.UniSelector.UseDefaultNameFilter = false; contactSelector.IsSiteManager = ContactHelper.IsSiteManager; modifyAccountContact = AccountHelper.AuthorizedModifyAccount(SiteID, false) || ContactHelper.AuthorizedModifyContact(SiteID, false); // Register JS scripts RegisterScripts(); } else { StopProcessing = true; } }
protected void Page_Load(object sender, EventArgs e) { bool isGlobal = Account.AccountSiteID == 0; // Current contact is global object if (isGlobal) { filter.SiteID = CMSContext.CurrentSiteID; // Display site selector in site manager if (ContactHelper.IsSiteManager) { filter.SiteID = UniSelector.US_GLOBAL_RECORD; filter.DisplaySiteSelector = true; } // Display 'site or global' selector in CMS desk for global objects else if (AccountHelper.AuthorizedModifyAccount(CMSContext.CurrentSiteID, false) && AccountHelper.AuthorizedReadAccount(CMSContext.CurrentSiteID, false)) { filter.DisplayGlobalOrSiteSelector = true; } } else { filter.SiteID = Account.AccountSiteID; } filter.ShowGlobalStatuses = ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false) && (SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSCMGlobalConfiguration") || ContactHelper.IsSiteManager); filter.ShowChildren = ShowChildrenOption; string where = filter.WhereCondition; if (!filter.ChildrenSelected) { // Display only direct children ("first level") where = SqlHelperClass.AddWhereCondition(where, "AccountGlobalAccountID = " + Account.AccountID + " OR AccountMergedWithAccountID = " + Account.AccountID); } else if (isGlobal) { // Get children for global contact where = SqlHelperClass.AddWhereCondition(where, "AccountID IN (SELECT * FROM Func_OM_Account_GetChildren_Global(" + Account.AccountID + ", 0))"); } else { // Get children for site contact where = SqlHelperClass.AddWhereCondition(where, "AccountID IN (SELECT * FROM Func_OM_Account_GetChildren(" + Account.AccountID + ", 0))"); } gridElem.WhereCondition = where; gridElem.ZeroRowsText = GetString("om.account.noaccountsfound"); gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound); btnSplit.Click += new EventHandler(btnSplit_Click); // Register JS scripts RegisterScripts(); }
protected void btnOk_Click(object sender, EventArgs e) { if (AccountHelper.AuthorizedModifyAccount(SiteID, true)) { 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 = CMSContext.ResolveMacros(gridElem.WhereCondition); break; // Selected items case What.Selected: where = SqlHelperClass.GetWhereCondition <int>("AccountID", gridElem.SelectedItems, false); break; default: return; } switch (action) { // Action 'Remove' case Action.Remove: // Clear HQ ID of selected accounts AccountInfoProvider.UpdateAccountHQ(0, where); resultMessage = GetString("om.account.massaction.removed"); break; default: return; } if (!string.IsNullOrEmpty(resultMessage)) { lblInfo.Text = resultMessage; lblInfo.Visible = true; } // Reload UniGrid gridElem.ClearSelectedItems(); gridElem.ReloadData(); pnlUpdate.Update(); } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); // Hide footer if grid is empty or if the account is merged (is not active) pnlFooter.Visible = (!gridElem.IsEmpty) && (gridElem.GridOptions.ShowSelection); // Hide controls when account is merged or user doesn't have permission if ((ai.AccountMergedWithAccountID != 0) || (!AccountHelper.AuthorizedModifyAccount(this.SiteID, false) && !ContactHelper.AuthorizedModifyContact(this.SiteID, false))) { pnlFooter.Visible = false; pnlSelector.Visible = false; } }
protected void Page_Load(object sender, EventArgs e) { if (Account != null) { // Current account is global object if (Account.AccountSiteID == 0) { mFilter.SiteID = SiteContext.CurrentSiteID; // Display site selector in site manager if (ContactHelper.IsSiteManager) { mFilter.DisplaySiteSelector = true; mFilter.SiteID = UniSelector.US_GLOBAL_RECORD; } // Display 'site or global' selector in CMS desk for global objects else if (AccountHelper.AuthorizedModifyAccount(SiteContext.CurrentSiteID, false) && AccountHelper.AuthorizedReadAccount(SiteContext.CurrentSiteID, false)) { mFilter.DisplayGlobalOrSiteSelector = true; } mFilter.HideMergedIntoGlobal = true; } else { mFilter.SiteID = Account.AccountSiteID; } mFilter.ShowGlobalStatuses = ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false) && (SettingsKeyInfoProvider.GetBoolValue(SiteContext.CurrentSiteName + ".CMSCMGlobalConfiguration") || ContactHelper.IsSiteManager); gridElem.WhereCondition = mFilter.WhereCondition; gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, "AccountID <> " + Account.AccountID); gridElem.ZeroRowsText = GetString("om.account.noaccountsfound"); btnMergeSelected.Click += btnMergeSelected_Click; btnMergeAll.Click += btnMergeAll_Click; if (Request[Page.postEventArgumentID] == "saved") { ShowConfirmation(GetString("om.account.merging")); // Clear selected items gridElem.ResetSelection(); } } else { StopProcessing = true; Visible = false; } }
/// <summary> /// Button merge click. /// </summary> private void btnMerge_Click(object sender, EventArgs e) { if (AccountHelper.AuthorizedModifyAccount(SiteID, true)) { if (gridElem.SelectedItems.Count > 0) { SetDialogParameters(false); OpenWindow(); } else { ShowError(GetString("om.account.selectaccounts")); } } }
/// <summary> /// Button merge click. /// </summary> private void btnMergeAll_Click(object sender, EventArgs e) { if (AccountHelper.AuthorizedModifyAccount(SiteID, true)) { if (!DataHelper.DataSourceIsEmpty(gridElem.GridView.DataSource)) { SetDialogParameters(true); OpenWindow(); } else { ShowError(GetString("om.account.noaccounts")); } } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); // Disable actions for unauthorized users if (!AccountHelper.AuthorizedModifyAccount(listElem.SiteID, false)) { hdrActions.Enabled = false; } // Allow new button only for particular sites or (global) site else if ((listElem.SiteID < 0) && (listElem.SiteID != UniSelector.US_GLOBAL_RECORD)) { hdrActions.Enabled = false; lblWarnNew.Visible = true; } }
/// <summary> /// Button merge click. /// </summary> void btnMergeAll_Click(object sender, EventArgs e) { if (AccountHelper.AuthorizedModifyAccount(this.SiteID, true)) { if (!DataHelper.DataSourceIsEmpty(gridElem.GridView.DataSource)) { SetDialogParameters(true); OpenWindow(); } else { lblError.Visible = true; lblError.ResourceString = "om.account.noaccounts"; } } }
/// <summary> /// UniGrid button clicked. /// </summary> private void gridElem_OnAction(string actionName, object actionArgument) { if (actionName == "remove") { if (AccountHelper.AuthorizedModifyAccount(SiteID, true)) { int relationId = ValidationHelper.GetInteger(actionArgument, 0); AccountInfo editedObject = AccountInfoProvider.GetAccountInfo(relationId); if (editedObject != null) { editedObject.AccountSubsidiaryOfID = 0; AccountInfoProvider.SetAccountInfo(editedObject); } } } }
/// <summary> /// Button merge click. /// </summary> void btnMerge_Click(object sender, EventArgs e) { if (AccountHelper.AuthorizedModifyAccount(this.SiteID, true)) { if (gridElem.SelectedItems.Count > 0) { SetDialogParameters(false); OpenWindow(); } else { lblError.Visible = true; lblError.ResourceString = "om.account.selectaccounts"; } } }
protected void Page_Load(object sender, EventArgs e) { if (this.Account != null) { // Current account is global object if (this.Account.AccountSiteID == 0) { filter.SiteID = CMSContext.CurrentSiteID; // Display site selector in site manager if (ContactHelper.IsSiteManager) { filter.SiteID = UniSelector.US_GLOBAL_RECORD; filter.DisplaySiteSelector = true; } // Display 'site or global' selector in CMS desk for global objects else if (AccountHelper.AuthorizedModifyAccount(CMSContext.CurrentSiteID, false) && AccountHelper.AuthorizedReadAccount(CMSContext.CurrentSiteID, false)) { filter.DisplayGlobalOrSiteSelector = true; } filter.HideMergedIntoGlobal = true; } else { filter.SiteID = Account.AccountSiteID; } filter.ShowGlobalStatuses = ConfigurationHelper.AuthorizedReadConfiguration(UniSelector.US_GLOBAL_RECORD, false) && (SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSCMGlobalConfiguration") || ContactHelper.IsSiteManager); gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(CMControlsHelper.UniGridOnExternalDataBound); gridElem.WhereCondition = filter.WhereCondition; gridElem.WhereCondition = SqlHelperClass.AddWhereCondition(gridElem.WhereCondition, "AccountID <> " + this.Account.AccountID); gridElem.ZeroRowsText = GetString("om.account.noaccountsfound"); btnMergeSelected.Click += new EventHandler(btnMergeSelected_Click); btnMergeAll.Click += new EventHandler(btnMergeAll_Click); if (QueryHelper.GetBoolean("saved", false)) { lblInfo.Visible = true; } } else { this.StopProcessing = true; this.Visible = false; } }
protected void Page_Init(object sender, EventArgs e) { mContactInfo = (ContactInfo)UIContext.EditedObject; if (mContactInfo == null) { RedirectToAccessDenied(GetString("general.invalidparameters")); } SiteID = mContactInfo.ContactSiteID; // Setup unigrid gridElem.GridOptions.ShowSelection = (mContactInfo.ContactMergedWithContactID == 0); gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, "(ContactID = " + mContactInfo.ContactID + ") AND ((AccountMergedWithAccountID IS NULL AND AccountSiteID > 0) OR (AccountGlobalAccountID IS NULL AND AccountSiteID IS NULL))"); gridElem.OnAction += gridElem_OnAction; gridElem.OnExternalDataBound += gridElem_OnExternalDataBound; gridElem.ZeroRowsText = GetString("om.contact.noaccounts"); // Initialize dropdown lists if (!RequestHelper.IsPostBack()) { drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString())); drpAction.Items.Add(new ListItem(GetString("general.remove"), Convert.ToInt32(Action.Remove).ToString())); drpAction.Items.Add(new ListItem(GetString("om.contactrole.selectitem"), Convert.ToInt32(Action.SelectRole).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.account." + What.Selected), Convert.ToInt32(What.Selected).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.account." + What.All), Convert.ToInt32(What.All).ToString())); } else { if (ControlsHelper.CausedPostBack(btnOk)) { // Set delayed reload for unigrid if mass action is performed gridElem.DelayedReload = true; } } // Initialize contact selector accountSelector.UniSelector.OnItemsSelected += UniSelector_OnItemsSelected; accountSelector.UniSelector.SelectionMode = SelectionModeEnum.MultipleButton; accountSelector.UniSelector.SelectItemPageUrl = "~/CMSModules/ContactManagement/Pages/Tools/Contact/Add_Account_Dialog.aspx"; accountSelector.UniSelector.SetValue("SiteID", SiteID); accountSelector.UniSelector.SetValue("IsLiveSite", false); accountSelector.IsSiteManager = ContactHelper.IsSiteManager; accountSelector.UniSelector.DialogButton.ResourceString = "om.account.addaccount"; mModifyAccountContact = AccountHelper.AuthorizedModifyAccount(SiteID, false) || ContactHelper.AuthorizedModifyContact(SiteID, false); }
private void btnSplit_Click(object sender, EventArgs e) { if (AccountHelper.AuthorizedModifyAccount(Account.AccountSiteID, true)) { if (gridElem.SelectedItems.Count > 0) { AccountHelper.Split(Account, gridElem.SelectedItems, chkCopyMissingFields.Checked, chkRemoveContacts.Checked, chkRemoveContactGroups.Checked); gridElem.ReloadData(); gridElem.ClearSelectedItems(); ShowConfirmation(GetString("om.account.splitting")); pnlUpdate.Update(); } else { ShowError(GetString("om.account.selectaccountssplit")); } } }
void btnSplit_Click(object sender, EventArgs e) { if (AccountHelper.AuthorizedModifyAccount(this.Account.AccountSiteID, true)) { if (gridElem.SelectedItems.Count > 0) { AccountHelper.Split(this.Account, gridElem.SelectedItems, chkCopyMissingFields.Checked, chkRemoveContacts.Checked, chkRemoveContactGroups.Checked); gridElem.ReloadData(); gridElem.ClearSelectedItems(); lblInfo.Visible = true; pnlUpdate.Update(); } else { lblError.Visible = true; } } }
protected void btnOk_Click(object sender, EventArgs e) { if (AccountHelper.AuthorizedModifyAccount(SiteID, true)) { 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 = MacroResolver.Resolve(gridElem.WhereCondition); break; // Selected items case What.Selected: where = SqlHelper.GetWhereCondition <int>("AccountID", gridElem.SelectedItems, false); break; default: return; } switch (action) { // Action 'Remove' case Action.Remove: // Clear HQ ID of selected accounts AccountInfoProvider.UpdateAccountHQ(0, where); ShowConfirmation(GetString("om.account.massaction.removed")); break; default: return; } // Reload UniGrid gridElem.ClearSelectedItems(); gridElem.ReloadData(); pnlUpdate.Update(); } }
/// <summary> /// Items changed event handler. /// </summary> void UniSelector_OnItemsSelected(object sender, EventArgs e) { if (AccountHelper.AuthorizedModifyAccount(this.SiteID, false) || ContactHelper.AuthorizedReadContact(this.SiteID, false)) { // Get new items from selector string newValues = ValidationHelper.GetString(contactSelector.Value, null); if (!String.IsNullOrEmpty(newValues)) { string[] newItems = newValues.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { int previousStop = 0; string where = FetchNextContacts(ref previousStop, newItems, 1000); while (!String.IsNullOrEmpty(where)) { AccountContactInfoProvider.SetContactsIntoAccount(ai.AccountID, "ContactID IN (" + where + ")", ValidationHelper.GetInteger(hdnRoleID.Value, 0)); where = FetchNextContacts(ref previousStop, newItems, 1000); } } gridElem.ReloadData(); pnlUpdate.Update(); contactSelector.Value = null; } } // No permission modify else { if (this.SiteID > 0) { CMSPage.RedirectToCMSDeskAccessDenied("CMS.ContactManagement", "ModifyAccounts"); } else { CMSPage.RedirectToCMSDeskAccessDenied("CMS.ContactManagement", "ModifyGlobalAccounts"); } } }
/// <summary> /// Items changed event handler. /// </summary> private void UniSelector_OnItemsSelected(object sender, EventArgs e) { if (AccountHelper.AuthorizedModifyAccount(SiteID, true)) { // Get new items from selector string newValues = ValidationHelper.GetString(accountSelector.Value, null); string[] newItems = newValues.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (newItems != null) { // Set HQ ID of selected accounts to edited account ID string where = SqlHelper.GetWhereCondition <int>("AccountID", newItems, false); AccountInfoProvider.UpdateAccountHQ(ai.AccountID, where); gridElem.ReloadData(); pnlUpdate.Update(); accountSelector.Value = null; } } }
protected void Page_Load(object sender, EventArgs e) { if (CMSContext.EditedObject != null) { ai = (AccountInfo)CMSContext.EditedObject; SiteID = ai.AccountSiteID; // Setup UniGrid gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound); gridElem.OnAction += new OnActionEventHandler(gridElem_OnAction); gridElem.ZeroRowsText = GetString("om.account.noaccountsfound"); // Initialize dropdown lists if (!RequestHelper.IsPostBack()) { drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString())); drpAction.Items.Add(new ListItem(GetString("general.remove"), Convert.ToInt32(Action.Remove).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.account." + What.Selected), Convert.ToInt32(What.Selected).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.account." + What.All), Convert.ToInt32(What.All).ToString())); } // Initialize account selector accountSelector.UniSelector.Enabled = AccountHelper.AuthorizedModifyAccount(SiteID, false); accountSelector.UniSelector.ButtonImage = GetImageUrl("/Objects/OM_Account/add.png"); accountSelector.UniSelector.DialogImage.CssClass = "NewItemImage"; accountSelector.UniSelector.DialogLink.CssClass = "MenuItemEdit"; accountSelector.UniSelector.DialogLabel.ResourceString = "om.account.addaccount"; accountSelector.UniSelector.OnItemsSelected += new EventHandler(UniSelector_OnItemsSelected); accountSelector.UniSelector.SelectionMode = SelectionModeEnum.MultipleButton; // Isn't child of someone else accountSelector.WhereCondition = "AccountMergedWithAccountID IS NULL AND AccountSubsidiaryOfID IS NULL"; // And isn't recursive parent of edited account accountSelector.WhereCondition = SqlHelperClass.AddWhereCondition(accountSelector.WhereCondition, "AccountID NOT IN (SELECT * FROM Func_OM_Account_GetSubsidiaryOf(" + ai.AccountID + ", 1))"); // Register JS scripts RegisterScripts(); } else { StopProcessing = true; } }
/// <summary> /// Actions handler. /// </summary> protected void HeaderActions_ActionPerformed(object sender, CommandEventArgs e) { AccountHelper.AuthorizedModifyAccount(SiteID, true); // Split from parent account if (e.CommandName == "split") { List <AccountInfo> mergedAccount = new List <AccountInfo>(); mergedAccount.Add(ai); AccountHelper.Split(parentAI, mergedAccount, false, false, false); ScriptHelper.RefreshTabHeader(Page, null); string url = URLHelper.AddParameterToUrl(URLHelper.CurrentURL, "split", "1"); ScriptHelper.RegisterStartupScript(Page, typeof(string), "RefreshPage", ScriptHelper.GetScript("window.location.replace('" + url + "');")); } // Save contact else { Save(); } }
/// <summary> /// Button merge click. /// </summary> void btnMerge_Click(object sender, EventArgs e) { // Check permissions if (AccountHelper.AuthorizedModifyAccount(parentAccount.AccountSiteID, true)) { // Validate form if (ValidateForm()) { // Change parent contact values Save(); // Update hashtable with account-contact roles UpdateRoles(); // Merge contacts AccountHelper.Merge(parentAccount, mergedAccounts, roles, GetContactGroups()); // Close window and refresh parent window ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "WOpenerRefresh", ScriptHelper.GetScript(@"wopener.RefreshPage(); window.close();")); } } }
protected void Page_Init(object sender, EventArgs e) { if (UIContext.EditedObject != null) { ai = (AccountInfo)UIContext.EditedObject; SiteID = ai.AccountSiteID; filter.SiteID = ai.AccountSiteID; // Initialize account selector accountSelector.UniSelector.Enabled = AccountHelper.AuthorizedModifyAccount(SiteID, false); accountSelector.UniSelector.OnItemsSelected += UniSelector_OnItemsSelected; accountSelector.UniSelector.SelectionMode = SelectionModeEnum.MultipleButton; accountSelector.UniSelector.DialogButton.ResourceString = "om.account.addaccount"; // Setup UniGrid gridElem.OnExternalDataBound += gridElem_OnExternalDataBound; gridElem.OnAction += gridElem_OnAction; gridElem.ZeroRowsText = GetString("om.account.noaccountsfound"); // Initialize dropdown lists if (!RequestHelper.IsPostBack()) { drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString())); drpAction.Items.Add(new ListItem(GetString("general.remove"), Convert.ToInt32(Action.Remove).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.account." + What.Selected), Convert.ToInt32(What.Selected).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.account." + What.All), Convert.ToInt32(What.All).ToString())); } // Isn't child of someone else accountSelector.WhereCondition = "AccountMergedWithAccountID IS NULL AND AccountSubsidiaryOfID IS NULL"; // And isn't recursive parent of edited account accountSelector.WhereCondition = SqlHelper.AddWhereCondition(accountSelector.WhereCondition, "AccountID NOT IN (SELECT * FROM Func_OM_Account_GetSubsidiaryOf(" + ai.AccountID + ", 1))"); } else { StopProcessing = true; } }
protected void Page_Load(object sender, EventArgs e) { // Ensure, that it is going to be rendered pnlRole.Visible = true; ScriptHelper.RegisterWOpenerScript(Page); ScriptHelper.RegisterJQuery(Page); // Try to get parameters string identifier = QueryHelper.GetString("params", null); Hashtable parameters = (Hashtable)WindowHelper.GetItem(identifier); // Validate hash if ((QueryHelper.ValidateHash("hash", "selectedvalue")) && (parameters != null)) { int siteid = ValidationHelper.GetInteger(parameters["SiteID"], -1); if (siteid != -1) { AccountHelper.AuthorizedReadAccount(siteid, true); if (AccountHelper.AuthorizedModifyAccount(siteid, false) || ContactHelper.AuthorizedModifyContact(siteid, false)) { contactRoleSelector.SiteID = siteid; contactRoleSelector.IsLiveSite = ValidationHelper.GetBoolean(parameters["IsLiveSite"], false); contactRoleSelector.UniSelector.DialogWindowName = "SelectContactRole"; contactRoleSelector.IsSiteManager = ValidationHelper.GetBoolean(parameters["IsSiteManager"], false); selectionDialog.LocalizeItems = QueryHelper.GetBoolean("localize", true); // Load resource prefix string resourcePrefix = ValidationHelper.GetString(parameters["ResourcePrefix"], "general"); // Set the page title string titleText = GetString(resourcePrefix + ".selectitem|general.selectitem"); // Validity group text pnlRole.GroupingText = GetString(resourcePrefix + ".contactsrole"); CurrentMaster.Title.TitleText = titleText; Page.Title = titleText; string imgPath = ValidationHelper.GetString(parameters["IconPath"], null); if (String.IsNullOrEmpty(imgPath)) { string objectType = ValidationHelper.GetString(parameters["ObjectType"], null); CurrentMaster.Title.TitleImage = GetObjectIconUrl(objectType, null); } else { CurrentMaster.Title.TitleImage = imgPath; } // Cancel button btnCancel.ResourceString = "general.cancel"; btnCancel.Attributes.Add("onclick", "return US_Cancel();"); } // No permission modify else { RedirectToCMSDeskAccessDenied(ModuleEntry.CONTACTMANAGEMENT, "ModifyAccount"); } } else { // Redirect to error page URLHelper.Redirect(ResolveUrl("~/CMSMessages/Error.aspx?title=" + ResHelper.GetString("dialogs.badhashtitle") + "&text=" + ResHelper.GetString("dialogs.badhashtext"))); } } }
protected void Page_Load(object sender, EventArgs e) { chkContacts.Enabled = (CurrentAccount.AccountPrimaryContactID != 0) || (CurrentAccount.AccountSecondaryContactID != 0); chkAddress.Enabled = !String.IsNullOrEmpty(CurrentAccount.AccountAddress1) || !String.IsNullOrEmpty(CurrentAccount.AccountAddress2) || !String.IsNullOrEmpty(CurrentAccount.AccountCity) || !String.IsNullOrEmpty(CurrentAccount.AccountZIP); chkEmail.Enabled = !String.IsNullOrEmpty(CurrentAccount.AccountEmail); chkURL.Enabled = !String.IsNullOrEmpty(CurrentAccount.AccountWebSite); chkPhone.Enabled = !String.IsNullOrEmpty(CurrentAccount.AccountPhone) || !String.IsNullOrEmpty(CurrentAccount.AccountFax); // Current account is global object if (ai.AccountSiteID == 0) { plcSite.Visible = true; plcContact.Visible = false; // Display site selector in site manager if (ContactHelper.IsSiteManager) { siteOrGlobalSelector.Visible = false; } // Display 'site or global' selector in CMS desk for global objects else if (AccountHelper.AuthorizedReadAccount(SiteContext.CurrentSiteID, false) && AccountHelper.AuthorizedModifyAccount(SiteContext.CurrentSiteID, false)) { siteSelector.Visible = false; } else { plcSite.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { filter.SiteID = SiteID; filter.DisableGeneratingSiteClause = true; modifyPermission = AccountHelper.AuthorizedModifyAccount(SiteID, false); if (SiteID == UniSelector.US_GLOBAL_AND_SITE_RECORD) { modifyGlobal = AccountHelper.AuthorizedModifyAccount(UniSelector.US_GLOBAL_RECORD, false); modifySite = AccountHelper.AuthorizedModifyAccount(SiteContext.CurrentSiteID, false); } // Edit action URL string url = UIContextHelper.GetElementUrl(ModuleName.ONLINEMARKETING, "EditAccount", false); url = URLHelper.AddParameterToUrl(url, "objectid", "{0}"); url = URLHelper.AddParameterToUrl(url, "siteid", SiteID.ToString()); if (ContactHelper.IsSiteManager) { url = URLHelper.AddParameterToUrl(url, "issitemanager", "1"); } // Setup UniGrid gridElem.OnBeforeDataReload += gridElem_OnBeforeDataReload; gridElem.OnExternalDataBound += gridElem_OnExternalDataBound; gridElem.WhereCondition = SqlHelper.AddWhereCondition(gridElem.WhereCondition, WhereCondition); gridElem.EditActionUrl = url; gridElem.ZeroRowsText = GetString("om.account.noaccountsfound"); gridElem.FilteredZeroRowsText = GetString("om.account.noaccountsfound.filtered"); // Initialize dropdown lists if (!RequestHelper.IsPostBack()) { drpAction.Items.Add(new ListItem(GetString("general." + Action.SelectAction), Convert.ToInt32(Action.SelectAction).ToString())); if ((modifyPermission || ContactGroupHelper.AuthorizedModifyContactGroup(SiteID, false)) && ContactGroupHelper.AuthorizedReadContactGroup(SiteID, false)) { drpAction.Items.Add(new ListItem(GetString("om.account." + Action.AddToGroup), Convert.ToInt32(Action.AddToGroup).ToString())); } if (modifyPermission) { drpAction.Items.Add(new ListItem(GetString("general.delete"), Convert.ToInt32(Action.Delete).ToString())); drpAction.Items.Add(new ListItem(GetString("om.account." + Action.Merge), Convert.ToInt32(Action.Merge).ToString())); drpAction.Items.Add(new ListItem(GetString("om.account." + Action.ChangeStatus), Convert.ToInt32(Action.ChangeStatus).ToString())); } drpWhat.Items.Add(new ListItem(GetString("om.account." + What.Selected), Convert.ToInt32(What.Selected).ToString())); drpWhat.Items.Add(new ListItem(GetString("om.account." + What.All), Convert.ToInt32(What.All).ToString())); } else { if (ControlsHelper.CausedPostBack(btnOk)) { // Set delayed reload for UniGrid if mass action is performed gridElem.DelayedReload = true; } } if (Request.Params[Page.postEventArgumentID] == ACCOUNTS_MERGED) { ShowConfirmation(GetString("om.account.merginglist")); } // Register JS scripts RegisterScripts(); }
protected void formCustomFields_OnBeforeSave(object sender, EventArgs e) { // Check modify permissions AccountHelper.AuthorizedModifyAccount(siteId, true); }