private IEnumerable <string> GetSelectedIds()
    {
        ISelectionService oSelectionService = SelectionServiceRequest.GetSelectionService();

        if (oSelectionService == null)
        {
            ShowMessage("Err_SelectionService");
            return(null);
        }
        ISelectionContext oSelectionContext = oSelectionService.GetSelectionContext(hfSelections.Value);

        if (oSelectionContext == null)
        {
            ShowMessage("Err_SelectionContext");
            return(null);
        }
        var ids = oSelectionContext.GetSelectedIds();

        if (ids.Count == 0)
        {
            ShowMessage("Err_Selection");
            return(null);
        }
        return(ids);
    }
    protected void btnComplete_Click(object sender, EventArgs e)
    {
        string            key              = hfSelections.Value;
        bool              completeAll      = true;
        ISelectionService srv              = SelectionServiceRequest.GetSelectionService();
        ISelectionContext selectionContext = srv.GetSelectionContext(key);
        List <string>     ids              = selectionContext.GetSelectedIds();

        foreach (string id in ids)
        {
            ILitRequest lit = EntityFactory.GetById <ILitRequest>(id);

            if (UserCalendar.CurrentUserCanEdit(lit.CreateUser))
            {
                lit.CompleteLitRequest();
            }
            else
            {
                completeAll = false;
            }
        }
        // this has to occur after the fulfillment is completed.  The status needs to be updated before refresh is called.
        ScriptManager.RegisterStartupScript(this, typeof(SmartParts_TaskPane_LiteratureManagementTasks), "refreshList", "RefreshList();", true);

        if (!completeAll)
        {
            DialogService.ShowMessage(GetLocalResourceObject("Err_Complete").ToString(), 70, 400);
        }
    }
    protected void btnFulfill_Click(object sender, EventArgs e)
    {
        StringBuilder     labelIds         = new StringBuilder();
        string            key              = hfSelections.Value;
        ISelectionService srv              = SelectionServiceRequest.GetSelectionService();
        ISelectionContext selectionContext = srv.GetSelectionContext(key);
        List <string>     ids              = selectionContext.GetSelectedIds();

        foreach (string id in ids)
        {
            if (hfLastFulfilledIds.Value.Contains(id))
            {
                var lit = EntityFactory.GetById <ILitRequest>(id);
                if (lit != null)
                {
                    labelIds.Append(string.Format("{0},", lit.Contact.Id));
                    lit.FulfillLitRequest();
                }
            }
        }
        if (LabelsDropdown.SelectedIndex > 0)
        {
            string sPluginId = LabelsDropdown.SelectedValue;
            if (labelIds.ToString().EndsWith(","))
            {
                labelIds = labelIds.Remove(labelIds.Length - 1, 1);
            }
            ScriptManager.RegisterStartupScript(this, typeof(SmartParts_TaskPane_LiteratureManagementTasks), "printLabels", string.Format("PrintLabels('{0}', '{1}');", sPluginId, labelIds), true);
        }
        // this has to occur after the fulfillment is completed.  The status needs to be updated before refresh is called.
        ScriptManager.RegisterStartupScript(this, typeof(SmartParts_TaskPane_LiteratureManagementTasks), "refreshList", "RefreshList();", true);
    }
        public static void OnLoad1Step(IInsertSalesOrder form, EventArgs args)
        {
            ISalesOrder so = form.CurrentEntity as ISalesOrder;

            if (so == null)
            {
                return;
            }
            IAppIdMappingService mappingService = ApplicationContext.Current.Services.Get <IAppIdMappingService>(false);
            ISelectionService    srv            = ApplicationContext.Current.Services.Get <ISelectionService>(true);

            if (srv != null)
            {
                ISelectionContext sc = srv.GetSelectionContext("QuickInsertAccountContact");
                if (sc != null)
                {
                    List <string> sels = sc.GetSelectedIds();
                    if (sels.Count > 0)
                    {
                        string   newContactId = sels[0];
                        IContact newContact   = EntityFactory.GetById <IContact>(newContactId);
                        IAccount newAccount   = newContact.Account;
                        so.Account         = newAccount;
                        so.AccountManager  = newAccount.AccountManager;
                        so.BillingContact  = newContact;
                        so.ShippingContact = newContact;
                        so.BillToName      = newContact.NameLF;
                        so.ShipToName      = newContact.NameLF;

                        if (so.BillingAddress == null)
                        {
                            ISalesOrderAddress billAddr = EntityFactory.Create <ISalesOrderAddress>();
                            so.BillingAddress = billAddr;
                        }
                        so.SetSalesOrderBillingAddress(newContact.Address);

                        if (so.ShippingAddress == null)
                        {
                            ISalesOrderAddress shipAddr = EntityFactory.Create <ISalesOrderAddress>();
                            so.ShippingAddress = shipAddr;
                        }
                        so.SetSalesOrderShippingAddress(newContact.Address);
                        srv.SetSelectionContext("QuickInsertAccountContact", null);
                    }
                }
            }
        }
        public static void OnLoad1Step(IInsertQuote form, EventArgs args)
        {
            IQuote quote = form.CurrentEntity as IQuote;

            if (quote == null)
            {
                return;
            }
            var srv = ApplicationContext.Current.Services.Get <ISelectionService>();

            if (srv != null)
            {
                ISelectionContext sc = srv.GetSelectionContext("QuickInsertAccountContact");
                if (sc != null)
                {
                    var sels = sc.GetSelectedIds();
                    if (sels.Count > 0)
                    {
                        string   newContactId = sels[0];
                        IContact newContact   = EntityFactory.GetById <IContact>(newContactId);
                        IAccount newAccount   = newContact.Account;
                        quote.Account         = newAccount;
                        quote.AccountManager  = newAccount.AccountManager;
                        quote.BillingContact  = newContact;
                        quote.ShippingContact = newContact;
                        quote.BillToName      = newContact.NameLF;
                        quote.ShipToName      = newContact.NameLF;

                        if (quote.BillingAddress == null)
                        {
                            quote.BillingAddress = EntityFactory.Create <IQuoteAddress>();
                        }
                        quote.SetQuoteBillingAddress(newContact.Address);

                        if (quote.ShippingAddress == null)
                        {
                            quote.ShippingAddress = EntityFactory.Create <IQuoteAddress>();
                        }
                        quote.SetQuoteShippingAddress(newContact.Address);
                        srv.SetSelectionContext("QuickInsertAccountContact", null);
                    }
                }
            }
        }
    private List <String> GetSelectedRecords()
    {
        ISelectionService srv = SelectionServiceRequest.GetSelectionService();
        ISelectionContext selectionContext = srv.GetSelectionContext(hfSelections.Value);

        if (selectionContext != null)
        {
            return(selectionContext.GetSelectedIds());
        }
        //if none selected, assume it is the current one
        EntityPage page = Page as EntityPage;

        if (page != null && page.EntityContext != null)
        {
            return(new List <string> {
                page.EntityContext.EntityID.ToString()
            });
        }
        return(null);
    }
    public void MergeRecords(String selectionContextKey)
    {
        Dialog.SetSpecs(-1, -1, 750, 650, "MergeRecords");
        IGroupContextService srv = ApplicationContext.Current.Services.Get <IGroupContextService>() as GroupContextService;
        EntityGroupInfo      currentEntityGroupInfo = srv.GetGroupContext().CurrentGroupInfo;
        ISelectionService    selectionService       = (ISelectionService)SelectionServiceRequest.GetSelectionService();
        ISelectionContext    selectionContext       = selectionService.GetSelectionContext(selectionContextKey);
        IList <string>       list = selectionContext.GetSelectedIds();

        if (list != null)
        {
            MergeArguments mergeArguments = new MergeArguments(list[0], list[1], currentEntityGroupInfo.EntityType, currentEntityGroupInfo.EntityType);
            Dialog.DialogParameters.Add("mergeArguments", mergeArguments);
            Dialog.ShowDialog();
        }
        else
        {
            throw new ValidationException("The selection service does not contain any selected records.");
        }
    }
