/// <summary>
        /// Gets the client details.
        /// </summary>
        private void GetClientDetails(string matterReference)
        {
            ClientServiceClient clientService = null;

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

                ClientSearchCriteria criteria = new ClientSearchCriteria();
                criteria.ClientReference = matterReference.Substring(0, 6);

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

                if (returnValue.Success)
                {
                    if (returnValue.Clients != null)
                    {
                        Session[SessionName.MemberId]       = returnValue.Clients.Rows[0].MemberId;
                        Session[SessionName.OrganisationId] = returnValue.Clients.Rows[0].OrganisationId;
                        Session[SessionName.ClientRef]      = returnValue.Clients.Rows[0].ClientReference;
                        Session[SessionName.ClientName]     = returnValue.Clients.Rows[0].Name;
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (clientService != null)
                {
                    if (clientService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        clientService.Close();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Searches for clients that match the search criteria.
        /// </summary>
        public ClientSearchItem[] SearchClient(int startRow, int pageSize, string sortBy, string name, string NINo, string partner,
                                               string DOB, string postcode, string town, bool forceRefresh)
        {
            ClientServiceClient clientService = null;

            ClientSearchItem[] clients = null;
            try
            {
                if (HttpContext.Current.Session[SessionName.LogonSettings] != null)
                {
                    if (name == null || name.Trim() == string.Empty)
                    {
                        if (NINo == null || NINo == string.Empty)
                        {
                            if (partner == null || partner.Trim() == string.Empty)
                            {
                                if (DOB == null || DOB.Trim() == string.Empty)
                                {
                                    if (postcode == null || postcode.Trim() == string.Empty)
                                    {
                                        if (town == null || town.Trim() == string.Empty)
                                        {
                                            throw new Exception("Please enter search criteria");
                                        }
                                    }
                                }
                            }
                        }
                    }


                    if (!IsReset)
                    {
                        // LSC - Insert Wildcards - 28/08/2010
                        if (!string.IsNullOrWhiteSpace(name) && !name.Contains('%'))
                        {
                            name = "%" + name.Trim() + "%";
                        }

                        Guid _logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;
                        CollectionRequest collectionRequest = new CollectionRequest();
                        collectionRequest.ForceRefresh = forceRefresh;
                        collectionRequest.StartRow     = startRow;
                        collectionRequest.RowCount     = pageSize;


                        ClientSearchCriteria criteria = new ClientSearchCriteria();
                        criteria.Name = name != null?name.Replace("'", "''")  : name;

                        criteria.NINumber = NINo != null?NINo.Replace("'", "''")  : NINo;

                        criteria.OrganisationId = DataConstants.DummyGuid;
                        criteria.MemberId       = DataConstants.DummyGuid;
                        criteria.OrderBy        = sortBy;
                        Guid partnerId = DataConstants.DummyGuid;

                        if (partner != null && partner != string.Empty)
                        {
                            partnerId = new Guid(partner);
                        }
                        criteria.Partner = partnerId;

                        if (DOB != null && DOB.Length > 0)
                        {
                            criteria.DateOfBirthFrom = Convert.ToDateTime(DOB.Trim());
                            criteria.DateOfBirthTo   = Convert.ToDateTime(DOB.Trim());
                        }
                        else
                        {
                            criteria.DateOfBirthFrom = null;
                            criteria.DateOfBirthTo   = null;
                        }

                        criteria.PostCode = postcode != null?postcode.Replace("'", "''")  : postcode;

                        criteria.Town = town != null?town.Replace("'", "''")  : town;

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

                        if (returnValue.Success)
                        {
                            _clientRowCount = returnValue.Clients.TotalRowCount;
                            clients         = returnValue.Clients.Rows;
                        }
                        else
                        {
                            if (returnValue.Message == "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.")
                            {
                                throw new Exception("Date is invalid");
                            }
                            else
                            {
                                throw new Exception(returnValue.Message);
                            }
                        }
                    }
                }
                return(clients);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (clientService != null)
                {
                    if (clientService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        clientService.Close();
                    }
                }
            }
        }
        /// <summary>
        /// Searches for clients that match the search criteria.
        /// </summary>
        public ClientSearchItem[] SearchClient(int startRow, int pageSize, string sortBy,  string name, string NINo, string partner,
                                    string DOB, string postcode, string town, bool forceRefresh)
        {
            ClientServiceClient clientService = null;
            ClientSearchItem[] clients = null;
            try
            {
                if (HttpContext.Current.Session[SessionName.LogonSettings] != null)
                {
                    if (name == null || name.Trim() == string.Empty)
                        if (NINo == null || NINo == string.Empty)
                            if (partner == null || partner.Trim() == string.Empty)
                                if (DOB == null || DOB.Trim() == string.Empty)
                                    if (postcode == null || postcode.Trim() == string.Empty)
                                        if (town == null || town.Trim() == string.Empty)
                                                throw new Exception("Please enter search criteria");

                    if (!IsReset)
                    {
                        // LSC - Insert Wildcards - 28/08/2010
                        if (!string.IsNullOrWhiteSpace(name) && !name.Contains('%'))
                        {
                            name = "%" + name.Trim() + "%";
                        }

                        Guid _logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;
                        CollectionRequest collectionRequest = new CollectionRequest();
                        collectionRequest.ForceRefresh = forceRefresh;
                        collectionRequest.StartRow = startRow;
                        collectionRequest.RowCount = pageSize;

                        ClientSearchCriteria criteria = new ClientSearchCriteria();
                        criteria.Name = name != null ? name.Replace("'", "''")  : name;
                        criteria.NINumber = NINo != null ? NINo.Replace("'", "''")  : NINo;
                        criteria.OrganisationId = DataConstants.DummyGuid;
                        criteria.MemberId = DataConstants.DummyGuid;
                        criteria.OrderBy = sortBy;
                        Guid partnerId = DataConstants.DummyGuid;

                        if (partner != null && partner != string.Empty)
                        {
                            partnerId = new Guid(partner);
                        }
                        criteria.Partner = partnerId;

                        if (DOB != null && DOB.Length > 0)
                        {
                            criteria.DateOfBirthFrom = Convert.ToDateTime(DOB.Trim());
                            criteria.DateOfBirthTo = Convert.ToDateTime(DOB.Trim());
                        }
                        else
                        {
                            criteria.DateOfBirthFrom = null;
                            criteria.DateOfBirthTo = null;
                        }

                        criteria.PostCode = postcode != null ? postcode.Replace("'", "''")  : postcode;
                        criteria.Town = town != null ? town.Replace("'", "''")  : town;

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

                        if (returnValue.Success)
                        {
                            _clientRowCount = returnValue.Clients.TotalRowCount;
                            clients = returnValue.Clients.Rows;
                        }
                        else
                        {
                            if (returnValue.Message == "SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.")
                                throw new Exception("Date is invalid");
                            else
                                throw new Exception(returnValue.Message);

                        }
                    }
                }
                return clients;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (clientService != null)
                {
                    if (clientService.State != System.ServiceModel.CommunicationState.Faulted)
                        clientService.Close();
                }
            }
        }
        /// <summary>
        /// Gets the client details.
        /// </summary>
        private void GetClientDetails(string matterReference)
        {
            ClientServiceClient clientService = null;
            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.ForceRefresh = true;

                ClientSearchCriteria criteria = new ClientSearchCriteria();
                criteria.ClientReference = matterReference.Substring(0, 6);

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

                if (returnValue.Success)
                {
                    if (returnValue.Clients != null)
                    {
                        Session[SessionName.MemberId] = returnValue.Clients.Rows[0].MemberId;
                        Session[SessionName.OrganisationId] = returnValue.Clients.Rows[0].OrganisationId;
                        Session[SessionName.ClientRef] = returnValue.Clients.Rows[0].ClientReference;
                        Session[SessionName.ClientName] = returnValue.Clients.Rows[0].Name;
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (clientService != null)
                {
                    if (clientService.State != System.ServiceModel.CommunicationState.Faulted)
                        clientService.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 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();
                    }
                }
            }
        }