示例#1
0
        /// <summary>
        /// Method to display the available address types.
        /// </summary>
        private void GetAddressTypes()
        {
            ContactServiceClient contactService = null;

            try
            {
                CollectionRequest         collectionRequest = new CollectionRequest();
                AddressTypeSearchCriteria searchCriteria    = new AddressTypeSearchCriteria();
                searchCriteria.MemberId       = _memId;
                searchCriteria.OrganisationId = _orgId;

                contactService = new ContactServiceClient();
                AddressTypeReturnValue returnValue = contactService.GetAddressTypes(_logonId, collectionRequest, searchCriteria);

                if (returnValue.Success)
                {
                    _ddlAddressType.DataSource     = returnValue.AddressTypes.Rows;
                    _ddlAddressType.DataTextField  = "Description";
                    _ddlAddressType.DataValueField = "Id";
                    _ddlAddressType.DataBind();
                }
                else
                {
                    throw new Exception(returnValue.Message);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (contactService != null)
                {
                    if (contactService.State != System.ServiceModel.CommunicationState.Faulted)
                    {
                        contactService.Close();
                    }
                }
            }
        }
        /// <summary>
        /// Method to display the available address types.
        /// </summary>
        private void GetAddressTypes()
        {
            ContactServiceClient contactService = null;
            try
            {
                CollectionRequest collectionRequest = new CollectionRequest();
                AddressTypeSearchCriteria searchCriteria = new AddressTypeSearchCriteria();
                searchCriteria.MemberId = _memId;
                searchCriteria.OrganisationId = _orgId;

                contactService = new ContactServiceClient();
                AddressTypeReturnValue returnValue = contactService.GetAddressTypes(_logonId, collectionRequest, searchCriteria);

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