コード例 #1
0
        /// <summary>
        /// Saves the client details(user types 1 and 2).
        /// </summary>
        private void SaveClient()
        {
            //Perform HO UCN field length validation as it is not checked in the service layer
            if (_txtHOUCN.Text.Length > 0 && _txtHOUCN.Text.Length < 8)
            {
                _lblMessage.CssClass = "errorMessage";
                _lblMessage.Text = "All characters have not been entered for the HO UCN";
                return;
            }

            ClientServiceClient clientService = null;
            try
            {
                SaveAddresses();

                clientService = new ClientServiceClient();
                IRIS.Law.WebServiceInterfaces.Client.Client client = GetClientDetails();
                Person person = GetPersonDetails();
                Organisation organisation = GetOrganisationDetails();
                ReturnValue returnValue = clientService.UpdateClient(_logonSettings.LogonId, client, person, organisation);
                if (returnValue.Success)
                {
                    _lblMessage.CssClass = "successMessage";
                    _lblMessage.Text = "Edit successful";
                    //Generate client name label as the details may have changed
                    if (_memberId != DataConstants.DummyGuid)
                    {
                        _lblClientName.Text = CommonFunctions.MakeFullName(_ddlTitle.SelectedItem.Text.Trim(),
                                    _txtForenames.Text.Trim(), _txtSurname.Text.Trim());
                    }
                    else
                    {
                        _lblClientName.Text = _txtOrganisationName.Text.Trim();
                    }

                    _imgClientArchieved.Visible = _chkArchiveClient.Checked;
                }
                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 (clientService != null)
                {
                    if (clientService.State != System.ServiceModel.CommunicationState.Faulted)
                        clientService.Close();
                }
            }
        }