/// <summary>
        /// Show/hide the search that can be performed based on the selected association role id
        /// </summary>
        private void ShowHideAssociationSearch()
        {
            if (_ddlRole.Items.Count > 0)
            {
                CheckForClientOnSpecialMatters();

                //Create a json object that will be used to show/hide the available searches.
                string jsonStr = "{";

                ContactServiceClient contactService = null;

                try
                {
                    CollectionRequest collectionRequest = new CollectionRequest();
                    AssociationRoleSearchCriteria associationRoleCriteria = new AssociationRoleSearchCriteria();
                    associationRoleCriteria.RoleId = Convert.ToInt32(_ddlRole.SelectedValue);
                    contactService = new ContactServiceClient();
                    AssociationRoleSearchReturnValue associationRoleReturnValue =
                                                contactService.AssociationRoleForRoleIdSearch(_logonSettings.LogonId,
                                                                                     collectionRequest,
                                                                                     associationRoleCriteria);
                    if (associationRoleReturnValue.Success)
                    {
                        if (associationRoleReturnValue.AssociationRole != null)
                        {
                            // Decide which rows to Show/Hide based on the selected role.
                            // Build a json object which will be used to show/hide the options using js
                            if (associationRoleReturnValue.AssociationRole.Rows.Length > 0)
                            {
                                // Client & Matter.
                                if ((associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchClient) &&
                                    (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchMatter))
                                {
                                    _lblClientSearch.Text = "Client/Matter";
                                    jsonStr += "\"ClientSearch\":\"true\"";
                                    _clientSearch.DisplayMattersForClientGridview = true;
                                }
                                // Client.
                                else if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchClient)
                                {
                                    _lblClientSearch.Text = "Client";
                                    jsonStr += "\"ClientSearch\":\"true\"";
                                    _clientSearch.DisplayMattersForClientGridview = false;
                                }
                                // Matter.
                                else if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchMatter)
                                {
                                    _lblClientSearch.Text = "Matter";
                                    jsonStr += "\"ClientSearch\":\"true\"";
                                    _clientSearch.DisplayMattersForClientGridview = true;
                                }
                                else
                                {
                                    jsonStr += "\"ClientSearch\":\"false\"";
                                }

                                // General Contact.
                                if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchGeneral)
                                {
                                    jsonStr += ",\"ContactSearch\":\"true\"";
                                }
                                else
                                {
                                    jsonStr += ",\"ContactSearch\":\"false\"";
                                }

                                // Service Contact.
                                if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchService)
                                {
                                    jsonStr += ",\"ServiceSearch\":\"true\"";
                                }
                                else
                                {
                                    jsonStr += ",\"ServiceSearch\":\"false\"";
                                }

                                // Search for Fee Earner
                                if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchFeeEarner)
                                {
                                    jsonStr += ",\"FeeEarnerSearch\":\"true\"";
                                }
                                else
                                {
                                    jsonStr += ",\"FeeEarnerSearch\":\"false\"";
                                }

                                jsonStr += "}";

                                _hdnSearchDisplay.Value = jsonStr;

                                // Determine whether the selected Association Role requires a specialised search.
                                if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSpecialisedSearch)
                                {
                                    _hdnIsSpecialisedSearch.Value = "true";
                                }
                                else
                                {
                                    _hdnIsSpecialisedSearch.Value = "false";
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new Exception(associationRoleReturnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (contactService != null)
                    {
                        if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                            contactService.Close();
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Show/hide the search that can be performed based on the selected association role id
        /// </summary>
        private void ShowHideAssociationSearch()
        {
            if (_ddlRole.Items.Count > 0)
            {
                CheckForClientOnSpecialMatters();

                //Create a json object that will be used to show/hide the available searches.
                string jsonStr = "{";

                ContactServiceClient contactService = null;

                try
                {
                    CollectionRequest             collectionRequest       = new CollectionRequest();
                    AssociationRoleSearchCriteria associationRoleCriteria = new AssociationRoleSearchCriteria();
                    associationRoleCriteria.RoleId = Convert.ToInt32(_ddlRole.SelectedValue);
                    contactService = new ContactServiceClient();
                    AssociationRoleSearchReturnValue associationRoleReturnValue =
                        contactService.AssociationRoleForRoleIdSearch(_logonSettings.LogonId,
                                                                      collectionRequest,
                                                                      associationRoleCriteria);
                    if (associationRoleReturnValue.Success)
                    {
                        if (associationRoleReturnValue.AssociationRole != null)
                        {
                            // Decide which rows to Show/Hide based on the selected role.
                            // Build a json object which will be used to show/hide the options using js
                            if (associationRoleReturnValue.AssociationRole.Rows.Length > 0)
                            {
                                // Client & Matter.
                                if ((associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchClient) &&
                                    (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchMatter))
                                {
                                    _lblClientSearch.Text = "Client/Matter";
                                    jsonStr += "\"ClientSearch\":\"true\"";
                                    _clientSearch.DisplayMattersForClientGridview = true;
                                }
                                // Client.
                                else if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchClient)
                                {
                                    _lblClientSearch.Text = "Client";
                                    jsonStr += "\"ClientSearch\":\"true\"";
                                    _clientSearch.DisplayMattersForClientGridview = false;
                                }
                                // Matter.
                                else if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchMatter)
                                {
                                    _lblClientSearch.Text = "Matter";
                                    jsonStr += "\"ClientSearch\":\"true\"";
                                    _clientSearch.DisplayMattersForClientGridview = true;
                                }
                                else
                                {
                                    jsonStr += "\"ClientSearch\":\"false\"";
                                }

                                // General Contact.
                                if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchGeneral)
                                {
                                    jsonStr += ",\"ContactSearch\":\"true\"";
                                }
                                else
                                {
                                    jsonStr += ",\"ContactSearch\":\"false\"";
                                }

                                // Service Contact.
                                if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchService)
                                {
                                    jsonStr += ",\"ServiceSearch\":\"true\"";
                                }
                                else
                                {
                                    jsonStr += ",\"ServiceSearch\":\"false\"";
                                }

                                // Search for Fee Earner
                                if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSearchFeeEarner)
                                {
                                    jsonStr += ",\"FeeEarnerSearch\":\"true\"";
                                }
                                else
                                {
                                    jsonStr += ",\"FeeEarnerSearch\":\"false\"";
                                }

                                jsonStr += "}";

                                _hdnSearchDisplay.Value = jsonStr;

                                // Determine whether the selected Association Role requires a specialised search.
                                if (associationRoleReturnValue.AssociationRole.Rows[0].AssociationRoleSpecialisedSearch)
                                {
                                    _hdnIsSpecialisedSearch.Value = "true";
                                }
                                else
                                {
                                    _hdnIsSpecialisedSearch.Value = "false";
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new Exception(associationRoleReturnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (contactService != null)
                    {
                        if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                        {
                            contactService.Close();
                        }
                    }
                }
            }
        }