<?php
session_start(); // Initialize session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg6.php" ?>
<?php include "ewmysql6.php" ?>
<?php include "phpfn6.php" ?>
<?php include "pv_deltroninfo.php" ?>
<?php include "usuarioinfo.php" ?>
<?php include "userfn6.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

// Define page object
$pv_deltron_edit = new cpv_deltron_edit();
$Page =& $pv_deltron_edit;

// Page init processing
$pv_deltron_edit->Page_Init();

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

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

// page properties
pv_deltron_edit.PageID = "edit"; // page ID
var EW_PAGE_ID = pv_deltron_edit.PageID; // for backward compatibility

// extend page with ValidateForm function
pv_deltron_edit.ValidateForm = function(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 + "_codigo"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, "Please enter required field - codigo");
		elm = fobj.elements["x" + infix + "_stockDT"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "Incorrect integer - stock DT");
		elm = fobj.elements["x" + infix + "_prDT"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "Incorrect floating point number - pr DT");
		elm = fobj.elements["x" + infix + "_precio_s"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "Incorrect floating point number - precio s");

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

// extend page with Form_CustomValidate function
pv_deltron_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) { ?>
pv_deltron_edit.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
pv_deltron_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">Edit TABLE: pv deltron<br><br>
<a href="<?php echo $pv_deltron->getReturnUrl() ?>">Go Back</a></span></p>
<?php $pv_deltron_edit->ShowMessage() ?>
<form name="fpv_deltronedit" id="fpv_deltronedit" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return pv_deltron_edit.ValidateForm(this);">
<p>
<input type="hidden" name="a_table" id="a_table" value="pv_deltron">
<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 ($pv_deltron->categoria->Visible) { // categoria ?>
	<tr<?php echo $pv_deltron->categoria->RowAttributes ?>>
		<td class="ewTableHeader">categoria</td>
		<td<?php echo $pv_deltron->categoria->CellAttributes() ?>><span id="el_categoria">
<input type="text" name="x_categoria" id="x_categoria" size="30" maxlength="255" value="<?php echo $pv_deltron->categoria->EditValue ?>"<?php echo $pv_deltron->categoria->EditAttributes() ?>>
</span><?php echo $pv_deltron->categoria->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pv_deltron->codigo->Visible) { // codigo ?>
	<tr<?php echo $pv_deltron->codigo->RowAttributes ?>>
		<td class="ewTableHeader">codigo<span class="ewRequired">&nbsp;*</span></td>
		<td<?php echo $pv_deltron->codigo->CellAttributes() ?>><span id="el_codigo">
<div<?php echo $pv_deltron->codigo->ViewAttributes() ?>><?php echo $pv_deltron->codigo->EditValue ?></div><input type="hidden" name="x_codigo" id="x_codigo" value="<?php echo ew_HtmlEncode($pv_deltron->codigo->CurrentValue) ?>">
</span><?php echo $pv_deltron->codigo->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pv_deltron->nombre->Visible) { // nombre ?>
	<tr<?php echo $pv_deltron->nombre->RowAttributes ?>>
		<td class="ewTableHeader">nombre</td>
		<td<?php echo $pv_deltron->nombre->CellAttributes() ?>><span id="el_nombre">
<input type="text" name="x_nombre" id="x_nombre" size="30" maxlength="255" value="<?php echo $pv_deltron->nombre->EditValue ?>"<?php echo $pv_deltron->nombre->EditAttributes() ?>>
</span><?php echo $pv_deltron->nombre->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pv_deltron->stockDT->Visible) { // stockDT ?>
	<tr<?php echo $pv_deltron->stockDT->RowAttributes ?>>
		<td class="ewTableHeader">stock DT</td>
		<td<?php echo $pv_deltron->stockDT->CellAttributes() ?>><span id="el_stockDT">
<input type="text" name="x_stockDT" id="x_stockDT" size="30" value="<?php echo $pv_deltron->stockDT->EditValue ?>"<?php echo $pv_deltron->stockDT->EditAttributes() ?>>
</span><?php echo $pv_deltron->stockDT->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pv_deltron->prDT->Visible) { // prDT ?>
	<tr<?php echo $pv_deltron->prDT->RowAttributes ?>>
		<td class="ewTableHeader">pr DT</td>
		<td<?php echo $pv_deltron->prDT->CellAttributes() ?>><span id="el_prDT">
<input type="text" name="x_prDT" id="x_prDT" size="30" value="<?php echo $pv_deltron->prDT->EditValue ?>"<?php echo $pv_deltron->prDT->EditAttributes() ?>>
</span><?php echo $pv_deltron->prDT->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pv_deltron->precio_s->Visible) { // precio_s ?>
	<tr<?php echo $pv_deltron->precio_s->RowAttributes ?>>
		<td class="ewTableHeader">precio s</td>
		<td<?php echo $pv_deltron->precio_s->CellAttributes() ?>><span id="el_precio_s">
<input type="text" name="x_precio_s" id="x_precio_s" size="30" value="<?php echo $pv_deltron->precio_s->EditValue ?>"<?php echo $pv_deltron->precio_s->EditAttributes() ?>>
</span><?php echo $pv_deltron->precio_s->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pv_deltron->garantia->Visible) { // garantia ?>
	<tr<?php echo $pv_deltron->garantia->RowAttributes ?>>
		<td class="ewTableHeader">garantia</td>
		<td<?php echo $pv_deltron->garantia->CellAttributes() ?>><span id="el_garantia">
<input type="text" name="x_garantia" id="x_garantia" size="30" maxlength="255" value="<?php echo $pv_deltron->garantia->EditValue ?>"<?php echo $pv_deltron->garantia->EditAttributes() ?>>
</span><?php echo $pv_deltron->garantia->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($pv_deltron->marca->Visible) { // marca ?>
	<tr<?php echo $pv_deltron->marca->RowAttributes ?>>
		<td class="ewTableHeader">marca</td>
		<td<?php echo $pv_deltron->marca->CellAttributes() ?>><span id="el_marca">
<input type="text" name="x_marca" id="x_marca" size="30" maxlength="255" value="<?php echo $pv_deltron->marca->EditValue ?>"<?php echo $pv_deltron->marca->EditAttributes() ?>>
</span><?php echo $pv_deltron->marca->CustomMsg ?></td>
	</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="   Edit   ">
</form>
<script language="JavaScript" type="text/javascript">
<!--

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

</script>
<?php include "footer.php" ?>
<?php

//
// Page Class
//
class cpv_deltron_edit {

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

	// Table Name
	var $TableName = 'pv_deltron';

	// Page Object Name
	var $PageObjName = 'pv_deltron_edit';

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

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

	// 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() {
		if ($this->getMessage() <> "") { // Message in Session, display
			echo "<p><span class=\"ewMessage\">" . $this->getMessage() . "</span></p>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}
	}

	// Validate Page request
	function IsPageRequest() {
		global $objForm, $pv_deltron;
		if ($pv_deltron->UseTokenInUrl) {

			//IsPageRequest = False
			if ($objForm)
				return ($pv_deltron->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($pv_deltron->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

	//
	//  Class initialize
	//  - init objects
	//  - open connection
	//
	function cpv_deltron_edit() {
		global $conn;

		// Initialize table object
		$GLOBALS["pv_deltron"] = new cpv_deltron();

		// Initialize other table object
		$GLOBALS['usuario'] = new cusuario();

		// Intialize page id (for backward compatibility)
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'edit', TRUE);

		// Initialize table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'pv_deltron', TRUE);

		// Open connection to the database
		$conn = ew_Connect();
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $pv_deltron;
		global $Security;
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}

		// Global page loading event (in userfn6.php)
		Page_Loading();

		// Page load event, used in current page
		$this->Page_Load();
	}

	//
	//  Page_Terminate
	//  - called when exit page
	//  - if URL specified, redirect to the URL
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page unload event, used in current page
		$this->Page_Unload();

		// Global page unloaded event (in userfn*.php)
		Page_Unloaded();

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

		// Go to URL if specified
		if ($url <> "") {
			ob_end_clean();
			header("Location: $url");
		}
		exit();
	}

	// 
	// Page main processing
	//
	function Page_Main() {
		global $objForm, $gsFormError, $pv_deltron;

		// Load key from QueryString
		if (@$_GET["codigo"] <> "")
			$pv_deltron->codigo->setQueryStringValue($_GET["codigo"]);

		// Create form object
		$objForm = new cFormObj();
		if (@$_POST["a_edit"] <> "") {
			$pv_deltron->CurrentAction = $_POST["a_edit"]; // Get action code
			$this->LoadFormValues(); // Get form values

			// Validate Form
			if (!$this->ValidateForm()) {
				$pv_deltron->CurrentAction = ""; // Form error, reset action
				$this->setMessage($gsFormError);
			}
		} else {
			$pv_deltron->CurrentAction = "I"; // Default action is display
		}

		// Check if valid key
		if ($pv_deltron->codigo->CurrentValue == "")
			$this->Page_Terminate("pv_deltronlist.php"); // Invalid key, return to list
		switch ($pv_deltron->CurrentAction) {
			case "I": // Get a record to display
				if (!$this->LoadRow()) { // Load record based on key
					$this->setMessage("No records found"); // No record found
					$this->Page_Terminate("pv_deltronlist.php"); // No matching record, return to list
				}
				break;
			Case "U": // Update
				$pv_deltron->SendEmail = TRUE; // Send email on update success
				if ($this->EditRow()) { // Update record based on key
					$this->setMessage("Update succeeded"); // Update success
					$sReturnUrl = $pv_deltron->getReturnUrl();
					$this->Page_Terminate($sReturnUrl); // Return to caller
				} else {
					$this->RestoreFormValues(); // Restore form values if update failed
				}
		}

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

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

		// Get upload data
	}

	// Load form values
	function LoadFormValues() {

		// Load from form
		global $objForm, $pv_deltron;
		$pv_deltron->categoria->setFormValue($objForm->GetValue("x_categoria"));
		$pv_deltron->codigo->setFormValue($objForm->GetValue("x_codigo"));
		$pv_deltron->nombre->setFormValue($objForm->GetValue("x_nombre"));
		$pv_deltron->stockDT->setFormValue($objForm->GetValue("x_stockDT"));
		$pv_deltron->prDT->setFormValue($objForm->GetValue("x_prDT"));
		$pv_deltron->precio_s->setFormValue($objForm->GetValue("x_precio_s"));
		$pv_deltron->garantia->setFormValue($objForm->GetValue("x_garantia"));
		$pv_deltron->marca->setFormValue($objForm->GetValue("x_marca"));
	}

	// Restore form values
	function RestoreFormValues() {
		global $pv_deltron;
		$this->LoadRow();
		$pv_deltron->categoria->CurrentValue = $pv_deltron->categoria->FormValue;
		$pv_deltron->codigo->CurrentValue = $pv_deltron->codigo->FormValue;
		$pv_deltron->nombre->CurrentValue = $pv_deltron->nombre->FormValue;
		$pv_deltron->stockDT->CurrentValue = $pv_deltron->stockDT->FormValue;
		$pv_deltron->prDT->CurrentValue = $pv_deltron->prDT->FormValue;
		$pv_deltron->precio_s->CurrentValue = $pv_deltron->precio_s->FormValue;
		$pv_deltron->garantia->CurrentValue = $pv_deltron->garantia->FormValue;
		$pv_deltron->marca->CurrentValue = $pv_deltron->marca->FormValue;
	}

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

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

		// Load sql based on filter
		$pv_deltron->CurrentFilter = $sFilter;
		$sSql = $pv_deltron->SQL();
		if ($rs = $conn->Execute($sSql)) {
			if ($rs->EOF) {
				$LoadRow = FALSE;
			} else {
				$LoadRow = TRUE;
				$rs->MoveFirst();
				$this->LoadRowValues($rs); // Load row values

				// Call Row Selected event
				$pv_deltron->Row_Selected($rs);
			}
			$rs->Close();
		} else {
			$LoadRow = FALSE;
		}
		return $LoadRow;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $pv_deltron;
		$pv_deltron->categoria->setDbValue($rs->fields('categoria'));
		$pv_deltron->codigo->setDbValue($rs->fields('codigo'));
		$pv_deltron->nombre->setDbValue($rs->fields('nombre'));
		$pv_deltron->stockDT->setDbValue($rs->fields('stockDT'));
		$pv_deltron->prDT->setDbValue($rs->fields('prDT'));
		$pv_deltron->precio_s->setDbValue($rs->fields('precio_s'));
		$pv_deltron->garantia->setDbValue($rs->fields('garantia'));
		$pv_deltron->marca->setDbValue($rs->fields('marca'));
	}

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

		// Call Row_Rendering event
		$pv_deltron->Row_Rendering();

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

		$pv_deltron->categoria->CellCssStyle = "";
		$pv_deltron->categoria->CellCssClass = "";

		// codigo
		$pv_deltron->codigo->CellCssStyle = "";
		$pv_deltron->codigo->CellCssClass = "";

		// nombre
		$pv_deltron->nombre->CellCssStyle = "";
		$pv_deltron->nombre->CellCssClass = "";

		// stockDT
		$pv_deltron->stockDT->CellCssStyle = "";
		$pv_deltron->stockDT->CellCssClass = "";

		// prDT
		$pv_deltron->prDT->CellCssStyle = "";
		$pv_deltron->prDT->CellCssClass = "";

		// precio_s
		$pv_deltron->precio_s->CellCssStyle = "";
		$pv_deltron->precio_s->CellCssClass = "";

		// garantia
		$pv_deltron->garantia->CellCssStyle = "";
		$pv_deltron->garantia->CellCssClass = "";

		// marca
		$pv_deltron->marca->CellCssStyle = "";
		$pv_deltron->marca->CellCssClass = "";
		if ($pv_deltron->RowType == EW_ROWTYPE_VIEW) { // View row

			// categoria
			$pv_deltron->categoria->ViewValue = $pv_deltron->categoria->CurrentValue;
			$pv_deltron->categoria->CssStyle = "";
			$pv_deltron->categoria->CssClass = "";
			$pv_deltron->categoria->ViewCustomAttributes = "";

			// codigo
			$pv_deltron->codigo->ViewValue = $pv_deltron->codigo->CurrentValue;
			$pv_deltron->codigo->CssStyle = "";
			$pv_deltron->codigo->CssClass = "";
			$pv_deltron->codigo->ViewCustomAttributes = "";

			// nombre
			$pv_deltron->nombre->ViewValue = $pv_deltron->nombre->CurrentValue;
			$pv_deltron->nombre->CssStyle = "";
			$pv_deltron->nombre->CssClass = "";
			$pv_deltron->nombre->ViewCustomAttributes = "";

			// stockDT
			$pv_deltron->stockDT->ViewValue = $pv_deltron->stockDT->CurrentValue;
			$pv_deltron->stockDT->CssStyle = "";
			$pv_deltron->stockDT->CssClass = "";
			$pv_deltron->stockDT->ViewCustomAttributes = "";

			// prDT
			$pv_deltron->prDT->ViewValue = $pv_deltron->prDT->CurrentValue;
			$pv_deltron->prDT->CssStyle = "";
			$pv_deltron->prDT->CssClass = "";
			$pv_deltron->prDT->ViewCustomAttributes = "";

			// precio_s
			$pv_deltron->precio_s->ViewValue = $pv_deltron->precio_s->CurrentValue;
			$pv_deltron->precio_s->CssStyle = "";
			$pv_deltron->precio_s->CssClass = "";
			$pv_deltron->precio_s->ViewCustomAttributes = "";

			// garantia
			$pv_deltron->garantia->ViewValue = $pv_deltron->garantia->CurrentValue;
			$pv_deltron->garantia->CssStyle = "";
			$pv_deltron->garantia->CssClass = "";
			$pv_deltron->garantia->ViewCustomAttributes = "";

			// marca
			$pv_deltron->marca->ViewValue = $pv_deltron->marca->CurrentValue;
			$pv_deltron->marca->CssStyle = "";
			$pv_deltron->marca->CssClass = "";
			$pv_deltron->marca->ViewCustomAttributes = "";

			// categoria
			$pv_deltron->categoria->HrefValue = "";

			// codigo
			$pv_deltron->codigo->HrefValue = "";

			// nombre
			$pv_deltron->nombre->HrefValue = "";

			// stockDT
			$pv_deltron->stockDT->HrefValue = "";

			// prDT
			$pv_deltron->prDT->HrefValue = "";

			// precio_s
			$pv_deltron->precio_s->HrefValue = "";

			// garantia
			$pv_deltron->garantia->HrefValue = "";

			// marca
			$pv_deltron->marca->HrefValue = "";
		} elseif ($pv_deltron->RowType == EW_ROWTYPE_EDIT) { // Edit row

			// categoria
			$pv_deltron->categoria->EditCustomAttributes = "";
			$pv_deltron->categoria->EditValue = ew_HtmlEncode($pv_deltron->categoria->CurrentValue);

			// codigo
			$pv_deltron->codigo->EditCustomAttributes = "";
			$pv_deltron->codigo->EditValue = $pv_deltron->codigo->CurrentValue;
			$pv_deltron->codigo->CssStyle = "";
			$pv_deltron->codigo->CssClass = "";
			$pv_deltron->codigo->ViewCustomAttributes = "";

			// nombre
			$pv_deltron->nombre->EditCustomAttributes = "";
			$pv_deltron->nombre->EditValue = ew_HtmlEncode($pv_deltron->nombre->CurrentValue);

			// stockDT
			$pv_deltron->stockDT->EditCustomAttributes = "";
			$pv_deltron->stockDT->EditValue = ew_HtmlEncode($pv_deltron->stockDT->CurrentValue);

			// prDT
			$pv_deltron->prDT->EditCustomAttributes = "";
			$pv_deltron->prDT->EditValue = ew_HtmlEncode($pv_deltron->prDT->CurrentValue);

			// precio_s
			$pv_deltron->precio_s->EditCustomAttributes = "";
			$pv_deltron->precio_s->EditValue = ew_HtmlEncode($pv_deltron->precio_s->CurrentValue);

			// garantia
			$pv_deltron->garantia->EditCustomAttributes = "";
			$pv_deltron->garantia->EditValue = ew_HtmlEncode($pv_deltron->garantia->CurrentValue);

			// marca
			$pv_deltron->marca->EditCustomAttributes = "";
			$pv_deltron->marca->EditValue = ew_HtmlEncode($pv_deltron->marca->CurrentValue);

			// Edit refer script
			// categoria

			$pv_deltron->categoria->HrefValue = "";

			// codigo
			$pv_deltron->codigo->HrefValue = "";

			// nombre
			$pv_deltron->nombre->HrefValue = "";

			// stockDT
			$pv_deltron->stockDT->HrefValue = "";

			// prDT
			$pv_deltron->prDT->HrefValue = "";

			// precio_s
			$pv_deltron->precio_s->HrefValue = "";

			// garantia
			$pv_deltron->garantia->HrefValue = "";

			// marca
			$pv_deltron->marca->HrefValue = "";
		}

		// Call Row Rendered event
		$pv_deltron->Row_Rendered();
	}

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

		// Initialize
		$gsFormError = "";

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return ($gsFormError == "");
		if ($pv_deltron->codigo->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= "Please enter required field - codigo";
		}
		if (!ew_CheckInteger($pv_deltron->stockDT->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= "Incorrect integer - stock DT";
		}
		if (!ew_CheckNumber($pv_deltron->prDT->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= "Incorrect floating point number - pr DT";
		}
		if (!ew_CheckNumber($pv_deltron->precio_s->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= "Incorrect floating point number - precio s";
		}

		// 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, $pv_deltron;
		$sFilter = $pv_deltron->KeyFilter();
		$pv_deltron->CurrentFilter = $sFilter;
		$sSql = $pv_deltron->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();

			// Field categoria
			$pv_deltron->categoria->SetDbValueDef($pv_deltron->categoria->CurrentValue, NULL);
			$rsnew['categoria'] =& $pv_deltron->categoria->DbValue;

			// Field codigo
			// Field nombre

			$pv_deltron->nombre->SetDbValueDef($pv_deltron->nombre->CurrentValue, NULL);
			$rsnew['nombre'] =& $pv_deltron->nombre->DbValue;

			// Field stockDT
			$pv_deltron->stockDT->SetDbValueDef($pv_deltron->stockDT->CurrentValue, NULL);
			$rsnew['stockDT'] =& $pv_deltron->stockDT->DbValue;

			// Field prDT
			$pv_deltron->prDT->SetDbValueDef($pv_deltron->prDT->CurrentValue, NULL);
			$rsnew['prDT'] =& $pv_deltron->prDT->DbValue;

			// Field precio_s
			$pv_deltron->precio_s->SetDbValueDef($pv_deltron->precio_s->CurrentValue, NULL);
			$rsnew['precio_s'] =& $pv_deltron->precio_s->DbValue;

			// Field garantia
			$pv_deltron->garantia->SetDbValueDef($pv_deltron->garantia->CurrentValue, NULL);
			$rsnew['garantia'] =& $pv_deltron->garantia->DbValue;

			// Field marca
			$pv_deltron->marca->SetDbValueDef($pv_deltron->marca->CurrentValue, NULL);
			$rsnew['marca'] =& $pv_deltron->marca->DbValue;

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

		// Call Row_Updated event
		if ($EditRow)
			$pv_deltron->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";
	}

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

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