Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/cceadmin/
Upload File :
Current File : /var/www/cesa.co.za/cceadmin/CCEExamSectionsedit.php

<?php
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg7.php" ?>
<?php include "ewmysql7.php" ?>
<?php include "phpfn7.php" ?>
<?php include "CCEExamSectionsinfo.php" ?>
<?php include "CCEUsersinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Create page object
$CCEExamSections_edit = new cCCEExamSections_edit();
$Page =& $CCEExamSections_edit;

// Page init
$CCEExamSections_edit->Page_Init();

// Page main
$CCEExamSections_edit->Page_Main();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--

// Create page object
var CCEExamSections_edit = new ew_Page("CCEExamSections_edit");

// page properties
CCEExamSections_edit.PageID = "edit"; // page ID
CCEExamSections_edit.FormID = "fCCEExamSectionsedit"; // form ID
var EW_PAGE_ID = CCEExamSections_edit.PageID; // for backward compatibility

// extend page with ValidateForm function
CCEExamSections_edit.ValidateForm = function(fobj) {
	ew_PostAutoSuggest(fobj);
	if (!this.ValidateRequired)
		return true; // ignore validation
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_Display_Order"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEExamSections->Display_Order->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_NumToSelect"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEExamSections->NumToSelect->FldErrMsg()) ?>");

		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj)) return false;
	}
	return true;
}

// extend page with Form_CustomValidate function
CCEExamSections_edit.Form_CustomValidate =  
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
<?php if (EW_CLIENT_VALIDATE) { ?>
CCEExamSections_edit.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CCEExamSections_edit.ValidateRequired = false; // no JavaScript validation
<?php } ?>

