/// <summary>
        /// Gets the matters for the selected client.
        /// </summary>
        private void GetClientMatters(Guid memberId, Guid organisationId)
        {
            _ddlClientMatters.Items.Clear();
            if (_ddlClients.Items.Count > 0)
            {
                MatterServiceClient matterService = null;
                try
                {
                    matterService = new MatterServiceClient();
                    MatterSearchReturnValue matterReturnValue = new MatterSearchReturnValue();
                    CollectionRequest       collectionRequest = new CollectionRequest();
                    collectionRequest.ForceRefresh = true;
                    MatterSearchCriteria criteria = new MatterSearchCriteria();

                    criteria.MemberId       = memberId;
                    criteria.OrganisationId = organisationId;

                    matterReturnValue = matterService.MatterSearch(_logonId,
                                                                   collectionRequest, criteria);

                    if (matterReturnValue.Success)
                    {
                        if (matterReturnValue.Matters.Rows.Length > 0)
                        {
                            foreach (MatterSearchItem matter in matterReturnValue.Matters.Rows)
                            {
                                ListItem item = new ListItem();
                                item.Text  = matter.Reference.Substring(6) + " - " + matter.Description;
                                item.Value = matter.Id.ToString();
                                _ddlClientMatters.Items.Add(item);
                            }
                        }
                        else
                        {
                            SuccessEventArgs success = new SuccessEventArgs();
                            success.Message = "No Matters found for this client.";
                            OnSearchSuccessful(success);
                        }
                    }
                    else
                    {
                        throw new Exception(matterReturnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (matterService != null)
                    {
                        if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                        {
                            matterService.Close();
                        }
                    }
                }
            }
        }
 protected virtual void OnSearchSuccessful(SuccessEventArgs e)
 {
     if (SearchSuccessful != null)
     {
         SearchSuccessful(this, e);
     }
 }
        /// <summary>
        /// Gets the matters for the selected client.
        /// </summary>
        private void GetClientMatters(Guid memberId, Guid organisationId)
        {
            _ddlClientMatters.Items.Clear();
            if (_ddlClients.Items.Count > 0)
            {
                MatterServiceClient matterService = null;
                try
                {
                    matterService = new MatterServiceClient();
                    MatterSearchReturnValue matterReturnValue = new MatterSearchReturnValue();
                    CollectionRequest collectionRequest = new CollectionRequest();
                    collectionRequest.ForceRefresh = true;
                    MatterSearchCriteria criteria = new MatterSearchCriteria();

                    criteria.MemberId = memberId;
                    criteria.OrganisationId = organisationId;

                    matterReturnValue = matterService.MatterSearch(_logonId,
                                                                    collectionRequest, criteria);

                    if (matterReturnValue.Success)
                    {
                        if (matterReturnValue.Matters.Rows.Length > 0)
                        {
                            foreach (MatterSearchItem matter in matterReturnValue.Matters.Rows)
                            {
                                ListItem item = new ListItem();
                                item.Text = matter.Reference.Substring(6) + " - " + matter.Description;
                                item.Value = matter.Id.ToString();
                                _ddlClientMatters.Items.Add(item);
                            }
                        }
                        else
                        {
                            SuccessEventArgs success = new SuccessEventArgs();
                            success.Message = "No Matters found for this client.";
                            OnSearchSuccessful(success);
                        }
                    }
                    else
                    {
                        throw new Exception(matterReturnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (matterService != null)
                    {
                        if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                             matterService.Close();
                    }
                }
            }
        }
        protected void _imgBtnSearch_Click(object sender, ImageClickEventArgs e)
        {
            if (_txtSearch.Text.Trim() == string.Empty)
            {
                _txtSearch.Text = AllClients;
            }

            ClientServiceClient clientService = null;
            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.ForceRefresh = true;

                ClientSearchCriteria criteria = new ClientSearchCriteria();
                if (_txtSearch.Text.Trim() == string.Empty || _txtSearch.Text.Trim() == AllClients)
                {
                    criteria.Name = string.Empty;
                }
                else
                {
                    criteria.Name = _txtSearch.Text.Trim();
                }

                if (_ddlFeeEarner.SelectedIndex > 0)
                {
                    criteria.Partner = new Guid(_ddlFeeEarner.SelectedValue);
                }

                clientService = new ClientServiceClient();
                ClientSearchReturnValue returnValue = clientService.ClientSearch(_logonId,
                                            collectionRequest, criteria);

                _ddlClients.Items.Clear();
                _ddlClientMatters.Items.Clear();

                if (returnValue.Success)
                {
                    if (returnValue.Clients.Rows.Length > 0)
                    {
                        foreach (ClientSearchItem client in returnValue.Clients.Rows)
                        {
                            ListItem item = new ListItem();
                            item.Text = client.ClientReference.Trim() + " - " + client.Name;
                            item.Value = client.MemberId.ToString() + "$" + client.OrganisationId.ToString();
                            _ddlClients.Items.Add(item);
                        }
                    }
                    else
                    {
                        SuccessEventArgs success = new SuccessEventArgs();
                        success.Message = "Search is complete. There are no results to display.";
                        OnSearchSuccessful(success);
                    }

                    if (_ddlClients.Items.Count > 0)
                    {
                        _clientRowCount = _ddlClients.Items.Count;

                        Guid memberId = new Guid(GetValueOnIndexFromArray(_ddlClients.SelectedValue, 0));
                        Guid organisationId = new Guid(GetValueOnIndexFromArray(_ddlClients.SelectedValue, 1));
                        GetClientMatters(memberId, organisationId);
                        SelectLastMatter();
                    }

                }
                else
                {
                    ErrorEventArgs error = new ErrorEventArgs();
                    error.Message = returnValue.Message.Replace("WebClientSearch requires some parameters", "Please select a Fee Earner or use the client search.");
                    OnError(error);
                }
            }
            catch (Exception ex)
            {
                ErrorEventArgs error = new ErrorEventArgs();
                error.Message = ex.Message;
                OnError(error);
            }
            finally
            {
                if (clientService != null)
                {
                    if (clientService.State != System.ServiceModel.CommunicationState.Faulted)
                        clientService.Close();
                }
            }
        }
 protected virtual void OnSearchSuccessful(SuccessEventArgs e)
 {
     if (SearchSuccessful != null)
     {
         SearchSuccessful(this, e);
     }
 }
        protected void _imgBtnSearch_Click(object sender, ImageClickEventArgs e)
        {
            if (_txtSearch.Text.Trim() == string.Empty)
            {
                _txtSearch.Text = AllClients;
            }

            ClientServiceClient clientService = null;

            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.ForceRefresh = true;

                ClientSearchCriteria criteria = new ClientSearchCriteria();
                if (_txtSearch.Text.Trim() == string.Empty || _txtSearch.Text.Trim() == AllClients)
                {
                    criteria.Name = string.Empty;
                }
                else
                {
                    criteria.Name = _txtSearch.Text.Trim();
                }

                if (_ddlFeeEarner.SelectedIndex > 0)
                {
                    criteria.Partner = new Guid(_ddlFeeEarner.SelectedValue);
                }

                clientService = new ClientServiceClient();
                ClientSearchReturnValue returnValue = clientService.ClientSearch(_logonId,
                                                                                 collectionRequest, criteria);

                _ddlClients.Items.Clear();
                _ddlClientMatters.Items.Clear();

                if (returnValue.Success)
                {
                    if (returnValue.Clients.Rows.Length > 0)
                    {
                        foreach (ClientSearchItem client in returnValue.Clients.Rows)
                        {
                            ListItem item = new ListItem();
                            item.Text  = client.ClientReference.Trim() + " - " + client.Name;
                            item.Value = client.MemberId.ToString() + "$" + client.OrganisationId.ToString();
                            _ddlClients.Items.Add(item);
                        }
                    }
                    else
                    {
                        SuccessEventArgs success = new SuccessEventArgs();
                        success.Message = "Search is complete. There are no results to display.";
                        OnSearchSuccessful(success);
                    }

                    if (_ddlClients.Items.Count > 0)
                    {
                        _clientRowCount = _ddlClients.Items.Count;

                        Guid memberId       = new Guid(GetValueOnIndexFromArray(_ddlClients.SelectedValue, 0));
                        Guid organisationId = new Guid(GetValueOnIndexFromArray(_ddlClients.SelectedValue, 1));
                        GetClientMatters(memberId, organisationId);
                        SelectLastMatter();
                    }
                }
                else
                {
                    ErrorEventArgs error = new ErrorEventArgs();
                    error.Message = returnValue.Message.Replace("WebClientSearch requires some parameters", "Please select a Fee Earner or use the client search.");
                    OnError(error);
                }
            }
            catch (Exception ex)
            {
                ErrorEventArgs error = new ErrorEventArgs();
                error.Message = ex.Message;
                OnError(error);
            }
            finally
            {
                if (clientService != null)
                {
                    if (clientService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        clientService.Close();
                    }
                }
            }
        }
 protected void _msFileReviews_SearchSuccessful(object sender, SuccessEventArgs e)
 {
     _lblMessage.CssClass = "successMessage";
     _lblMessage.Text = e.Message;
 }
        protected void _msAddTimeEntry_SearchSuccessful(object sender, SuccessEventArgs e)
        {
            _lblMessage.CssClass = "successMessage";
            _lblMessage.Text = e.Message;

            if (_msAddTimeEntry.ClientRowCount == 0)
            {

                _ddlTimeType.Items.Clear();
            }
        }