function Main()
 {
     switch ($this->formArray["formAction"]) {
         case "edit":
             $this->tpl->set_var("MessageBlock", "");
             $ImprovementsBuildingsClassesDetails = new SoapObject(NCCBIZ . "ImprovementsBuildingsClassesDetails.php", "urn:Object");
             if (!($xmlStr = $ImprovementsBuildingsClassesDetails->getImprovementsBuildingsClassesDetails($this->formArray["improvementsBuildingsClassesID"]))) {
                 $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                 $this->tpl->set_var("TableBlock", "record not found");
             } else {
                 if (!($domDoc = domxml_open_mem($xmlStr))) {
                     $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                     $this->tpl->set_var("TableBlock", "error xmlDoc");
                 } else {
                     $improvementsBuildingsClasses = new ImprovementsBuildingsClasses();
                     $improvementsBuildingsClasses->parseDomDocument($domDoc);
                     $this->formArray["improvementsBuildingsClassesID"] = $improvementsBuildingsClasses->getImprovementsBuildingsClassesID();
                     $this->formArray["code"] = $improvementsBuildingsClasses->getCode();
                     $this->formArray["description"] = $improvementsBuildingsClasses->getDescription();
                     $this->formArray["rangeLowerBound"] = $improvementsBuildingsClasses->getRangeLowerBound();
                     $this->formArray["rangeUpperBound"] = $improvementsBuildingsClasses->getRangeUpperBound();
                     $this->formArray["value"] = $improvementsBuildingsClasses->getValue();
                     $this->formArray["type"] = $improvementsBuildingsClasses->getType();
                     $this->formArray["status"] = $improvementsBuildingsClasses->getStatus();
                 }
             }
             break;
         case "save":
             if ($this->codeAlreadyExists() == true) {
                 $this->message = "Error. Cannot Save. Code already exists.";
                 $this->tpl->set_var("message", $this->message);
                 $this->tpl->parse("MessageBlock", "Message", true);
                 break;
             } else {
                 $this->tpl->set_var("MessageBlock", "");
             }
             $ImprovementsBuildingsClassesEncode = new SoapObject(NCCBIZ . "ImprovementsBuildingsClassesEncode.php", "urn:Object");
             if ($this->formArray["improvementsBuildingsClassesID"] != "") {
                 $ImprovementsBuildingsClassesDetails = new SoapObject(NCCBIZ . "ImprovementsBuildingsClassesDetails.php", "urn:Object");
                 if (!($xmlStr = $ImprovementsBuildingsClassesDetails->getImprovementsBuildingsClassesDetails($this->formArray["improvementsBuildingsClassesID"]))) {
                     exit("record not found");
                 } else {
                     if (!($domDoc = domxml_open_mem($xmlStr))) {
                         $this->tpl->set_block("rptsTemplate", "Table", "TableBlock");
                         $this->tpl->set_var("TableBlock", "error xmlDoc");
                     } else {
                         $improvementsBuildingsClasses = new ImprovementsBuildingsClasses();
                         $improvementsBuildingsClasses->parseDomDocument($domDoc);
                         $improvementsBuildingsClasses->setImprovementsBuildingsClassesID($this->formArray["improvementsBuildingsClassesID"]);
                         $improvementsBuildingsClasses->setCode($this->formArray["code"]);
                         $improvementsBuildingsClasses->setDescription($this->formArray["description"]);
                         $improvementsBuildingsClasses->setRangeLowerBound($this->formArray["rangeLowerBound"]);
                         $improvementsBuildingsClasses->setRangeUpperBound($this->formArray["rangeUpperBound"]);
                         $improvementsBuildingsClasses->setValue($this->formArray["value"]);
                         $improvementsBuildingsClasses->setType($this->formArray["type"]);
                         $improvementsBuildingsClasses->setStatus($this->formArray["status"]);
                         $improvementsBuildingsClasses->setDomDocument();
                         $doc = $improvementsBuildingsClasses->getDomDocument();
                         $xmlStr = $doc->dump_mem(true);
                         if (!($ret = $ImprovementsBuildingsClassesEncode->updateImprovementsBuildingsClasses($xmlStr))) {
                             exit("error update");
                         }
                     }
                 }
             } else {
                 $improvementsBuildingsClasses = new ImprovementsBuildingsClasses();
                 $improvementsBuildingsClasses->setImprovementsBuildingsClassesID($this->formArray["improvementsBuildingsClassesID"]);
                 $improvementsBuildingsClasses->setCode($this->formArray["code"]);
                 $improvementsBuildingsClasses->setDescription($this->formArray["description"]);
                 $improvementsBuildingsClasses->setRangeLowerBound($this->formArray["rangeLowerBound"]);
                 $improvementsBuildingsClasses->setRangeUpperBound($this->formArray["rangeUpperBound"]);
                 $improvementsBuildingsClasses->setValue($this->formArray["value"]);
                 $improvementsBuildingsClasses->setType($this->formArray["type"]);
                 $improvementsBuildingsClasses->setStatus($this->formArray["status"]);
                 $improvementsBuildingsClasses->setDomDocument();
                 $doc = $improvementsBuildingsClasses->getDomDocument();
                 $xmlStr = $doc->dump_mem(true);
                 if (!($ret = $ImprovementsBuildingsClassesEncode->saveImprovementsBuildingsClasses($xmlStr))) {
                     exit("error save");
                 }
             }
             $this->formArray["improvementsBuildingsClassesID"] = $ret;
             header("location: ImprovementsBuildingsClassesClose.php" . $this->sess->url("") . $this->sess->add_query(array("improvementsBuildingsClassesID" => $ret)));
             //header("location: ImprovementsBuildingsClassesEncode.php");
             exit;
             break;
         case "cancel":
             header("location: ImprovementsBuildingsClassesClose.php" . $this->sess->url("") . $this->sess->add_query(array("improvementsBuildingsClassesID" => $ret)));
             //header("location: ImprovementsBuildingsClassesList.php");
             exit;
             break;
         default:
             $this->tpl->set_block("rptsTemplate", "ImprovementsBuildingsClassesID", "ImprovementsBuildingsClassesIDBlock");
             $this->tpl->set_var("ImprovementsBuildingsClassesIDBlock", "");
             $this->tpl->set_block("rptsTemplate", "ACK", "ACKBlock");
             $this->tpl->set_var("ACKBlock", "");
             $this->tpl->set_var("MessageBlock", "");
     }
     $this->setForm();
     $this->tpl->parse("templatePage", "rptsTemplate");
     $this->tpl->finish("templatePage");
     $this->tpl->p("templatePage");
 }