protected function btnSave_Click() { $blnError = false; // Do not allow duplicate depreciation class names if ($this->blnEditMode) { $objDepreciationClassDuplicate = DepreciationClass::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::DepreciationClass()->ShortDescription, $this->txtShortDescription->Text), QQ::NotEqual(QQN::DepreciationClass()->DepreciationClassId, $this->objDepreciationClass->DepreciationClassId))); } else { $objDepreciationClassDuplicate = DepreciationClass::QuerySingle(QQ::Equal(QQN::DepreciationClass()->ShortDescription, $this->txtShortDescription->Text)); } if ($objDepreciationClassDuplicate) { $blnError = true; $this->txtShortDescription->Warning = 'This Depreciation Class Name is already in use. Please try another.'; $this->txtShortDescription->Focus(); } // Enforce positive integer for Life if (!preg_match("/^\\d+\$/", $this->txtLife->Text)) { $this->btnCancel->Warning = 'Life must be a positive whole number'; $blnError = true; } if (!$blnError) { $this->UpdateDepreciationClassFields(); $this->objDepreciationClass->Save(); QApplication::Redirect('depreciation.php'); } }
/** * Load a single DepreciationClass object, * by ShortDescription Index(es) * @param string $strShortDescription * @return DepreciationClass */ public static function LoadByShortDescription($strShortDescription, $objOptionalClauses = null) { return DepreciationClass::QuerySingle(QQ::Equal(QQN::DepreciationClass()->ShortDescription, $strShortDescription), $objOptionalClauses); }