/**
  * Refresh this MetaControl with Data from the local Category object.
  * @param boolean $blnReload reload Category from the database
  * @return void
  */
 public function Refresh($blnReload = false)
 {
     if ($blnReload) {
         $this->objCategory->Reload();
     }
     if ($this->lblCategoryId) {
         if ($this->blnEditMode) {
             $this->lblCategoryId->Text = $this->objCategory->CategoryId;
         }
     }
     if ($this->txtShortDescription) {
         $this->txtShortDescription->Text = $this->objCategory->ShortDescription;
     }
     if ($this->lblShortDescription) {
         $this->lblShortDescription->Text = $this->objCategory->ShortDescription;
     }
     if ($this->txtLongDescription) {
         $this->txtLongDescription->Text = $this->objCategory->LongDescription;
     }
     if ($this->lblLongDescription) {
         $this->lblLongDescription->Text = $this->objCategory->LongDescription;
     }
     if ($this->txtImagePath) {
         $this->txtImagePath->Text = $this->objCategory->ImagePath;
     }
     if ($this->lblImagePath) {
         $this->lblImagePath->Text = $this->objCategory->ImagePath;
     }
     if ($this->chkAssetFlag) {
         $this->chkAssetFlag->Checked = $this->objCategory->AssetFlag;
     }
     if ($this->lblAssetFlag) {
         $this->lblAssetFlag->Text = $this->objCategory->AssetFlag ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
     if ($this->chkInventoryFlag) {
         $this->chkInventoryFlag->Checked = $this->objCategory->InventoryFlag;
     }
     if ($this->lblInventoryFlag) {
         $this->lblInventoryFlag->Text = $this->objCategory->InventoryFlag ? QApplication::Translate('Yes') : QApplication::Translate('No');
     }
     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->objCategory->CreatedByObject && $this->objCategory->CreatedByObject->UserAccountId == $objCreatedByObject->UserAccountId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstCreatedByObject->AddItem($objListItem);
             }
         }
     }
     if ($this->lblCreatedBy) {
         $this->lblCreatedBy->Text = $this->objCategory->CreatedByObject ? $this->objCategory->CreatedByObject->__toString() : null;
     }
     if ($this->calCreationDate) {
         $this->calCreationDate->DateTime = $this->objCategory->CreationDate;
     }
     if ($this->lblCreationDate) {
         $this->lblCreationDate->Text = sprintf($this->objCategory->CreationDate) ? $this->objCategory->__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->objCategory->ModifiedByObject && $this->objCategory->ModifiedByObject->UserAccountId == $objModifiedByObject->UserAccountId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstModifiedByObject->AddItem($objListItem);
             }
         }
     }
     if ($this->lblModifiedBy) {
         $this->lblModifiedBy->Text = $this->objCategory->ModifiedByObject ? $this->objCategory->ModifiedByObject->__toString() : null;
     }
     if ($this->lblModifiedDate) {
         if ($this->blnEditMode) {
             $this->lblModifiedDate->Text = $this->objCategory->ModifiedDate;
         }
     }
     if ($this->lstCategoryCustomFieldHelper) {
         $this->lstCategoryCustomFieldHelper->RemoveAllItems();
         $this->lstCategoryCustomFieldHelper->AddItem(QApplication::Translate('- Select One -'), null);
         $objCategoryCustomFieldHelperArray = CategoryCustomFieldHelper::LoadAll();
         if ($objCategoryCustomFieldHelperArray) {
             foreach ($objCategoryCustomFieldHelperArray as $objCategoryCustomFieldHelper) {
                 $objListItem = new QListItem($objCategoryCustomFieldHelper->__toString(), $objCategoryCustomFieldHelper->CategoryId);
                 if ($objCategoryCustomFieldHelper->CategoryId == $this->objCategory->CategoryId) {
                     $objListItem->Selected = true;
                 }
                 $this->lstCategoryCustomFieldHelper->AddItem($objListItem);
             }
         }
         // Because CategoryCustomFieldHelper's CategoryCustomFieldHelper is not null, if a value is already selected, it cannot be changed.
         if ($this->lstCategoryCustomFieldHelper->SelectedValue) {
             $this->lstCategoryCustomFieldHelper->Enabled = false;
         } else {
             $this->lstCategoryCustomFieldHelper->Enabled = true;
         }
     }
     if ($this->lblCategoryCustomFieldHelper) {
         $this->lblCategoryCustomFieldHelper->Text = $this->objCategory->CategoryCustomFieldHelper ? $this->objCategory->CategoryCustomFieldHelper->__toString() : null;
     }
 }
Ejemplo n.º 2
0
 protected function lstCategoryCustomFieldHelper_Create()
 {
     $this->lstCategoryCustomFieldHelper = new QListBox($this);
     $this->lstCategoryCustomFieldHelper->Name = QApplication::Translate('Category Custom Field Helper');
     $this->lstCategoryCustomFieldHelper->AddItem(QApplication::Translate('- Select One -'), null);
     $objCategoryCustomFieldHelperArray = CategoryCustomFieldHelper::LoadAll();
     if ($objCategoryCustomFieldHelperArray) {
         foreach ($objCategoryCustomFieldHelperArray as $objCategoryCustomFieldHelper) {
             $objListItem = new QListItem($objCategoryCustomFieldHelper->__toString(), $objCategoryCustomFieldHelper->CategoryId);
             if ($objCategoryCustomFieldHelper->CategoryId == $this->objCategory->CategoryId) {
                 $objListItem->Selected = true;
             }
             $this->lstCategoryCustomFieldHelper->AddItem($objListItem);
         }
     }
     // Because CategoryCustomFieldHelper's CategoryCustomFieldHelper is not null, if a value is already selected, it cannot be changed.
     if ($this->lstCategoryCustomFieldHelper->SelectedValue) {
         $this->lstCategoryCustomFieldHelper->Enabled = false;
     }
 }