/** * 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; } }
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); }
/** * 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()); }
/** * Reload this CategoryCustomFieldHelper 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 CategoryCustomFieldHelper object.'); } // Reload the Object $objReloaded = CategoryCustomFieldHelper::Load($this->intCategoryId); // Update $this's local variables to match $this->CategoryId = $objReloaded->CategoryId; $this->__intCategoryId = $this->intCategoryId; }