/**
  * Main utility method to aid with data binding.  It is used by the default BindAllRows() databinder but
  * could and should be used by any custom databind methods that would be used for instances of this
  * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. 
  *
  * If a paginator is set on this DataBinder, it will use it.  If not, then no pagination will be used.
  * It will also perform any sorting (if applicable).
  *
  * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself
  * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query		 
  * @return void
  */
 public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null)
 {
     // Setup input parameters to default values if none passed in
     if (!$objCondition) {
         $objCondition = QQ::All();
     }
     $objClauses = $objOptionalClauses ? $objOptionalClauses : array();
     // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below
     if ($this->Paginator) {
         $this->TotalItemCount = CategoryCustomFieldHelper::QueryCount($objCondition, $objClauses);
     }
     // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add
     // the OrderByClause to the $objClauses array
     if ($objClause = $this->OrderByClause) {
         array_push($objClauses, $objClause);
     }
     // Add the LimitClause information, as well
     if ($objClause = $this->LimitClause) {
         array_push($objClauses, $objClause);
     }
     // Set the DataSource to be a Query result from CategoryCustomFieldHelper, given the clauses above
     $this->DataSource = CategoryCustomFieldHelper::QueryArray($objCondition, $objClauses);
 }
 /**
  * This will save this object's Category instance,
  * updating only the fields which have had a control created for it.
  */
 public function SaveCategory()
 {
     try {
         // Update any fields for controls that have been created
         if ($this->txtShortDescription) {
             $this->objCategory->ShortDescription = $this->txtShortDescription->Text;
         }
         if ($this->txtLongDescription) {
             $this->objCategory->LongDescription = $this->txtLongDescription->Text;
         }
         if ($this->txtImagePath) {
             $this->objCategory->ImagePath = $this->txtImagePath->Text;
         }
         if ($this->chkAssetFlag) {
             $this->objCategory->AssetFlag = $this->chkAssetFlag->Checked;
         }
         if ($this->chkInventoryFlag) {
             $this->objCategory->InventoryFlag = $this->chkInventoryFlag->Checked;
         }
         if ($this->lstCreatedByObject) {
             $this->objCategory->CreatedBy = $this->lstCreatedByObject->SelectedValue;
         }
         if ($this->calCreationDate) {
             $this->objCategory->CreationDate = $this->calCreationDate->DateTime;
         }
         if ($this->lstModifiedByObject) {
             $this->objCategory->ModifiedBy = $this->lstModifiedByObject->SelectedValue;
         }
         // Update any UniqueReverseReferences (if any) for controls that have been created for it
         if ($this->lstCategoryCustomFieldHelper) {
             $this->objCategory->CategoryCustomFieldHelper = CategoryCustomFieldHelper::Load($this->lstCategoryCustomFieldHelper->SelectedValue);
         }
         // Save the Category object
         $this->objCategory->Save();
         // Finally, update any ManyToManyReferences (if any)
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }
 /**
  * Override method to perform a property "Get"
  * This will get the value of $strName
  *
  * @param string $strName Name of the property to get
  * @return mixed
  */
 public function __get($strName)
 {
     switch ($strName) {
         ///////////////////
         // Member Variables
         ///////////////////
         case 'CategoryId':
             // Gets the value for intCategoryId (Read-Only PK)
             // @return integer
             return $this->intCategoryId;
         case 'ShortDescription':
             // Gets the value for strShortDescription (Not Null)
             // @return string
             return $this->strShortDescription;
         case 'LongDescription':
             // Gets the value for strLongDescription
             // @return string
             return $this->strLongDescription;
         case 'ImagePath':
             // Gets the value for strImagePath
             // @return string
             return $this->strImagePath;
         case 'AssetFlag':
             // Gets the value for blnAssetFlag (Not Null)
             // @return boolean
             return $this->blnAssetFlag;
         case 'InventoryFlag':
             // Gets the value for blnInventoryFlag (Not Null)
             // @return boolean
             return $this->blnInventoryFlag;
         case 'CreatedBy':
             // Gets the value for intCreatedBy
             // @return integer
             return $this->intCreatedBy;
         case 'CreationDate':
             // Gets the value for dttCreationDate
             // @return QDateTime
             return $this->dttCreationDate;
         case 'ModifiedBy':
             // Gets the value for intModifiedBy
             // @return integer
             return $this->intModifiedBy;
         case 'ModifiedDate':
             // Gets the value for strModifiedDate (Read-Only Timestamp)
             // @return string
             return $this->strModifiedDate;
             ///////////////////
             // Member Objects
             ///////////////////
         ///////////////////
         // Member Objects
         ///////////////////
         case 'CreatedByObject':
             // Gets the value for the UserAccount object referenced by intCreatedBy
             // @return UserAccount
             try {
                 if (!$this->objCreatedByObject && !is_null($this->intCreatedBy)) {
                     $this->objCreatedByObject = UserAccount::Load($this->intCreatedBy);
                 }
                 return $this->objCreatedByObject;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'ModifiedByObject':
             // Gets the value for the UserAccount object referenced by intModifiedBy
             // @return UserAccount
             try {
                 if (!$this->objModifiedByObject && !is_null($this->intModifiedBy)) {
                     $this->objModifiedByObject = UserAccount::Load($this->intModifiedBy);
                 }
                 return $this->objModifiedByObject;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
         case 'CategoryCustomFieldHelper':
             // Gets the value for the CategoryCustomFieldHelper object that uniquely references this Category
             // by objCategoryCustomFieldHelper (Unique)
             // @return CategoryCustomFieldHelper
             try {
                 if ($this->objCategoryCustomFieldHelper === false) {
                     // We've attempted early binding -- and the reverse reference object does not exist
                     return null;
                 }
                 if (!$this->objCategoryCustomFieldHelper) {
                     $this->objCategoryCustomFieldHelper = CategoryCustomFieldHelper::LoadByCategoryId($this->intCategoryId);
                 }
                 return $this->objCategoryCustomFieldHelper;
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
             ////////////////////////////
             // Virtual Object References (Many to Many and Reverse References)
             // (If restored via a "Many-to" expansion)
             ////////////////////////////
         ////////////////////////////
         // Virtual Object References (Many to Many and Reverse References)
         // (If restored via a "Many-to" expansion)
         ////////////////////////////
         case '_AssetModel':
             // Gets the value for the private _objAssetModel (Read-Only)
             // if set due to an expansion on the asset_model.category_id reverse relationship
             // @return AssetModel
             return $this->_objAssetModel;
         case '_AssetModelArray':
             // Gets the value for the private _objAssetModelArray (Read-Only)
             // if set due to an ExpandAsArray on the asset_model.category_id reverse relationship
             // @return AssetModel[]
             return (array) $this->_objAssetModelArray;
         case '_InventoryModel':
             // Gets the value for the private _objInventoryModel (Read-Only)
             // if set due to an expansion on the inventory_model.category_id reverse relationship
             // @return InventoryModel
             return $this->_objInventoryModel;
         case '_InventoryModelArray':
             // Gets the value for the private _objInventoryModelArray (Read-Only)
             // if set due to an ExpandAsArray on the inventory_model.category_id reverse relationship
             // @return InventoryModel[]
             return (array) $this->_objInventoryModelArray;
         case '__Restored':
             return $this->__blnRestored;
         default:
             try {
                 return parent::__get($strName);
             } catch (QCallerException $objExc) {
                 $objExc->IncrementOffset();
                 throw $objExc;
             }
     }
 }
 /**
  * Static Helper Method to Create using PK arguments
  * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
  * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
  * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to 
  * edit, or if we are also allowed to create a new one, etc.
  * 
  * @param mixed $objParentObject QForm or QPanel which will be using this CategoryCustomFieldHelperMetaControl
  * @param integer $intCategoryId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing CategoryCustomFieldHelper object creation - defaults to CreateOrEdit
  * @return CategoryCustomFieldHelperMetaControl
  */
 public static function Create($objParentObject, $intCategoryId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intCategoryId)) {
         $objCategoryCustomFieldHelper = CategoryCustomFieldHelper::Load($intCategoryId);
         // CategoryCustomFieldHelper was found -- return it!
         if ($objCategoryCustomFieldHelper) {
             return new CategoryCustomFieldHelperMetaControl($objParentObject, $objCategoryCustomFieldHelper);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a CategoryCustomFieldHelper object with PK arguments: ' . $intCategoryId);
             }
         }
         // If EditOnly is specified, throw an exception
     } else {
         if ($intCreateType == QMetaControlCreateType::EditOnly) {
             throw new QCallerException('No PK arguments specified');
         }
     }
     // If we are here, then we need to create a new record
     return new CategoryCustomFieldHelperMetaControl($objParentObject, new CategoryCustomFieldHelper());
 }
 protected function UpdateCategoryFields()
 {
     $this->objCategory->ShortDescription = $this->txtShortDescription->Text;
     $this->objCategory->LongDescription = $this->txtLongDescription->Text;
     $this->objCategory->ImagePath = $this->txtImagePath->Text;
     $this->objCategory->AssetFlag = $this->chkAssetFlag->Checked;
     $this->objCategory->InventoryFlag = $this->chkInventoryFlag->Checked;
     $this->objCategory->CreatedBy = $this->lstCreatedByObject->SelectedValue;
     $this->objCategory->CreationDate = $this->calCreationDate->DateTime;
     $this->objCategory->ModifiedBy = $this->lstModifiedByObject->SelectedValue;
     $this->objCategory->CategoryCustomFieldHelper = CategoryCustomFieldHelper::Load($this->lstCategoryCustomFieldHelper->SelectedValue);
 }
 public static function GetSoapArrayFromArray($objArray)
 {
     if (!$objArray) {
         return null;
     }
     $objArrayToReturn = array();
     foreach ($objArray as $objObject) {
         array_push($objArrayToReturn, CategoryCustomFieldHelper::GetSoapObjectFromObject($objObject, true));
     }
     return unserialize(serialize($objArrayToReturn));
 }