protected function UpdateInventoryModelFields() { $this->objInventoryModel->CategoryId = $this->lstCategory->SelectedValue; $this->objInventoryModel->ManufacturerId = $this->lstManufacturer->SelectedValue; $this->objInventoryModel->InventoryModelCode = $this->txtInventoryModelCode->Text; $this->objInventoryModel->ShortDescription = $this->txtShortDescription->Text; $this->objInventoryModel->LongDescription = $this->txtLongDescription->Text; $this->objInventoryModel->ImagePath = $this->txtImagePath->Text; $this->objInventoryModel->Price = $this->txtPrice->Text; $this->objInventoryModel->CreatedBy = $this->lstCreatedByObject->SelectedValue; $this->objInventoryModel->CreationDate = $this->calCreationDate->DateTime; $this->objInventoryModel->ModifiedBy = $this->lstModifiedByObject->SelectedValue; $this->objInventoryModel->InventoryModelCustomFieldHelper = InventoryModelCustomFieldHelper::Load($this->lstInventoryModelCustomFieldHelper->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 InventoryModelCustomFieldHelperMetaControl * @param integer $intInventoryModelId primary key value * @param QMetaControlCreateType $intCreateType rules governing InventoryModelCustomFieldHelper object creation - defaults to CreateOrEdit * @return InventoryModelCustomFieldHelperMetaControl */ public static function Create($objParentObject, $intInventoryModelId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intInventoryModelId)) { $objInventoryModelCustomFieldHelper = InventoryModelCustomFieldHelper::Load($intInventoryModelId); // InventoryModelCustomFieldHelper was found -- return it! if ($objInventoryModelCustomFieldHelper) { return new InventoryModelCustomFieldHelperMetaControl($objParentObject, $objInventoryModelCustomFieldHelper); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a InventoryModelCustomFieldHelper object with PK arguments: ' . $intInventoryModelId); } } // 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 InventoryModelCustomFieldHelperMetaControl($objParentObject, new InventoryModelCustomFieldHelper()); }
/** * This will save this object's InventoryModel instance, * updating only the fields which have had a control created for it. */ public function SaveInventoryModel() { try { // Update any fields for controls that have been created if ($this->lstCategory) { $this->objInventoryModel->CategoryId = $this->lstCategory->SelectedValue; } if ($this->lstManufacturer) { $this->objInventoryModel->ManufacturerId = $this->lstManufacturer->SelectedValue; } if ($this->txtInventoryModelCode) { $this->objInventoryModel->InventoryModelCode = $this->txtInventoryModelCode->Text; } if ($this->txtShortDescription) { $this->objInventoryModel->ShortDescription = $this->txtShortDescription->Text; } if ($this->txtLongDescription) { $this->objInventoryModel->LongDescription = $this->txtLongDescription->Text; } if ($this->txtImagePath) { $this->objInventoryModel->ImagePath = $this->txtImagePath->Text; } if ($this->txtPrice) { $this->objInventoryModel->Price = $this->txtPrice->Text; } if ($this->lstCreatedByObject) { $this->objInventoryModel->CreatedBy = $this->lstCreatedByObject->SelectedValue; } if ($this->calCreationDate) { $this->objInventoryModel->CreationDate = $this->calCreationDate->DateTime; } if ($this->lstModifiedByObject) { $this->objInventoryModel->ModifiedBy = $this->lstModifiedByObject->SelectedValue; } // Update any UniqueReverseReferences (if any) for controls that have been created for it if ($this->lstInventoryModelCustomFieldHelper) { $this->objInventoryModel->InventoryModelCustomFieldHelper = InventoryModelCustomFieldHelper::Load($this->lstInventoryModelCustomFieldHelper->SelectedValue); } // Save the InventoryModel object $this->objInventoryModel->Save(); // Finally, update any ManyToManyReferences (if any) } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } }
/** * Reload this InventoryModelCustomFieldHelper 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 InventoryModelCustomFieldHelper object.'); } // Reload the Object $objReloaded = InventoryModelCustomFieldHelper::Load($this->intInventoryModelId); // Update $this's local variables to match $this->InventoryModelId = $objReloaded->InventoryModelId; $this->__intInventoryModelId = $this->intInventoryModelId; }