protected function lstAddressCustomFieldHelper_Create()
 {
     $this->lstAddressCustomFieldHelper = new QListBox($this);
     $this->lstAddressCustomFieldHelper->Name = QApplication::Translate('Address Custom Field Helper');
     $this->lstAddressCustomFieldHelper->AddItem(QApplication::Translate('- Select One -'), null);
     $objAddressCustomFieldHelperArray = AddressCustomFieldHelper::LoadAll();
     if ($objAddressCustomFieldHelperArray) {
         foreach ($objAddressCustomFieldHelperArray as $objAddressCustomFieldHelper) {
             $objListItem = new QListItem($objAddressCustomFieldHelper->__toString(), $objAddressCustomFieldHelper->AddressId);
             if ($objAddressCustomFieldHelper->AddressId == $this->objAddress->AddressId) {
                 $objListItem->Selected = true;
             }
             $this->lstAddressCustomFieldHelper->AddItem($objListItem);
         }
     }
     // Because AddressCustomFieldHelper's AddressCustomFieldHelper is not null, if a value is already selected, it cannot be changed.
     if ($this->lstAddressCustomFieldHelper->SelectedValue) {
         $this->lstAddressCustomFieldHelper->Enabled = false;
     }
 }
 /**
  * Refresh this MetaControl with Data from the local Address object.
  * @param boolean $blnReload reload Address from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objAddress->Reload();
     }
     if ($this->lblAddressId) {
         if ($this->blnEditMode) {
             $this->lblAddressId->Text = $this->objAddress->AddressId;
         }
     }
     if ($this->lstCompany) {
         $this->lstCompany->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstCompany->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objCompanyArray = Company::LoadAll();
         if ($objCompanyArray) {
             foreach ($objCompanyArray as $objCompany) {
                 $objListItem = new QListItem($objCompany->__toString(), $objCompany->CompanyId);
                 if ($this->objAddress->Company && $this->objAddress->Company->CompanyId == $objCompany->CompanyId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstCompany->AddItem($objListItem);
             }
         }
     }
     if ($this->lblCompanyId) {
         $this->lblCompanyId->Text = $this->objAddress->Company ? $this->objAddress->Company->__toString() : null;
     }
     if ($this->txtShortDescription) {
         $this->txtShortDescription->Text = $this->objAddress->ShortDescription;
     }
     if ($this->lblShortDescription) {
         $this->lblShortDescription->Text = $this->objAddress->ShortDescription;
     }
     if ($this->lstCountry) {
         $this->lstCountry->RemoveAllItems();
         if (!$this->blnEditMode) {
             $this->lstCountry->AddItem(QApplication::Translate('- Select One -'), null);
         }
         $objCountryArray = Country::LoadAll();
         if ($objCountryArray) {
             foreach ($objCountryArray as $objCountry) {
                 $objListItem = new QListItem($objCountry->__toString(), $objCountry->CountryId);
                 if ($this->objAddress->Country && $this->objAddress->Country->CountryId == $objCountry->CountryId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstCountry->AddItem($objListItem);
             }
         }
     }
     if ($this->lblCountryId) {
         $this->lblCountryId->Text = $this->objAddress->Country ? $this->objAddress->Country->__toString() : null;
     }
     if ($this->txtAddress1) {
         $this->txtAddress1->Text = $this->objAddress->Address1;
     }
     if ($this->lblAddress1) {
         $this->lblAddress1->Text = $this->objAddress->Address1;
     }
     if ($this->txtAddress2) {
         $this->txtAddress2->Text = $this->objAddress->Address2;
     }
     if ($this->lblAddress2) {
         $this->lblAddress2->Text = $this->objAddress->Address2;
     }
     if ($this->txtCity) {
         $this->txtCity->Text = $this->objAddress->City;
     }
     if ($this->lblCity) {
         $this->lblCity->Text = $this->objAddress->City;
     }
     if ($this->lstStateProvince) {
         $this->lstStateProvince->RemoveAllItems();
         $this->lstStateProvince->AddItem(QApplication::Translate('- Select One -'), null);
         $objStateProvinceArray = StateProvince::LoadAll();
         if ($objStateProvinceArray) {
             foreach ($objStateProvinceArray as $objStateProvince) {
                 $objListItem = new QListItem($objStateProvince->__toString(), $objStateProvince->StateProvinceId);
                 if ($this->objAddress->StateProvince && $this->objAddress->StateProvince->StateProvinceId == $objStateProvince->StateProvinceId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstStateProvince->AddItem($objListItem);
             }
         }
     }
     if ($this->lblStateProvinceId) {
         $this->lblStateProvinceId->Text = $this->objAddress->StateProvince ? $this->objAddress->StateProvince->__toString() : null;
     }
     if ($this->txtPostalCode) {
         $this->txtPostalCode->Text = $this->objAddress->PostalCode;
     }
     if ($this->lblPostalCode) {
         $this->lblPostalCode->Text = $this->objAddress->PostalCode;
     }
     if ($this->lstCreatedByObject) {
         $this->lstCreatedByObject->RemoveAllItems();
         $this->lstCreatedByObject->AddItem(QApplication::Translate('- Select One -'), null);
         $objCreatedByObjectArray = UserAccount::LoadAll();
         if ($objCreatedByObjectArray) {
             foreach ($objCreatedByObjectArray as $objCreatedByObject) {
                 $objListItem = new QListItem($objCreatedByObject->__toString(), $objCreatedByObject->UserAccountId);
                 if ($this->objAddress->CreatedByObject && $this->objAddress->CreatedByObject->UserAccountId == $objCreatedByObject->UserAccountId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstCreatedByObject->AddItem($objListItem);
             }
         }
     }
     if ($this->lblCreatedBy) {
         $this->lblCreatedBy->Text = $this->objAddress->CreatedByObject ? $this->objAddress->CreatedByObject->__toString() : null;
     }
     if ($this->calCreationDate) {
         $this->calCreationDate->DateTime = $this->objAddress->CreationDate;
     }
     if ($this->lblCreationDate) {
         $this->lblCreationDate->Text = sprintf($this->objAddress->CreationDate) ? $this->objAddress->__toString($this->strCreationDateDateTimeFormat) : null;
     }
     if ($this->lstModifiedByObject) {
         $this->lstModifiedByObject->RemoveAllItems();
         $this->lstModifiedByObject->AddItem(QApplication::Translate('- Select One -'), null);
         $objModifiedByObjectArray = UserAccount::LoadAll();
         if ($objModifiedByObjectArray) {
             foreach ($objModifiedByObjectArray as $objModifiedByObject) {
                 $objListItem = new QListItem($objModifiedByObject->__toString(), $objModifiedByObject->UserAccountId);
                 if ($this->objAddress->ModifiedByObject && $this->objAddress->ModifiedByObject->UserAccountId == $objModifiedByObject->UserAccountId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstModifiedByObject->AddItem($objListItem);
             }
         }
     }
     if ($this->lblModifiedBy) {
         $this->lblModifiedBy->Text = $this->objAddress->ModifiedByObject ? $this->objAddress->ModifiedByObject->__toString() : null;
     }
     if ($this->lblModifiedDate) {
         if ($this->blnEditMode) {
             $this->lblModifiedDate->Text = $this->objAddress->ModifiedDate;
         }
     }
     if ($this->lstAddressCustomFieldHelper) {
         $this->lstAddressCustomFieldHelper->RemoveAllItems();
         $this->lstAddressCustomFieldHelper->AddItem(QApplication::Translate('- Select One -'), null);
         $objAddressCustomFieldHelperArray = AddressCustomFieldHelper::LoadAll();
         if ($objAddressCustomFieldHelperArray) {
             foreach ($objAddressCustomFieldHelperArray as $objAddressCustomFieldHelper) {
                 $objListItem = new QListItem($objAddressCustomFieldHelper->__toString(), $objAddressCustomFieldHelper->AddressId);
                 if ($objAddressCustomFieldHelper->AddressId == $this->objAddress->AddressId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstAddressCustomFieldHelper->AddItem($objListItem);
             }
         }
         // Because AddressCustomFieldHelper's AddressCustomFieldHelper is not null, if a value is already selected, it cannot be changed.
         if ($this->lstAddressCustomFieldHelper->SelectedValue) {
             $this->lstAddressCustomFieldHelper->Enabled = false;
         } else {
             $this->lstAddressCustomFieldHelper->Enabled = true;
         }
     }
     if ($this->lblAddressCustomFieldHelper) {
         $this->lblAddressCustomFieldHelper->Text = $this->objAddress->AddressCustomFieldHelper ? $this->objAddress->AddressCustomFieldHelper->__toString() : null;
     }
 }