//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<p><span class="phpmaker"><?php echo $Language->Phrase("Edit") ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $CCEExamSections->TableCaption() ?><br><br>
<a href="<?php echo $CCEExamSections->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$CCEExamSections_edit->ShowMessage();
?>
<form name="fCCEExamSectionsedit" id="fCCEExamSectionsedit" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return CCEExamSections_edit.ValidateForm(this);">
<p>
<input type="hidden" name="a_table" id="a_table" value="CCEExamSections">
<input type="hidden" name="a_edit" id="a_edit" value="U">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($CCEExamSections->Section_ID->Visible) { // Section_ID ?>
	<tr<?php echo $CCEExamSections->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamSections->Section_ID->FldCaption() ?></td>
		<td<?php echo $CCEExamSections->Section_ID->CellAttributes() ?>><span id="el_Section_ID">
<div<?php echo $CCEExamSections->Section_ID->ViewAttributes() ?>><?php echo $CCEExamSections->Section_ID->EditValue ?></div><input type="hidden" name="x_Section_ID" id="x_Section_ID" value="<?php echo ew_HtmlEncode($CCEExamSections->Section_ID->CurrentValue) ?>">
</span><?php echo $CCEExamSections->Section_ID->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEExamSections->Questionnaire_ID->Visible) { // Questionnaire_ID ?>
	<tr<?php echo $CCEExamSections->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamSections->Questionnaire_ID->FldCaption() ?></td>
		<td<?php echo $CCEExamSections->Questionnaire_ID->CellAttributes() ?>><span id="el_Questionnaire_ID">
<select id="x_Questionnaire_ID" name="x_Questionnaire_ID" title="<?php echo $CCEExamSections->Questionnaire_ID->FldTitle() ?>"<?php echo $CCEExamSections->Questionnaire_ID->EditAttributes() ?>>
<?php
if (is_array($CCEExamSections->Questionnaire_ID->EditValue)) {
	$arwrk = $CCEExamSections->Questionnaire_ID->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($CCEExamSections->Questionnaire_ID->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
</option>
<?php
	}
}
?>
</select>
</span><?php echo $CCEExamSections->Questionnaire_ID->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEExamSections->Section_Name->Visible) { // Section_Name ?>
	<tr<?php echo $CCEExamSections->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamSections->Section_Name->FldCaption() ?></td>
		<td<?php echo $CCEExamSections->Section_Name->CellAttributes() ?>><span id="el_Section_Name">
<input type="text" name="x_Section_Name" id="x_Section_Name" title="<?php echo $CCEExamSections->Section_Name->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCEExamSections->Section_Name->EditValue ?>"<?php echo $CCEExamSections->Section_Name->EditAttributes() ?>>
</span><?php echo $CCEExamSections->Section_Name->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEExamSections->Section_Text->Visible) { // Section_Text ?>
	<tr<?php echo $CCEExamSections->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamSections->Section_Text->FldCaption() ?></td>
		<td<?php echo $CCEExamSections->Section_Text->CellAttributes() ?>><span id="el_Section_Text">
<textarea name="x_Section_Text" id="x_Section_Text" title="<?php echo $CCEExamSections->Section_Text->FldTitle() ?>" cols="35" rows="4"<?php echo $CCEExamSections->Section_Text->EditAttributes() ?>><?php echo $CCEExamSections->Section_Text->EditValue ?></textarea>
</span><?php echo $CCEExamSections->Section_Text->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEExamSections->Display_Order->Visible) { // Display_Order ?>
	<tr<?php echo $CCEExamSections->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamSections->Display_Order->FldCaption() ?></td>
		<td<?php echo $CCEExamSections->Display_Order->CellAttributes() ?>><span id="el_Display_Order">
<input type="text" name="x_Display_Order" id="x_Display_Order" title="<?php echo $CCEExamSections->Display_Order->FldTitle() ?>" size="30" value="<?php echo $CCEExamSections->Display_Order->EditValue ?>"<?php echo $CCEExamSections->Display_Order->EditAttributes() ?>>
</span><?php echo $CCEExamSections->Display_Order->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEExamSections->SelectRandom->Visible) { // SelectRandom ?>
	<tr<?php echo $CCEExamSections->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamSections->SelectRandom->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $CCEExamSections->SelectRandom->CellAttributes() ?>><span id="el_SelectRandom">
<div id="tp_x_SelectRandom" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME ?>"><label><input type="radio" name="x_SelectRandom" id="x_SelectRandom" title="<?php echo $CCEExamSections->SelectRandom->FldTitle() ?>" value="{value}"<?php echo $CCEExamSections->SelectRandom->EditAttributes() ?>></label></div>
<div id="dsl_x_SelectRandom" repeatcolumn="5">
<?php
$arwrk = $CCEExamSections->SelectRandom->EditValue;
if (is_array($arwrk)) {
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($CCEExamSections->SelectRandom->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " checked=\"checked\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;

		// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label><input type="radio" name="x_SelectRandom" id="x_SelectRandom" title="<?php echo $CCEExamSections->SelectRandom->FldTitle() ?>" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $CCEExamSections->SelectRandom->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
?>
</div>
</span><?php echo $CCEExamSections->SelectRandom->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEExamSections->NumToSelect->Visible) { // NumToSelect ?>
	<tr<?php echo $CCEExamSections->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamSections->NumToSelect->FldCaption() ?></td>
		<td<?php echo $CCEExamSections->NumToSelect->CellAttributes() ?>><span id="el_NumToSelect">
<input type="text" name="x_NumToSelect" id="x_NumToSelect" title="<?php echo $CCEExamSections->NumToSelect->FldTitle() ?>" size="30" value="<?php echo $CCEExamSections->NumToSelect->EditValue ?>"<?php echo $CCEExamSections->NumToSelect->EditAttributes() ?>>
</span><?php echo $CCEExamSections->NumToSelect->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEExamSections->ShowHeading->Visible) { // ShowHeading ?>
	<tr<?php echo $CCEExamSections->RowAttributes() ?>>
		<td class="ewTableHeader"><?php echo $CCEExamSections->ShowHeading->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $CCEExamSections->ShowHeading->CellAttributes() ?>><span id="el_ShowHeading">
<div id="tp_x_ShowHeading" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME ?>"><label><input type="radio" name="x_ShowHeading" id="x_ShowHeading" title="<?php echo $CCEExamSections->ShowHeading->FldTitle() ?>" value="{value}"<?php echo $CCEExamSections->ShowHeading->EditAttributes() ?>></label></div>
<div id="dsl_x_ShowHeading" repeatcolumn="5">
<?php
$arwrk = $CCEExamSections->ShowHeading->EditValue;
if (is_array($arwrk)) {
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($CCEExamSections->ShowHeading->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " checked=\"checked\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;

		// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label><input type="radio" name="x_ShowHeading" id="x_ShowHeading" title="<?php echo $CCEExamSections->ShowHeading->FldTitle() ?>" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $CCEExamSections->ShowHeading->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
	}
}
?>
</div>
</span><?php echo $CCEExamSections->ShowHeading->CustomMsg ?></td>
	</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="<?php echo ew_BtnCaption($Language->Phrase("EditBtn")) ?>">
</form>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php include "footer.php" ?>
<?php
$CCEExamSections_edit->Page_Terminate();
?>
<?php

//
// Page class
//
class cCCEExamSections_edit {

	// Page ID
	var $PageID = 'edit';

	// Table name
	var $TableName = 'CCEExamSections';

	// Page object name
	var $PageObjName = 'CCEExamSections_edit';

	// Page name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $CCEExamSections;
		if ($CCEExamSections->UseTokenInUrl) $PageUrl .= "t=" . $CCEExamSections->TableVar . "&"; // Add page token
		return $PageUrl;
	}

	// Page URLs
	var $AddUrl;
	var $EditUrl;
	var $CopyUrl;
	var $DeleteUrl;
	var $ViewUrl;
	var $ListUrl;

	// Export URLs
	var $ExportPrintUrl;
	var $ExportHtmlUrl;
	var $ExportExcelUrl;
	var $ExportWordUrl;
	var $ExportXmlUrl;
	var $ExportCsvUrl;

	// Update URLs
	var $InlineAddUrl;
	var $InlineCopyUrl;
	var $InlineEditUrl;
	var $GridAddUrl;
	var $GridEditUrl;
	var $MultiDeleteUrl;
	var $MultiUpdateUrl;

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
			$_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
		} else {
			$_SESSION[EW_SESSION_MESSAGE] = $v;
		}
	}

	// Show message
	function ShowMessage() {
		$sMessage = $this->getMessage();
		$this->Message_Showing($sMessage);
		if ($sMessage <> "") { // Message in Session, display
			echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}
	}

	// Validate page request
	function IsPageRequest() {
		global $objForm, $CCEExamSections;
		if ($CCEExamSections->UseTokenInUrl) {
			if ($objForm)
				return ($CCEExamSections->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($CCEExamSections->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

	//
	// Page class constructor
	//
	function __construct() {
		global $conn, $Language;

		// Language object
		$Language = new cLanguage();

		// Table object (CCEExamSections)
		$GLOBALS["CCEExamSections"] = new cCCEExamSections();

		// Table object (CCEUsers)
		$GLOBALS['CCEUsers'] = new cCCEUsers();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'edit', TRUE);

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'CCEExamSections', TRUE);

		// Start timer
		$GLOBALS["gsTimer"] = new cTimer();

		// Open connection
		$conn = ew_Connect();
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
		global $CCEExamSections;

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		$Security->TablePermission_Loading();
		$Security->LoadCurrentUserLevel($this->TableName);
		$Security->TablePermission_Loaded();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
		if (!$Security->CanEdit()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("CCEExamSectionslist.php");
		}

		// Create form object
		$objForm = new cFormObj();

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();
	}

	//
	// Page_Terminate
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();

		 // Close connection
		$conn->Close();

		// Go to URL if specified
		$this->Page_Redirecting($url);
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();
			header("Location: " . $url);
		}
		exit();
	}
	var $sDbMasterFilter;
	var $sDbDetailFilter;

	// 
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsFormError, $CCEExamSections;

		// Load key from QueryString
		if (@$_GET["Section_ID"] <> "")
			$CCEExamSections->Section_ID->setQueryStringValue($_GET["Section_ID"]);
		if (@$_POST["a_edit"] <> "") {
			$CCEExamSections->CurrentAction = $_POST["a_edit"]; // Get action code
			$this->LoadFormValues(); // Get form values

			// Validate form
			if (!$this->ValidateForm()) {
				$CCEExamSections->CurrentAction = ""; // Form error, reset action
				$this->setMessage($gsFormError);
				$CCEExamSections->EventCancelled = TRUE; // Event cancelled
				$this->RestoreFormValues();
			}
		} else {
			$CCEExamSections->CurrentAction = "I"; // Default action is display
		}

		// Check if valid key
		if ($CCEExamSections->Section_ID->CurrentValue == "")
			$this->Page_Terminate("CCEExamSectionslist.php"); // Invalid key, return to list
		switch ($CCEExamSections->CurrentAction) {
			case "I": // Get a record to display
				if (!$this->LoadRow()) { // Load record based on key
					$this->setMessage($Language->Phrase("NoRecord")); // No record found
					$this->Page_Terminate("CCEExamSectionslist.php"); // No matching record, return to list
				}
				break;
			Case "U": // Update
				$CCEExamSections->SendEmail = TRUE; // Send email on update success
				if ($this->EditRow()) { // Update record based on key
					$this->setMessage($Language->Phrase("UpdateSuccess")); // Update success
					$sReturnUrl = $CCEExamSections->getReturnUrl();
					if (ew_GetPageName($sReturnUrl) == "CCEExamSectionsview.php")
						$sReturnUrl = $CCEExamSections->ViewUrl(); // View paging, return to View page directly
					$this->Page_Terminate($sReturnUrl); // Return to caller
				} else {
					$CCEExamSections->EventCancelled = TRUE; // Event cancelled
					$this->RestoreFormValues(); // Restore form values if update failed
				}
		}

		// Render the record
		$CCEExamSections->RowType = EW_ROWTYPE_EDIT; // Render as Edit
		$this->RenderRow();
	}

	// Get upload files
	function GetUploadFiles() {
		global $objForm, $CCEExamSections;

		// Get upload data
	}

	// Load form values
	function LoadFormValues() {

		// Load from form
		global $objForm, $CCEExamSections;
		$CCEExamSections->Section_ID->setFormValue($objForm->GetValue("x_Section_ID"));
		$CCEExamSections->Questionnaire_ID->setFormValue($objForm->GetValue("x_Questionnaire_ID"));
		$CCEExamSections->Section_Name->setFormValue($objForm->GetValue("x_Section_Name"));
		$CCEExamSections->Section_Text->setFormValue($objForm->GetValue("x_Section_Text"));
		$CCEExamSections->Display_Order->setFormValue($objForm->GetValue("x_Display_Order"));
		$CCEExamSections->SelectRandom->setFormValue($objForm->GetValue("x_SelectRandom"));
		$CCEExamSections->NumToSelect->setFormValue($objForm->GetValue("x_NumToSelect"));
		$CCEExamSections->ShowHeading->setFormValue($objForm->GetValue("x_ShowHeading"));
	}

	// Restore form values
	function RestoreFormValues() {
		global $objForm, $CCEExamSections;
		$this->LoadRow();
		$CCEExamSections->Section_ID->CurrentValue = $CCEExamSections->Section_ID->FormValue;
		$CCEExamSections->Questionnaire_ID->CurrentValue = $CCEExamSections->Questionnaire_ID->FormValue;
		$CCEExamSections->Section_Name->CurrentValue = $CCEExamSections->Section_Name->FormValue;
		$CCEExamSections->Section_Text->CurrentValue = $CCEExamSections->Section_Text->FormValue;
		$CCEExamSections->Display_Order->CurrentValue = $CCEExamSections->Display_Order->FormValue;
		$CCEExamSections->SelectRandom->CurrentValue = $CCEExamSections->SelectRandom->FormValue;
		$CCEExamSections->NumToSelect->CurrentValue = $CCEExamSections->NumToSelect->FormValue;
		$CCEExamSections->ShowHeading->CurrentValue = $CCEExamSections->ShowHeading->FormValue;
	}

	// Load row based on key values
	function LoadRow() {
		global $conn, $Security, $CCEExamSections;
		$sFilter = $CCEExamSections->KeyFilter();

		// Call Row Selecting event
		$CCEExamSections->Row_Selecting($sFilter);

		// Load SQL based on filter
		$CCEExamSections->CurrentFilter = $sFilter;
		$sSql = $CCEExamSections->SQL();
		$res = FALSE;
		$rs = ew_LoadRecordset($sSql);
		if ($rs && !$rs->EOF) {
			$res = TRUE;
			$this->LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$CCEExamSections->Row_Selected($rs);
			$rs->Close();
		}
		return $res;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $CCEExamSections;
		$CCEExamSections->Section_ID->setDbValue($rs->fields('Section_ID'));
		$CCEExamSections->Questionnaire_ID->setDbValue($rs->fields('Questionnaire_ID'));
		$CCEExamSections->Section_Name->setDbValue($rs->fields('Section_Name'));
		$CCEExamSections->Section_Text->setDbValue($rs->fields('Section_Text'));
		$CCEExamSections->Display_Order->setDbValue($rs->fields('Display_Order'));
		$CCEExamSections->SelectRandom->setDbValue($rs->fields('SelectRandom'));
		$CCEExamSections->NumToSelect->setDbValue($rs->fields('NumToSelect'));
		$CCEExamSections->ShowHeading->setDbValue($rs->fields('ShowHeading'));
	}

	// Render row values based on field settings
	function RenderRow() {
		global $conn, $Security, $Language, $CCEExamSections;

		// Initialize URLs
		// Call Row_Rendering event

		$CCEExamSections->Row_Rendering();

		// Common render codes for all row types
		// Section_ID

		$CCEExamSections->Section_ID->CellCssStyle = ""; $CCEExamSections->Section_ID->CellCssClass = "";
		$CCEExamSections->Section_ID->CellAttrs = array(); $CCEExamSections->Section_ID->ViewAttrs = array(); $CCEExamSections->Section_ID->EditAttrs = array();

		// Questionnaire_ID
		$CCEExamSections->Questionnaire_ID->CellCssStyle = ""; $CCEExamSections->Questionnaire_ID->CellCssClass = "";
		$CCEExamSections->Questionnaire_ID->CellAttrs = array(); $CCEExamSections->Questionnaire_ID->ViewAttrs = array(); $CCEExamSections->Questionnaire_ID->EditAttrs = array();

		// Section_Name
		$CCEExamSections->Section_Name->CellCssStyle = ""; $CCEExamSections->Section_Name->CellCssClass = "";
		$CCEExamSections->Section_Name->CellAttrs = array(); $CCEExamSections->Section_Name->ViewAttrs = array(); $CCEExamSections->Section_Name->EditAttrs = array();

		// Section_Text
		$CCEExamSections->Section_Text->CellCssStyle = ""; $CCEExamSections->Section_Text->CellCssClass = "";
		$CCEExamSections->Section_Text->CellAttrs = array(); $CCEExamSections->Section_Text->ViewAttrs = array(); $CCEExamSections->Section_Text->EditAttrs = array();

		// Display_Order
		$CCEExamSections->Display_Order->CellCssStyle = ""; $CCEExamSections->Display_Order->CellCssClass = "";
		$CCEExamSections->Display_Order->CellAttrs = array(); $CCEExamSections->Display_Order->ViewAttrs = array(); $CCEExamSections->Display_Order->EditAttrs = array();

		// SelectRandom
		$CCEExamSections->SelectRandom->CellCssStyle = ""; $CCEExamSections->SelectRandom->CellCssClass = "";
		$CCEExamSections->SelectRandom->CellAttrs = array(); $CCEExamSections->SelectRandom->ViewAttrs = array(); $CCEExamSections->SelectRandom->EditAttrs = array();

		// NumToSelect
		$CCEExamSections->NumToSelect->CellCssStyle = ""; $CCEExamSections->NumToSelect->CellCssClass = "";
		$CCEExamSections->NumToSelect->CellAttrs = array(); $CCEExamSections->NumToSelect->ViewAttrs = array(); $CCEExamSections->NumToSelect->EditAttrs = array();

		// ShowHeading
		$CCEExamSections->ShowHeading->CellCssStyle = ""; $CCEExamSections->ShowHeading->CellCssClass = "";
		$CCEExamSections->ShowHeading->CellAttrs = array(); $CCEExamSections->ShowHeading->ViewAttrs = array(); $CCEExamSections->ShowHeading->EditAttrs = array();
		if ($CCEExamSections->RowType == EW_ROWTYPE_VIEW) { // View row

			// Section_ID
			$CCEExamSections->Section_ID->ViewValue = $CCEExamSections->Section_ID->CurrentValue;
			$CCEExamSections->Section_ID->CssStyle = "";
			$CCEExamSections->Section_ID->CssClass = "";
			$CCEExamSections->Section_ID->ViewCustomAttributes = "";

			// Questionnaire_ID
			if (strval($CCEExamSections->Questionnaire_ID->CurrentValue) <> "") {
				$sFilterWrk = "`Questionnaire_ID` = " . ew_AdjustSql($CCEExamSections->Questionnaire_ID->CurrentValue) . "";
			$sSqlWrk = "SELECT `Questionnaire_Name` FROM `CCEExams`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `Questionnaire_Name` Asc";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$CCEExamSections->Questionnaire_ID->ViewValue = $rswrk->fields('Questionnaire_Name');
					$rswrk->Close();
				} else {
					$CCEExamSections->Questionnaire_ID->ViewValue = $CCEExamSections->Questionnaire_ID->CurrentValue;
				}
			} else {
				$CCEExamSections->Questionnaire_ID->ViewValue = NULL;
			}
			$CCEExamSections->Questionnaire_ID->CssStyle = "";
			$CCEExamSections->Questionnaire_ID->CssClass = "";
			$CCEExamSections->Questionnaire_ID->ViewCustomAttributes = "";

			// Section_Name
			$CCEExamSections->Section_Name->ViewValue = $CCEExamSections->Section_Name->CurrentValue;
			$CCEExamSections->Section_Name->CssStyle = "";
			$CCEExamSections->Section_Name->CssClass = "";
			$CCEExamSections->Section_Name->ViewCustomAttributes = "";

			// Section_Text
			$CCEExamSections->Section_Text->ViewValue = $CCEExamSections->Section_Text->CurrentValue;
			$CCEExamSections->Section_Text->CssStyle = "";
			$CCEExamSections->Section_Text->CssClass = "";
			$CCEExamSections->Section_Text->ViewCustomAttributes = "";

			// Display_Order
			$CCEExamSections->Display_Order->ViewValue = $CCEExamSections->Display_Order->CurrentValue;
			$CCEExamSections->Display_Order->CssStyle = "";
			$CCEExamSections->Display_Order->CssClass = "";
			$CCEExamSections->Display_Order->ViewCustomAttributes = "";

			// SelectRandom
			if (strval($CCEExamSections->SelectRandom->CurrentValue) <> "") {
				switch ($CCEExamSections->SelectRandom->CurrentValue) {
					case "1":
						$CCEExamSections->SelectRandom->ViewValue = "Yes";
						break;
					case "0":
						$CCEExamSections->SelectRandom->ViewValue = "No";
						break;
					default:
						$CCEExamSections->SelectRandom->ViewValue = $CCEExamSections->SelectRandom->CurrentValue;
				}
			} else {
				$CCEExamSections->SelectRandom->ViewValue = NULL;
			}
			$CCEExamSections->SelectRandom->CssStyle = "";
			$CCEExamSections->SelectRandom->CssClass = "";
			$CCEExamSections->SelectRandom->ViewCustomAttributes = "";

			// NumToSelect
			$CCEExamSections->NumToSelect->ViewValue = $CCEExamSections->NumToSelect->CurrentValue;
			$CCEExamSections->NumToSelect->CssStyle = "";
			$CCEExamSections->NumToSelect->CssClass = "";
			$CCEExamSections->NumToSelect->ViewCustomAttributes = "";

			// ShowHeading
			if (strval($CCEExamSections->ShowHeading->CurrentValue) <> "") {
				switch ($CCEExamSections->ShowHeading->CurrentValue) {
					case "1":
						$CCEExamSections->ShowHeading->ViewValue = "Yes";
						break;
					case "0":
						$CCEExamSections->ShowHeading->ViewValue = "No";
						break;
					default:
						$CCEExamSections->ShowHeading->ViewValue = $CCEExamSections->ShowHeading->CurrentValue;
				}
			} else {
				$CCEExamSections->ShowHeading->ViewValue = NULL;
			}
			$CCEExamSections->ShowHeading->CssStyle = "";
			$CCEExamSections->ShowHeading->CssClass = "";
			$CCEExamSections->ShowHeading->ViewCustomAttributes = "";

			// Section_ID
			$CCEExamSections->Section_ID->HrefValue = "";
			$CCEExamSections->Section_ID->TooltipValue = "";

			// Questionnaire_ID
			$CCEExamSections->Questionnaire_ID->HrefValue = "";
			$CCEExamSections->Questionnaire_ID->TooltipValue = "";

			// Section_Name
			$CCEExamSections->Section_Name->HrefValue = "";
			$CCEExamSections->Section_Name->TooltipValue = "";

			// Section_Text
			$CCEExamSections->Section_Text->HrefValue = "";
			$CCEExamSections->Section_Text->TooltipValue = "";

			// Display_Order
			$CCEExamSections->Display_Order->HrefValue = "";
			$CCEExamSections->Display_Order->TooltipValue = "";

			// SelectRandom
			$CCEExamSections->SelectRandom->HrefValue = "";
			$CCEExamSections->SelectRandom->TooltipValue = "";

			// NumToSelect
			$CCEExamSections->NumToSelect->HrefValue = "";
			$CCEExamSections->NumToSelect->TooltipValue = "";

			// ShowHeading
			$CCEExamSections->ShowHeading->HrefValue = "";
			$CCEExamSections->ShowHeading->TooltipValue = "";
		} elseif ($CCEExamSections->RowType == EW_ROWTYPE_EDIT) { // Edit row

			// Section_ID
			$CCEExamSections->Section_ID->EditCustomAttributes = "";
			$CCEExamSections->Section_ID->EditValue = $CCEExamSections->Section_ID->CurrentValue;
			$CCEExamSections->Section_ID->CssStyle = "";
			$CCEExamSections->Section_ID->CssClass = "";
			$CCEExamSections->Section_ID->ViewCustomAttributes = "";

			// Questionnaire_ID
			$CCEExamSections->Questionnaire_ID->EditCustomAttributes = "";
				$sFilterWrk = "";
			$sSqlWrk = "SELECT `Questionnaire_ID`, `Questionnaire_Name`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `CCEExams`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `Questionnaire_Name` Asc";
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
			$CCEExamSections->Questionnaire_ID->EditValue = $arwrk;

			// Section_Name
			$CCEExamSections->Section_Name->EditCustomAttributes = "";
			$CCEExamSections->Section_Name->EditValue = ew_HtmlEncode($CCEExamSections->Section_Name->CurrentValue);

			// Section_Text
			$CCEExamSections->Section_Text->EditCustomAttributes = "";
			$CCEExamSections->Section_Text->EditValue = ew_HtmlEncode($CCEExamSections->Section_Text->CurrentValue);

			// Display_Order
			$CCEExamSections->Display_Order->EditCustomAttributes = "";
			$CCEExamSections->Display_Order->EditValue = ew_HtmlEncode($CCEExamSections->Display_Order->CurrentValue);

			// SelectRandom
			$CCEExamSections->SelectRandom->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("1", "Yes");
			$arwrk[] = array("0", "No");
			$CCEExamSections->SelectRandom->EditValue = $arwrk;

			// NumToSelect
			$CCEExamSections->NumToSelect->EditCustomAttributes = "";
			$CCEExamSections->NumToSelect->EditValue = ew_HtmlEncode($CCEExamSections->NumToSelect->CurrentValue);

			// ShowHeading
			$CCEExamSections->ShowHeading->EditCustomAttributes = "";
			$arwrk = array();
			$arwrk[] = array("1", "Yes");
			$arwrk[] = array("0", "No");
			$CCEExamSections->ShowHeading->EditValue = $arwrk;

			// Edit refer script
			// Section_ID

			$CCEExamSections->Section_ID->HrefValue = "";

			// Questionnaire_ID
			$CCEExamSections->Questionnaire_ID->HrefValue = "";

			// Section_Name
			$CCEExamSections->Section_Name->HrefValue = "";

			// Section_Text
			$CCEExamSections->Section_Text->HrefValue = "";

			// Display_Order
			$CCEExamSections->Display_Order->HrefValue = "";

			// SelectRandom
			$CCEExamSections->SelectRandom->HrefValue = "";

			// NumToSelect
			$CCEExamSections->NumToSelect->HrefValue = "";

			// ShowHeading
			$CCEExamSections->ShowHeading->HrefValue = "";
		}

		// Call Row Rendered event
		if ($CCEExamSections->RowType <> EW_ROWTYPE_AGGREGATEINIT)
			$CCEExamSections->Row_Rendered();
	}

	// Validate form
	function ValidateForm() {
		global $Language, $gsFormError, $CCEExamSections;

		// Initialize form error message
		$gsFormError = "";

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return ($gsFormError == "");
		if (!ew_CheckInteger($CCEExamSections->Display_Order->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $CCEExamSections->Display_Order->FldErrMsg();
		}
		if (!ew_CheckInteger($CCEExamSections->NumToSelect->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $CCEExamSections->NumToSelect->FldErrMsg();
		}

		// Return validate result
		$ValidateForm = ($gsFormError == "");

		// Call Form_CustomValidate event
		$sFormCustomError = "";
		$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
		if ($sFormCustomError <> "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $sFormCustomError;
		}
		return $ValidateForm;
	}

	// Update record based on key values
	function EditRow() {
		global $conn, $Security, $Language, $CCEExamSections;
		$sFilter = $CCEExamSections->KeyFilter();
		$CCEExamSections->CurrentFilter = $sFilter;
		$sSql = $CCEExamSections->SQL();
		$conn->raiseErrorFn = 'ew_ErrorFn';
		$rs = $conn->Execute($sSql);
		$conn->raiseErrorFn = '';
		if ($rs === FALSE)
			return FALSE;
		if ($rs->EOF) {
			$EditRow = FALSE; // Update Failed
		} else {

			// Save old values
			$rsold =& $rs->fields;
			$rsnew = array();

			// Questionnaire_ID
			$CCEExamSections->Questionnaire_ID->SetDbValueDef($rsnew, $CCEExamSections->Questionnaire_ID->CurrentValue, NULL, FALSE);

			// Section_Name
			$CCEExamSections->Section_Name->SetDbValueDef($rsnew, $CCEExamSections->Section_Name->CurrentValue, NULL, FALSE);

			// Section_Text
			$CCEExamSections->Section_Text->SetDbValueDef($rsnew, $CCEExamSections->Section_Text->CurrentValue, NULL, FALSE);

			// Display_Order
			$CCEExamSections->Display_Order->SetDbValueDef($rsnew, $CCEExamSections->Display_Order->CurrentValue, NULL, FALSE);

			// SelectRandom
			$CCEExamSections->SelectRandom->SetDbValueDef($rsnew, $CCEExamSections->SelectRandom->CurrentValue, 0, FALSE);

			// NumToSelect
			$CCEExamSections->NumToSelect->SetDbValueDef($rsnew, $CCEExamSections->NumToSelect->CurrentValue, NULL, FALSE);

			// ShowHeading
			$CCEExamSections->ShowHeading->SetDbValueDef($rsnew, $CCEExamSections->ShowHeading->CurrentValue, 0, FALSE);

			// Call Row Updating event
			$bUpdateRow = $CCEExamSections->Row_Updating($rsold, $rsnew);
			if ($bUpdateRow) {
				$conn->raiseErrorFn = 'ew_ErrorFn';
				$EditRow = $conn->Execute($CCEExamSections->UpdateSQL($rsnew));
				$conn->raiseErrorFn = '';
			} else {
				if ($CCEExamSections->CancelMessage <> "") {
					$this->setMessage($CCEExamSections->CancelMessage);
					$CCEExamSections->CancelMessage = "";
				} else {
					$this->setMessage($Language->Phrase("UpdateCancelled"));
				}
				$EditRow = FALSE;
			}
		}

		// Call Row_Updated event
		if ($EditRow)
			$CCEExamSections->Row_Updated($rsold, $rsnew);
		$rs->Close();
		return $EditRow;
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	function Message_Showing(&$msg) {

		// Example:
		//$msg = "your new message";

	}

	// Form Custom Validate event
	function Form_CustomValidate(&$CustomError) {

		// Return error message in CustomError
		return TRUE;
	}
}
?>