}//END method

    // ==================================================================================
    /// <summary>
    /// THis method saves the ResultData object updating the field values contained in the 
    /// parameter list.
    /// </summary>
    /// <param name="PageCommand">Evado.Model.UniForm.Command object.</param>
    /// <returns>Application Data object</returns>
    //  ----------------------------------------------------------------------------------
    private Evado.Model.UniForm.AppData updateObject ( 
      Evado.Model.UniForm.Command PageCommand )
    {
      this.LogMethod ( "updateObject" );
      this.LogValue ( "PageEvado.Model.UniForm.Command: " + PageCommand.getAsString ( false, false ) );

      this.LogValue ( "Guid: " + this.Session.Trial.Guid );
      this.LogValue ( "ProjectId: " + this.Session.Trial.TrialId );
      this.LogValue ( "Title: " + this.Session.Trial.Title );
      try
      {
        //
        // Initialise the methods variables and objects.
        //
        this.Session.AncillaryRecord.Action = EvAncillaryRecords.ACTION_SAVE;

        // 
        // Log access to page.
        // 
        this.LogPageAccess (
          "Evado.UniForm.Clinical.SubjectRecords.updateObject",
          this.Session.UserProfile );

        // 
        // Delete the object.
        // 
        if ( PageCommand.Method == Evado.Model.UniForm.ApplicationMethods.Delete_Object )
        {
          return this.Session.LastPage;
        }

        //
        // Initialise the binary file object to retrieve binary files associated with the visit.
        // 
        EuBinaryFiles binaryFiles = new EuBinaryFiles (
                this.ApplicationObjects,
                this.ServiceUserProfile,
                this.Session,
                this.UniForm_BinaryFilePath,
                this.UniForm_BinaryServiceUrl,
                this._FileRepositoryPath,
                this.ClassParameters );

        this.LogClass ( binaryFiles.Log );

        // 
        // Get the save action value.
        // 
        String stSaveAction = PageCommand.GetParameter (  Evado.Model.Clinical.EvcStatics.CONST_SAVE_ACTION );
        if ( stSaveAction != String.Empty )
        {
          this.Session.AncillaryRecord.Action = stSaveAction;
        }
        this.LogValue ( "AncillaryRecord.Action: " + this.Session.AncillaryRecord.Action );

        //
        // if the guid is set to new object reset it to empty to add a new record.
        //
        if ( this.Session.AncillaryRecord.Guid ==  Evado.Model.Clinical.EvcStatics.CONST_NEW_OBJECT_ID )
        {
          this.Session.AncillaryRecord.Guid = Guid.NewGuid ( );
          this.Session.AncillaryRecord.SubjectId = this.Session.Subject.SubjectId;
          this.Session.AncillaryRecord.ProjectId = this.Session.Subject.TrialId;
          this.Session.AncillaryRecord.Action = EvAncillaryRecords.ACTION_NEW;
        }

        if (
          this.Session.AncillaryRecord.RecordDate ==  Evado.Model.Clinical.EvcStatics.CONST_DATE_NULL )
        {
          this.Session.AncillaryRecord.RecordDate = DateTime.Now;
        }

        // 
        // Initialise the update variables.
        // 
        this.Session.AncillaryRecord.UpdatedByUserId = this.Session.UserProfile.UserId;
        this.Session.AncillaryRecord.UserCommonName = this.Session.UserProfile.CommonName;
        // 
        // Update the object.
        // 
        this.updateObjectValue ( PageCommand.Parameters );

        //
        // save the binary files to the file repository.
        // 
        binaryFiles.addBinaryData (
          PageCommand,
          this.Session.Subject.Guid,
          this.Session.Subject.SubjectId,
          this.Session.AncillaryRecord.Guid,
          this.Session.AncillaryRecord.RecordId,
          Guid.Empty, String.Empty );

        this.LogValue ( "BinaryFiles: " + binaryFiles.Log );

        // 
        // update the object.
        // 
        EvEventCodes result = this._Bll_AncillaryRecords.saveItem ( this.Session.AncillaryRecord );

        // 
        // get the debug ResultData.
        // 
        this.LogValue ( this._Bll_AncillaryRecords.DebugLog );

        // 
        // if an error state is returned create log the event.
        // 
        if ( result != EvEventCodes.Ok )
        {
          string StEvent = this._Bll_AncillaryRecords.Log + " returned error message: " + Evado.Model.Clinical.EvcStatics.getEventMessage ( result );
          this.LogError ( EvEventCodes.Database_Record_Update_Error, StEvent );

          switch ( result )
          {
            case EvEventCodes.Data_Duplicate_Id_Error:
              {
                this.ErrorMessage =
                  String.Format (
                    EvLabels.Activity_Duplicate_Identifier_Error_Message,
                    this.Session.Activity.ActivityId );
                break;
              }
            case EvEventCodes.Identifier_Project_Id_Error:
              {
                this.ErrorMessage = EvLabels.Project_Identifier_Empty_Error_Message;
                break;
              }
            case EvEventCodes.Identifier_Subject_Id_Error:
              {
                this.ErrorMessage = EvLabels.Subject_Identifier_Empty_Error_Message;
                break;
              }
            default:
              {
                this.ErrorMessage = EvLabels.Ancilliary_Record_Update_Error_Message;
                break;
              }
          }
          return this.Session.LastPage;
        }

        return new Model.UniForm.AppData();

      }
      catch ( Exception Ex )
      {
        // 
        // Create the error message to be displayed to the user.
        // 
        this.ErrorMessage = EvLabels.Ancilliary_Record_Update_Error_Message;

        // 
        // Generate the log the error event.
        // 
        this.LogException ( Ex );
      }
      return this.Session.LastPage;

    }//END method
    }//END getClientDataObject_FieldGroup method.

    //===================================================================================
    /// <summary>
    /// This method generates the relevant inary files groups for the milestone record page.
    /// </summary>
    /// <param name="Page">Evado.Model.UniForm.Page object</param>
    //-----------------------------------------------------------------------------------
    private void getClientDataObject_BinaryFileGroup (
      Evado.Model.UniForm.Page Page )
    {
      this.LogMethod ( "getClientDataObject_BinaryFileGroup" );
      // 
      // Initialise the methods variables and objects.
      // 
      this.Session.FileMetaDataList = new List<EvBinaryFileMetaData> ( );

      //
      // Exit if binary ResultData is not being collected.
      //
      if ( this.Session.Trial.Data.EnableBinaryData == false )
      {
        this.LogValue ( "Trial not collecting binary data." );

        return;
      }

      //
      // Initialise the binary file object to retrieve binary files associated with the visit.
      // 
      EuBinaryFiles binaryFiles = new EuBinaryFiles (
              this.ApplicationObjects,
              this.ServiceUserProfile,
              this.Session,
              this.UniForm_BinaryFilePath,
              this.UniForm_BinaryServiceUrl,
              this._FileRepositoryPath,
              this.ClassParameters );

      binaryFiles.LoggingLevel = this.LoggingLevel;

      this.LogValue ( "Initialise the binary files class. " + binaryFiles.Log );

      Evado.Model.UniForm.Group group = binaryFiles.getListGroup ( EuAdapterClasses.Ancillary_Record, 200 );

      this.LogValue ( "binaryFiles.getListGroup debuglog: " + binaryFiles.Log );

      if ( group != null )
      {
        this.LogValue ( "Display group not null" );
        Page.AddGroup ( group );
      }

      //
      // If the user has edit access add binary upload pageMenuGroup.
      //
      if ( Page.EditAccess == Evado.Model.UniForm.EditAccess.Enabled )
      {
        //
        // Get the binary file pageMenuGroup
        //
        group = binaryFiles.getUploadGroup ( EuAdapterClasses.Ancillary_Record );

        this.LogValue ( "binaryFiles.getUploadGroup debuglog: " + binaryFiles.Log );

        if ( group != null )
        {
          this.LogValue ( "Upload group not null" );
          Page.AddGroup ( group );
        }
      }

      this.LogMethodEnd ( "getClientDataObject_BinaryFileGroup" );

    }//END getClientDataObject_BinaryFileGroup method