/// <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();
                        }
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Displays the client matters.
        /// </summary>
        public MatterSearchItem[] GetClientMatters(int startRow, int pageSize,
                                                   string memberId, string organisationId, bool forceRefresh)
        {
            MatterServiceClient matterService = null;

            MatterSearchItem[] clientMatters = null;
            try
            {
                Guid logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;
                Guid orgId   = new Guid(organisationId);
                Guid memId   = new Guid(memberId);

                matterService = new MatterServiceClient();

                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.StartRow     = startRow;
                collectionRequest.RowCount     = pageSize;
                collectionRequest.ForceRefresh = forceRefresh;
                MatterSearchCriteria searchCriteria = new MatterSearchCriteria();

                if (memId != DataConstants.DummyGuid)
                {
                    searchCriteria.MemberId = memId;
                }
                else
                {
                    searchCriteria.OrganisationId = orgId;
                }

                MatterSearchReturnValue returnValue = matterService.MatterSearch(logonId,
                                                                                 collectionRequest, searchCriteria);

                if (returnValue.Success)
                {
                    _clientMatterRowCount = returnValue.Matters.TotalRowCount;
                    clientMatters         = returnValue.Matters.Rows;
                }

                return(clientMatters);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (matterService != null)
                {
                    if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        matterService.Close();
                    }
                }
            }
        }
