/** * This will save this object's Contact instance, * updating only the fields which have had a control created for it. */ public function SaveContact() { try { // Update any fields for controls that have been created if ($this->lstCompany) { $this->objContact->CompanyId = $this->lstCompany->SelectedValue; } if ($this->lstAddress) { $this->objContact->AddressId = $this->lstAddress->SelectedValue; } if ($this->txtFirstName) { $this->objContact->FirstName = $this->txtFirstName->Text; } if ($this->txtLastName) { $this->objContact->LastName = $this->txtLastName->Text; } if ($this->txtTitle) { $this->objContact->Title = $this->txtTitle->Text; } if ($this->txtEmail) { $this->objContact->Email = $this->txtEmail->Text; } if ($this->txtPhoneOffice) { $this->objContact->PhoneOffice = $this->txtPhoneOffice->Text; } if ($this->txtPhoneHome) { $this->objContact->PhoneHome = $this->txtPhoneHome->Text; } if ($this->txtPhoneMobile) { $this->objContact->PhoneMobile = $this->txtPhoneMobile->Text; } if ($this->txtFax) { $this->objContact->Fax = $this->txtFax->Text; } if ($this->txtDescription) { $this->objContact->Description = $this->txtDescription->Text; } if ($this->lstCreatedByObject) { $this->objContact->CreatedBy = $this->lstCreatedByObject->SelectedValue; } if ($this->calCreationDate) { $this->objContact->CreationDate = $this->calCreationDate->DateTime; } if ($this->lstModifiedByObject) { $this->objContact->ModifiedBy = $this->lstModifiedByObject->SelectedValue; } // Update any UniqueReverseReferences (if any) for controls that have been created for it if ($this->lstContactCustomFieldHelper) { $this->objContact->ContactCustomFieldHelper = ContactCustomFieldHelper::Load($this->lstContactCustomFieldHelper->SelectedValue); } // Save the Contact object $this->objContact->Save(); // Finally, update any ManyToManyReferences (if any) } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } }
/** * Reload this ContactCustomFieldHelper 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 ContactCustomFieldHelper object.'); } // Reload the Object $objReloaded = ContactCustomFieldHelper::Load($this->intContactId); // Update $this's local variables to match $this->ContactId = $objReloaded->ContactId; $this->__intContactId = $this->intContactId; }
protected function UpdateContactFields() { $this->objContact->CompanyId = $this->lstCompany->SelectedValue; $this->objContact->AddressId = $this->lstAddress->SelectedValue; $this->objContact->FirstName = $this->txtFirstName->Text; $this->objContact->LastName = $this->txtLastName->Text; $this->objContact->Title = $this->txtTitle->Text; $this->objContact->Email = $this->txtEmail->Text; $this->objContact->PhoneOffice = $this->txtPhoneOffice->Text; $this->objContact->PhoneHome = $this->txtPhoneHome->Text; $this->objContact->PhoneMobile = $this->txtPhoneMobile->Text; $this->objContact->Fax = $this->txtFax->Text; $this->objContact->Description = $this->txtDescription->Text; $this->objContact->CreatedBy = $this->lstCreatedByObject->SelectedValue; $this->objContact->CreationDate = $this->calCreationDate->DateTime; $this->objContact->ModifiedBy = $this->lstModifiedByObject->SelectedValue; $this->objContact->ContactCustomFieldHelper = ContactCustomFieldHelper::Load($this->lstContactCustomFieldHelper->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 ContactCustomFieldHelperMetaControl * @param integer $intContactId primary key value * @param QMetaControlCreateType $intCreateType rules governing ContactCustomFieldHelper object creation - defaults to CreateOrEdit * @return ContactCustomFieldHelperMetaControl */ public static function Create($objParentObject, $intContactId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intContactId)) { $objContactCustomFieldHelper = ContactCustomFieldHelper::Load($intContactId); // ContactCustomFieldHelper was found -- return it! if ($objContactCustomFieldHelper) { return new ContactCustomFieldHelperMetaControl($objParentObject, $objContactCustomFieldHelper); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a ContactCustomFieldHelper object with PK arguments: ' . $intContactId); } } // 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 ContactCustomFieldHelperMetaControl($objParentObject, new ContactCustomFieldHelper()); }