Exemple #8
0
    /// <summary>
    ///
    /// </summary>
    /// <returns></returns>
    private IList <string> GetSelectedIds(string selectionKey)
    {
        List <string> ids = new List <string>();

        if (selectionKey == "selectAll")
        {
            GroupContextService groupContextService = ApplicationContext.Current.Services.Get <IGroupContextService>() as GroupContextService;
            if (groupContextService != null)
            {
                CachedGroup currentGroup = groupContextService.GetGroupContext().CurrentGroupInfo.CurrentGroup;
                ids = currentGroup.GetIdList();
            }
        }
        else
        {
            ISelectionService srv = SelectionServiceRequest.GetSelectionService();
            ISelectionContext selectionContext = srv.GetSelectionContext(selectionKey);
            ids = selectionContext.GetSelectedIds();
        }

        return(ids);
    }
    private string GetSelectedRecord()
    {
        ISelectionService srv = (ISelectionService)SelectionServiceRequest.GetSelectionService();
        ISelectionContext selectionContext = srv.GetSelectionContext(hfSelections.Value);

        if (selectionContext != null)
        {
            List <string> ids = selectionContext.GetSelectedIds();
            if (ids.Count > 0)
            {
                return(ids[0]);
            }
        }
        //if none selected, assume it is the current one
        EntityPage page = Page as EntityPage;

        if (page != null && !page.IsListMode && page.EntityContext != null)
        {
            return(page.EntityContext.EntityID.ToString());
        }
        return(String.Empty);
    }
    private static void RemoveUnSelectedRows(ISelectionContext selectionContext, DataTable table)
    {
        if (selectionContext == null || selectionContext.SelectionInfo.Mode == "selectAll")
            return;

        // Clean up the table to include only our client side selections
        bool keep;

        IList<string> selections = selectionContext.GetSelectedIds();

        int i = 1;
        foreach (DataRow row in table.Rows)
        {
            keep = false;
            foreach (string id in selections)
            {
                if (row[0].ToString() == id)
                {
                    keep = true;
                    continue;
                }
            }
            if (!keep)
            {
                row.Delete();
            }
            i++;
        }
        table.AcceptChanges();
    }
        public static void OnLoad1Step(IInsertSalesOrder form, EventArgs args)
        {
            ISalesOrder so = form.CurrentEntity as ISalesOrder;

            if (so == null)
            {
                return;
            }
            if (String.IsNullOrEmpty(form.rdgSOType.SelectedValue))
            {
                form.rdgSOType.SelectedValue = "SalesOrder";
            }
            Sage.Platform.SData.IAppIdMappingService oMappingService = Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.SData.IAppIdMappingService>(false);
            if (oMappingService != null && oMappingService.IsIntegrationEnabled())
            {
                if (!so.CanChangeOperatingCompany())
                {
                    form.lueERPApplication.Enabled = false;
                    form.luePriceList.Enabled      = false;
                }
                else
                {
                    form.lueERPApplication.Enabled = true;
                    form.luePriceList.Enabled      = (form.lueERPApplication.LookupResultValue != null);
                }
            }
            else
            {
                form.clIntegrationContract.Visible = false;
            }

            ISelectionService srv = ApplicationContext.Current.Services.Get <ISelectionService>(true);

            if (srv != null)
            {
                ISelectionContext sc = srv.GetSelectionContext("QuickInsertAccountContact");
                if (sc != null)
                {
                    List <string> sels = sc.GetSelectedIds();
                    if (sels.Count > 0)
                    {
                        string   newContactId = sels[0];
                        IContact newContact   = Sage.Platform.EntityFactory.GetById <IContact>(newContactId);
                        IAccount newAccount   = newContact.Account;
                        so.Account         = newAccount;
                        so.AccountManager  = newAccount.AccountManager;
                        so.BillingContact  = newContact;
                        so.ShippingContact = newContact;
                        so.BillToName      = newContact.NameLF;
                        so.ShipToName      = newContact.NameLF;

                        if (so.BillingAddress == null)
                        {
                            ISalesOrderAddress billAddr = Sage.Platform.EntityFactory.Create <ISalesOrderAddress>();
                            so.BillingAddress = billAddr;
                        }
                        so.SetSalesOrderBillingAddress(newContact.Address);

                        if (so.ShippingAddress == null)
                        {
                            ISalesOrderAddress shipAddr = Sage.Platform.EntityFactory.Create <ISalesOrderAddress>();
                            so.ShippingAddress = shipAddr;
                        }
                        so.SetSalesOrderShippingAddress(newContact.Address);
                        srv.SetSelectionContext("QuickInsertAccountContact", null);
                    }
                }
            }
        }
        public static void OnLoad1Step(IInsertSalesOrder form, EventArgs args)
        {
            ISalesOrder so = form.CurrentEntity as ISalesOrder;

            if (so == null)
            {
                return;
            }
            if (String.IsNullOrEmpty(form.rdgSOType.SelectedValue))
            {
                form.rdgSOType.SelectedValue = "SalesOrder";
            }
            Sage.Platform.SData.IAppIdMappingService oMappingService = Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.SData.IAppIdMappingService>(false);
            if (oMappingService != null && oMappingService.IsIntegrationEnabled())
            {
                form.clIntegrationContract.Visible = true;
                object oValue = form.lueERPApplication.LookupResultValue;
                string sValue = string.Empty;
                if (oValue != null)
                {
                    sValue = oValue.ToString();
                }
                if (string.IsNullOrEmpty(sValue))
                {
                    form.luePriceList.Text = string.Empty;
                    form.luePriceList.LookupResultValue = null;
                    form.luePriceList.Enabled           = false;
                }
                else
                {
                    form.luePriceList.Enabled = true;
                }

                Sage.SalesLogix.HighLevelTypes.LookupPreFilter filterAppId = new Sage.SalesLogix.HighLevelTypes.LookupPreFilter();
                filterAppId.LookupEntityName = "Sage.Entity.Interfaces.IAppIdMapping";
                filterAppId.PropertyName     = "Id";
                filterAppId.OperatorCode     = "!=";
                filterAppId.FilterValue      = oMappingService.LocalAppId;
                filterAppId.PropertyType     = "System.String";
                form.lueERPApplication.LookupPreFilters.Add(filterAppId);
            }
            else
            {
                form.clIntegrationContract.Visible = false;
            }

            ISelectionService srv = ApplicationContext.Current.Services.Get <ISelectionService>(true);

            if (srv != null)
            {
                ISelectionContext sc = srv.GetSelectionContext("QuickInsertAccountContact");
                if (sc != null)
                {
                    List <string> sels = sc.GetSelectedIds();
                    if (sels.Count > 0)
                    {
                        string   newContactId = sels[0];
                        IContact newContact   = Sage.Platform.EntityFactory.GetById <IContact>(newContactId);
                        IAccount newAccount   = newContact.Account;
                        so.Account         = newAccount;
                        so.AccountManager  = newAccount.AccountManager;
                        so.BillingContact  = newContact;
                        so.ShippingContact = newContact;
                        so.BillToName      = newContact.NameLF;
                        so.ShipToName      = newContact.NameLF;

                        if (so.BillingAddress == null)
                        {
                            ISalesOrderAddress billAddr = Sage.Platform.EntityFactory.Create <ISalesOrderAddress>();
                            so.BillingAddress = billAddr;
                        }
                        so.BillingAddress.Address1   = newContact.Address.Address1;
                        so.BillingAddress.Address2   = newContact.Address.Address2;
                        so.BillingAddress.Address3   = newContact.Address.Address3;
                        so.BillingAddress.Address4   = newContact.Address.Address4;
                        so.BillingAddress.City       = newContact.Address.City;
                        so.BillingAddress.State      = newContact.Address.State;
                        so.BillingAddress.Country    = newContact.Address.Country;
                        so.BillingAddress.County     = newContact.Address.County;
                        so.BillingAddress.PostalCode = newContact.Address.PostalCode;

                        if (so.ShippingAddress == null)
                        {
                            ISalesOrderAddress shipAddr = Sage.Platform.EntityFactory.Create <ISalesOrderAddress>();
                            so.ShippingAddress = shipAddr;
                        }

                        so.ShippingAddress.Address1   = newContact.Address.Address1;
                        so.ShippingAddress.Address2   = newContact.Address.Address2;
                        so.ShippingAddress.Address3   = newContact.Address.Address3;
                        so.ShippingAddress.Address4   = newContact.Address.Address4;
                        so.ShippingAddress.City       = newContact.Address.City;
                        so.ShippingAddress.State      = newContact.Address.State;
                        so.ShippingAddress.Country    = newContact.Address.Country;
                        so.ShippingAddress.County     = newContact.Address.County;
                        so.ShippingAddress.PostalCode = newContact.Address.PostalCode;

                        srv.SetSelectionContext("QuickInsertAccountContact", null);
                    }
                }
            }
        }