Ejemplo n.º 1
0
        /// <summary>
        /// This Method gets all the department disregard of the branch as this is required on the load of the
        /// search page
        /// </summary>
        private void BindDeptDropDownList()
        {
            BranchDeptServiceClient departmentSearch = null;

            try
            {
                DepartmentSearchCriteria searchCriteria = new DepartmentSearchCriteria();
                //Set this flag to true to get all the departments
                searchCriteria.AllDepartment = true;

                departmentSearch = new BranchDeptServiceClient();
                CollectionRequest collectionRequest = new CollectionRequest();
                collectionRequest.ForceRefresh = false;

                DepartmentSearchReturnValue returnValue = departmentSearch.DepartmentSearch(_logonSettings.LogonId, collectionRequest, searchCriteria);

                if (returnValue.Success)
                {
                    foreach (DepartmentSearchItem department in returnValue.Departments.Rows)
                    {
                        ListItem item = new ListItem();
                        item.Text  = department.Name;
                        item.Value = department.Id.ToString() + "$" + department.No;
                        _ddlDepartment.Items.Add(item);
                    }
                    AddDefaultToDropDownList(_ddlDepartment, "All Departments");
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (departmentSearch != null)
                {
                    if (departmentSearch.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        departmentSearch.Close();
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void BindBranchDropDownList()
        {
            BranchDeptServiceClient branchSearch = null;

            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();

                branchSearch = new BranchDeptServiceClient();
                BranchSearchReturnValue returnValue = branchSearch.BranchSearch(_logonSettings.LogonId,
                                                                                collectionRequest);

                if (returnValue.Success)
                {
                    _ddlBranch.Items.Clear();
                    foreach (BranchSearchItem branch in returnValue.Branches.Rows)
                    {
                        ListItem item = new ListItem();
                        item.Text  = branch.Name;
                        item.Value = branch.Reference.Trim() + "$" + branch.OrganisationId.ToString();
                        _ddlBranch.Items.Add(item);
                    }
                    AddDefaultToDropDownList(_ddlBranch, "All Branch");
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (branchSearch != null)
                {
                    if (branchSearch.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        branchSearch.Close();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the departments.
        /// </summary>
        private void GetDepartments()
        {
            if (_ddlBranch.SelectedValue != string.Empty)
            {
                BranchDeptServiceClient departmentSearch = null;
                try
                {
                    CollectionRequest collectionRequest = new CollectionRequest();

                    DepartmentSearchCriteria searchCriteria = new DepartmentSearchCriteria();
                    searchCriteria.OrganisationId  = new Guid(GetBranchValueOnIndex(_ddlBranch.SelectedValue, 1));
                    searchCriteria.IncludeArchived = true;

                    departmentSearch = new BranchDeptServiceClient();

                    DepartmentSearchReturnValue returnValue = departmentSearch.DepartmentSearch(_logonSettings.LogonId,
                                                                                                collectionRequest, searchCriteria);

                    //Store the previous selected value. This will prevent the dept from being reset
                    //if its valid for the current branch
                    string prevValue = _ddlDepartment.SelectedValue;

                    _ddlDepartment.Items.Clear();
                    if (returnValue.Success)
                    {
                        foreach (DepartmentSearchItem department in returnValue.Departments.Rows)
                        {
                            ListItem item = new ListItem();
                            item.Text  = department.Name;
                            item.Value = department.Id.ToString() + "$" + department.No;
                            _ddlDepartment.Items.Add(item);
                        }
                        AddDefaultToDropDownList(_ddlDepartment, "All Departments");

                        //Set the prev value if it is valid for the current branch
                        if (_ddlDepartment.Items.FindByValue(prevValue) != null)
                        {
                            _ddlDepartment.SelectedValue = prevValue;
                        }
                    }
                    else
                    {
                        throw new Exception(returnValue.Message);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (departmentSearch != null)
                    {
                        if (departmentSearch.State != System.ServiceModel.CommunicationState.Faulted)
                        {
                            departmentSearch.Close();
                        }
                    }
                }
            }
            else
            {
                //No branch selected. Reset Departments
                _ddlDepartment.Items.Clear();
                BindDeptDropDownList();
            }
        }
 /// <summary>
 /// Gets the branches.
 /// </summary>
 private void GetBranches()
 {
     BranchDeptServiceClient branchDeptService = null;
     try
     {
         branchDeptService = new BranchDeptServiceClient();
         CollectionRequest collectionRequest = new CollectionRequest();
         BranchSearchReturnValue returnValue = branchDeptService.BranchSearch(_logonSettings.LogonId, collectionRequest);
         if (returnValue.Success)
         {
             _ddlBranch.DataSource = returnValue.Branches.Rows;
             _ddlBranch.DataTextField = "Name";
             _ddlBranch.DataValueField = "Reference";
             _ddlBranch.DataBind();
         }
         else
         {
             throw new Exception(returnValue.Message);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         if (branchDeptService != null)
         {
             if (branchDeptService.State != System.ServiceModel.CommunicationState.Faulted)
                 branchDeptService.Close();
         }
     }
 }
        /// <summary>
        /// Gets the departments.
        /// </summary>
        private void GetDepartments()
        {
            if (_ddlBranch.SelectedValue != string.Empty)
            {
                BranchDeptServiceClient departmentSearch = null;
                try
                {
                    CollectionRequest collectionRequest = new CollectionRequest();

                    DepartmentSearchCriteria searchCriteria = new DepartmentSearchCriteria();
                    searchCriteria.OrganisationId = new Guid(GetBranchValueOnIndex(_ddlBranch.SelectedValue, 1));
                    searchCriteria.IncludeArchived = false;

                    departmentSearch = new BranchDeptServiceClient();

                    DepartmentSearchReturnValue returnValue = departmentSearch.DepartmentSearch(_logonSettings.LogonId,
                                                        collectionRequest, searchCriteria);

                    //Store the previous selected value. This will prevent the dept from being reset
                    //if its valid for the current branch
                    string prevValue = _ddlDepartment.SelectedValue;

                    _ddlDepartment.Items.Clear();
                    if (returnValue.Success)
                    {
                        _ddlDepartment.DataSource = returnValue.Departments.Rows;
                        _ddlDepartment.DataTextField = "Name";
                        _ddlDepartment.DataValueField = "id";
                        _ddlDepartment.DataBind();

                        //Set the prev value if it is valid for the current branch
                        if (_ddlDepartment.Items.FindByValue(prevValue) != null)
                        {
                            _ddlDepartment.SelectedValue = prevValue;
                        }
                    }
                    else
                    {
                        throw new Exception(returnValue.Message);
                    }

                    AddDefaultToDropDownList(_ddlDepartment);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                finally
                {
                    if (departmentSearch != null)
                    {
                        if (departmentSearch.State != System.ServiceModel.CommunicationState.Faulted)
                            departmentSearch.Close();
                    }
                }
            }
        }
        /// <summary>
        /// Gets the branches.
        /// </summary>
        private void GetBranches()
        {
            BranchDeptServiceClient branchSearch = null;
            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();

                branchSearch = new BranchDeptServiceClient();
                BranchSearchReturnValue returnValue = branchSearch.BranchSearch(_logonSettings.LogonId,collectionRequest);

                if (returnValue.Success)
                {
                    _ddlBranch.Items.Clear();
                    foreach (BranchSearchItem branch in returnValue.Branches.Rows)
                    {
                        ListItem item = new ListItem();
                        item.Text = branch.Name;
                        item.Value = branch.Reference.Trim() + "$" + branch.OrganisationId.ToString();
                        _ddlBranch.Items.Add(item);
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
                AddDefaultToDropDownList(_ddlBranch);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (branchSearch != null)
                {
                    if (branchSearch.State != System.ServiceModel.CommunicationState.Faulted)
                        branchSearch.Close();
                }
            }
        }
        /// <summary>
        /// Sets the Client Bank,Office Bank and supervisor defaults based on the branch and department.
        /// </summary>
        private void SetBranchDepartmentDefaults()
        {
            BranchDeptServiceClient branchDepartmentService = null;
            try
            {
                branchDepartmentService = new BranchDeptServiceClient();
                Guid branchOrgId = new Guid(GetBranchValueOnIndex(_ddlBranch.SelectedValue, 1));
                int deptId = Convert.ToInt32(_ddlDepartment.SelectedValue);
                MatterReturnValue returnValue = branchDepartmentService.GetBranchDepartmentDefaults(_logonSettings.LogonId,
                                            branchOrgId, deptId);

                if (returnValue.Success)
                {
                    //Check if the default values exists and set them
                    if (_ddlClientBank.Items.FindByValue(returnValue.Matter.ClientBankId.ToString()) != null)
                    {
                        _ddlClientBank.SelectedValue = returnValue.Matter.ClientBankId.ToString();
                    }

                    if (_ddlOfficeBank.Items.FindByValue(returnValue.Matter.OfficeBankId.ToString()) != null)
                    {
                        _ddlOfficeBank.SelectedValue = returnValue.Matter.OfficeBankId.ToString();
                    }

                    if (_ddlSupervisor.Items.FindByValue(returnValue.Matter.PartnerMemberId.ToString()) != null)
                    {
                        _ddlSupervisor.SelectedValue = returnValue.Matter.PartnerMemberId.ToString();
                    }
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (branchDepartmentService != null)
                {
                    if (branchDepartmentService.State != System.ServiceModel.CommunicationState.Faulted)
                        branchDepartmentService.Close();
                }
            }
        }