Example #3
0
        private void BindWorkTypeDropDownList()
        {
            MatterServiceClient matterService = null;

            try
            {
                WorkTypeSearchCriteria workTypeCriteria = new WorkTypeSearchCriteria();
                //Set this flag to true to get all the worktype records
                workTypeCriteria.AllWorkTypes = true;

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

                matterService = new MatterServiceClient();
                WorkTypeSearchReturnValue returnValue = matterService.WorkTypeSearch(_logonSettings.LogonId, collectionRequest, workTypeCriteria);

                if (returnValue.Success)
                {
                    _ddlWorkType.DataSource     = returnValue.WorkTypes.Rows;
                    _ddlWorkType.DataTextField  = "Description";
                    _ddlWorkType.DataValueField = "Code";
                    _ddlWorkType.DataBind();
                    AddDefaultToDropDownList(_ddlWorkType, "All WorkType");
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (matterService != null)
                {
                    if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        matterService.Close();
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// Dont allow to add associations for special matters.
        /// </summary>
        private void CheckForClientOnSpecialMatters()
        {
            if (Session[SessionName.ProjectId] != null && _ddlRole.SelectedIndex != -1)
            {
                MatterServiceClient matterService = new MatterServiceClient();

                try
                {
                    MatterTypeReturnValue returnValue =
                        matterService.GetMatterTypeId(_logonSettings.LogonId, (Guid)Session[SessionName.ProjectId]);

                    if (returnValue.Success)
                    {
                        int    roleId     = Convert.ToInt32(_ddlRole.SelectedValue);
                        Button nextButton = (Button)_wizardAddAssociationsForMatter.FindControl("StartNavigationTemplateContainerID").FindControl("_btnWizardStartNextButton");
                        bool   disabled   = false;
                        if ((returnValue.MatterTypeId != 1) && (returnValue.MatterTypeId != 6) && (roleId <= 2))
                        {
                            disabled = true;
                        }

                        ScriptManager.RegisterStartupScript(this, Page.GetType(), "SpecialMatters",
                                                            string.Format("$(\"#{0}\").attr(\"disabled\", {1});", nextButton.ClientID, disabled.ToString().ToLower()), true);
                    }
                    else
                    {
                        throw new Exception(returnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        matterService.Close();
                    }
                }
            }
        }
Example #5
0
        public void LoadClientMatterDetails()
        {
            try
            {
                MatterServiceClient matterService = new MatterServiceClient();
                try
                {
                    MatterSearchReturnValue matterReturnValue = new MatterSearchReturnValue();
                    CollectionRequest       collectionRequest = new CollectionRequest();
                    collectionRequest.ForceRefresh = true;
                    MatterSearchCriteria criteria = new MatterSearchCriteria();
                    if (_isClientMember)
                    {
                        criteria.MemberId       = new Guid(HttpContext.Current.Session[SessionName.MemberId].ToString());;
                        criteria.OrganisationId = DataConstants.DummyGuid;
                    }
                    else
                    {
                        criteria.MemberId       = DataConstants.DummyGuid;
                        criteria.OrganisationId = new Guid(HttpContext.Current.Session[SessionName.OrganisationId].ToString());;
                    }
                    matterReturnValue = matterService.MatterSearch(((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId,
                                                                   collectionRequest, criteria);

                    if (matterReturnValue.Success)
                    {
                        if (matterReturnValue != null)
                        {
                            _ddlMatterReference.Items.Clear();

                            _clientSearch.SearchText = Convert.ToString(HttpContext.Current.Session[SessionName.ClientRef]);
                            _linkClientName.Text     = Convert.ToString(HttpContext.Current.Session[SessionName.ClientName]);
                            _lnkMatter.Text          = string.Empty;

                            if (matterReturnValue.Matters.Rows.Length == 0)
                            {
                                HttpContext.Current.Session[SessionName.ProjectId] = null;
                                _message = "No Matter(s) found for this client.";

                                if (MatterChanged != null)
                                {
                                    OnMatterChanged(System.EventArgs.Empty);
                                }
                                return;
                            }

                            for (int i = 0; i < matterReturnValue.Matters.Rows.Length; i++)
                            {
                                ListItem item = new ListItem();
                                item.Text  = matterReturnValue.Matters.Rows[i].Reference.Substring(6) + " - " + matterReturnValue.Matters.Rows[i].Description;
                                item.Value = matterReturnValue.Matters.Rows[i].Id.ToString() + "$" + matterReturnValue.Matters.Rows[i].Description;

                                // This will be used if this method is called from some content page, which will set the default matter
                                if (HttpContext.Current.Session[SessionName.ProjectId] != null)
                                {
                                    if (new Guid(HttpContext.Current.Session[SessionName.ProjectId].ToString()) == matterReturnValue.Matters.Rows[i].Id)
                                    {
                                        item.Selected   = true;
                                        _lnkMatter.Text = matterReturnValue.Matters.Rows[i].Description;
                                    }
                                }

                                _ddlMatterReference.Items.Add(item);
                            }

                            if (HttpContext.Current.Session[SessionName.ProjectId] == null)
                            {
                                _ddlMatterReference.SelectedIndex = -1;
                                if (_ddlMatterReference.Items.Count > 0)
                                {
                                    _ddlMatterReference.SelectedIndex = _ddlMatterReference.Items.Count - 1;
                                    _lnkMatter.Text = GetValueOnIndexFromArray(_ddlMatterReference.Items[_ddlMatterReference.Items.Count - 1].Value, 1);
                                    HttpContext.Current.Session[SessionName.ProjectId] = GetValueOnIndexFromArray(_ddlMatterReference.Items[_ddlMatterReference.Items.Count - 1].Value, 0);
                                }
                            }

                            if (HttpContext.Current.Session[SessionName.ProjectId] != null)
                            {
                                IRIS.Law.WebApp.App_Code.AppFunctions.SetClientMatterDetailsInSession((Guid)HttpContext.Current.Session[SessionName.MemberId], (Guid)HttpContext.Current.Session[SessionName.OrganisationId], Convert.ToString(HttpContext.Current.Session[SessionName.ClientName]), (new Guid(HttpContext.Current.Session[SessionName.ProjectId].ToString())), _lnkMatter.Text);
                                ((ILBHomePage)Page.Master).DisplayClientMatterDetailsInContext();
                            }
                        }
                    }
                    else
                    {
                        _message = matterReturnValue.Message;
                        return;
                    }
                }
                catch (Exception ex)
                {
                    _message = ex.Message;
                }
                finally
                {
                    if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        matterService.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// Displays the client matters.
        /// </summary>
        public MatterSearchItem[] GetClientMatters(int startRow, int pageSize,
                                                   string memberId, string organisationId, bool forceRefresh)
        {
            MatterServiceClient matterService = null;
            MatterSearchItem[] clientMatters = null;
            try
            {
                Guid logonId = ((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId;
                Guid orgId = new Guid(organisationId);
                Guid memId = new Guid(memberId);

                matterService = new MatterServiceClient();

                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.StartRow = startRow;
                collectionRequest.RowCount = pageSize;
                collectionRequest.ForceRefresh = forceRefresh;
                MatterSearchCriteria searchCriteria = new MatterSearchCriteria();

                if (memId != DataConstants.DummyGuid)
                {
                    searchCriteria.MemberId = memId;
                }
                else
                {
                    searchCriteria.OrganisationId = orgId;
                }

                MatterSearchReturnValue returnValue = matterService.MatterSearch(logonId,
                                                collectionRequest, searchCriteria);

                if (returnValue.Success)
                {
                    _clientMatterRowCount = returnValue.Matters.TotalRowCount;
                    clientMatters = returnValue.Matters.Rows;
                }

                return clientMatters;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (matterService != null)
                {
                    if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                        matterService.Close();
                }
            }
        }
        /// <summary>
        /// Loads the client matter details.
        /// </summary>
        private void LoadClientMatterDetails()
        {
            if (_projectId != DataConstants.DummyGuid)
            {
                Guid memberId;
                Guid organisationId;

                try
                {
                    MatterServiceClient matterService = new MatterServiceClient();
                    try
                    {
                        MatterReturnValue matterReturnValue = new MatterReturnValue();
                        matterReturnValue = matterService.GetMatter(_logonId, _projectId);

                        if (matterReturnValue.Success)
                        {
                            #region Load Client Details

                            if (matterReturnValue.ClientDetails.IsMember)
                            {
                                memberId = matterReturnValue.ClientDetails.MemberId;
                                organisationId = DataConstants.DummyGuid;
                            }
                            else
                            {
                                memberId = DataConstants.DummyGuid;
                                organisationId = matterReturnValue.ClientDetails.MemberId;
                            }

                            ListItem item = new ListItem();
                            item.Text = matterReturnValue.ClientDetails.FullName;
                            item.Value = memberId.ToString() + "$" + organisationId.ToString();
                            _ddlClients.Items.Add(item);

                            //Get the matters for the client
                            GetClientMatters(memberId, organisationId);

                            //Select the matter
                            if (_ddlClientMatters.Items.Count > 0)
                            {
                                ListItem matter = _ddlClientMatters.Items.FindByValue(_projectId.ToString());
                                if (matter != null)
                                {
                                    _ddlClientMatters.SelectedValue = matter.Value;
                                    OnMatterChanged(EventArgs.Empty);
                                }
                            }
                            else
                            {
                                throw new Exception("Error loading matter");
                            }

                            #endregion
                        }
                        else
                        {
                            throw new Exception(matterReturnValue.Message);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                            matterService.Close();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        /// <summary>
        /// Loads client matter details on load controls in edit mode
        /// </summary>
        /// <param name="projectId"></param>
        private void LoadClientMatterDetails(Guid projectId)
        {
            MatterServiceClient matterService = null;
            MatterReturnValue matterReturnValue = null;

            try
            {
                matterService = new MatterServiceClient();

                try
                {
                    matterReturnValue = new MatterReturnValue();
                    matterReturnValue = matterService.GetMatter(((LogonReturnValue)Session[SessionName.LogonSettings]).LogonId, projectId);

                    if (matterReturnValue.Success)
                    {
                        if (matterReturnValue != null)
                        {
                            #region Load Client Details
                            // Stores ClientID
                            if (matterReturnValue.ClientDetails.IsMember)
                            {
                                Session[SessionName.MemberId] = matterReturnValue.ClientDetails.MemberId;
                                Session[SessionName.OrganisationId] = DataConstants.DummyGuid;
                            }
                            else
                            {
                                Session[SessionName.MemberId] = DataConstants.DummyGuid;
                                // Shouldn't be looking for  MemberId for Organisation Client
                               // Session[SessionName.OrganisationId] = matterReturnValue.ClientDetails.MemberId;
                                Session[SessionName.OrganisationId] = matterReturnValue.ClientDetails.OrganisationId;

                            }

                            _cliMatDetails.IsClientMember = matterReturnValue.ClientDetails.IsMember;
                            Session[SessionName.ClientRef] = matterReturnValue.ClientDetails.Reference;
                            Session[SessionName.ClientName] = matterReturnValue.ClientDetails.FullName;

                            if (_cliMatDetails.Message != null)
                            {
                                if (_cliMatDetails.Message.Trim().Length > 0)
                                {
                                    throw new Exception("Loading failed for Client Matter Details.<br>Exception occured is: " + _cliMatDetails.Message);
                                }
                            }

                            #endregion
                        }
                        else
                        {
                            throw new Exception("Load failed.");
                        }
                    }
                    else
                    {
                        throw new Exception(matterReturnValue.Message);
                    }
                }
                catch (System.ServiceModel.EndpointNotFoundException)
                {
                    _lblMessage.Text = DataConstants.WSEndPointErrorMessage;
                    _lblMessage.CssClass = "errorMessage";
                }
                catch (Exception ex)
                {
                    _lblMessage.CssClass = "errorMessage";
                    _lblMessage.Text = ex.Message;
                }
                finally
                {
                    if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                        matterService.Close();
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblMessage.Text = DataConstants.WSEndPointErrorMessage;
                _lblMessage.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblMessage.CssClass = "errorMessage";
                _lblMessage.Text = ex.Message;
            }
        }
        /// <summary>
        /// Toggles UCN,UFN,HOUCN and sets other defaults based on the selected work type.
        /// </summary>
        private void SetWorkTypeDefaults()
        {
            Guid memberId = (Guid)Session[SessionName.MemberId];
            Guid organisationId = (Guid)Session[SessionName.OrganisationId];
            Guid clientId;
            if (memberId != DataConstants.DummyGuid)
            {
                clientId = memberId;
            }
            else
            {
                clientId = organisationId;
            }

            if (_ddlWorkType.SelectedValue != string.Empty)
            {
                MatterServiceClient matterService = null;
                try
                {
                    WorkTypeSearchCriteria searchCriteria = new WorkTypeSearchCriteria();
                    searchCriteria.Id = new Guid(_ddlWorkType.SelectedValue);
                    searchCriteria.ClientId = clientId;

                    matterService = new MatterServiceClient();
                    WorkTypeSearchReturnValue returnValue = matterService.GetValuesOnWorkTypeSelected(_logonSettings.LogonId, searchCriteria);

                    if (returnValue.Success)
                    {
                        //set matter LA Flag to worktype IsLa status, Department to worktype dept and Charge Description to Worktype chargeDesc
                        _chkPublicFunding.Checked = returnValue.IsPublicFunded;

                        _chkSQM.Checked = returnValue.Franchised;

                        if (returnValue.IsPublicFunded)
                        {
                            int clientTypeId = (int)ViewState[ClientType];
                            switch (returnValue.WorkCategoryUFN)
                            {
                                case 1:
                                    #region UFN Only.
                                    if (clientTypeId == 1)
                                    {
                                        _trUFN.Visible = true;

                                        _ccUFNDate.DateText = DateTime.Now.ToString("dd/MM/yyyy");
                                        UFNDateTextChanged();
                                        _trHOUCN.Visible = false;
                                        _trUCN.Visible = false;
                                        _chkPublicFunding.Visible = true;
                                        _chkPublicFunding.Enabled = true;
                                        _chkSQM.Enabled = true;
                                    }
                                    else
                                    {
                                        _trUFN.Visible = false;
                                        _trHOUCN.Visible = false;
                                        _trUCN.Visible = false;
                                    }
                                    #endregion
                                    break;

                                case 2:
                                    #region HO UCN & UCN.
                                    if (clientTypeId == 1)
                                    {
                                        _trUFN.Visible = false;
                                        _trHOUCN.Visible = true;
                                        _trUCN.Visible = true;

                                        if (returnValue.ClientHOUCN != string.Empty)
                                        {
                                            _txtHOUCN.ReadOnly = true;
                                            _txtHOUCN.Text = returnValue.ClientHOUCN;
                                        }
                                        else
                                        {
                                            _txtHOUCN.ReadOnly = false;
                                            _txtHOUCN.Text = string.Empty;
                                        }

                                        if (returnValue.ClientUCN != BlankUCN & !string.IsNullOrEmpty(returnValue.ClientUCN))
                                        {
                                            _txtUCN.Text = returnValue.ClientUCN;
                                        }
                                    }
                                    else
                                    {
                                        _trUFN.Visible = false;
                                        _trHOUCN.Visible = false;
                                        _trUCN.Visible = false;
                                    }
                                    #endregion
                                    break;

                                case 3:
                                    #region UFN, HO UCN & UCN.
                                    if (clientTypeId == 1)
                                    {
                                        _trUFN.Visible = true;

                                        _ccUFNDate.DateText = DateTime.Now.ToString("dd/MM/yyyy");
                                        UFNDateTextChanged();
                                        _trHOUCN.Visible = true;
                                        _trUCN.Visible = true;

                                        if (!string.IsNullOrEmpty(returnValue.ClientHOUCN))
                                        {
                                            _txtHOUCN.ReadOnly = true;
                                            _txtHOUCN.Text = returnValue.ClientHOUCN;
                                        }
                                        else
                                        {
                                            _txtHOUCN.ReadOnly = false;
                                            _txtHOUCN.Text = string.Empty;
                                        }

                                        if (returnValue.ClientUCN != BlankUCN & !string.IsNullOrEmpty(returnValue.ClientUCN))
                                        {
                                            _txtUCN.Text = returnValue.ClientUCN;
                                        }
                                    }
                                    else
                                    {
                                        _trUFN.Visible = false;
                                        _trHOUCN.Visible = false;
                                        _trUCN.Visible = false;
                                    }
                                    #endregion
                                    break;

                                default:
                                    _trUFN.Visible = false;
                                    _trHOUCN.Visible = false;
                                    _trUCN.Visible = false;
                                    break;
                            }

                            _chkSQM.Visible = true;
                            _ddlCourtType.Enabled = false;
                        }
                        else
                        {
                            _trUFN.Visible = false;
                            _trHOUCN.Visible = false;
                            _trUCN.Visible = false;
                            _chkPublicFunding.Visible = false;
                            _chkPublicFunding.Enabled = false;
                            _chkSQM.Visible = false;
                            _chkSQM.Enabled = false;
                            _chkSQM.Checked = false;
                            _ddlCourtType.Enabled = true;
                        }

                        GetChargeRates(_chkPublicFunding.Checked);

                        //Set the default charge rate for the worktype
                        if (returnValue.ChargeRateDescriptionId != Guid.Empty && returnValue.ChargeRateDescriptionId != DataConstants.DummyGuid)
                        {
                            foreach (ListItem chargeRate in _ddlChargeRate.Items)
                            {
                                if (GetChargeRateValueOnIndex(chargeRate.Value, 0) == returnValue.ChargeRateDescriptionId.ToString())
                                {
                                    chargeRate.Selected = true;
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        throw new Exception(returnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (matterService != null)
                    {
                        if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                            matterService.Close();
                    }
                }
            }
        }
        /// <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();
                    }
                }
            }
        }
        /// <summary>
        /// Dont allow to add associations for special matters.
        /// </summary>
        private void CheckForClientOnSpecialMatters()
        {
            if (Session[SessionName.ProjectId] != null && _ddlRole.SelectedIndex != -1)
            {
                MatterServiceClient matterService = new MatterServiceClient();

                try
                {
                    MatterTypeReturnValue returnValue =
                                                matterService.GetMatterTypeId(_logonSettings.LogonId, (Guid)Session[SessionName.ProjectId]);

                    if (returnValue.Success)
                    {
                        int roleId = Convert.ToInt32(_ddlRole.SelectedValue);
                        Button nextButton = (Button)_wizardAddAssociationsForMatter.FindControl("StartNavigationTemplateContainerID").FindControl("_btnWizardStartNextButton");
                        bool disabled = false;
                        if ((returnValue.MatterTypeId != 1) && (returnValue.MatterTypeId != 6) && (roleId <= 2))
                        {
                            disabled = true;
                        }

                        ScriptManager.RegisterStartupScript(this, Page.GetType(), "SpecialMatters",
                                        string.Format("$(\"#{0}\").attr(\"disabled\", {1});", nextButton.ClientID, disabled.ToString().ToLower()), true);
                    }
                    else
                    {
                        throw new Exception(returnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                        matterService.Close();
                }
            }
        }
Example #12
0
        /// <summary>
        /// Searches the matter.
        /// </summary>
        public MatterSearchItem[] SearchMatter(int startRow, int pageSize, string sortBy, string clientReference, string description,
                                               string keyDescription, string department, string branch,
                                               string feeEarner, string workTypeCode, string openedFrom,
                                               string openedTo, string closedFrom, string closedTo,
                                               string reference, string prevReference, string UFN, bool forceRefresh)
        {
            MatterServiceClient matterService = null;

            MatterSearchItem[] matters = null;
            try
            {
                if (HttpContext.Current.Session[SessionName.LogonSettings] != null)
                {
                    if (description == null || description.Trim() == string.Empty)
                    {
                        if (keyDescription == null || keyDescription == string.Empty)
                        {
                            if (clientReference == null || clientReference.Trim() == string.Empty)
                            {
                                if (UFN == null || UFN.Trim() == "______/___")
                                {
                                    if (prevReference == null || prevReference.Trim() == string.Empty)
                                    {
                                        if (branch == null || branch.Trim() == string.Empty)
                                        {
                                            if (department == null || department.Trim() == string.Empty)
                                            {
                                                if (feeEarner == null || feeEarner.Trim() == string.Empty)
                                                {
                                                    if (workTypeCode == null || workTypeCode.Trim() == string.Empty)
                                                    {
                                                        if (openedFrom == null || openedFrom.Trim() == string.Empty)
                                                        {
                                                            if (openedTo == null || openedTo.Trim() == string.Empty)
                                                            {
                                                                if (closedFrom == null || closedFrom.Trim() == string.Empty)
                                                                {
                                                                    if (closedTo == null || closedTo.Trim() == string.Empty)
                                                                    {
                                                                        if (reference == null || reference.Trim() == string.Empty)
                                                                        {
                                                                            throw new Exception("Please enter search criteria");
                                                                        }
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

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

                    MatterSearchCriteria criteria = new MatterSearchCriteria();
                    criteria.MatterId = DataConstants.DummyGuid;
                    criteria.OrderBy  = sortBy;

                    if (null == clientReference || clientReference == ClientSearch.NoClientSelected)
                    {
                        criteria.OrganisationId = DataConstants.DummyGuid;
                        criteria.MemberId       = DataConstants.DummyGuid;
                    }
                    else
                    {
                        if (HttpContext.Current.Session[SessionName.MemberId] != null)
                        {
                            criteria.MemberId = new Guid(Convert.ToString(HttpContext.Current.Session[SessionName.MemberId]));
                        }
                        else
                        {
                            criteria.MemberId = DataConstants.DummyGuid;
                        }

                        if (HttpContext.Current.Session[SessionName.OrganisationId] != null)
                        {
                            criteria.OrganisationId = new Guid(Convert.ToString(HttpContext.Current.Session[SessionName.OrganisationId]));
                        }
                        else
                        {
                            criteria.OrganisationId = DataConstants.DummyGuid;
                        }
                    }

                    criteria.MatterDescription = description != null?description.Replace("'", "''") : description;

                    if (!string.IsNullOrEmpty(criteria.MatterDescription))
                    {
                        criteria.MatterDescription = string.Format("%{0}%", criteria.MatterDescription);
                    }

                    criteria.KeyDescription = keyDescription != null?keyDescription.Replace("'", "''") : keyDescription;

                    if (department != null && department != String.Empty)
                    {
                        criteria.DepartmentCode = GetDepartmentValueOnIndex(department, 1);
                    }

                    if (branch != null && branch != String.Empty)
                    {
                        criteria.BranchCode = GetBranchValueOnIndex(branch, 0);
                    }

                    if (feeEarner != null && feeEarner != String.Empty)
                    {
                        criteria.FeeEarner = new Guid(GetFeeEarnerValueOnIndex(feeEarner, 1));
                    }
                    else
                    {
                        criteria.FeeEarner = DataConstants.DummyGuid;
                    }

                    criteria.WorkTypeCode = workTypeCode;

                    if (openedFrom != null && openedFrom.Length > 0)
                    {
                        criteria.OpenedDateFrom = Convert.ToDateTime(openedFrom.Trim());
                    }
                    else
                    {
                        criteria.OpenedDateFrom = null;
                    }

                    if (openedTo != null && openedTo.Length > 0)
                    {
                        criteria.OpenedDateTo = Convert.ToDateTime(openedTo.Trim());
                    }
                    else
                    {
                        criteria.OpenedDateTo = null;
                    }

                    if (closedFrom != null && closedFrom.Length > 0)
                    {
                        criteria.ClosedDateFrom = Convert.ToDateTime(closedFrom.Trim());
                    }
                    else
                    {
                        criteria.ClosedDateFrom = null;
                    }

                    if (closedTo != null && closedTo.Length > 0)
                    {
                        criteria.ClosedDateTo = Convert.ToDateTime(closedTo.Trim());
                    }
                    else
                    {
                        criteria.ClosedDateTo = null;
                    }

                    if (reference != null)
                    {
                        criteria.MatterReference = reference != null?reference.Replace("'", "''").Replace("-", "") : reference;
                    }
                    criteria.MatterPreviousReference = prevReference != null?prevReference.Replace("'", "''") : prevReference;

                    //Check if the ufn field is empty.
                    //Replace the prompt char for the masked control to check if its blank
                    if (UFN != null && UFN.Replace("_", "") == "/")
                    {
                        criteria.UFN = string.Empty;
                    }
                    else
                    {
                        criteria.UFN = UFN;
                    }

                    matterService = new MatterServiceClient();
                    MatterSearchReturnValue returnValue = matterService.MatterSearch(_logonId,
                                                                                     collectionRequest, criteria);

                    if (returnValue.Success)
                    {
                        _matterRowCount = returnValue.Matters.TotalRowCount;
                        matters         = returnValue.Matters.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(matters);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (matterService != null)
                {
                    if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        matterService.Close();
                    }
                }
            }
        }
        /// <summary>
        /// Loads client matter details on load controls in edit mode
        /// </summary>
        /// <param name="projectId"></param>
        private void LoadClientMatterDetails(Guid projectId)
        {
            MatterServiceClient matterService     = null;
            MatterReturnValue   matterReturnValue = null;

            try
            {
                matterService = new MatterServiceClient();

                try
                {
                    matterReturnValue = new MatterReturnValue();
                    matterReturnValue = matterService.GetMatter(((LogonReturnValue)Session[SessionName.LogonSettings]).LogonId, projectId);

                    if (matterReturnValue.Success)
                    {
                        if (matterReturnValue != null)
                        {
                            #region Load Client Details
                            // Stores ClientID
                            if (matterReturnValue.ClientDetails.IsMember)
                            {
                                Session[SessionName.MemberId]       = matterReturnValue.ClientDetails.MemberId;
                                Session[SessionName.OrganisationId] = DataConstants.DummyGuid;
                            }
                            else
                            {
                                Session[SessionName.MemberId] = DataConstants.DummyGuid;
                                // Shouldn't be looking for  MemberId for Organisation Client
                                // Session[SessionName.OrganisationId] = matterReturnValue.ClientDetails.MemberId;
                                Session[SessionName.OrganisationId] = matterReturnValue.ClientDetails.OrganisationId;
                            }

                            _cliMatDetails.IsClientMember   = matterReturnValue.ClientDetails.IsMember;
                            Session[SessionName.ClientRef]  = matterReturnValue.ClientDetails.Reference;
                            Session[SessionName.ClientName] = matterReturnValue.ClientDetails.FullName;

                            if (_cliMatDetails.Message != null)
                            {
                                if (_cliMatDetails.Message.Trim().Length > 0)
                                {
                                    throw new Exception("Loading failed for Client Matter Details.<br>Exception occured is: " + _cliMatDetails.Message);
                                }
                            }

                            #endregion
                        }
                        else
                        {
                            throw new Exception("Load failed.");
                        }
                    }
                    else
                    {
                        throw new Exception(matterReturnValue.Message);
                    }
                }
                catch (System.ServiceModel.EndpointNotFoundException)
                {
                    _lblMessage.Text     = DataConstants.WSEndPointErrorMessage;
                    _lblMessage.CssClass = "errorMessage";
                }
                catch (Exception ex)
                {
                    _lblMessage.CssClass = "errorMessage";
                    _lblMessage.Text     = ex.Message;
                }
                finally
                {
                    if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        matterService.Close();
                    }
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                _lblMessage.Text     = DataConstants.WSEndPointErrorMessage;
                _lblMessage.CssClass = "errorMessage";
            }
            catch (Exception ex)
            {
                _lblMessage.CssClass = "errorMessage";
                _lblMessage.Text     = ex.Message;
            }
        }
        /// <summary>
        /// Gets the cash collection procedures.
        /// </summary>
        private void GetCashCollectionProcedures()
        {
            MatterServiceClient matterService = null;
            try
            {
                matterService = new MatterServiceClient();
                CollectionRequest collectionRequest = new CollectionRequest();
                CashCollectionSearchCriteria searchCriteria = new CashCollectionSearchCriteria();
                searchCriteria.IncludeArchived = false;
                CashCollectionSearchReturnValue returnValue = matterService.CashCollectionSearch(_logonSettings.LogonId, collectionRequest,
                                                                    searchCriteria);

                if (returnValue.Success)
                {
                    _ddlCashCollection.DataSource = returnValue.CashCollection.Rows;
                    _ddlCashCollection.DataTextField = "Description";
                    _ddlCashCollection.DataValueField = "Id";
                    _ddlCashCollection.DataBind();
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (matterService != null)
                {
                    if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                        matterService.Close();
                }
            }

            AddDefaultToDropDownList(_ddlCashCollection);
        }
        /// <summary>
        /// Gets the matter types.
        /// </summary>
        private void GetMatterTypes()
        {
            MatterServiceClient matterService = null;
            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();

                MatterTypeSearchCriteria criteria = new MatterTypeSearchCriteria();
                criteria.ClientTypeId = (int)ViewState[ClientType];

                matterService = new MatterServiceClient();
                MatterTypeSearchReturnValue returnValue = matterService.MatterTypeSearch(_logonSettings.LogonId,
                                            collectionRequest, criteria);

                if (returnValue.Success)
                {
                    _ddlMatterType.DataSource = returnValue.MatterTypes.Rows;
                    _ddlMatterType.DataTextField = "Description";
                    _ddlMatterType.DataValueField = "Id";
                    _ddlMatterType.DataBind();
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (matterService != null)
                {
                    if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                        matterService.Close();
                }
            }
        }
        protected void ValidateStepChange(object sender, EventArgs e)
        {
            if (_wizardAddMatter.ActiveStepIndex == 1)
            {
                MatterServiceClient earnerService = new MatterServiceClient();
                try
                {
                    if (_txtUFNNumber.Text.Trim().Length > 0 || _ccUFNDate.DateText.Trim().Length > 0)
                    {
                        try
                        {
                            DateTime dtParse = DateTime.Parse(_ccUFNDate.DateText);
                        }
                        catch
                        {
                            _lblMessage.CssClass = "errorMessage";
                            _lblMessage.Text = "Invalid UFN Date.";
                            return;
                        }

                        Guid earnerId = new Guid(GetFeeEarnerValueOnIndex(_ddlFeeEarner.SelectedValue, 1));
                        DateTime UFNdate = Convert.ToDateTime(_ccUFNDate.DateText);
                        string UFNNumber = _txtUFNNumber.Text.Trim();

                        if (UFNNumber == string.Empty)
                            UFNNumber = null;

                        CollectionRequest collectionReq = new CollectionRequest();

                        UFNReturnValue item = earnerService.UFNValidation(_logonSettings.LogonId, earnerId, UFNdate, UFNNumber);

                        if (item.Success)
                        {
                            _txtUFNNumber.Text = item.Number;

                            _lblMessage.Text = "";
                        }
                        else
                        {
                            _lblMessage.CssClass = "errorMessage";
                            _lblMessage.Text = item.Message;

                            _wizardAddMatter.ActiveStepIndex = 0;
                        }
                    }
                    else
                    {
                        _ccUFNDate.DateText = string.Empty;
                    }
                }
                catch (System.ServiceModel.EndpointNotFoundException)
                {
                    _lblMessage.Text = DataConstants.WSEndPointErrorMessage;
                    _lblMessage.CssClass = "errorMessage";

                    _wizardAddMatter.ActiveStepIndex = 0;
                }
                catch (Exception ex)
                {
                    _lblMessage.CssClass = "errorMessage";
                    _lblMessage.Text = ex.Message;

                    _wizardAddMatter.ActiveStepIndex = 0;
                }
                finally
                {
                    if (earnerService != null)
                    {
                        if (earnerService.State != System.ServiceModel.CommunicationState.Faulted)
                            earnerService.Close();
                    }

                }
            }
        }
        protected void _btnWizardStepFinishButton_Click(object sender, EventArgs e)
        {
            //Save the matter
            if (Page.IsValid)
            {
                MatterServiceClient matterService = null;
                try
                {
                    WebServiceInterfaces.Matter.Matter matter = GetControlData();

                    matterService = new MatterServiceClient();
                    MatterReturnValue returnValue = matterService.AddMatter(_logonSettings.LogonId, matter);

                    if (returnValue.Success)
                    {
                        Session[SessionName.ProjectId] = returnValue.Matter.Id;
                        Response.Redirect("~/Pages/Matter/EditMatter.aspx", true);
                    }
                    else
                    {
                        _lblMessage.CssClass = "errorMessage";
                        _lblMessage.Text = returnValue.Message;
                    }
                }
                catch (System.ServiceModel.EndpointNotFoundException)
                {
                    _lblMessage.Text = DataConstants.WSEndPointErrorMessage;
                    _lblMessage.CssClass = "errorMessage";
                }
                catch (Exception ex)
                {
                    _lblMessage.CssClass = "errorMessage";
                    _lblMessage.Text = ex.Message;
                }
                finally
                {
                    if (matterService != null)
                    {
                        if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                            matterService.Close();
                    }
                }
            }
        }
        private void LoadClientMatterDetails(Guid projectId)
        {
            try
            {
                MatterServiceClient matterService = new MatterServiceClient();
                try
                {
                    MatterReturnValue matterReturnValue = new MatterReturnValue();
                    matterReturnValue = matterService.GetMatter(((LogonReturnValue)Session[SessionName.LogonSettings]).LogonId, projectId);

                    if (matterReturnValue.Success)
                    {
                        if (matterReturnValue != null)
                        {
                            #region Load Client Details
                            // Store ClientID
                            if (matterReturnValue.ClientDetails.IsMember)
                            {
                                _cliMatDetails.MemberId = matterReturnValue.ClientDetails.MemberId;
                                _cliMatDetails.OrganisationId = DataConstants.DummyGuid;
                            }
                            else
                            {
                                _cliMatDetails.MemberId = DataConstants.DummyGuid;
                                _cliMatDetails.OrganisationId = matterReturnValue.ClientDetails.MemberId;
                            }

                            _cliMatDetails.IsClientMember = matterReturnValue.ClientDetails.IsMember;
                            _cliMatDetails.ClientRef = matterReturnValue.ClientDetails.Reference;
                            _cliMatDetails.ClientName = matterReturnValue.ClientDetails.FullName;

                            if (_cliMatDetails.Message != null)
                            {
                                if (_cliMatDetails.Message.Trim().Length > 0)
                                {
                                    throw new Exception("Loading failed for Client Matter Details.<br>Exception occured is: " + _cliMatDetails.Message);
                                }
                            }

                            #endregion
                        }
                        else
                        {
                            throw new Exception("Load failed.");
                        }
                    }
                    else
                    {
                        throw new Exception(matterReturnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                        matterService.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void LoadClientMatterDetails(Guid projectId)
        {
            try
            {
                MatterServiceClient matterService = new MatterServiceClient();
                try
                {
                    MatterReturnValue matterReturnValue = new MatterReturnValue();
                    matterReturnValue = matterService.GetMatter(((LogonReturnValue)Session[SessionName.LogonSettings]).LogonId, projectId);

                    if (matterReturnValue.Success)
                    {
                        if (matterReturnValue != null)
                        {
                            #region Load Client Details
                            // Store ClientID
                            if (matterReturnValue.ClientDetails.IsMember)
                            {
                                _cliMatDetails.MemberId       = matterReturnValue.ClientDetails.MemberId;
                                _cliMatDetails.OrganisationId = DataConstants.DummyGuid;
                            }
                            else
                            {
                                _cliMatDetails.MemberId       = DataConstants.DummyGuid;
                                _cliMatDetails.OrganisationId = matterReturnValue.ClientDetails.MemberId;
                            }

                            _cliMatDetails.IsClientMember = matterReturnValue.ClientDetails.IsMember;
                            _cliMatDetails.ClientRef      = matterReturnValue.ClientDetails.Reference;
                            _cliMatDetails.ClientName     = matterReturnValue.ClientDetails.FullName;

                            if (_cliMatDetails.Message != null)
                            {
                                if (_cliMatDetails.Message.Trim().Length > 0)
                                {
                                    throw new Exception("Loading failed for Client Matter Details.<br>Exception occured is: " + _cliMatDetails.Message);
                                }
                            }

                            #endregion
                        }
                        else
                        {
                            throw new Exception("Load failed.");
                        }
                    }
                    else
                    {
                        throw new Exception(matterReturnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        matterService.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void LoadMatterFeeEarner(Guid ProjectID)
        {
            MatterServiceClient matterService = new MatterServiceClient();
            try
            {
                MatterReturnValue matterReturnValue = new MatterReturnValue();
                matterReturnValue = matterService.GetMatter(_logonSettings.LogonId, ProjectID);

                if (matterReturnValue.Success)
                {
                    if (matterReturnValue != null)
                    {
                        if (matterReturnValue.Matter.FeeEarnerMemberId != null)
                        {
                            EarnerServiceClient partnerClient = new EarnerServiceClient();
                            try
                            {
                                PartnerSearchCriteria partnerCriteria = new PartnerSearchCriteria();
                                CollectionRequest collectionRequest = new CollectionRequest();
                                collectionRequest.StartRow = 0;

                                PartnerSearchReturnValue partnerReturnValue = partnerClient.PartnerSearch(_logonSettings.LogonId, collectionRequest, partnerCriteria);

                                if (partnerReturnValue.Success)
                                {
                                    if (partnerReturnValue.Partners != null)
                                    {
                                        for (int i = 0; i < partnerReturnValue.Partners.Rows.Length; i++)
                                        {
                                            if (partnerReturnValue.Partners.Rows[i].PartnerId.ToString() == matterReturnValue.Matter.FeeEarnerMemberId.ToString())
                                            {
                                                _txtAttendees.Text = CommonFunctions.MakeFullName(partnerReturnValue.Partners.Rows[i].PersonTitle, partnerReturnValue.Partners.Rows[i].Name, partnerReturnValue.Partners.Rows[i].Surname);
                                                _hdnAttendeesMemberId.Value = partnerReturnValue.Partners.Rows[i].PartnerId.ToString() + ";";
                                            }

                                        }
                                    }
                                }
                                else
                                {
                                    _lblError.Text = partnerReturnValue.Message;
                                }
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                            finally
                            {
                                if (partnerClient.State != System.ServiceModel.CommunicationState.Faulted)
                                    partnerClient.Close();
                            }

                        }
                    }

                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                    matterService.Close();
            }
        }
        /// <summary>
        /// Gets the work types based on the selected branch and department.
        /// </summary>
        private void GetWorkTypes()
        {
            //Matter type is required to get the work types
            if (_ddlMatterType.SelectedValue != string.Empty)
            {
                Guid memberId = (Guid)Session[SessionName.MemberId];
                bool isMember = false;
                if (memberId != DataConstants.DummyGuid)
                {
                    isMember = true;
                }

                //Check if a department is selected
                if (_ddlDepartment.SelectedValue != string.Empty)
                {
                    MatterServiceClient matterService = null;
                    try
                    {
                        int clientTypeId = (int)ViewState[ClientType];
                        bool privateClient = true;
                        switch (clientTypeId)
                        {
                            case 1: // Standard Client.
                                if (isMember == false)
                                {
                                    privateClient = false;
                                }
                                else
                                {
                                    privateClient = true;
                                }
                                break;

                            case 2: // LSC Client.
                                privateClient = true;
                                break;

                            case 3: // Firm Client.
                                privateClient = false;
                                break;

                            default:
                                privateClient = true;
                                break;
                        }

                        CollectionRequest collectionRequest = new CollectionRequest();

                        WorkTypeSearchCriteria searchCriteria = new WorkTypeSearchCriteria();
                        searchCriteria.DepartmentId = Convert.ToInt32(_ddlDepartment.SelectedValue);
                        searchCriteria.OrganisationID = new Guid(GetBranchValueOnIndex(_ddlBranch.SelectedValue, 1));
                        searchCriteria.IsPrivateClient = privateClient;
                        searchCriteria.MatterTypeId = Convert.ToInt32(_ddlMatterType.SelectedValue);

                        matterService = new MatterServiceClient();
                        WorkTypeSearchReturnValue returnValue = matterService.WorkTypeSearch(_logonSettings.LogonId,
                                                collectionRequest, searchCriteria);

                        //Store the previous selected value. This will prevent the worktype from being reset if its valid
                        string prevValue = _ddlWorkType.SelectedValue;

                        if (returnValue.Success)
                        {
                            _ddlWorkType.DataSource = returnValue.WorkTypes.Rows;
                            _ddlWorkType.DataTextField = "Description";
                            _ddlWorkType.DataValueField = "Id";
                            _ddlWorkType.DataBind();

                            if (_ddlWorkType.Items.FindByValue(prevValue) != null)
                            {
                                _ddlWorkType.SelectedValue = prevValue;
                            }
                        }
                        else
                        {
                            throw new Exception(returnValue.Message);
                        }

                        AddDefaultToDropDownList(_ddlWorkType);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        if (matterService != null)
                        {
                            if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                                matterService.Close();
                        }
                    }
                }
                else
                {
                    //No dept selected. Reset Worktypes
                    _ddlWorkType.Items.Clear();
                }
            }
        }
        /// <summary>
        /// Loads the client matter details.
        /// </summary>
        private void LoadClientMatterDetails()
        {
            if (_projectId != DataConstants.DummyGuid)
            {
                Guid memberId;
                Guid organisationId;

                try
                {
                    MatterServiceClient matterService = new MatterServiceClient();
                    try
                    {
                        MatterReturnValue matterReturnValue = new MatterReturnValue();
                        matterReturnValue = matterService.GetMatter(_logonId, _projectId);

                        if (matterReturnValue.Success)
                        {
                            #region Load Client Details

                            if (matterReturnValue.ClientDetails.IsMember)
                            {
                                memberId       = matterReturnValue.ClientDetails.MemberId;
                                organisationId = DataConstants.DummyGuid;
                            }
                            else
                            {
                                memberId       = DataConstants.DummyGuid;
                                organisationId = matterReturnValue.ClientDetails.MemberId;
                            }

                            ListItem item = new ListItem();
                            item.Text  = matterReturnValue.ClientDetails.FullName;
                            item.Value = memberId.ToString() + "$" + organisationId.ToString();
                            _ddlClients.Items.Add(item);

                            //Get the matters for the client
                            GetClientMatters(memberId, organisationId);

                            //Select the matter
                            if (_ddlClientMatters.Items.Count > 0)
                            {
                                ListItem matter = _ddlClientMatters.Items.FindByValue(_projectId.ToString());
                                if (matter != null)
                                {
                                    _ddlClientMatters.SelectedValue = matter.Value;
                                    OnMatterChanged(EventArgs.Empty);
                                }
                            }
                            else
                            {
                                throw new Exception("Error loading matter");
                            }

                            #endregion
                        }
                        else
                        {
                            throw new Exception(matterReturnValue.Message);
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                        {
                            matterService.Close();
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        public void LoadClientMatterDetailsWithoutUsingSession()
        {
            _clientSearch.SetSession = false;
            try
            {
                MatterServiceClient matterService = new MatterServiceClient();
                try
                {
                    MatterSearchReturnValue matterReturnValue = new MatterSearchReturnValue();
                    CollectionRequest collectionRequest = new CollectionRequest();
                    collectionRequest.ForceRefresh = true;
                    MatterSearchCriteria criteria = new MatterSearchCriteria();
                    if (_isClientMember)
                    {
                        criteria.MemberId = _memberId ;
                        criteria.OrganisationId = DataConstants.DummyGuid;
                    }
                    else
                    {
                        criteria.MemberId = DataConstants.DummyGuid;
                        criteria.OrganisationId = _organisationId ;
                    }
                    matterReturnValue = matterService.MatterSearch(((LogonReturnValue)HttpContext.Current.Session[SessionName.LogonSettings]).LogonId,
                                                                    collectionRequest, criteria);

                    if (matterReturnValue.Success)
                    {
                        if (matterReturnValue != null)
                        {
                            _ddlMatterReference.Items.Clear();

                            _clientSearch.SearchText = _clientRef;
                            _linkClientName.Text = _clientName;
                            _lnkMatter.Text = string.Empty;

                            if (matterReturnValue.Matters.Rows.Length == 0)
                            {
                                _projectId = DataConstants.DummyGuid;
                                _message = "No Matter(s) found for this client.";

                                if (MatterChanged != null)
                                {
                                    OnMatterChanged(System.EventArgs.Empty);
                                }
                                return;
                            }

                            for (int i = 0; i < matterReturnValue.Matters.Rows.Length; i++)
                            {
                                ListItem item = new ListItem();
                                item.Text = matterReturnValue.Matters.Rows[i].Reference.Substring(6) + " - " + matterReturnValue.Matters.Rows[i].Description;
                                item.Value = matterReturnValue.Matters.Rows[i].Id.ToString() + "$" + matterReturnValue.Matters.Rows[i].Description;

                                // This will be used if this method is called from some content page, which will set the default matter
                                if (_projectId != DataConstants.DummyGuid)
                                {
                                    if (_projectId == matterReturnValue.Matters.Rows[i].Id)
                                    {
                                        _ddlMatterReference.SelectedIndex = -1;
                                        item.Selected = true;
                                        _lnkMatter.Text = matterReturnValue.Matters.Rows[i].Description;
                                    }
                                }

                                _ddlMatterReference.Items.Add(item);
                            }

                            if (_projectId == DataConstants.DummyGuid)
                            {
                                _ddlMatterReference.SelectedIndex = -1;
                                if (_ddlMatterReference.Items.Count > 0)
                                {
                                    _ddlMatterReference.SelectedIndex = _ddlMatterReference.Items.Count - 1;
                                    _lnkMatter.Text = GetValueOnIndexFromArray(_ddlMatterReference.Items[_ddlMatterReference.Items.Count - 1].Value, 1);
                                    _projectId = new Guid(GetValueOnIndexFromArray(_ddlMatterReference.Items[_ddlMatterReference.Items.Count - 1].Value, 0));
                                }
                            }
                        }
                    }
                    else
                    {
                        _message = matterReturnValue.Message;
                        return;
                    }
                }
                catch (Exception ex)
                {
                    _message = ex.Message;
                }
                finally
                {
                    if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                        matterService.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #24
0
        /// <summary>
        /// Gets the work types based on the selected branch and department.
        /// </summary>
        private void GetWorkTypes()
        {
            //Check if a department is selected
            if (_ddlDepartment.SelectedValue != string.Empty)
            {
                MatterServiceClient matterService = null;
                try
                {
                    CollectionRequest      collectionRequest = new CollectionRequest();
                    WorkTypeSearchCriteria searchCriteria    = new WorkTypeSearchCriteria();

                    if (_ddlDepartment.SelectedValue != String.Empty)
                    {
                        searchCriteria.DepartmentNo = GetDepartmentValueOnIndex(_ddlDepartment.SelectedValue, 1);
                    }

                    searchCriteria.IsPrivateClient = true;
                    searchCriteria.MatterTypeId    = 0;

                    matterService = new MatterServiceClient();
                    WorkTypeSearchReturnValue returnValue = matterService.GetWorkTypesForDepartment(_logonSettings.LogonId,
                                                                                                    collectionRequest, searchCriteria);

                    //Store the previous selected value. This will prevent the worktype from being reset
                    //if its valid
                    string prevValue = _ddlWorkType.SelectedValue;

                    if (returnValue.Success)
                    {
                        _ddlWorkType.DataSource     = returnValue.WorkTypes.Rows;
                        _ddlWorkType.DataTextField  = "Description";
                        _ddlWorkType.DataValueField = "Code";
                        _ddlWorkType.DataBind();
                        AddDefaultToDropDownList(_ddlWorkType, "All WorkType");

                        if (_ddlWorkType.Items.FindByValue(prevValue) != null)
                        {
                            _ddlWorkType.SelectedValue = prevValue;
                        }
                    }
                    else
                    {
                        throw new Exception(returnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (matterService != null)
                    {
                        if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                        {
                            matterService.Close();
                        }
                    }
                }
            }
            else
            {
                //No dept selected. Reset Worktypes
                _ddlWorkType.Items.Clear();
                BindWorkTypeDropDownList();
            }
        }
        private void LoadMatterFeeEarner(Guid ProjectID)
        {
            MatterServiceClient matterService = new MatterServiceClient();

            try
            {
                MatterReturnValue matterReturnValue = new MatterReturnValue();
                matterReturnValue = matterService.GetMatter(_logonSettings.LogonId, ProjectID);

                if (matterReturnValue.Success)
                {
                    if (matterReturnValue != null)
                    {
                        if (matterReturnValue.Matter.FeeEarnerMemberId != null)
                        {
                            EarnerServiceClient partnerClient = new EarnerServiceClient();
                            try
                            {
                                PartnerSearchCriteria partnerCriteria   = new PartnerSearchCriteria();
                                CollectionRequest     collectionRequest = new CollectionRequest();
                                collectionRequest.StartRow = 0;

                                PartnerSearchReturnValue partnerReturnValue = partnerClient.PartnerSearch(_logonSettings.LogonId, collectionRequest, partnerCriteria);

                                if (partnerReturnValue.Success)
                                {
                                    if (partnerReturnValue.Partners != null)
                                    {
                                        for (int i = 0; i < partnerReturnValue.Partners.Rows.Length; i++)
                                        {
                                            if (partnerReturnValue.Partners.Rows[i].PartnerId.ToString() == matterReturnValue.Matter.FeeEarnerMemberId.ToString())
                                            {
                                                _txtAttendees.Text          = CommonFunctions.MakeFullName(partnerReturnValue.Partners.Rows[i].PersonTitle, partnerReturnValue.Partners.Rows[i].Name, partnerReturnValue.Partners.Rows[i].Surname);
                                                _hdnAttendeesMemberId.Value = partnerReturnValue.Partners.Rows[i].PartnerId.ToString() + ";";
                                            }
                                        }
                                    }
                                }
                                else
                                {
                                    _lblError.Text = partnerReturnValue.Message;
                                }
                            }
                            catch (Exception ex)
                            {
                                throw ex;
                            }
                            finally
                            {
                                if (partnerClient.State != System.ServiceModel.CommunicationState.Faulted)
                                {
                                    partnerClient.Close();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (matterService.State != System.ServiceModel.CommunicationState.Faulted)
                {
                    matterService.Close();
                }
            }
        }