예제 #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();
                    }
                }
            }
        }
예제 #2
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 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();
                    }
                }
            }
        }