function Main()
 {
     switch ($this->formArray["formAction"]) {
         case "edit":
             $this->tpl->set_var("MessageBlock", "");
             $PlantsTreesActualUsesDetails = new SoapObject(NCCBIZ . "PlantsTreesActualUsesDetails.php", "urn:Object");
             if (!($xmlStr = $PlantsTreesActualUsesDetails->getPlantsTreesActualUsesDetails($this->formArray["plantsTreesActualUsesID"]))) {
                 $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 {
                     $plantsTreesActualUses = new PlantsTreesActualUses();
                     $plantsTreesActualUses->parseDomDocument($domDoc);
                     $this->formArray["plantsTreesActualUsesID"] = $plantsTreesActualUses->getPlantsTreesActualUsesID();
                     $this->formArray["code"] = $plantsTreesActualUses->getCode();
                     $this->formArray["reportCode"] = $plantsTreesActualUses->getReportCode();
                     $this->formArray["description"] = $plantsTreesActualUses->getDescription();
                     $this->formArray["value"] = $plantsTreesActualUses->getValue();
                     $this->formArray["status"] = $plantsTreesActualUses->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", "");
             }
             $PlantsTreesActualUsesEncode = new SoapObject(NCCBIZ . "PlantsTreesActualUsesEncode.php", "urn:Object");
             if ($this->formArray["plantsTreesActualUsesID"] != "") {
                 $PlantsTreesActualUsesDetails = new SoapObject(NCCBIZ . "PlantsTreesActualUsesDetails.php", "urn:Object");
                 if (!($xmlStr = $PlantsTreesActualUsesDetails->getPlantsTreesActualUsesDetails($this->formArray["plantsTreesActualUsesID"]))) {
                     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 {
                         $plantsTreesActualUses = new PlantsTreesActualUses();
                         $plantsTreesActualUses->parseDomDocument($domDoc);
                         $plantsTreesActualUses->setPlantsTreesActualUsesID($this->formArray["plantsTreesActualUsesID"]);
                         $plantsTreesActualUses->setCode($this->formArray["code"]);
                         $plantsTreesActualUses->setReportCode($this->formArray["reportCode"]);
                         $plantsTreesActualUses->setDescription($this->formArray["description"]);
                         $plantsTreesActualUses->setValue($this->formArray["value"]);
                         $plantsTreesActualUses->setStatus($this->formArray["status"]);
                         $plantsTreesActualUses->setDomDocument();
                         $doc = $plantsTreesActualUses->getDomDocument();
                         $xmlStr = $doc->dump_mem(true);
                         if (!($ret = $PlantsTreesActualUsesEncode->updatePlantsTreesActualUses($xmlStr))) {
                             exit("error update");
                         }
                     }
                 }
             } else {
                 $plantsTreesActualUses = new PlantsTreesActualUses();
                 $plantsTreesActualUses->setPlantsTreesActualUsesID($this->formArray["plantsTreesActualUsesID"]);
                 $plantsTreesActualUses->setCode($this->formArray["code"]);
                 $plantsTreesActualUses->setReportCode($this->formArray["reportCode"]);
                 $plantsTreesActualUses->setDescription($this->formArray["description"]);
                 $plantsTreesActualUses->setValue($this->formArray["value"]);
                 $plantsTreesActualUses->setStatus($this->formArray["status"]);
                 $plantsTreesActualUses->setDomDocument();
                 $doc = $plantsTreesActualUses->getDomDocument();
                 $xmlStr = $doc->dump_mem(true);
                 if (!($ret = $PlantsTreesActualUsesEncode->savePlantsTreesActualUses($xmlStr))) {
                     exit("error save");
                 }
             }
             $this->formArray["plantsTreesActualUsesID"] = $ret;
             header("location: PlantsTreesActualUsesClose.php" . $this->sess->url("") . $this->sess->add_query(array("plantsTreesActualUsesID" => $ret)));
             //header("location: PlantsTreesActualUsesEncode.php");
             exit;
             break;
         case "cancel":
             header("location: PlantsTreesActualUsesClose.php" . $this->sess->url("") . $this->sess->add_query(array("plantsTreesActualUsesID" => $ret)));
             //header("location: PlantsTreesActualUsesList.php");
             exit;
             break;
         default:
             $this->tpl->set_block("rptsTemplate", "PlantsTreesActualUsesID", "PlantsTreesActualUsesIDBlock");
             $this->tpl->set_var("PlantsTreesActualUsesIDBlock", "");
             $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");
 }