/**
  * Reload this AssetCustomFieldHelper from the database.
  * @return void
  */
 public function Reload()
 {
     // Make sure we are actually Restored from the database
     if (!$this->__blnRestored) {
         throw new QCallerException('Cannot call Reload() on a new, unsaved AssetCustomFieldHelper object.');
     }
     // Reload the Object
     $objReloaded = AssetCustomFieldHelper::Load($this->intAssetId);
     // Update $this's local variables to match
     $this->AssetId = $objReloaded->AssetId;
     $this->__intAssetId = $this->intAssetId;
 }
 /**
  * This will save this object's Asset instance,
  * updating only the fields which have had a control created for it.
  */
 public function SaveAsset()
 {
     try {
         // Update any fields for controls that have been created
         if ($this->lstParentAsset) {
             $this->objAsset->ParentAssetId = $this->lstParentAsset->SelectedValue;
         }
         if ($this->lstAssetModel) {
             $this->objAsset->AssetModelId = $this->lstAssetModel->SelectedValue;
         }
         if ($this->lstLocation) {
             $this->objAsset->LocationId = $this->lstLocation->SelectedValue;
         }
         if ($this->txtAssetCode) {
             $this->objAsset->AssetCode = $this->txtAssetCode->Text;
         }
         if ($this->txtImagePath) {
             $this->objAsset->ImagePath = $this->txtImagePath->Text;
         }
         if ($this->chkCheckedOutFlag) {
             $this->objAsset->CheckedOutFlag = $this->chkCheckedOutFlag->Checked;
         }
         if ($this->chkReservedFlag) {
             $this->objAsset->ReservedFlag = $this->chkReservedFlag->Checked;
         }
         if ($this->chkLinkedFlag) {
             $this->objAsset->LinkedFlag = $this->chkLinkedFlag->Checked;
         }
         if ($this->chkArchivedFlag) {
             $this->objAsset->ArchivedFlag = $this->chkArchivedFlag->Checked;
         }
         if ($this->lstCreatedByObject) {
             $this->objAsset->CreatedBy = $this->lstCreatedByObject->SelectedValue;
         }
         if ($this->calCreationDate) {
             $this->objAsset->CreationDate = $this->calCreationDate->DateTime;
         }
         if ($this->lstModifiedByObject) {
             $this->objAsset->ModifiedBy = $this->lstModifiedByObject->SelectedValue;
         }
         if ($this->chkDepreciationFlag) {
             $this->objAsset->DepreciationFlag = $this->chkDepreciationFlag->Checked;
         }
         if ($this->calPurchaseDate) {
             $this->objAsset->PurchaseDate = $this->calPurchaseDate->DateTime;
         }
         if ($this->txtPurchaseCost) {
             $this->objAsset->PurchaseCost = $this->txtPurchaseCost->Text;
         }
         // Update any UniqueReverseReferences (if any) for controls that have been created for it
         if ($this->lstAssetCustomFieldHelper) {
             $this->objAsset->AssetCustomFieldHelper = AssetCustomFieldHelper::Load($this->lstAssetCustomFieldHelper->SelectedValue);
         }
         // Save the Asset object
         $this->objAsset->Save();
         // Finally, update any ManyToManyReferences (if any)
     } catch (QCallerException $objExc) {
         $objExc->IncrementOffset();
         throw $objExc;
     }
 }
예제 #3
0
 protected function UpdateAssetFields()
 {
     $this->objAsset->ParentAssetId = $this->lstParentAsset->SelectedValue;
     $this->objAsset->AssetModelId = $this->lstAssetModel->SelectedValue;
     $this->objAsset->LocationId = $this->lstLocation->SelectedValue;
     $this->objAsset->AssetCode = $this->txtAssetCode->Text;
     $this->objAsset->ImagePath = $this->txtImagePath->Text;
     $this->objAsset->CheckedOutFlag = $this->chkCheckedOutFlag->Checked;
     $this->objAsset->ReservedFlag = $this->chkReservedFlag->Checked;
     $this->objAsset->LinkedFlag = $this->chkLinkedFlag->Checked;
     $this->objAsset->ArchivedFlag = $this->chkArchivedFlag->Checked;
     $this->objAsset->CreatedBy = $this->lstCreatedByObject->SelectedValue;
     $this->objAsset->CreationDate = $this->calCreationDate->DateTime;
     $this->objAsset->ModifiedBy = $this->lstModifiedByObject->SelectedValue;
     $this->objAsset->AssetCustomFieldHelper = AssetCustomFieldHelper::Load($this->lstAssetCustomFieldHelper->SelectedValue);
 }
 /**
  * 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 AssetCustomFieldHelperMetaControl
  * @param integer $intAssetId primary key value
  * @param QMetaControlCreateType $intCreateType rules governing AssetCustomFieldHelper object creation - defaults to CreateOrEdit
  * @return AssetCustomFieldHelperMetaControl
  */
 public static function Create($objParentObject, $intAssetId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit)
 {
     // Attempt to Load from PK Arguments
     if (strlen($intAssetId)) {
         $objAssetCustomFieldHelper = AssetCustomFieldHelper::Load($intAssetId);
         // AssetCustomFieldHelper was found -- return it!
         if ($objAssetCustomFieldHelper) {
             return new AssetCustomFieldHelperMetaControl($objParentObject, $objAssetCustomFieldHelper);
         } else {
             if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) {
                 throw new QCallerException('Could not find a AssetCustomFieldHelper object with PK arguments: ' . $intAssetId);
             }
         }
         // 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 AssetCustomFieldHelperMetaControl($objParentObject, new AssetCustomFieldHelper());
 }