function Main()
 {
     switch ($this->formArray["formAction"]) {
         case "edit":
             $this->tpl->set_var("MessageBlock", "");
             $ImprovementsBuildingsActualUsesDetails = new SoapObject(NCCBIZ . "ImprovementsBuildingsActualUsesDetails.php", "urn:Object");
             if (!($xmlStr = $ImprovementsBuildingsActualUsesDetails->getImprovementsBuildingsActualUsesDetails($this->formArray["improvementsBuildingsActualUsesID"]))) {
                 $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 {
                     $improvementsBuildingsActualUses = new ImprovementsBuildingsActualUses();
                     $improvementsBuildingsActualUses->parseDomDocument($domDoc);
                     $this->formArray["improvementsBuildingsActualUsesID"] = $improvementsBuildingsActualUses->getImprovementsBuildingsActualUsesID();
                     $this->formArray["code"] = $improvementsBuildingsActualUses->getCode();
                     $this->formArray["reportCode"] = $improvementsBuildingsActualUses->getReportCode();
                     $this->formArray["description"] = $improvementsBuildingsActualUses->getDescription();
                     $this->formArray["rangeLowerBound"] = $improvementsBuildingsActualUses->getRangeLowerBound();
                     $this->formArray["rangeUpperBound"] = $improvementsBuildingsActualUses->getRangeUpperBound();
                     $this->formArray["value"] = $improvementsBuildingsActualUses->getValue();
                     $this->formArray["status"] = $improvementsBuildingsActualUses->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", "");
             }
             $ImprovementsBuildingsActualUsesEncode = new SoapObject(NCCBIZ . "ImprovementsBuildingsActualUsesEncode.php", "urn:Object");
             if ($this->formArray["improvementsBuildingsActualUsesID"] != "") {
                 $ImprovementsBuildingsActualUsesDetails = new SoapObject(NCCBIZ . "ImprovementsBuildingsActualUsesDetails.php", "urn:Object");
                 if (!($xmlStr = $ImprovementsBuildingsActualUsesDetails->getImprovementsBuildingsActualUsesDetails($this->formArray["improvementsBuildingsActualUsesID"]))) {
                     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 {
                         $improvementsBuildingsActualUses = new ImprovementsBuildingsActualUses();
                         $improvementsBuildingsActualUses->parseDomDocument($domDoc);
                         $improvementsBuildingsActualUses->setImprovementsBuildingsActualUsesID($this->formArray["improvementsBuildingsActualUsesID"]);
                         $improvementsBuildingsActualUses->setCode($this->formArray["code"]);
                         $improvementsBuildingsActualUses->setReportCode($this->formArray["reportCode"]);
                         $improvementsBuildingsActualUses->setDescription($this->formArray["description"]);
                         $improvementsBuildingsActualUses->setRangeLowerBound($this->formArray["rangeLowerBound"]);
                         $improvementsBuildingsActualUses->setRangeUpperBound($this->formArray["rangeUpperBound"]);
                         $improvementsBuildingsActualUses->setValue($this->formArray["value"]);
                         $improvementsBuildingsActualUses->setStatus($this->formArray["status"]);
                         $improvementsBuildingsActualUses->setDomDocument();
                         $doc = $improvementsBuildingsActualUses->getDomDocument();
                         $xmlStr = $doc->dump_mem(true);
                         if (!($ret = $ImprovementsBuildingsActualUsesEncode->updateImprovementsBuildingsActualUses($xmlStr))) {
                             exit("error update");
                         }
                     }
                 }
             } else {
                 $improvementsBuildingsActualUses = new ImprovementsBuildingsActualUses();
                 $improvementsBuildingsActualUses->setImprovementsBuildingsActualUsesID($this->formArray["improvementsBuildingsActualUsesID"]);
                 $improvementsBuildingsActualUses->setCode($this->formArray["code"]);
                 $improvementsBuildingsActualUses->setReportCode($this->formArray["reportCode"]);
                 $improvementsBuildingsActualUses->setDescription($this->formArray["description"]);
                 $improvementsBuildingsActualUses->setRangeLowerBound($this->formArray["rangeLowerBound"]);
                 $improvementsBuildingsActualUses->setRangeUpperBound($this->formArray["rangeUpperBound"]);
                 $improvementsBuildingsActualUses->setValue($this->formArray["value"]);
                 $improvementsBuildingsActualUses->setStatus($this->formArray["status"]);
                 $improvementsBuildingsActualUses->setDomDocument();
                 $doc = $improvementsBuildingsActualUses->getDomDocument();
                 $xmlStr = $doc->dump_mem(true);
                 if (!($ret = $ImprovementsBuildingsActualUsesEncode->saveImprovementsBuildingsActualUses($xmlStr))) {
                     exit("error save");
                 }
             }
             $this->formArray["improvementsBuildingsActualUsesID"] = $ret;
             header("location: ImprovementsBuildingsActualUsesClose.php" . $this->sess->url("") . $this->sess->add_query(array("improvementsBuildingsActualUsesID" => $ret)));
             //header("location: ImprovementsBuildingsActualUsesEncode.php");
             exit;
             break;
         case "cancel":
             header("location: ImprovementsBuildingsActualUsesClose.php" . $this->sess->url("") . $this->sess->add_query(array("improvementsBuildingsActualUsesID" => $ret)));
             //header("location: ImprovementsBuildingsActualUsesList.php");
             exit;
             break;
         default:
             $this->tpl->set_block("rptsTemplate", "ImprovementsBuildingsActualUsesID", "ImprovementsBuildingsActualUsesIDBlock");
             $this->tpl->set_var("ImprovementsBuildingsActualUsesIDBlock", "");
             $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");
 }