<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Código Metrópoli &#187; Proyectos</title>
	<atom:link href="http://www.codigometropoli.com/category/proyectos/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codigometropoli.com</link>
	<description>Programación para Super Héroes</description>
	<lastBuildDate>Tue, 08 Jun 2010 00:30:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sistema de Gastos en Flex con AMFPHP y MySQL</title>
		<link>http://www.codigometropoli.com/sistema-de-gastos-en-flex-con-amfphp-y-mysql/</link>
		<comments>http://www.codigometropoli.com/sistema-de-gastos-en-flex-con-amfphp-y-mysql/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 16:30:48 +0000</pubDate>
		<dc:creator>Carla Macías</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Proyectos]]></category>
		<category><![CDATA[AMFPHP]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.codigometropoli.com/?p=472</guid>
		<description><![CDATA[En este tutorial veremos cómo acceder a los registros de una base de datos MySQL desde Flex utilizando AMFPHP. Realizaremos un pequeño Sistema de Gastos en el cual haremos inserciones a la base de datos, consultas, modificaciones y eliminación de registros. Si no sabes qué es y para qué sirve el AMFPHP, visita nuestro tutorial [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="float: right;" src="http://codigometropoli.com/images/flex_sticker.jpg" alt="Flex" width="93" height="93" />En este tutorial veremos cómo acceder a los registros de una base de datos MySQL desde Flex utilizando <a href="http://www.amfphp.org/" target="_blank">AMFPHP</a>. Realizaremos un pequeño Sistema de Gastos en el cual haremos inserciones a la base de datos, consultas, modificaciones y eliminación de registros. Si no sabes qué es y para qué sirve el AMFPHP, visita nuestro tutorial de <a href="http://www.codigometropoli.com/introduccion-a-amfphp/" target="_self">Introducción a AMFPHP</a>.</p>
<p><span id="more-472"></span></p>
<p>En esta ocasión no veremos a detalle todo el código que involucra el sistema; sin embargo, puedes encontrar al final de esta entrada los archivos fuentes.<br />
El sistema funciona de la siguiente manera:<br />
- El usuario primero da de alta tipo de monedas en la Sección de Divisas (Su nombre y símbolo).<br />
- Posteriormente el usuario puede dar de alta servicios en la Sección de Servicios (valga la redundancia). Estos servicios son opcionales y pueden seleccionarse cuando un usuario introduce un gasto en el sistema. Ejemplo de servicios: teléfono, gas, luz, educación, restaurantes, entretenimiento, etc.<br />
- Dentro del sistema, el usuario puede dar de alta gastos e ingresos. Estos gastos o ingresos requieren de la fecha, cantidad y divisa con la cual se realizó la operación. De manera opcional se puede introducir un concepto (descripción) y se puede seleccionar un servicio (si se trata de un gasto).</p>
<p>Comenzaremos con el script de nuestra base de datos:</p>
<div class="igBar"><span id="lsql-11"><a href="#" onclick="javascript:showPlainTxt('sql-11'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-11">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># Host: localhost&nbsp; &nbsp; Database: codmetr_gastos</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># ------------------------------------------------------</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># Server version 4.1.22-community-nt</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># Table structure for table tbldivisa</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`tbldivisa`</span> <span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`INTNUMDIVISA`</span> int<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">11</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span>,</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`STRNOMBRE`</span> varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">30</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">''</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`STRSIMBOLO`</span> varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">5</span><span style="color:#006600; font-weight:bold;">&#41;</span> character <span style="color: #993333; font-weight: bold;">SET</span> utf8 <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span>&nbsp; <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">`INTNUMDIVISA`</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span> ENGINE=MyISAM <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span>=<span style="color: #cc66cc;color:#800000;">3</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET=latin1;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># Table structure for table tbloperacion</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`tbloperacion`</span> <span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`INTNUMOPERACION`</span> int<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">11</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span>,</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`DTMFECHA`</span> date <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0000-00-00'</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`STRCONCEPTO`</span> varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">100</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`NUMCANTIDAD`</span> decimal<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">10</span>,<span style="color: #cc66cc;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`INTNUMDIVISA`</span> int<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">11</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0'</span>,</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`INTNUMSERVICIO`</span> int<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">11</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`INTOPERACION`</span> int<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">11</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #ff0000;">'0'</span>,</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span>&nbsp; <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">`INTNUMOPERACION`</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span> ENGINE=MyISAM <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span>=<span style="color: #cc66cc;color:#800000;">4</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET=latin1;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;"># Table structure for table tblservicio</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">#</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`tblservicio`</span> <span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`INTNUMSERVICIO`</span> int<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">11</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span> <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span>,</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #ff0000;">`STRNOMBRE`</span> varchar<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">50</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span>&nbsp; <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">`INTNUMSERVICIO`</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span> ENGINE=MyISAM <span style="color: #993333; font-weight: bold;">AUTO_INCREMENT</span>=<span style="color: #cc66cc;color:#800000;">3</span> <span style="color: #993333; font-weight: bold;">DEFAULT</span> CHARSET=latin1; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Del código anterior podemos observar que tenemos una tabla <strong>tbldivisa</strong>, en la cual almacenamos los tipos de moneda que utilizamos. Una tabla <strong>tblservicio</strong> donde guardamos los servicios ingresados; y una tabla <strong>tbloperacion</strong> en donde almacenamos las operaciones (gastos e ingresos). Las relaciones entre divisas y servicios con respecto a las operaciones están dadas por el ID de estas tablas (INTNUMDIVISA e INTNUMSERVICIO).</p>
<p>Ahora veremos el código PHP de nuestra que funcionará como servicio:</p>
<div class="igBar"><span id="lphp-12"><a href="#" onclick="javascript:showPlainTxt('php-12'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-12">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">&lt;?php</span> </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">class</span> SistemaGastos</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$sqlstring</span> = <span style="color:#FF0000;">""</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$server</span> = <span style="color:#FF0000;">"localhost"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$user</span> =&nbsp; <span style="color:#FF0000;">"usuario_database"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$pass</span> = <span style="color:#FF0000;">"contrasena_database"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$database</span> = <span style="color:#FF0000;">"codigometr_gastos"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$db</span> = <span style="color:#CC66CC;color:#800000;">0</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$rs</span> = <span style="color:#CC66CC;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$row</span> = <span style="color:#CC66CC;color:#800000;">0</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$recordcount</span> = <span style="color:#CC66CC;color:#800000;">0</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">var</span> <span style="color:#0000FF;">$EOF</span> = <span style="color:#000000; font-weight:bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> _conectarBaseDatos<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">db</span> = <a href="http://www.php.net/mysql_connect"><span style="color:#000066;">mysql_connect</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">server</span>,<span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">user</span>,<span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">pass</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp;&nbsp; <a href="http://www.php.net/mysql_select_db"><span style="color:#000066;">mysql_select_db</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">database</span>,<span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">db</span><span style="color:#006600; font-weight:bold;">&#41;</span> or <a href="http://www.php.net/die"><span style="color:#000066;">die</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><a href="http://www.php.net/mysql_error"><span style="color:#000066;">mysql_error</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> _ejecutarQuery<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$strSql</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">sqlstring</span> = <span style="color:#0000FF;">$strSql</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_exec_command<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">lastid</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> _exec_command<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">db</span> &amp;&amp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">sqlstring</span>!=<span style="color:#FF0000;">""</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">rs</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">sqlstring</span>,<span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">db</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">rs</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">EOF</span> = <span style="color:#000000; font-weight:bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">recordcount</span> = <a href="http://www.php.net/mysql_affected_rows"><span style="color:#000066;">mysql_affected_rows</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">lastid</span> = <a href="http://www.php.net/mysql_insert_id"><span style="color:#000066;">mysql_insert_id</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">else</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">recordcount</span> = <span style="color:#CC66CC;color:#800000;">0</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">EOF</span> = <span style="color:#000000; font-weight:bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span> </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">else</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">recordcount</span> = <span style="color:#CC66CC;color:#800000;">0</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">EOF</span> = <span style="color:#000000; font-weight:bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span>&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span>&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> _destruir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">db</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/mysql_close"><span style="color:#000066;">mysql_close</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$this</span>-&gt;<span style="color:#006600;">db</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000;">/* Métodos para la tabla tbldivisa */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> insertarDivisa<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$nombre</span>, <span style="color:#0000FF;">$simbolo</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_conectarBaseDatos<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"Insert into `tbldivisa` (`STRNOMBRE`, `STRSIMBOLO`) VALUES ('"</span> . <span style="color:#0000FF;">$nombre</span> . <span style="color:#FF0000;">"', '"</span> . <span style="color:#0000FF;">$simbolo</span> . <span style="color:#FF0000;">"')"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_ejecutarQuery<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_destruir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> modificarDivisa<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$idDivisa</span>, <span style="color:#0000FF;">$nombre</span>, <span style="color:#0000FF;">$simbolo</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_conectarBaseDatos<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"Update `tbldivisa` set `STRNOMBRE` = '"</span> . <span style="color:#0000FF;">$nombre</span> . <span style="color:#FF0000;">"', `STRSIMBOLO` = '"</span> . <span style="color:#0000FF;">$simbolo</span> . <span style="color:#FF0000;">"' where `INTNUMDIVISA` = "</span> . <span style="color:#0000FF;">$idDivisa</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_ejecutarQuery<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_destruir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> eliminarDivisa<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$idDivisa</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_conectarBaseDatos<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"Delete from `tbldivisa` where `INTNUMDIVISA`= "</span> . <span style="color:#0000FF;">$idDivisa</span>;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$result</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"Delete from `tbloperacion` where `INTNUMDIVISA`= "</span> . <span style="color:#0000FF;">$idDivisa</span>;&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_destruir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$result</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> obtenerDivisas<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_conectarBaseDatos<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"Select INTNUMDIVISA, STRNOMBRE, STRSIMBOLO from tbldivisa ORDER BY STRNOMBRE asc"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$result</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">while</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$row</span> = <a href="http://www.php.net/mysql_fetch_object"><span style="color:#000066;">mysql_fetch_object</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$result</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$divisas</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$row</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span>&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_destruir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$divisas</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000;">/* Métodos para la tabla tblservicio */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> insertarServicio<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$nombre</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_conectarBaseDatos<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"Insert into `tblservicio` (`STRNOMBRE`) VALUES ('"</span> . <span style="color:#0000FF;">$nombre</span> . <span style="color:#FF0000;">"')"</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_ejecutarQuery<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_destruir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> modificarServicio<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$idServicio</span>, <span style="color:#0000FF;">$nombre</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_conectarBaseDatos<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"Update `tblservicio` set `STRNOMBRE` = '"</span> . <span style="color:#0000FF;">$nombre</span> . <span style="color:#FF0000;">"' where `INTNUMSERVICIO` = "</span> . <span style="color:#0000FF;">$idServicio</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_ejecutarQuery<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_destruir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> eliminarServicio<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$idServicio</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_conectarBaseDatos<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"Delete from `tblservicio` where `INTNUMSERVICIO`= "</span> . <span style="color:#0000FF;">$idServicio</span>;&nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$result</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"Delete from `tbloperacion` where `INTNUMSERVICIO`= "</span> . <span style="color:#0000FF;">$idServicio</span>;&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_destruir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$result</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> obtenerServicios<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_conectarBaseDatos<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"Select INTNUMSERVICIO, STRNOMBRE from tblservicio ORDER BY STRNOMBRE asc"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$result</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">while</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$row</span> = <a href="http://www.php.net/mysql_fetch_object"><span style="color:#000066;">mysql_fetch_object</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$result</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$servicios</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$row</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span>&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_destruir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$servicios</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000;">/* Métodos para la tabla tbloperacion */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> insertarOperacion<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$fecha</span>, <span style="color:#0000FF;">$concepto</span>, <span style="color:#0000FF;">$cantidad</span>, <span style="color:#0000FF;">$id_divisa</span>, <span style="color:#0000FF;">$servicio</span>, <span style="color:#0000FF;">$operacion</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_conectarBaseDatos<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"INSERT INTO `tbloperacion` (DTMFECHA, STRCONCEPTO, NUMCANTIDAD, INTNUMDIVISA, INTNUMSERVICIO, INTOPERACION) VALUES ('"</span> . <span style="color:#0000FF;">$fecha</span> . <span style="color:#FF0000;">"','"</span> . <span style="color:#0000FF;">$concepto</span> . <span style="color:#FF0000;">"',"</span> . <span style="color:#0000FF;">$cantidad</span> . <span style="color:#FF0000;">","</span> . <span style="color:#0000FF;">$id_divisa</span> . <span style="color:#FF0000;">","</span> . <span style="color:#0000FF;">$servicio</span> . <span style="color:#FF0000;">","</span> . <span style="color:#0000FF;">$operacion</span> . <span style="color:#FF0000;">")"</span>;&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$result</span> = <span style="color:#0000FF;">$this</span>-&gt;_ejecutarQuery<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_destruir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$result</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> actualizarOperacion<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$idOperacion</span>, <span style="color:#0000FF;">$fecha</span>, <span style="color:#0000FF;">$concepto</span>, <span style="color:#0000FF;">$cantidad</span>, <span style="color:#0000FF;">$id_divisa</span>, <span style="color:#0000FF;">$servicio</span>, <span style="color:#0000FF;">$operacion</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_conectarBaseDatos<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"Update `tbloperacion` set `DTMFECHA` = '"</span> . <span style="color:#0000FF;">$fecha</span> . <span style="color:#FF0000;">"', `STRCONCEPTO` = '"</span> . <span style="color:#0000FF;">$concepto</span> . <span style="color:#FF0000;">"', `NUMCANTIDAD` = "</span> . <span style="color:#0000FF;">$cantidad</span> . <span style="color:#FF0000;">", `INTNUMDIVISA` = "</span> . <span style="color:#0000FF;">$id_divisa</span> . <span style="color:#FF0000;">", `INTNUMSERVICIO` = "</span> . <span style="color:#0000FF;">$servicio</span> . <span style="color:#FF0000;">", `INTOPERACION` = "</span> . <span style="color:#0000FF;">$operacion</span> . <span style="color:#FF0000;">" where `INTNUMOPERACION` = "</span> . <span style="color:#0000FF;">$idOperacion</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$result</span> = <span style="color:#0000FF;">$this</span>-&gt;_ejecutarQuery<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_destruir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$result</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> eliminarOperacion<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$idOperacion</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_conectarBaseDatos<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"Delete from `tbloperacion` where `INTNUMOPERACION`= "</span> . <span style="color:#0000FF;">$idOperacion</span>;&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$result</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_destruir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span> <span style="color:#0000FF;">$result</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> obtenerOperaciones<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_conectarBaseDatos<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"Select * from `tbloperacion` ORDER BY DTMFECHA asc"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$result</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">while</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$row</span> = <a href="http://www.php.net/mysql_fetch_object"><span style="color:#000066;">mysql_fetch_object</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$result</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$operaciones</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$row</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span>&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_destruir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$operaciones</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#000000; font-weight:bold;">function</span> realizarConsulta<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$servicio</span>, <span style="color:#0000FF;">$divisa</span>, <span style="color:#0000FF;">$concepto</span>, <span style="color:#0000FF;">$fecha1</span>, <span style="color:#0000FF;">$fecha2</span>, <span style="color:#0000FF;">$cantidad1</span>, <span style="color:#0000FF;">$cantidad2</span>, <span style="color:#0000FF;">$operacion</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_conectarBaseDatos<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> = <span style="color:#FF0000;">"Select top.DTMFECHA, top.STRCONCEPTO, top.NUMCANTIDAD, top.INTNUMDIVISA, top.INTNUMSERVICIO, top.INTOPERACION, td.STRNOMBRE, td.STRSIMBOLO FROM tbloperacion AS top, tbldivisa as td WHERE td.INTNUMDIVISA = top.INTNUMDIVISA"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#008000;">/* Selección Concepto */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$concepto</span> != <span style="color:#FF0000;">""</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> .= <span style="color:#FF0000;">" AND top.STRCONCEPTO LIKE '%"</span> . <span style="color:#0000FF;">$concepto</span> . <span style="color:#FF0000;">"%'"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#008000;">/* Selección Divisa */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$divisa</span> != <span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> .= <span style="color:#FF0000;">" AND top.INTNUMDIVISA = "</span> . <span style="color:#0000FF;">$divisa</span> . <span style="color:#FF0000;">" AND td.INTNUMDIVISA = "</span> . <span style="color:#0000FF;">$divisa</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#008000;">/* Selección Servicio */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$servicio</span> != <span style="color:#CC66CC;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> .= <span style="color:#FF0000;">" AND top.INTNUMSERVICIO = "</span> . <span style="color:#0000FF;">$servicio</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$cantidad1</span> != <span style="color:#FF0000;">""</span> &amp;&amp; <span style="color:#0000FF;">$cantidad2</span> != <span style="color:#FF0000;">""</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$cantidad1</span> &lt;= <span style="color:#0000FF;">$cantidad2</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> .= <span style="color:#FF0000;">" AND top.NUMCANTIDAD BETWEEN "</span> . <span style="color:#0000FF;">$cantidad1</span> . <span style="color:#FF0000;">" AND "</span> . <span style="color:#0000FF;">$cantidad2</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">else</span> </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> .= <span style="color:#FF0000;">" AND top.NUMCANTIDADBETWEEN "</span> . <span style="color:#0000FF;">$cantidad2</span> . <span style="color:#FF0000;">" AND "</span> . <span style="color:#0000FF;">$cantidad1</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">else</span> <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$cantidad1</span> != <span style="color:#FF0000;">""</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> .= <span style="color:#FF0000;">" AND top.NUMCANTIDAD = "</span> . <span style="color:#0000FF;">$cantidad1</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">else</span> <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$cantidad2</span> != <span style="color:#FF0000;">""</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> .= <span style="color:#FF0000;">" AND top.NUMCANTIDAD = "</span> . <span style="color:#0000FF;">$cantidad2</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#008000;">/* Selección Operación */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$operacion</span> == <span style="color:#CC66CC;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> .= <span style="color:#FF0000;">" AND top.INTOPERACION&gt;= 1 AND top.INTOPERACION &lt;= 2"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">else</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> .= <span style="color:#FF0000;">" AND top.INTOPERACION = "</span>&nbsp; . <span style="color:#0000FF;">$operacion</span>;&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$fecha1</span> != <span style="color:#000000; font-weight:bold;">NULL</span> || <span style="color:#0000FF;">$fecha2</span> != <span style="color:#000000; font-weight:bold;">NULL</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$fecha1</span> != <span style="color:#FF0000;">""</span> &amp;&amp; <span style="color:#0000FF;">$fecha2</span> == <span style="color:#FF0000;">""</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> .= <span style="color:#FF0000;">" AND top.DTMFECHA = '"</span> . <span style="color:#0000FF;">$fecha1</span> . <span style="color:#FF0000;">"'"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">else</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> .= <span style="color:#FF0000;">" AND top.DTMFECHA&gt;= '"</span> . <span style="color:#0000FF;">$fecha1</span> . <span style="color:#FF0000;">"' AND top.DTMFECHA &lt;= '"</span> . <span style="color:#0000FF;">$fecha2</span> . <span style="color:#FF0000;">"'"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$sql</span> .= <span style="color:#FF0000;">" ORDER BY top.DTMFECHA asc, top.NUMCANTIDAD asc"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$result</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$sql</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">while</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$row</span> = <a href="http://www.php.net/mysql_fetch_object"><span style="color:#000066;">mysql_fetch_object</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$result</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$registros</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF;">$row</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span>&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#0000FF;">$this</span>-&gt;_destruir<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color:#616100;">return</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$registros</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#000000; font-weight:bold;">?&gt;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Los métodos que inician con guión bajo (_) son métodos privados y por lo tanto no podemos acceder a ellos desde Flex. Los otros métodos <em>insertarDivisa</em>, <em>modificarDivisa</em>, <em>eliminarDivisa</em>, <em>obtenerDivisas</em>, etc. son métodos públicos a los cuales accedemos desde Flex.<br />
Observa cómo en los métodos obtenerXXX almacenamos los registros en un arreglo y lo regresamos a nuestra aplicación. Los queries en realidad son muy sencillos, por lo que no requieren explicación; solamente observa cómo en los métodos <strong>eliminarServicio</strong> y <strong>eliminarDivisa</strong> hacemos el borrado de los registros que involucran estos registros en la tabla <em>tbloperacion</em>. Esto es para evitar que haya inconsistencia en la base de datos.</p>
<p>Ahora veremos el código principal de nuestra aplicación en Flex.<br />
Para poder hacer uso del AMFPHP necesitamos de las librerías <strong>NetConnection</strong> y <strong>Responder</strong>.</p>
<div class="igBar"><span id="lactionscript-13"><a href="#" onclick="javascript:showPlainTxt('actionscript-13'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-13">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #0066CC;">NetConnection</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">Responder</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Para poder acceder a los servicios en AMFPHP debemos especificar la ruta en la cual se encuentra el archivo gateway.php de AMFPHP:</p>
<div class="igBar"><span id="lactionscript-14"><a href="#" onclick="javascript:showPlainTxt('actionscript-14'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-14">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> gateway:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"http://www.codigometropoli.com/wp-content/uploads/2008/10/SistemaGastos/AMFPHP1.9/gateway.php"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> connection:<span style="color: #0066CC;">NetConnection</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> responder:Responder; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Al iniciar la aplicación debemos llamar a la función <em>connect</em> pasándole como parámetro el <em>gateway</em>:</p>
<div class="igBar"><span id="lactionscript-15"><a href="#" onclick="javascript:showPlainTxt('actionscript-15'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-15">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000; font-weight: bold;">function</span> iniciaAplicacion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; connection = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">NetConnection</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; connection.<span style="color: #0066CC;">connect</span><span style="color: #66cc66;">&#40;</span>gateway<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Dentro del constructor de la clase Responder debemos especificar las funciones que se ejecutarán en caso de que la llamada haya sido sido exitosa y en caso de que haya existido un error. Para hacer la llamada al servicio utilizamos la función <em>call</em>; a la cual pasamos como parámetro el nombre de la función que queremos llamar y que se encuentra en la clase <strong>SistemaGastos.php</strong>, nuestro objeto de la clase Responder y los parámetros que debemos pasarle a la función:</p>
<div class="igBar"><span id="lactionscript-16"><a href="#" onclick="javascript:showPlainTxt('actionscript-16'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-16">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">responder = <span style="color: #000000; font-weight: bold;">new</span> Responder<span style="color: #66cc66;">&#40;</span>insertarOperacionResult, errorConsulta<span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">connection.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"SistemaGastos.insertarOperacion"</span>, responder, param1, param2, param3...<span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Del código anterior podemos deducir que el nombre de nuestra clase en PHP es <strong>SistemaGastos</strong> y que tiene un método público llamado <strong>insertarOperacion</strong>.</p>
<p>En caso de que la llamada haya sido exitosa, se ejecutará el método <em>insertarOperacionResult</em>:</p>
<div class="igBar"><span id="lactionscript-17"><a href="#" onclick="javascript:showPlainTxt('actionscript-17'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-17">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> insertarOperacionResult<span style="color: #66cc66;">&#40;</span>result:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>result.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #ff0000;">"0"</span><span style="color: #66cc66;">&#41;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span> </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; restablecerForma<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Registro almacenado"</span>, <span style="color: #ff0000;">"Aviso"</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"No se pudo almacenar el registro"</span>, <span style="color: #ff0000;">"Error"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>En caso contrario, si existiera algún error en la llamada al servicio, la función <em>errorConsulta</em> se ejecutará:</p>
<div class="igBar"><span id="lactionscript-18"><a href="#" onclick="javascript:showPlainTxt('actionscript-18'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-18">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> errorConsulta<span style="color: #66cc66;">&#40;</span>fault:<span style="color: #0066CC;">Object</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span>fault.<span style="color: #006600;">description</span>, <span style="color: #ff0000;">"Error"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; CursorManager.<span style="color: #006600;">removeBusyCursor</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Nuestra forma de alta de operación (Gasto o Ingreso) será la siguiente:</p>
<div align="center"><img src="http://www.codigometropoli.com/images/screens/sistema_gastos_flex_alta.jpg" alt="Formulario de alta de gastos o ingresos" /></div>
<p>De la imagen anterior puedes saber qué tipo de información estamos solicitando, cuál es la obligatoria (Fecha, Cantidad y Divisa), así como la forma en qué estamos mostrando al usuario las divisas y servicios dados de alta (por medio de ComboBox).</p>
<p>Las partes de código mostradas forman parte de la llamada a una función que se encarga de insertar un registro. El código no tendrá variación cuando se trate de modificar un registro; y cuando se trate de eliminar un registro solamente le pasaremos el ID del registro a eliminar. ¿Pero qué pasa cuando se trata de una consulta? ¿Cómo obtenemos los registros registros regresados por la base de datos? ¿Cómo mostramos esos registros?</p>
<p>Si leíste el tutorial sobre <a href="http://www.codigometropoli.com/componente-datagrid/">Componente DataGrid</a> y las cuatro entregas del tutorial <a href="http://www.codigometropoli.com/category/air/">Sistema de Clientes en AIR</a> sabrás que podemos recorrer cada uno de los registros obtenidos de la base de datos y almacenarlos en un arreglo por medio del método <em>push</em>; posteriormente ese arreglo es pasado al DataGrid como su proveedor de datos (<em>dataProvider</em>).</p>
<p>Primero hacemos la llamada al método <em>realizarConsulta</em> del servicio <strong>SistemaGastos</strong>:</p>
<div class="igBar"><span id="lactionscript-19"><a href="#" onclick="javascript:showPlainTxt('actionscript-19'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-19">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">responder = <span style="color: #000000; font-weight: bold;">new</span> Responder<span style="color: #66cc66;">&#40;</span>realizarConsultaResult, errorConsulta<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">connection.<span style="color: #0066CC;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"SistemaGastos.realizarConsulta"</span>, responder, param1, param2, param3...<span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Definimos el código de nuestra función realizarConsultaResult:</p>
<div class="igBar"><span id="lactionscript-20"><a href="#" onclick="javascript:showPlainTxt('actionscript-20'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-20">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> realizarConsultaResult<span style="color: #66cc66;">&#40;</span>result:<span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>result != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> totalRegistros:<span style="color: #0066CC;">Number</span> = result.<span style="color: #0066CC;">length</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> totales_array:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;color:#800000;">0</span>; i &lt;result.<span style="color: #0066CC;">length</span>; i++<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ...</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">var</span> divisa_txt:<span style="color: #0066CC;">String</span> = result<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">STRNOMBRE</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;<span style="color: #000000; font-weight: bold;">var</span> simbolo_txt:<span style="color: #0066CC;">String</span> = result<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">STRSIMBOLO</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;...&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> cantidad:<span style="color: #0066CC;">Number</span> = result<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">NUMCANTIDAD</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>totales_array.<span style="color: #0066CC;">length</span> == <span style="color: #cc66cc;color:#800000;">0</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; totales_array.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>cantidad:cantidad, divisaID:result<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">INTNUMDIVISA</span>, divisa:divisa_txt, simbolo:result<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">STRSIMBOLO</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> posicion:<span style="color: #0066CC;">Number</span> = regresaPosicionMoneda<span style="color: #66cc66;">&#40;</span>totales_array, result<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">INTNUMDIVISA</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>posicion != -<span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> total:<span style="color: #0066CC;">Number</span> = totales_array<span style="color: #66cc66;">&#91;</span>posicion<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">cantidad</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; total += cantidad;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; totales_array<span style="color: #66cc66;">&#91;</span>posicion<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">cantidad</span> = total;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span>&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; totales_array.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>cantidad:cantidad, divisaID:result<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">INTNUMDIVISA</span>, divisa:divisa_txt, simbolo:result<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">STRSIMBOLO</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">data_provider.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>fecha_operacion:DateUtilities.<span style="color: #006600;">returnReadableDate</span><span style="color: #66cc66;">&#40;</span>result<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">DTMFECHA</span><span style="color: #66cc66;">&#41;</span>, concepto:result<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">STRCONCEPTO</span>, cantidad:currencyFormatter.<span style="color: #006600;">format</span><span style="color: #66cc66;">&#40;</span>result<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">NUMCANTIDAD</span><span style="color: #66cc66;">&#41;</span>, cantidad_numero:result<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">NUMCANTIDAD</span>, servicio:servicio_txt, divisa:divisa_txt, operacion:returnTipoOperacion<span style="color: #66cc66;">&#40;</span>result<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">INTOPERACION</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; registros_dg.<span style="color: #006600;">dataProvider</span> = data_provider;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; info_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"Total registros: "</span> + totalRegistros + <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> j:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;color:#800000;">0</span>; j &lt;totales_array.<span style="color: #0066CC;">length</span>; j++<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> simbolo:<span style="color: #0066CC;">String</span> = totales_array<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">simbolo</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>simbolo == <span style="color: #ff0000;">"?"</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp;simbolo = <span style="color: #ff0000;">"€"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;currencyFormatter.<span style="color: #006600;">currencySymbol</span> = simbolo;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;info_txt.<span style="color: #0066CC;">text</span> += <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\n</span>&nbsp; &nbsp; &nbsp;--&gt; "</span> + totales_array<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">divisa</span> +&nbsp; <span style="color: #ff0000;">" = "</span> + currencyFormatter.<span style="color: #006600;">format</span><span style="color: #66cc66;">&#40;</span>totales_array<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">cantidad</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <span style="color: #66cc66;">&#125;</span>&nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; info_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; CursorManager.<span style="color: #006600;">removeBusyCursor</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Del código anterior podemos decir que... primero verificamos que el resultado obtenido por el servicio sea distinto de nulo (es decir, que no esté vacío) ya que si no nos mostraría error. En la variable totalRegistros almacenamos el número de registros obtenidos mediante la propiedad <strong>length</strong> del arreglo. Recorremos el arreglo result por medio de un ciclo <strong>for</strong> y dentro de este ciclo hacemos las operaciones que requerimos con los valores obtenidos. Observa que para acceder a cada una de las columnas de nuestros registros lo hacemos de la forma result[i].STRNOMBRE, result[i].STRSIMBOLO, result[i].INTNUMDIVISA, etc. donde STRNOMBRE, STRSIMBOLO, ... son los nombres de nuestras columnas en la tabla <strong>tbloperacion</strong> de nuestra base de datos. Dentro del código de nuestro ciclo for estamos sumando (ingreso) o restando (si se trata de gasto) las cantidades pertenecientes a un mismo tipo de moneda; y así mostrar la cantidad ganada o gastada por tipo de moneda.</p>
<div align="center"><img src="http://www.codigometropoli.com/images/screens/sistema_gastos_flex1.jpg" alt="Resultado de las operaciones por moneda" /></div>
<p>Dentro del archivo SistemaGastos.php observarás que el código de la función realizarConsulta es largo y está lleno de condicionales. Esto es porque las consultas las podemos realizar de acuerdo a los siguientes criterios:</p>
<div align="center" style="margin-bottom:10px;"><a href="http://www.codigometropoli.com/images/screens/sistema_gastos_flex_consulta.jpg" target="_blank"><br />
<img src="http://www.codigometropoli.com/images/previews/sistema_gastos_flex_consulta.jpg" alt="Forma de consulta de gastos e ingresos" /></a></div>
<p>Hemos llegado al final de este tutorial, no olvidemos revisar el ejemplo y bajar los archivos fuentes.</p>
<div align="center" style="margin-top:10px"><script type="text/javascript"><!--
      google_ad_client = "pub-5808310808246221";
      /* 250x250, Posts */
      google_ad_slot = "8254875600";
      google_ad_width = 250;
      google_ad_height = 250;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></div>
<div align="center" style="margin-top:40px;margin-bottom:40px;">
<table border="0" cellspacing="0" cellpadding="0" width="180">
<tbody>
<tr>
<td valign="top"><a href="http://www.codigometropoli.com/wp-content/uploads/2008/10/SistemaGastos/Sistema_Gastos.html" target="_blank"><img title="Ver Ejempo" src="http://codigometropoli.com/images/ver_ejemplo.jpg" alt="Ver Ejemplo" /></a></td>
<td valign="top"><a href="http://www.megaupload.com/?d=DM0QBFMO" target="_blank"><img title="Descargar Archivo" src="../images/descargar_archivo.jpg" alt="Descargar Archivo" /></a></td>
</tr>
</tbody>
</table>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.codigometropoli.com/sistema-de-gastos-en-flex-con-amfphp-y-mysql/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
		<item>
		<title>Sistema de Clientes (AIR y SQLite) Parte IV (Consulta a la base de datos)</title>
		<link>http://www.codigometropoli.com/sistema-de-clientes-parte-iv/</link>
		<comments>http://www.codigometropoli.com/sistema-de-clientes-parte-iv/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 05:30:04 +0000</pubDate>
		<dc:creator>Carla Macías</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Proyectos]]></category>
		<category><![CDATA[Base de datos]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Proyecto]]></category>
		<category><![CDATA[Sistema]]></category>

		<guid isPermaLink="false">http://www.codigometropoli.com/?p=350</guid>
		<description><![CDATA[Esta es la cuarta y última parte del proyecto "Sistema de Clientes" desarrollado en AIR con SQLite como administrador de base de datos. En la entrada anterior vimos cómo modificar y eliminar registros en la base de datos (clientesDB.sqlite) desde nuestra aplicación en AIR.

En esta ocasión veremos cómo realizar consultas de los registros en la [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="float: right;" src="http://codigometropoli.com/images/air_sticker.jpg" alt="Adobe AIR" width="93" height="93" />Esta es la cuarta y última parte del proyecto "Sistema de Clientes" desarrollado en AIR con SQLite como administrador de base de datos. En la <a href="http://www.codigometropoli.com/sistema-de-clientes-parte-iii/" target="_blank">entrada</a> anterior vimos cómo modificar y eliminar registros en la base de datos (<em>clientesDB.sqlite</em>) desde nuestra aplicación en AIR.</p>
<p><span id="more-350"></span></p>
<p>En esta ocasión veremos cómo realizar consultas de los registros en la base de datos; para esto crearemos una forma en la cual el usuario puede introducir el nombre, teléfono o correo del cliente que está buscando. Los resultados de esta consulta los escribiremos en un archivo HTML y lo mostraremos dentro del componente <strong>HTML </strong>(aprovechando el <a href="http://www.codigometropoli.com/crear-archivo-en-air-con-flex-builder-3/" target="_blank">post</a> que publiqué hace ya tiempo sobre cómo crear un archivo en AIR).</p>
<p><span style="color: #ff0000;"><strong>Parte 4: Consulta a la base de datos en SQLite con AIR</strong></span></p>
<p>Recuerda que para mantener organizado el código de nuestro proyecto y para evitar que se pierdan con toda la información aquí mostrada, dividí el código del proyecto en archivos .as. Estos archivos estarán almacenados en la carpeta actionscript. La estructura de nuestro proyecto será la siguiente:</p>
<div align="center">
<div class="wp-caption aligncenter" style="width: 255px"><img title="Imagen 1: Estructura de la aplicación" src="http://www.codigometropoli.com/wp-content/uploads/2008/08/proy1image1.jpg" alt="Imagen 1: Estructura de la aplicación" width="245" height="373" />
<p class="wp-caption-text">Imagen 1: Estructura de la aplicación</p>
</div>
</div>
<p>Todas las interfaces de este proyecto están incluidas en la carpeta <em>componentes</em>. La interfaz que en esta ocasión veremos es la del archivo <em>ConsultaClientes.mxml</em>. Esta interfaz funciona de la siguiente manera:</p>
<div align="center">
<div class="wp-caption aligncenter" style="width: 391px"><a href="http://www.codigometropoli.com/images/screens/proy1image7.jpg" target="_blank"><img alt="Imagen 2: Interfaz del usuario" src="http://www.codigometropoli.com/images/previews/proy1image7.jpg" title="Imagen 2: Interfaz del usuario" width="381" height="295" /></a><p class="wp-caption-text">Imagen 2: Interfaz del usuario</p></div>
</div>
<p>Al seleccionar la opción "Consultar…" del menú, se mostrará una forma con tres campos de texto, en donde el usuario podrá introducir el nombre, teléfono y correo del cliente que está buscando. Además, en la forma tendremos el botón de <em>Mostrar</em>el cual ejecutará la búsqueda. Los resultados serán mostrados dentro del rectángulo que ves en la parte de abajo de la imagen anterior.</p>
<p>Una vez que el usuario ejecute al búsqueda, si no se encontraron registros que coincidan con los datos buscados, el sistema mostrará dentro del archivo HTML la leyenda "<em>No se encontraron resultados</em>". En caso contrario, el sistema mostrará los resultados de forma similar a la mostrada a continuación:</p>
<div align="center">
<div class="wp-caption aligncenter" style="width: 389px"><a href="http://www.codigometropoli.com/images/screens/proy1image8.jpg" target="_blank"><img alt="Imagen 2: Interfaz del usuario" src="http://www.codigometropoli.com/images/previews/proy1image8.jpg" title="Imagen 3: Resultado de la consulta" width="379" height="267" /></a><p class="wp-caption-text">Imagen 2: Interfaz del usuario</p></div>
</div>
<p>Dicho lo anterior, comenzaremos mostrando la estructura y el código del archivo <em>ConsultaClientes.mxml</em>:</p>
<ul>
<li>El <strong>ID</strong> del <strong>TextInput</strong> Nombre es <em>nombre_txt</em></li>
<li>El <strong>ID</strong> del <strong>TextInput</strong> Correo es <em>correo_txt</em></li>
<li>El <strong>ID</strong> del <strong>TextInput</strong> Teléfono es <em>teléfono_txt</em></li>
<li>El <strong>ID</strong> del componente <strong>HTML</strong> es <em>HTMLLoader</em></li>
</ul>
<p>El código de este  archivo  es el siguiente:</p>
<div class="igBar"><span id="lactionscript-26"><a href="#" onclick="javascript:showPlainTxt('actionscript-26'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-26">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">"1.0"</span> encoding=<span style="color: #ff0000;">"utf-8"</span>?&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:Canvas <span style="color: #0066CC;">show</span>=<span style="color: #ff0000;">"abreConexion();"</span> xmlns:mx=<span style="color: #ff0000;">"http://www.adobe.com/2006/mxml"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100%"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"100%"</span> <span style="color: #0066CC;">backgroundColor</span>=<span style="color: #ff0000;">"#FFFFFF"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Script source=<span style="color: #ff0000;">"../actionscript/ConsultarCliente.as"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"13"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Consulta de Clientes"</span> <span style="color: #0066CC;">right</span>=<span style="color: #ff0000;">"75"</span> <span style="color: #0066CC;">left</span>=<span style="color: #ff0000;">"55"</span> textAlign=<span style="color: #ff0000;">"center"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> fontSize=<span style="color: #ff0000;">"14"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#F64507"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"61"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Mostrar clientes por:"</span> textAlign=<span style="color: #ff0000;">"left"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"151"</span> x=<span style="color: #ff0000;">"31"</span> textDecoration=<span style="color: #ff0000;">"underline"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"89"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Nombre:"</span> textAlign=<span style="color: #ff0000;">"left"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"83"</span> x=<span style="color: #ff0000;">"62"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"119"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Correo:"</span> textAlign=<span style="color: #ff0000;">"left"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"65"</span> x=<span style="color: #ff0000;">"62"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"89"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Teléfono:"</span> textAlign=<span style="color: #ff0000;">"left"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"74"</span> x=<span style="color: #ff0000;">"285"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> x=<span style="color: #ff0000;">"415"</span> y=<span style="color: #ff0000;">"119"</span> label=<span style="color: #ff0000;">"Mostrar"</span> click=<span style="color: #ff0000;">"generaConsulta();"</span>/&gt;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">HTML</span> <span style="color: #0066CC;">focusEnabled</span>=<span style="color: #ff0000;">"false"</span> id=<span style="color: #ff0000;">"HTMLLoader"</span> borderStyle=<span style="color: #ff0000;">"solid"</span> <span style="color: #0066CC;">left</span>=<span style="color: #ff0000;">"31"</span> top=<span style="color: #ff0000;">"171"</span> <span style="color: #0066CC;">right</span>=<span style="color: #ff0000;">"31"</span> bottom=<span style="color: #ff0000;">"21"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"89"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"130"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"nombre_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> x=<span style="color: #ff0000;">"123"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"89"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"130"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"telefono_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> x=<span style="color: #ff0000;">"355"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"119"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"130"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"correo_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> x=<span style="color: #ff0000;">"123"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/mx:Canvas&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Observa en el código anterior que el tag principal de este archivo es <strong>&lt;mx:Canvas&gt;</strong> y no <strong>&lt;mx:WindowedApplication&gt;</strong>, esto es porque todas las interfaces que están dentro del directorio componentes las desplegaremos dentro de la aplicación principal (<em>Sistema_Clientes.mxml</em>); a la propiedad <strong>show</strong> del <strong>Canvas</strong> le estamos especificando que llame a la función  <em>abreConexion() </em>una vez que se haya terminado de mostrar el componente. También observa cómo estamos incluyendo el código de <em>ConsultarCliente.as</em>:</p>
<div class="igBar"><span id="lactionscript-27"><a href="#" onclick="javascript:showPlainTxt('actionscript-27'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-27">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:Script source=<span style="color: #ff0000;">"../actionscript/ConsultarCliente.as"</span>/&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Dentro del código del botón <em>Mostrar</em> hacemos la llamada a la función <em>generaConsulta</em> una vez que el usuario haya hecho click en dicho botón. El código de esta función (<em>generaConsulta</em>) y de la función principal (<em>abreConexion</em>) se encuentra dentro del archivo ConsultarCliente.as:</p>
<div class="igBar"><span id="lactionscript-28"><a href="#" onclick="javascript:showPlainTxt('actionscript-28'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-28">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Importamos todas las librerías y clases que necesitamos. La clase HTMLTags la hice para establecer el código de cada elemento del archivo HTML, así como los estilos que usa dicho archivo; esta clase la veremos más adelante. */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> clases.<span style="color: #006600;">HTMLTags</span>;&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">SQLConnection</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">SQLErrorEvent</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">SQLEvent</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">filesystem</span>.<span style="color: #006600;">File</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">html</span>.<span style="color: #006600;">HTMLLoader</span>;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">/* Es importante establecer el tipo de codficación (encodeType) para que, al momento de escribir y generar el archivo, se muestren los acentos correctamente.&nbsp; */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> _encodeType:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"iso-8859-1"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> conexion:SQLConnection;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> database:File;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> stream:FileStream = <span style="color: #000000; font-weight: bold;">new</span> FileStream<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Declaramos una variable de tipo FileStream para poder crear y escribir en el archivo */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> htmlElements:HTMLTags = <span style="color: #000000; font-weight: bold;">new</span> HTMLTags<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<span style="color: #808080; font-style: italic;">/* Este es un objeto de nuestra clase HTMLTags */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> queryStatement:SQLStatement = <span style="color: #000000; font-weight: bold;">new</span> SQLStatement<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> abreConexion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;database = <span style="color: #000000; font-weight: bold;">new</span> File<span style="color: #66cc66;">&#40;</span>File.<span style="color: #006600;">applicationStorageDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\d</span>atabase<span style="color: #000099; font-weight: bold;">\c</span>lientesDB.sqlite"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;conexion = <span style="color: #000000; font-weight: bold;">new</span> SQLConnection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;conexion.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SQLEvent.<span style="color: #006600;">OPEN</span>, dbAbrirConexion<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;conexion.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SQLErrorEvent.<span style="color: #0066CC;">ERROR</span>, dbErrorConexion<span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;conexion.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span>database<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dbAbrirConexion<span style="color: #66cc66;">&#40;</span>event:SQLEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dbErrorConexion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"No se pudo conectar a la base de datos"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Después de haber importado las librerías necesarias y de haber declarado nuestras variables, escribimos el código de la función <em>abreConexion</em>. Esta función la hemos estado utilizando en las entradas anteriores, por lo que su código no debería causarte ruido.</p>
<p>Antes de ver el código de la función <em>generaConsulta</em>, mostraré el código de la clase HTMLTags:</p>
<div class="igBar"><span id="lactionscript-29"><a href="#" onclick="javascript:showPlainTxt('actionscript-29'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-29">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">package clases</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HTMLTags</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> HTMLTags<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getEndTags<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">'&lt;/body&gt;<span style="color: #000099; font-weight: bold;">\n</span>&lt;/html&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _texto;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getRulerTag<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">'&lt;hr class=&quot;Ruler&quot; /&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _texto;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getFirstTags<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">'&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;head&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-2&quot; /&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;title&gt;Consulta: Tarjetas&lt;/title&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;style&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'body {<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font:Arial, Helvetica, sans-serif;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font-family:Arial, Helvetica, sans-serif;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font-size:12px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;margin-left:30px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'hr.Ruler {<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;margin-left:-20px !important;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;color:#003366;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;border:1px solid #003366;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;background-color:#003366;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;width:800px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'.Estilo3 {<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;color: #993300;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font-weight: bold;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;font-size: 14px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'.Estilo4 {font-size: 12px; color: #666666;}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'.Tabla_Datos td {<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp;height:25px;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'}<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;/style&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;/head&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;body&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _texto;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getTitleTags<span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">name</span>:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">'&lt;br /&gt;&lt;span class=&quot;Estilo3&quot;&gt;'</span> + <span style="color: #0066CC;">name</span> + <span style="color: #ff0000;">'&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _texto;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getTable1Tags<span style="color: #66cc66;">&#40;</span>nombre:<span style="color: #0066CC;">String</span>, direccion:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">'&lt;table class=&quot;Tabla_Datos&quot; width=&quot;700&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &lt;tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;&lt;strong&gt;Nombre:&lt;/strong&gt;&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;'</span> + nombre + <span style="color: #ff0000;">'&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;&lt;strong&gt;Dirección:&lt;/strong&gt;&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;'</span> + direccion + <span style="color: #ff0000;">'&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &lt;/tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _texto;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getTable2Tags<span style="color: #66cc66;">&#40;</span>telefono:<span style="color: #0066CC;">String</span>, correo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> _texto:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">''</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &lt;tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;&lt;strong&gt;Teléfono:&lt;/strong&gt;&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;'</span> + telefono + <span style="color: #ff0000;">'&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;&lt;strong&gt;Correo:&lt;/strong&gt;&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &nbsp; &lt;td&gt;'</span> + correo + <span style="color: #ff0000;">'&lt;/td&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&nbsp; &lt;/tr&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span> +</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'&lt;/table&gt;<span style="color: #000099; font-weight: bold;">\n</span>'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> _texto;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Como pudiste observar en el código anterior, esta clase lo único que hace es regresarnos los tags del documento HTML que vamos a generar. Por ejemplo, la función <em>getFirstTags</em> nos regresa los primeros elementos que debe llevar el archivo HTML (los tags &lt;html&gt;, &lt;head&gt;, &lt;meta&gt; y los estilos que usaremos &lt;style&gt;). La función <em>getTitleTags</em> la mandaremos a llamar cada vez que recorramos un nuevo registro, le pasaremos como parámetro un texto de tipo "Cliente N" donde N es el valor de un contador que pondremos en el código (Cliente #1, Cliente #2, etc.) y nos regresará un texto con los tags y estilo que debe llevar. A la función <em>getTable1Tags</em> le estamos pasando como parámetro el nombre y la dirección del cliente, y ésta a su vez nos está regresando la información en forma de tabla con el código en HTML. Lo mismo sucede con la función <em>getTable2Tags</em>. La función <em>getRulerTag</em> nos regresa el tag &lt;hr&gt; para mostrar una línea horizontal. Por último, la función <em>getEndTags</em> nos regresa un texto con los tags que nos faltaban por cerrar (&lt;/body&gt; y &lt;/html&gt;).</p>
<p>Ahora veremos el código de generaConsulta. Presta atención en los comentarios que se encuentran dentro del código:</p>
<div class="igBar"><span id="lactionscript-30"><a href="#" onclick="javascript:showPlainTxt('actionscript-30'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-30">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> generaConsulta<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> prep:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">" WHERE "</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">clearParameters</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">sqlConnection</span> = conexion;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> genericQuery:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"SELECT * FROM cliente "</span>; <span style="color: #808080; font-style: italic;">/* Seleccionamos todas las columnas del registro */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>nombre_txt.<span style="color: #0066CC;">text</span> != <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">/* Si el usuario sí escribió algo en el campo de texto nombre_txt */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; genericQuery += prep + <span style="color: #ff0000;">" nombre LIKE '%"</span> + nombre_txt.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">"%'"</span>; <span style="color: #808080; font-style: italic;">/* Adjuntamos al query el valor del campo de texto nombre */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prep = <span style="color: #ff0000;">" AND "</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>correo_txt.<span style="color: #0066CC;">text</span> != <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">/* Si el usuario sí escribió algo en el campo de texto correo_txt */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; genericQuery += prep + <span style="color: #ff0000;">" email LIKE '%"</span> + correo_txt.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">"%'"</span>; <span style="color: #808080; font-style: italic;">/* Adjuntamos al query el valor del campo de texto correo */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prep = <span style="color: #ff0000;">" AND "</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>telefono_txt.<span style="color: #0066CC;">text</span> != <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">/* Si el usuario sí escribió algo en el campo de texto telefono_txt */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; genericQuery += prep + <span style="color: #ff0000;">" telefono LIKE '%"</span> + telefono_txt.<span style="color: #0066CC;">text</span> + <span style="color: #ff0000;">"%'"</span>; <span style="color: #808080; font-style: italic;">/* Adjuntamos al query el valor del campo de texto telefono */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prep = <span style="color: #ff0000;">" AND "</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; genericQuery += <span style="color: #ff0000;">" ORDER BY nombre asc"</span>; <span style="color: #808080; font-style: italic;">/* Le especificamos al query que los resultados los ordene de manera ascendente de acuerdo al nombre del cliente */</span>&nbsp;&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #0066CC;">text</span> = genericQuery; <span style="color: #808080; font-style: italic;">// Asignamos la variable del query al SQLStatement</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Ejecutamos la consulta</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Este será el archivo HTML que estamos creando. Su nombre es ConsultaCliente.html y se encontrará dentro de la carpeta HTML */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> htmlFile:File = <span style="color: #000000; font-weight: bold;">new</span> File<span style="color: #66cc66;">&#40;</span>File.<span style="color: #006600;">applicationStorageDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">"/HTML/ConsultaCliente.html"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>stream != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #0066CC;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Cerramos el stream si es que existe */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream = <span style="color: #000000; font-weight: bold;">new</span> FileStream<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span>htmlFile, FileMode.<span style="color: #006600;">WRITE</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Abrimos el stream en modo de escritura */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>IOErrorEvent.<span style="color: #006600;">IO_ERROR</span>, writeIOErrorHandler<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Establecemos un listener para detectar el evento */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> result:SQLResult = queryStatement.<span style="color: #006600;">getResult</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Obtenemos los resultados regresados por la consulta */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>result.<span style="color: #0066CC;">data</span> != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">// Si existen resultados... </span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> numResults:<span style="color: #0066CC;">int</span> = result.<span style="color: #0066CC;">data</span>.<span style="color: #0066CC;">length</span>; <span style="color: #808080; font-style: italic;">// Determinamos el total de resultados regresados</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">writeUTFBytes</span><span style="color: #66cc66;">&#40;</span>htmlElements.<span style="color: #006600;">getFirstTags</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Escribimos en el archivo el texto regresado por la clase HTMLTags en su función getFirstTags */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;color:#800000;">0</span>; i &lt;numResults; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #808080; font-style: italic;">// Hacemos un ciclo para recorrer todos los registros obtenidos</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span>&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> row:<span style="color: #0066CC;">Object</span> = result.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; row.<span style="color: #006600;">nombre</span>;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Esta parte entraría a un ciclo */</span>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">writeMultiByte</span><span style="color: #66cc66;">&#40;</span>htmlElements.<span style="color: #006600;">getTitleTags</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Cliente #"</span> + <span style="color: #66cc66;">&#40;</span>i + <span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>, _encodeType<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">writeMultiByte</span><span style="color: #66cc66;">&#40;</span>htmlElements.<span style="color: #006600;">getTable1Tags</span><span style="color: #66cc66;">&#40;</span>row.<span style="color: #006600;">nombre</span>, row.<span style="color: #006600;">direccion</span><span style="color: #66cc66;">&#41;</span>, _encodeType<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">writeMultiByte</span><span style="color: #66cc66;">&#40;</span>htmlElements.<span style="color: #006600;">getTable2Tags</span><span style="color: #66cc66;">&#40;</span>row.<span style="color: #006600;">telefono</span>, row.<span style="color: #006600;">email</span><span style="color: #66cc66;">&#41;</span>, _encodeType<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stream.<span style="color: #006600;">writeUTFBytes</span><span style="color: #66cc66;">&#40;</span>htmlElements.<span style="color: #006600;">getRulerTag</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Esta parte entraría a un ciclo */</span>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;stream.<span style="color: #006600;">writeUTFBytes</span><span style="color: #66cc66;">&#40;</span>htmlElements.<span style="color: #006600;">getEndTags</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span>&nbsp; &nbsp;&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; stream.<span style="color: #006600;">writeUTFBytes</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"No se encontraron resultados"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;stream.<span style="color: #0066CC;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:SQLError<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error: "</span> + <span style="color: #0066CC;">error</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Si todo salió bien, ahora podremos mostrar el archivo html en nuestro HTMLLoader */</span>&nbsp;&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; HTMLLoader.<span style="color: #006600;">location</span> = File.<span style="color: #006600;">applicationStorageDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">"/HTML/ConsultaCliente.html"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Observa que al final estamos especificando al control <strong>HTML</strong> (cuyo <strong>ID</strong> es <em>HTMLLoader</em>) el archivo HTML que debe mostrar (ConsultaCliente.html dentro de la carpeta HTML).</p>
<p>Hemos llegado al final de esta cuarta parte y de todas las entregas, no olvides bajar los archivos que se encuentran más abajo.</p>
<div align="center" style="margin-top:0px"><script type="text/javascript"><!--
      google_ad_client = "pub-5808310808246221";
      /* 250x250, Posts */
      google_ad_slot = "8254875600";
      google_ad_width = 250;
      google_ad_height = 250;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></div>
<div style="margin-top:30px; margin-bottom:20px;" align="center">
<table border="0" cellspacing="0" cellpadding="0" width="180">
<tbody>
<tr>
<td valign="top"><a href="http://www.megaupload.com/?d=277H67ZZ" target="_blank"><img src="../images/descargar_archivo.jpg" alt="Descargar Archivo" /></a></td>
</tr>
</tbody>
</table>
</div>
<div style="margin-top:40px; margin-bottom:30px;">
<p><strong>Enlaces recomendados:</strong></p>
<p>» <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=SQL_01.html" target="_blank">Working with local SQL databases</a><br />
» <a href="http://livedocs.adobe.com/flex/3/langref/index.html" target="_blank">Adobe® Flex® 3 Language Reference</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.codigometropoli.com/sistema-de-clientes-parte-iv/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Sistema de Clientes (AIR y SQLite) Parte III (Modificar y Eliminar Registros)</title>
		<link>http://www.codigometropoli.com/sistema-de-clientes-parte-iii/</link>
		<comments>http://www.codigometropoli.com/sistema-de-clientes-parte-iii/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 04:15:49 +0000</pubDate>
		<dc:creator>Carla Macías</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Proyectos]]></category>
		<category><![CDATA[Base de datos]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Proyecto]]></category>
		<category><![CDATA[Sistema]]></category>

		<guid isPermaLink="false">http://www.codigometropoli.com/?p=334</guid>
		<description><![CDATA[Esta es la tercera parte del proyecto "Sistema de Clientes" desarrollado en AIR con SQLite como administrador de base de datos. En la entrada anterior vimos cómo insertar registros en la base de datos (clientesDB.sqlite) desde nuestra aplicación en AIR.
En esta ocasión veremos cómo editar y eliminar registros de la base de datos; para esto [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="float: right;" src="http://codigometropoli.com/images/air_sticker.jpg" alt="Adobe AIR" width="93" height="93" />Esta es la tercera parte del proyecto "Sistema de Clientes" desarrollado en AIR con SQLite como administrador de base de datos. En la <a href="http://www.codigometropoli.com/sistema-de-clientes-parte-ii/" target="_blank">entrada</a> anterior vimos cómo insertar registros en la base de datos (<em>clientesDB.sqlite</em>) desde nuestra aplicación en AIR.<br />
En esta ocasión veremos cómo editar y eliminar registros de la base de datos; para esto mostraremos dentro de un DataGrid todos los registros que tenemos en nuestra base de datos; en este DataGrid usaremos <strong>itemRenderer(s)</strong> para llenar con botones dos columnas, uno de los botones será para editar el registro seleccionado y el otro para eliminarlo.</p>
<p><span id="more-334"></span><span style="color: #ff0000;"><strong>Parte 3: Modificar y eliminar registros en SQLite con AIR</strong></span></p>
<p>Recuerda que para mantener organizado el código de nuestro proyecto y para evitar que se pierdan con toda la información aquí mostrada, dividí el código del proyecto en archivos .as. Estos archivos estarán almacenados en la carpeta actionscript. La estructura de nuestro proyecto será la siguiente:</p>
<div align="center">
<div class="wp-caption aligncenter" style="width: 255px"><img title="Imagen 1: Estructura de la aplicación" src="http://www.codigometropoli.com/wp-content/uploads/2008/08/proy1image1.jpg" alt="Imagen 1: Estructura de la aplicación" width="245" height="373" /><p class="wp-caption-text">Imagen 1: Estructura de la aplicación</p></div>
</div>
<p>Todas las interfaces de este proyecto están incluidas en la carpeta componentes. La interfaz que en esta ocasión veremos es la del archivo <em>EditarBorrarCliente.mxml</em>. Esta interfaz funciona de la siguiente manera:</p>
<div align="center">
<div class="wp-caption aligncenter" style="width: 552px"><a href="http://www.codigometropoli.com/images/screens/proy1image4.jpg" target="_blank"><img title="Imagen 2: Interfaz del usuario" src="http://www.codigometropoli.com/images/previews/proy1image4.jpg" alt="Imagen 2: Interfaz del usuario" width="542" height="255" /></a><p class="wp-caption-text">Imagen 2: Interfaz del usuario</p></div>
</div>
<p>Al seleccionar la opción "Editar/Eliminar…" del menú, se mostrará un DataGrid con todos los registros que tenemos dados de alta en nuestra base. En este ejemplo solamente tengo dos registros. Si el usuario hace click al botón de <strong>Modificar</strong> del primer registro, se mostrará lo siguiente:</p>
<div align="center">
<div class="wp-caption aligncenter" style="width: 552px"><a href="http://www.codigometropoli.com/images/screens/proy1image5.jpg" target="_blank"><img title="Imagen 3: Opción Modificar Cliente" src="http://www.codigometropoli.com/images/screens/proy1image5.jpg" alt="Imagen 3: Opción Modificar Cliente" width="542" height="511" /></a><p class="wp-caption-text">Imagen 3: Opción Modificar Cliente</p></div>
</div>
<p>…Un Canvas con los datos de nuestro registro. Si el usuario lo desea, podrá modificar o actualizar los datos de este registro. Por el contrario, si el usuario le da click al botón de <strong>Eliminar</strong> del primer registro, se mostrará un mensaje de alerta pidiéndole que confirme si desea o no borrar el registro.</p>
<div align="center">
<div class="wp-caption aligncenter" style="width: 551px"><a href="http://www.codigometropoli.com/images/screens/proy1image6.jpg" target="_blank"><img title="Imagen 4: Mensaje de confirmación" src="http://www.codigometropoli.com/images/previews/proy1image6.jpg" alt="Imagen 4: Mensaje de confirmación" width="541" height="254" /></a><p class="wp-caption-text">Imagen 4: Mensaje de confirmación</p></div>
</div>
<p>Explicado lo anterior, comenzaremos mostrando la estructura y el código del archivo EditarBorrarCliente.mxml:</p>
<ul>
<li> El <strong>ID</strong> del <strong>DataGrid </strong>donde mostraremos los registros es <em>clientes_dg</em></li>
<li>El <strong>ID </strong>de nuestro <strong>Canvas </strong>en donde mostraremos la información del registro que el usuario puede modificar es <em>Modificar_Cliente</em>
<ul>
<li>El botón de <em>Cambiar</em> que se encuentra dentro del Canvas tiene de <strong>ID </strong><em>guardarBtn</em></li>
<li>El botón con una X tiene de <strong>ID </strong><em>cerrarBtn</em></li>
<li>Los <strong>ID</strong>s de cada una de las áreas de texto son:
<ul>
<li>nombre_txt, direccion_txt (TextArea), telefono_txt, correo_txt</li>
<li>Además, tenemos tres etiquetas cuyo texto es <strong>(*)</strong> y con los cuales le indicaremos al usuario qué dato le faltó por llenar. Estas etiquetas tienen de <strong>ID</strong>: <em>msj1</em>, <em>msj2</em>, <em>msj3</em> y <em>msj4</em>.</li>
</ul>
</li>
</ul>
</li>
</ul>
<p>El código de este  archivo  es el siguiente:</p>
<div class="igBar"><span id="lactionscript-48"><a href="#" onclick="javascript:showPlainTxt('actionscript-48'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-48">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">"1.0"</span> encoding=<span style="color: #ff0000;">"utf-8"</span>?&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:Canvas <span style="color: #0066CC;">show</span>=<span style="color: #ff0000;">"abreConexion();"</span> xmlns:mx=<span style="color: #ff0000;">"http://www.adobe.com/2006/mxml"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100%"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"100%"</span> <span style="color: #0066CC;">backgroundColor</span>=<span style="color: #ff0000;">"#FFFFFF"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Script source=<span style="color: #ff0000;">"../actionscript/EditarBorrarCliente.as"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"13"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Lista de Clientes"</span> <span style="color: #0066CC;">right</span>=<span style="color: #ff0000;">"75"</span> <span style="color: #0066CC;">left</span>=<span style="color: #ff0000;">"55"</span> textAlign=<span style="color: #ff0000;">"center"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> fontSize=<span style="color: #ff0000;">"14"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#F64507"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:DataGrid y=<span style="color: #ff0000;">"57"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"600"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"223"</span> horizontalCenter=<span style="color: #ff0000;">"-14"</span> id=<span style="color: #ff0000;">"clientes_dg"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:columns&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:DataGridColumn <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"150"</span> textAlign=<span style="color: #ff0000;">"left"</span> headerText=<span style="color: #ff0000;">"Nombre"</span> dataField=<span style="color: #ff0000;">"nombre"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:DataGridColumn <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"120"</span> textAlign=<span style="color: #ff0000;">"left"</span> headerText=<span style="color: #ff0000;">"Teléfono"</span> dataField=<span style="color: #ff0000;">"telefono"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:DataGridColumn <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"165"</span> textAlign=<span style="color: #ff0000;">"left"</span> headerText=<span style="color: #ff0000;">"Correo"</span> dataField=<span style="color: #ff0000;">"correo"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:DataGridColumn sortable=<span style="color: #ff0000;">"false"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"85"</span> textAlign=<span style="color: #ff0000;">"center"</span> headerText=<span style="color: #ff0000;">"Modificar"</span> dataField=<span style="color: #ff0000;">"modificar"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:itemRenderer&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Component&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:HBox horizontalAlign=<span style="color: #ff0000;">"center"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">"editarBtn"</span> click=<span style="color: #ff0000;">"outerDocument.editarCliente(data.id_cliente, data.nombre, data.direccion, data.telefono, data.correo)"</span> label=<span style="color: #ff0000;">""</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"20"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"30"</span> icon=<span style="color: #ff0000;">"@Embed(source='../images/edit.png')"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:HBox&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:Component&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:itemRenderer&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:DataGridColumn&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:DataGridColumn sortable=<span style="color: #ff0000;">"false"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"80"</span> textAlign=<span style="color: #ff0000;">"center"</span> headerText=<span style="color: #ff0000;">"Eliminar"</span> dataField=<span style="color: #ff0000;">"eliminar"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:itemRenderer&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Component&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:HBox horizontalAlign=<span style="color: #ff0000;">"center"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">"borrarBtn"</span> click=<span style="color: #ff0000;">"outerDocument.borrarCliente(data.id_cliente)"</span> label=<span style="color: #ff0000;">""</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"20"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"30"</span> icon=<span style="color: #ff0000;">"@Embed(source='../images/remove.png')"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:HBox&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:Component&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:itemRenderer&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:DataGridColumn&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:columns&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/mx:DataGrid&gt;&nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Canvas id=<span style="color: #ff0000;">"Modificar_Cliente"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"true"</span> y=<span style="color: #ff0000;">"324"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"378"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"255"</span> horizontalCenter=<span style="color: #ff0000;">"-15"</span> <span style="color: #0066CC;">borderColor</span>=<span style="color: #ff0000;">"#ADADAD"</span> backgroundAlpha=<span style="color: #ff0000;">"0.0"</span> borderStyle=<span style="color: #ff0000;">"solid"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">"guardarBtn"</span> click=<span style="color: #ff0000;">"validaForma();"</span> y=<span style="color: #ff0000;">"221"</span> label=<span style="color: #ff0000;">"Cambiar"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100"</span> x=<span style="color: #ff0000;">"220"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"10"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Modificar Cliente:"</span> textAlign=<span style="color: #ff0000;">"left"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> fontSize=<span style="color: #ff0000;">"11"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#31384B"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"213"</span> x=<span style="color: #ff0000;">"10"</span> textDecoration=<span style="color: #ff0000;">"underline"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">"cerrarBtn"</span> y=<span style="color: #ff0000;">"1"</span> label=<span style="color: #ff0000;">"X"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"32"</span> x=<span style="color: #ff0000;">"343.3"</span> click=<span style="color: #ff0000;">"Modificar_Cliente.visible = false; reseteaForma();"</span> cornerRadius=<span style="color: #ff0000;">"0"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Text</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> x=<span style="color: #ff0000;">"10"</span> y=<span style="color: #ff0000;">"86"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Por favor introduzca la divisa"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontSize=<span style="color: #ff0000;">"10"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"184"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"33"</span> id=<span style="color: #ff0000;">"msj_nombre"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"50"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"nombre_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> x=<span style="color: #ff0000;">"108"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:TextArea y=<span style="color: #ff0000;">"81"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"69"</span> id=<span style="color: #ff0000;">"direccion_txt"</span> x=<span style="color: #ff0000;">"108"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"161"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"telefono_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> x=<span style="color: #ff0000;">"108"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"190"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"correo_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> x=<span style="color: #ff0000;">"108"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"50"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Nombre:"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"80"</span> textAlign=<span style="color: #ff0000;">"right"</span> x=<span style="color: #ff0000;">"10"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"86"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Dirección:"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"80"</span> textAlign=<span style="color: #ff0000;">"right"</span> x=<span style="color: #ff0000;">"10"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"161"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Teléfono:"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"80"</span> textAlign=<span style="color: #ff0000;">"right"</span> x=<span style="color: #ff0000;">"10"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"190"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Correo:"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"80"</span> textAlign=<span style="color: #ff0000;">"right"</span> x=<span style="color: #ff0000;">"10"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"50"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"(*)"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"27"</span> textAlign=<span style="color: #ff0000;">"left"</span> id=<span style="color: #ff0000;">"msj1"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> horizontalCenter=<span style="color: #ff0000;">"153"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"82"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"(*)"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"27"</span> textAlign=<span style="color: #ff0000;">"left"</span> id=<span style="color: #ff0000;">"msj2"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> horizontalCenter=<span style="color: #ff0000;">"153"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"161"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"(*)"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"27"</span> textAlign=<span style="color: #ff0000;">"left"</span> id=<span style="color: #ff0000;">"msj3"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> horizontalCenter=<span style="color: #ff0000;">"153"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"190"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"(*)"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"27"</span> textAlign=<span style="color: #ff0000;">"left"</span> id=<span style="color: #ff0000;">"msj4"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> horizontalCenter=<span style="color: #ff0000;">"153"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/mx:Canvas&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/mx:Canvas&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Observa en el código anterior que el tag principal de este archivo es <strong>&lt;mx:Canvas&gt; </strong>y no <strong>&lt;mx:WindowedApplication&gt;</strong>, esto es porque todas las interfaces que están dentro del directorio componentes las desplegaremos dentro de la aplicación principal (<em>Sistema_Clientes.mxml</em>); a la propiedad <strong>show </strong>del <strong>Canvas </strong>le estamos especificando que llame a la función  <em>abreConexion()</em> una vez que se haya terminado de mostrar el componente. También observa cómo estamos incluyendo el código de <em>EditarBorrarCliente.as</em>:</p>
<div class="igBar"><span id="lactionscript-49"><a href="#" onclick="javascript:showPlainTxt('actionscript-49'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-49">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:Script source=<span style="color: #ff0000;">"../actionscript/EditarBorrarCliente.as"</span>/&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>También presta atención en la forma en que estamos creando los <strong>renderers </strong>para las columnas.</p>
<div class="igBar"><span id="lactionscript-50"><a href="#" onclick="javascript:showPlainTxt('actionscript-50'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-50">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:DataGridColumn sortable=<span style="color: #ff0000;">"false"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"85"</span> textAlign=<span style="color: #ff0000;">"center"</span> headerText=<span style="color: #ff0000;">"Modificar"</span> dataField=<span style="color: #ff0000;">"modificar"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:itemRenderer&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:Component&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:HBox horizontalAlign=<span style="color: #ff0000;">"center"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">"editarBtn"</span> click=<span style="color: #ff0000;">"outerDocument.editarCliente(data.id_cliente, data.nombre, data.direccion, data.telefono, data.correo)"</span> label=<span style="color: #ff0000;">""</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"20"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"30"</span> icon=<span style="color: #ff0000;">"@Embed(source='../images/edit.png')"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:HBox&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:Component&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/mx:itemRenderer&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/mx:DataGridColumn&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Dentro de los tags  <strong>&lt;mx:itemRenderer&gt; </strong>y  <strong>&lt;/mx:itemRenderer&gt; </strong>estamos usando como <em>layout </em>el <strong>HBox </strong>(HorizontalBox), aunque en realidad no afecta mucho ya que sólo estamos poniendo un componente por cada celda (en caso de que pongamos más elementos en esa celda, estos elementos se mostrarán uno tras otro de izquierda a derecha). El componente que estamos insertando en cada celda es un botón; este botón en el momento de hacer <strong>click</strong> sobre él llamará a la función <em>editarCliente</em>, el cual recibe como parámetros el ID, nombre, dirección, teléfono y correo del cliente en cuyo registro hicimos click. La palabra reservada <strong>outerDocument </strong>nos permite acceder a elementos que se encuentran fueran del alcance del item renderer. Además, al botón le estamos asignando el icono edit.png (<img align="absmiddle" src="http://www.codigometropoli.com/images/screens/edit.png" alt="" width="16" height="16" />) que está dentro de nuestra carpeta <em>images</em>. Importante: Observa cómo a esta columna del DataGrid le estamos especificando que no se pueda ordenar (sortable = false). Esto es porque en realidad no le estamos asignando valor alguno a cada celda, por lo tanto si intentáramos ordenar los registros de acuerdo a esta columna, Flex nos desplegaría un error.</p>
<p>El código para la columna que llevará los botones de <em>Eliminar </em>es el siguiente:</p>
<div class="igBar"><span id="lactionscript-51"><a href="#" onclick="javascript:showPlainTxt('actionscript-51'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-51">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:DataGridColumn sortable=<span style="color: #ff0000;">"false"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"80"</span> textAlign=<span style="color: #ff0000;">"center"</span> headerText=<span style="color: #ff0000;">"Eliminar"</span> dataField=<span style="color: #ff0000;">"eliminar"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:itemRenderer&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Component&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:HBox horizontalAlign=<span style="color: #ff0000;">"center"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">"borrarBtn"</span> click=<span style="color: #ff0000;">"outerDocument.borrarCliente(data.id_cliente)"</span> label=<span style="color: #ff0000;">""</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"20"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"30"</span> icon=<span style="color: #ff0000;">"@Embed(source='../images/remove.png')"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/mx:HBox&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/mx:Component&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/mx:itemRenderer&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/mx:DataGridColumn&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>El código es similar al mostrado más arriba, lo único que cambia es que en esta ocasión el botón mandará a llamar a la función <em>borrarCliente</em>, pasándole como parámetro el ID del cliente. Además, el icono para este botón es remove.png (<img align="absmiddle" src="http://www.codigometropoli.com/images/screens/remove.png" alt="" width="16" height="16" />).</p>
<p>Antes de ver el código de las funciones <em>editarCliente </em>y <em>borrarCliente</em>, veremos cómo mostrar los registros de nuestra base de datos en el DataGrid. Para eso, el código que pegaré a continuación forma parte del archivo <strong>EditarBorrarCliente.as</strong>.</p>
<p>Primero, importamos las clases y declaramos las variables  que necesitamos. En el arreglo <em>data_provider</em> almacenaremos los datos obtenidos de nuestra consulta y lo asignaremos como <strong>dataProvider </strong>de nuestro DataGrid (<em>clientes_dg</em>). La variable <em>id_selected</em> nos servirá para almacenar el ID del registro seleccionado y posteriormente eliminarlo de la base de datos.</p>
<div class="igBar"><span id="lactionscript-52"><a href="#" onclick="javascript:showPlainTxt('actionscript-52'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-52">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #808080; font-style: italic;">// ActionScript file</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">SQLConnection</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">SQLErrorEvent</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">SQLEvent</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">CloseEvent</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">events</span>.<span style="color: #006600;">ListEvent</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> conexion:SQLConnection;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> database:File;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> queryStatement:SQLStatement = <span style="color: #000000; font-weight: bold;">new</span> SQLStatement<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#91;</span>Bindable<span style="color: #66cc66;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> data_provider:<span style="color: #0066CC;">Array</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> id_selected:<span style="color: #0066CC;">Number</span> = <span style="color: #cc66cc;color:#800000;">0</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>La primera función que es llamada en esta sección es <em>abrirConexion</em>:</p>
<div class="igBar"><span id="lactionscript-53"><a href="#" onclick="javascript:showPlainTxt('actionscript-53'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-53">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> abreConexion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; reseteaForma<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Modificar_Cliente.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; reiniciaVariables<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; clientes_dg.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>ListEvent.<span style="color: #006600;">CHANGE</span>, dgChangeHandler<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; database = <span style="color: #000000; font-weight: bold;">new</span> File<span style="color: #66cc66;">&#40;</span>File.<span style="color: #006600;">applicationStorageDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\d</span>atabase<span style="color: #000099; font-weight: bold;">\c</span>lientesDB.sqlite"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion = <span style="color: #000000; font-weight: bold;">new</span> SQLConnection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SQLEvent.<span style="color: #006600;">OPEN</span>, dbAbrirConexion<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SQLErrorEvent.<span style="color: #0066CC;">ERROR</span>, dbErrorConexion<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">sqlConnection</span> = conexion;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span>database<span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Dentro de <em>abreConexion </em>llamamos a la función <em>reseteaForma</em>, la cual se encarga de borrar los datos de la forma para la modificación de los datos.</p>
<div class="igBar"><span id="lactionscript-54"><a href="#" onclick="javascript:showPlainTxt('actionscript-54'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-54">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> reseteaForma<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nombre_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; direccion_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; telefono_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; correo_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; escondeMensajes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Después de llamar a la función <em>reseteaForma</em>, ocultamos el canvas <em>Modificar_Cliente</em> y llamamos a la función <em>reiniciaVariables</em>, la cual se encargará de resetear los arreglos para eliminar su contenido previo.</p>
<div class="igBar"><span id="lactionscript-55"><a href="#" onclick="javascript:showPlainTxt('actionscript-55'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-55">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> reiniciaVariables<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; clientes_dg.<span style="color: #006600;">dataProvider</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp;<span style="color: #808080; font-style: italic;">// Reiniciamos el arreglo para eliminar su contenido</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; data_provider = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Reiniciamos el arreglo para eliminar su contenido&nbsp; &nbsp;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Posteriormente le asignamos al datagrid <em>clientes_dg</em> el listener del evento <strong>CHANGE</strong>. Este evento es lanzado cuando el usuario hace click en alguno de los registros del DataGrid. Cuando se genere este evento, el programa se encargará de esconder el cambas <em>Modificar_Cliente</em> (es posible que previamente el usuario le haya dado click al botón de <span style="text-decoration: underline;">Editar</span> en alguno de los registros, es por eso que nos aseguramos de esconder el Canvas). Además, almacenamos en la vaiable <em>id_selected</em> el <strong>ID</strong> del registro seleccionado; y, por último, escondemos los posibles mensajes que se le mostraron al usuario para que, cuando vuelva a darle click al botón <span style="text-decoration: underline;">Editar</span>, no se le muestren.</p>
<div class="igBar"><span id="lactionscript-56"><a href="#" onclick="javascript:showPlainTxt('actionscript-56'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-56">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dgChangeHandler<span style="color: #66cc66;">&#40;</span>event:ListEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">escondeMensajes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Modificar_Cliente.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; id_selected = event.<span style="color: #0066CC;">target</span>.<span style="color: #006600;">selectedItem</span>.<span style="color: #006600;">id_cliente</span>;&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>El resto del código de la función <em>abreConexion</em> ya lo conoces de las entradas anteriores.<br />
Si no hubo ningún problema en la conexión a la base de datos, llamamos a la función <em>getClientes</em> para llenar el DataGrid con nuestros registros:</p>
<div class="igBar"><span id="lactionscript-57"><a href="#" onclick="javascript:showPlainTxt('actionscript-57'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-57">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dbAbrirConexion<span style="color: #66cc66;">&#40;</span>event:SQLEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; getClientes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> getClientes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">clearParameters</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"SELECT * FROM cliente ORDER BY nombre asc"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> result:SQLResult = queryStatement.<span style="color: #006600;">getResult</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>result.<span style="color: #0066CC;">data</span> != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">var</span> numResults:<span style="color: #0066CC;">int</span> = result.<span style="color: #0066CC;">data</span>.<span style="color: #0066CC;">length</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;color:#800000;">0</span>; i &lt;numResults; i++<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> row:<span style="color: #0066CC;">Object</span> = result.<span style="color: #0066CC;">data</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data_provider.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>nombre:row.<span style="color: #006600;">nombre</span>, id_cliente:row.<span style="color: #006600;">id</span>, direccion:row.<span style="color: #006600;">direccion</span>, correo:row.<span style="color: #006600;">email</span>, telefono:row.<span style="color: #006600;">telefono</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;clientes_dg.<span style="color: #006600;">dataProvider</span> = data_provider;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:SQLError<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error: "</span> + <span style="color: #0066CC;">error</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span>&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Dentro del código de <em>getClientes</em> haremos la consulta a la tabla <span style="text-decoration: underline;">cliente</span> para obtener todos los registros de nuestra base. Nuestro query es muy sencillo, en él estamos seleccionando (SELECT)  todas las columnas (*) de la tabla <em>cliente </em>y le estamos diciendo que lo ordene (ORDER BY) de forma ascendente (asc)  de acuerdo a la columna <em>nombre</em>.</p>
<div class="igBar"><span id="lsql-58"><a href="#" onclick="javascript:showPlainTxt('sql-58'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-58">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> cliente <span style="color: #993333; font-weight: bold;">ORDER</span> <span style="color: #993333; font-weight: bold;">BY</span> nombre <span style="color: #993333; font-weight: bold;">ASC</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Una vez que ejecutamos la consulta (queryStatement.execute()) obtenemos el resultado con la función <em>getResult</em>. Comprobamos que el resultado no sea vacío (result.data!= null) y obtenemos el total de registros obtenidos por medio de la propiedad <em>length</em>. Como ya sabemos cuántos registros nos regresó la consulta, haremos un ciclo <strong>for</strong> para almacenar los registros en nuestro arreglo <em>data_provider</em>. Finalmente estamos asignando el arreglo <em>data_provider</em> a la propiedad <strong>dataProvider </strong>del DataGrid. Importante: Si no comprendes esta parte donde llenamos el arreglo y se lo asignamos al DataGrid te recomiendo visitar la entrada sobre el <a href="http://www.codigometropoli.com/componente-datagrid/" target="_blank">Componente DataGrid</a> que publiqué anteriormente.</p>
<p>Hemos terminado la explicación de cómo realizar la consulta a la base de datos y mostrar los resultados en el DataGrid. Ahora veremos las funciones que habíamos dejado pendientes: <em>editarCliente </em>y <em>borrarCliente</em>.<br />
Como lo mencioné anteriormente, cuando el usuario hace click en el botón de Editar de alguno de los registros, la función <em>editarCliente </em>es llamada:</p>
<div class="igBar"><span id="lactionscript-59"><a href="#" onclick="javascript:showPlainTxt('actionscript-59'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-59">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> editarCliente<span style="color: #66cc66;">&#40;</span>id_cliente:<span style="color: #0066CC;">Number</span>, nombre:<span style="color: #0066CC;">String</span>, direccion:<span style="color: #0066CC;">String</span>, telefono:<span style="color: #0066CC;">String</span>, correo:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; id_selected = id_cliente;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nombre_txt.<span style="color: #0066CC;">text</span> = nombre;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; direccion_txt.<span style="color: #0066CC;">text</span> = direccion;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; telefono_txt.<span style="color: #0066CC;">text</span> = telefono;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; correo_txt.<span style="color: #0066CC;">text</span> = correo;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Modificar_Cliente.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Esta función recibe como parámetros el ID del cliente, su nombre, dirección, teléfono y correo, para posteriormente mostrarlo en el formulario del canvas <em>Modificar_Cliente</em>. Si el usuario hace click en el botón de <em>Cambiar</em>, la función es <em>validaForma </em>es ejecutada:</p>
<div class="igBar"><span id="lactionscript-60"><a href="#" onclick="javascript:showPlainTxt('actionscript-60'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-60">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> validaForma<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; escondeMensajes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>nombre_txt.<span style="color: #0066CC;">text</span> == <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; msj1.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; nombre_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>direccion_txt.<span style="color: #0066CC;">text</span> == <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; msj2.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; direccion_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>telefono_txt.<span style="color: #0066CC;">text</span> == <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; msj3.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; telefono_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>correo_txt.<span style="color: #0066CC;">text</span> == <span style="color: #ff0000;">""</span> || !mail<span style="color: #66cc66;">&#40;</span>correo_txt.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; msj4.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; correo_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; updateCliente<span style="color: #66cc66;">&#40;</span>id_selected<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Esta función es similar a la que usamos en la <a href="http://www.codigometropoli.com/sistema-de-clientes-parte-ii/" target="_blank">entrada</a> anterior, simplemente estamos verificando que todos los datos fueron llenados y, en caso positivo, llamamos a la función <em>updateCliente</em>.</p>
<div class="igBar"><span id="lactionscript-61"><a href="#" onclick="javascript:showPlainTxt('actionscript-61'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-61">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> updateCliente<span style="color: #66cc66;">&#40;</span>idCliente:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">clearParameters</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> sql:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"UPDATE `cliente` SET nombre = :nombre, direccion = :direccion, telefono = :telefono, email = :correo WHERE id = :idCliente"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":nombre"</span><span style="color: #66cc66;">&#93;</span> = nombre_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":direccion"</span><span style="color: #66cc66;">&#93;</span> = direccion_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":telefono"</span><span style="color: #66cc66;">&#93;</span> = telefono_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":correo"</span><span style="color: #66cc66;">&#93;</span> = correo_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":idCliente"</span><span style="color: #66cc66;">&#93;</span> = idCliente;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #0066CC;">text</span> = sql;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; abreConexion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:SQLError<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error: "</span> + <span style="color: #0066CC;">error</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Esta función recibe como parámetro el ID del registro seleccionado, crea el query para actualizar los datos del registro y los nuevos valores son pasados como parámetros a la sentencia SQL. Una vez que se ejecuta la sentencia llamamos nuevamente a la función <em>abreConexion </em>para que muestre todos los registros (incluyendo los nuevos) en el DataGrid.</p>
<p>La función <em>borrarCliente </em>es llamada cuando el usuario hace click en el botón de <em>Eliminar</em>:</p>
<div class="igBar"><span id="lactionscript-62"><a href="#" onclick="javascript:showPlainTxt('actionscript-62'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-62">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> borrarCliente<span style="color: #66cc66;">&#40;</span>id_cliente:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; id_selected = id_cliente;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Alert.<span style="color: #006600;">yesLabel</span> = <span style="color: #ff0000;">"Sí"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Alert.<span style="color: #006600;">noLabel</span> = <span style="color: #ff0000;">"No"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"¿Desea eliminar este cliente?"</span>, <span style="color: #ff0000;">"Importante"</span>, <span style="color: #cc66cc;color:#800000;">3</span>, <span style="color: #0066CC;">this</span>, alertClickHandler<span style="color: #66cc66;">&#41;</span>; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Esta función recibe como parámetro el ID del registro seleccionado por el usuario. Además, muestra un mensaje de alerta pidiéndole al usuario que confirme si desea eliminar el registro. Observa que al método <em>show </em>le pasamos como parámetro el manejador de eventos que debe considerar (<em>alertClickHandler</em>). Este manejador de eventos revisa si la respuesta del usuario fue positiva o negativa. En caso de que el usuario haya hecho click en el botón de Sí, llamamos a la función <em>delCliente </em>pasándole como parámetro el ID del registro seleccionado.</p>
<div class="igBar"><span id="lactionscript-63"><a href="#" onclick="javascript:showPlainTxt('actionscript-63'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-63">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> alertClickHandler<span style="color: #66cc66;">&#40;</span>event:CloseEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>event.<span style="color: #006600;">detail</span> == Alert.<span style="color: #006600;">YES</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; delCliente<span style="color: #66cc66;">&#40;</span>id_selected<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>La función <em>delCliente </em>se encarga de ejecutar el query para borrar el registro de la base de datos. A este query le estamos pasando el ID del registro que hay que eliminar. Después de ejecutar la sentencia llamamos nuevamente a la función <em>abreConexion </em>para mostrar todos los registros restantes de la base de datos en el DataGrid.</p>
<div class="igBar"><span id="lactionscript-64"><a href="#" onclick="javascript:showPlainTxt('actionscript-64'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-64">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> delCliente<span style="color: #66cc66;">&#40;</span>id_cliente:<span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">clearParameters</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"DELETE FROM cliente WHERE id = :id_cliente"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":id_cliente"</span><span style="color: #66cc66;">&#93;</span> = id_cliente;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; abreConexion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:SQLError<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error: "</span> + <span style="color: #0066CC;">error</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Hemos llegado al final de esta tercera parte; ya nada más nos queda pendiente la cuarta y última entrega.</p>
<div align="center" style="margin-top:0px"><script type="text/javascript"><!--
      google_ad_client = "pub-5808310808246221";
      /* 250x250, Posts */
      google_ad_slot = "8254875600";
      google_ad_width = 250;
      google_ad_height = 250;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></div>
<div style="margin-top:40px; margin-bottom:30px;">
<p><strong>Enlaces recomendados:</strong></p>
<p>» <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=SQL_01.html" target="_blank">Working with local SQL databases</a><br />
» <a href="http://livedocs.adobe.com/flex/3/langref/index.html" target="_blank">Adobe® Flex® 3 Language Reference</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.codigometropoli.com/sistema-de-clientes-parte-iii/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Sistema de Clientes (AIR y SQLite) Parte II (Insertar Registros)</title>
		<link>http://www.codigometropoli.com/sistema-de-clientes-parte-ii/</link>
		<comments>http://www.codigometropoli.com/sistema-de-clientes-parte-ii/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 16:47:38 +0000</pubDate>
		<dc:creator>Carla Macías</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Proyectos]]></category>
		<category><![CDATA[Base de datos]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Proyecto]]></category>
		<category><![CDATA[Sistema]]></category>

		<guid isPermaLink="false">http://www.codigometropoli.com/?p=312</guid>
		<description><![CDATA[Esta es la segunda parte del proyecto "Sistema de Clientes" desarrollado en AIR con SQLite como administrador de base de datos. En la entrada anterior vimos cómo crear la base de datos (clientesDB.sqlite), y cómo llenar con algunos registros por default la tabla cliente.
Esta entrada forma parte de un proyecto y los archivos de éste [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="float: right;" src="http://codigometropoli.com/images/air_sticker.jpg" alt="Adobe AIR" width="93" height="93" />Esta es la segunda parte del proyecto "Sistema de Clientes" desarrollado en AIR con SQLite como administrador de base de datos. En la <a href="http://www.codigometropoli.com/sistema-de-clientes-parte-i/" target="_blank">entrada</a> anterior vimos cómo crear la base de datos (<em>clientesDB.sqlite</em>), y cómo llenar con algunos registros por default la tabla cliente.<br />
Esta entrada forma parte de un proyecto y los archivos de éste los encontrarás cuando termine de publicar todas las partes (entradas). Recuerda que para este proyecto estamos usando Flex Builder 3, del cual puedes bajarte una versión de prueba del Flex Builder 3 <a href="https://www.adobe.com/cfusion/tdrc/index.cfm?product=flex" target="_blank">aquí</a>.<br />
<span id="more-312"></span></p>
<p>Como lo comenté en el post <a href="http://www.codigometropoli.com/sistema-de-clientes-parte-i/" target="_blank">anterior </a>, aquí mostraré solamente la información más importante y sobre la cual trata el tema, sin embargo el archivo fuente del proyecto está completo y tiene integrado todo lo que se mostrará en esta entrada, la <a href="http://www.codigometropoli.com/sistema-de-clientes-parte-i/" target="_blank">anterior</a> y en las siguientes, para así formar un proyecto completo. Dicho lo anterior, a continuación iniciaré la explicación sobre cómo insertar registros en una base SQLite.</p>
<p><span style="color: #ff0000;"><strong>Parte 2: Insertar registros en SQLite con AIR</strong></span></p>
<p>Recuerda que para mantener organizado el código de nuestro proyecto y para evitar que se pierdan con toda la información aquí mostrada, dividí el código del proyecto en archivos .as. Estos archivos estarán almacenados en la carpeta <em>actionscript</em>. La estructura de nuestro proyecto será la siguiente:</p>
<div align="center">
<div id="attachment_270" class="wp-caption aligncenter" style="width: 255px"><a href="http://www.codigometropoli.com/wp-content/uploads/2008/08/proy1image1.jpg"><img class="size-full wp-image-270" title="proy1image1" src="http://www.codigometropoli.com/wp-content/uploads/2008/08/proy1image1.jpg" alt="Imagen 1" width="245" height="373" /></a><p class="wp-caption-text">Imagen 1</p></div></div>
<p>Todas las interfaces de este proyecto están incluidas en la carpeta <em>componentes</em>. La interfaz para dar de alta un nuevo cliente está en el archivo <em>AltaCliente.mxml</em>. Esta interfaz será la siguiente:</p>
<div align="center"><div id="attachment_270" class="wp-caption aligncenter" style="width: 344px"><a href="http://www.codigometropoli.com/images/screens/proy1image3.jpg"><img class="size-full wp-image-270" title="proy1image1" src="http://www.codigometropoli.com/images/screens/proy1image3.jpg" alt="Imagen 1" width="334" height="274" /></a><p class="wp-caption-text">Imagen 2</p></div></div>
<p>Los IDs de cada uno de estos elementos son:</p>
<ul>
<li> nombre_txt</li>
<li>dirección_txt</li>
<li>telefono_txt</li>
<li>correo_txt</li>
</ul>
<p>El código del archivo <em>AltaCliente.mxml</em> es el siguiente:</p>
<div class="igBar"><span id="lactionscript-73"><a href="#" onclick="javascript:showPlainTxt('actionscript-73'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-73">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">"1.0"</span> encoding=<span style="color: #ff0000;">"utf-8"</span>?&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:Canvas <span style="color: #0066CC;">show</span>=<span style="color: #ff0000;">"abreConexion()"</span> xmlns:mx=<span style="color: #ff0000;">"http://www.adobe.com/2006/mxml"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100%"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"100%"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Script source=<span style="color: #ff0000;">"../actionscript/AltaCliente.as"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"16"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Alta de Clientes"</span> textAlign=<span style="color: #ff0000;">"center"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> fontSize=<span style="color: #ff0000;">"14"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#F64507"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> horizontalCenter=<span style="color: #ff0000;">"48"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"57"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"nombre_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> horizontalCenter=<span style="color: #ff0000;">"48"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:TextArea y=<span style="color: #ff0000;">"88"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"69"</span> id=<span style="color: #ff0000;">"direccion_txt"</span> horizontalCenter=<span style="color: #ff0000;">"48"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"168"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"telefono_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> horizontalCenter=<span style="color: #ff0000;">"48"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:TextInput y=<span style="color: #ff0000;">"197"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"212"</span> <span style="color: #0066CC;">height</span>=<span style="color: #ff0000;">"21"</span> id=<span style="color: #ff0000;">"correo_txt"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> horizontalCenter=<span style="color: #ff0000;">"48"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"57"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Nombre:"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"101"</span> textAlign=<span style="color: #ff0000;">"right"</span> horizontalCenter=<span style="color: #ff0000;">"-127"</span>/&gt;&nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"93"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Dirección:"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"101"</span> textAlign=<span style="color: #ff0000;">"right"</span> horizontalCenter=<span style="color: #ff0000;">"-127"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"168"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Teléfono:"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"101"</span> textAlign=<span style="color: #ff0000;">"right"</span> horizontalCenter=<span style="color: #ff0000;">"-127"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"197"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"Correo:"</span> fontSize=<span style="color: #ff0000;">"12"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"normal"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#000000"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"101"</span> textAlign=<span style="color: #ff0000;">"right"</span> horizontalCenter=<span style="color: #ff0000;">"-127"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:<span style="color: #0066CC;">Button</span> y=<span style="color: #ff0000;">"230"</span> label=<span style="color: #ff0000;">"Aceptar"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100"</span> horizontalCenter=<span style="color: #ff0000;">"104"</span> click=<span style="color: #ff0000;">"{validaForma();}"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"57"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"(*)"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"27"</span> textAlign=<span style="color: #ff0000;">"left"</span> id=<span style="color: #ff0000;">"msj1"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> horizontalCenter=<span style="color: #ff0000;">"171"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"89"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"(*)"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"27"</span> textAlign=<span style="color: #ff0000;">"left"</span> id=<span style="color: #ff0000;">"msj2"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> horizontalCenter=<span style="color: #ff0000;">"171"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"168"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"(*)"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"27"</span> textAlign=<span style="color: #ff0000;">"left"</span> id=<span style="color: #ff0000;">"msj3"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> horizontalCenter=<span style="color: #ff0000;">"171"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;mx:Label y=<span style="color: #ff0000;">"197"</span> <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">"(*)"</span> fontSize=<span style="color: #ff0000;">"10"</span> fontFamily=<span style="color: #ff0000;">"Verdana"</span> fontWeight=<span style="color: #ff0000;">"bold"</span> <span style="color: #0066CC;">color</span>=<span style="color: #ff0000;">"#B80808"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"27"</span> textAlign=<span style="color: #ff0000;">"left"</span> id=<span style="color: #ff0000;">"msj4"</span> <span style="color: #0066CC;">visible</span>=<span style="color: #ff0000;">"false"</span> horizontalCenter=<span style="color: #ff0000;">"171"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/mx:Canvas&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Observa en el código anterior que el tag principal de este archivo es  <strong>&lt;mx:Canvas&gt;</strong> y no <strong>&lt;mx:WindowedApplication&gt;</strong>, esto es porque todas las interfaces que están dentro del directorio <em>componentes </em>las desplegaremos dentro de la aplicación principal (<em>Sistema_Clientes.mxml</em>); a la propiedad <strong>show </strong>del <strong>Canvas </strong>le estamos especificando que llame a la función  <em>abreConexion()</em> una vez que se haya terminado de mostrar el componente. También observa cómo estamos incluyendo el código de <em>AltaCliente.as</em>:</p>
<div class="igBar"><span id="lactionscript-74"><a href="#" onclick="javascript:showPlainTxt('actionscript-74'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-74">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:Script source=<span style="color: #ff0000;">"../actionscript/AltaCliente.as"</span>/&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Otro punto importante a destacar del código anterior es el botón que tiene de etiqueta “Aceptar”, cuando se produce un click en este botón llamaremos a la función <em>validaForma()</em> para asegurarnos que todos los datos requeridos sean llenados.</p>
<div class="igBar"><span id="lactionscript-75"><a href="#" onclick="javascript:showPlainTxt('actionscript-75'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-75">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;mx:<span style="color: #0066CC;">Button</span> y=<span style="color: #ff0000;">"230"</span> label=<span style="color: #ff0000;">"Aceptar"</span> <span style="color: #0066CC;">width</span>=<span style="color: #ff0000;">"100"</span> horizontalCenter=<span style="color: #ff0000;">"104"</span> click=<span style="color: #ff0000;">"{validaForma();}"</span>/&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>A continuación está la explicación del código del archivo <strong>AltaCliente.as</strong>:</p>
<div class="igBar"><span id="lactionscript-76"><a href="#" onclick="javascript:showPlainTxt('actionscript-76'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-76">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">SQLConnection</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">SQLErrorEvent</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">SQLEvent</span>;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>; <span style="color: #808080; font-style: italic;">/* Haremos uso de los mensajes de alerta, por lo que de una vez añadimos la clase */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> conexion:SQLConnection; <span style="color: #808080; font-style: italic;">// Nuestro objeto de la clase SQLConnection</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> database:File; <span style="color: #808080; font-style: italic;">/* Aquí guardaremos la referencia de nuestro archivo .sqlite que es nuestra base de datos */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> queryStatement:SQLStatement = <span style="color: #000000; font-weight: bold;">new</span> SQLStatement<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Creamos una variable de tipo SQLStatement en la cual estableceremos los queries y parámetros de nuestras consultas */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> abreConexion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nombre_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; database = <span style="color: #000000; font-weight: bold;">new</span> File<span style="color: #66cc66;">&#40;</span>File.<span style="color: #006600;">applicationStorageDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\d</span>atabase<span style="color: #000099; font-weight: bold;">\c</span>lientesDB.sqlite"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion = <span style="color: #000000; font-weight: bold;">new</span> SQLConnection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SQLEvent.<span style="color: #006600;">OPEN</span>, dbAbrirConexion<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SQLErrorEvent.<span style="color: #0066CC;">ERROR</span>, dbErrorConexion<span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span>database<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">sqlConnection</span> = conexion;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Del código anterior, las seis primeras líneas no cambian en nada con respecto al código mostrado en el primer post. Cuando se llame la función <em>abreConexion</em> posicionaremos el cursor dentro del campo de texto nombre_txt, establecemos cuál es el archivo de la base de datos e intentamos abrirla; si existiera algún error es llamada la función dbErrorConexion; en caso contrario, es llamada la función dbErrorConexion.</p>
<p>En esta ocasión, la función <strong>abreConexion</strong> será llamada desde la intefaz que mostré más arriba (desde el archivo <em>AltaCliente.mxml</em>).</p>
<p>Como lo señalé más arriba, una vez que el usuario introduzca los datos y haga click en el botón de Aceptar, la función <em>validaForma()</em> será llamada, el código de esta función te lo presento a continuación:</p>
<div class="igBar"><span id="lactionscript-77"><a href="#" onclick="javascript:showPlainTxt('actionscript-77'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-77">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> validaForma<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; escondeMensajes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>nombre_txt.<span style="color: #0066CC;">text</span> == <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; msj1.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; nombre_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>direccion_txt.<span style="color: #0066CC;">text</span> == <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; msj2.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; direccion_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>telefono_txt.<span style="color: #0066CC;">text</span> == <span style="color: #ff0000;">""</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; msj3.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; telefono_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>correo_txt.<span style="color: #0066CC;">text</span> == <span style="color: #ff0000;">""</span> || !mail<span style="color: #66cc66;">&#40;</span>correo_txt.<span style="color: #0066CC;">text</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; msj4.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; correo_txt.<span style="color: #0066CC;">setFocus</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; compruebaCliente<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Dentro del código de <em>AltaCliente.mxml</em> están unas etiquetas con IDs <em>msj1</em>, <em>msj2</em>, <em>msj3</em>, etc. y cuyo texto es <strong>(*)</strong>; estas etiquetas nos permitirán mostrarle al usuario qué información le faltó por llenar. Como su nombre lo indica, la función <em>escondeMensajes</em> se encarga de "esconder" (visible = false) éstos mensajes y así mostrar solamente los que son necesarios.</p>
<p>En este ejemplo, tenemos cuatro sentencias <em>if</em> encargadas de verificar que la información en los campos de texto <em>nombre_txt</em>, <em>dirección_txt</em>, <em>telefono_txt</em> y <em>correo_txt</em> sean distintos de vacío. Además, nos aseguramos que el formato del correo electrónico sea correcto creando la función mail.</p>
<p>Finalmente, si ninguna de las cuatro condicionales <em>if</em> se cumple (es decir, toda la información requerida fue introducida) llamamos a la función <em>compruebaCliente</em> y verificar si el correo electrónico proporcionado ya existe en la base de datos.</p>
<p>A continuación, te muestro el código de las funciones <em>escondeMensajes</em>, <em>mail</em> y <em>compruebaCliente</em>:</p>
<div class="igBar"><span id="lactionscript-78"><a href="#" onclick="javascript:showPlainTxt('actionscript-78'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-78">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> escondeMensajes<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; msj1.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; msj2.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; msj3.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; msj4.<span style="color: #0066CC;">visible</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> mail<span style="color: #66cc66;">&#40;</span>email:<span style="color: #0066CC;">String</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">Boolean</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> res:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>email.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"@"</span><span style="color: #66cc66;">&#41;</span>&gt;<span style="color: #cc66cc;color:#800000;">0</span> &amp;&amp; email.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"@"</span><span style="color: #66cc66;">&#41;</span> == email.<span style="color: #0066CC;">lastIndexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"@"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>email.<span style="color: #0066CC;">lastIndexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"."</span><span style="color: #66cc66;">&#41;</span>&gt;email.<span style="color: #0066CC;">indexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"@"</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; email.<span style="color: #0066CC;">lastIndexOf</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"."</span><span style="color: #66cc66;">&#41;</span>&lt;email.<span style="color: #006600;">length</span>-<span style="color: #cc66cc;color:#800000;">1</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; res = <span style="color: #000000; font-weight: bold;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">return</span> res;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> compruebaCliente<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> correo:<span style="color: #0066CC;">String</span> = correo_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">clearParameters</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">"SELECT 1 FROM cliente WHERE email = :correo LIMIT 1"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":correo"</span><span style="color: #66cc66;">&#93;</span> = correo;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; query.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> result:SQLResult = query.<span style="color: #006600;">getResult</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>result.<span style="color: #0066CC;">data</span> != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Esa cuenta de correo ya existe"</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;insertaCliente<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:SQLError<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error: “ + error.toString());</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">&nbsp; &nbsp; }&nbsp; &nbsp;&nbsp; &nbsp;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #ff0000;">} </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Observa que dentro de la función <em>compruebaCliente</em> estamos declarando la variable <em>correo</em> y asignándole el valor del cuadro de texto <em>correo_txt</em>. Esta variable la pasaremos como parámetro a la consulta para verificar que esa cuenta de correo electrónico no exista en la base de datos. Con la función <strong>clearParameters</strong> de nuestro objeto <strong>SQLStatement</strong> estamos eliminando los posibles parámetros que hayamos asignado con anterioridad, de no hacer esto el programa generará un error indicándonos que la cantidad de parámetros establecidos en el query no concuerda con los parámetros del <strong>SQLStatement</strong>. A esta variable le indicamos a su propiedad <em>text</em> el <em>query</em> o la consulta que debe realizar. Además, le especificamos (dentro del query) que llevará el parámetro <em>:correo</em> y le asignamos a ese parámetro el valor de la variable <em>correo</em>.<br />
Por último, realizamos la ejecución de la consulta y verificamos si el resultado obtenido es distinto de vacío (nulo – null). Si el resultado es distinto de vacío quiere decir que sí existe un registro con esa cuenta de correo y por lo tanto mostramos un mensaje de alerta informándole al usuario; en caso contrario, llamamos a la función <em>insertaCliente()</em>:</p>
<div class="igBar"><span id="lactionscript-79"><a href="#" onclick="javascript:showPlainTxt('actionscript-79'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-79">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> insertaCliente<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> sql:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"INSERT INTO `cliente` (nombre, direccion, telefono, email)"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; sql += <span style="color: #ff0000;">" VALUES (:nombre, :direccion, :telefono, :email) "</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">clearParameters</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":nombre"</span><span style="color: #66cc66;">&#93;</span> = nombre_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":direccion"</span><span style="color: #66cc66;">&#93;</span> = direccion_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":telefono"</span><span style="color: #66cc66;">&#93;</span> = telefono_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":email"</span><span style="color: #66cc66;">&#93;</span> = correo_txt.<span style="color: #0066CC;">text</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #0066CC;">text</span> = sql;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Sus datos han sido almacenados"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; restableceForma<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:SQLError<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error: "</span> + <span style="color: #0066CC;">error</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Creamos la variable sql y le asignamos un string con nuestra consulta y los parámetros que recibirá (recuerda que los parámetros son especificados con dos puntos - : -). Llamamos a la función <strong>clearParameters</strong> y posteriormente le asignamos al <strong>SQLStatement</strong> los valores de los cuatro parámetros (estos valores son obtenidos de nuestros campos de texto).  Ejecutamos la sentencia, le mostramos un mensaje al usuario informándole que sus datos han sido almacenados y por último llamamos a la función <em>restableceForma</em> para borrar la información de los campos de texto.</p>
<div class="igBar"><span id="lactionscript-80"><a href="#" onclick="javascript:showPlainTxt('actionscript-80'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-80">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> restableceForma<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; nombre_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; direccion_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; telefono_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; correo_txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">""</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Hemos llegado al final de esta segunda parte. Si te perdiste la primera <a href="http://www.codigometropoli.com/sistema-de-clientes-parte-i/" target="_blank">parte</a> de este tutorial, te recuerdo que…  como recomendación y para que te asegures de que tu base de datos, la tabla y el registro fueron creados, puedes bajar el complemento para Firefox llamado <a href="https://addons.mozilla.org/es-ES/firefox/addon/5817" target="_blank"><strong>SQLite Manager</strong></a>, el cual es un pequeño y simple administrador de bases SQLite.</p>
<div align="center" style="margin-top:0px"><script type="text/javascript"><!--
      google_ad_client = "pub-5808310808246221";
      /* 250x250, Posts */
      google_ad_slot = "8254875600";
      google_ad_width = 250;
      google_ad_height = 250;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></div>
<div style="margin-top:40px; margin-bottom:30px;"><strong>Enlaces recomendados:</strong><br />
<br />
» <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=SQL_01.html" target="_blank">Working with local SQL databases</a><br />
» <a href="http://livedocs.adobe.com/flex/3/langref/index.html" target="_blank">Adobe® Flex® 3 Language Reference</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.codigometropoli.com/sistema-de-clientes-parte-ii/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Sistema de Clientes (AIR y SQLite) Parte I (Crear Base de datos)</title>
		<link>http://www.codigometropoli.com/sistema-de-clientes-parte-i/</link>
		<comments>http://www.codigometropoli.com/sistema-de-clientes-parte-i/#comments</comments>
		<pubDate>Tue, 26 Aug 2008 01:01:32 +0000</pubDate>
		<dc:creator>Carla Macías</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[Proyectos]]></category>
		<category><![CDATA[Base de datos]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Proyecto]]></category>
		<category><![CDATA[Sistema]]></category>

		<guid isPermaLink="false">http://www.codigometropoli.com/?p=269</guid>
		<description><![CDATA[Esta es la primera parte del proyecto "Sistema de Clientes" desarrollado en AIR con SQLite como administrador de base de datos. Para este proyecto usaremos Flex Builder 3, del cual puedes bajarte una versión de prueba del Flex Builder 3 aquí. Si requieres más información sobre qué es AIR y qué puedes hacer con él [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" style="float: right;" src="http://codigometropoli.com/images/air_sticker.jpg" alt="Adobe AIR" width="93" height="93" />Esta es la primera parte del proyecto "Sistema de Clientes" desarrollado en AIR con SQLite como administrador de base de datos. Para este proyecto usaremos Flex Builder 3, del cual puedes bajarte una versión de prueba del Flex Builder 3 <a href="https://www.adobe.com/cfusion/tdrc/index.cfm?product=flex" target="_blank">aquí</a>. Si requieres más información sobre qué es AIR y qué puedes hacer con él visita esta entrada. Los archivos de este proyecto los encontrarás al terminar de publicar todas las partes (entradas) de este proyecto.<br />
<span id="more-269"></span><br />
Para este proyecto, abre Flex Builder 3 y crea un nuevo proyecto de AIR (File -&gt; New -&gt; Flex Project. Como nombre de proyecto (Project name) ponle <strong>Sistema_Clientes</strong>; en la sección de <em>Application type</em> selecciona la opción <strong>Desktop application</strong> (runs in Adobe AIR) y haz click en el botón <em>Finish</em>.<br />
Como lo comenté en la sección de <a href="http://www.codigometropoli.com/proyectos/">Proyectos</a>, aquí mostraré solamente la información más importante y sobre la cual trata el tema, sin embargo el archivo fuente del proyecto está completo y tiene integrado todo lo que se mostrará en esta entrada y en las siguientes, para así formar un proyecto completo. Dicho lo anterior, a continuación iniciaré la explicación sobre cómo crear una base de datos en SQLite.</p>
<p><span style="color: #ff0000;"><strong>Parte 1: Crear Base de Datos en SQLite con AIR<br />
</strong></span><br />
Para mantener organizado el código de nuestro proyecto y para evitar que se pierdan con toda la información aquí mostrada, vamos a dividir el código del proyecto en archivos .as. Estos archivos estarán almacenados en la carpeta <em>actionscript</em>. La estructura de nuestro proyecto será la siguiente:</p>
<div align="center"><div id="attachment_270" class="wp-caption aligncenter" style="width: 255px"><a href="http://www.codigometropoli.com/wp-content/uploads/2008/08/proy1image1.jpg"><img class="size-full wp-image-270" title="proy1image1" src="http://www.codigometropoli.com/wp-content/uploads/2008/08/proy1image1.jpg" alt="Imagen 1" width="245" height="373" /></a><p class="wp-caption-text">Imagen 1</p></div></div>
<p>Comenzamos con el archivo <strong>CrearBaseDatos</strong>.as:</p>
<p>Necesitamos de las siguientes librerías para poder tener acceso a los métodos de conexión con la base de datos, la ejecución de los queries, etc. Las clases que usaremos son SQLConnection, SQLErrorEvent y SQL Event:</p>
<div class="igBar"><span id="lactionscript-88"><a href="#" onclick="javascript:showPlainTxt('actionscript-88'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-88">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">data</span>.<span style="color: #006600;">SQLConnection</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">SQLErrorEvent</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">events</span>.<span style="color: #006600;">SQLEvent</span>;&nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">controls</span>.<span style="color: #006600;">Alert</span>; <span style="color: #808080; font-style: italic;">/* Haremos uso de los mensajes de alerta, por lo que de una vez añadimos la clase */</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Ahora vamos a crear los objetos de estas clases y las variables que requeriremos a lo largo de este archivo:</p>
<div class="igBar"><span id="lactionscript-89"><a href="#" onclick="javascript:showPlainTxt('actionscript-89'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-89">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> conexion:SQLConnection; <span style="color: #808080; font-style: italic;">// Nuestro objeto de la clase SQLConnection</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> database:File; <span style="color: #808080; font-style: italic;">/* Aquí guardaremos la referencia de nuestro archivo .sqlite que es nuestra base de datos */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> existeBD:<span style="color: #0066CC;">Boolean</span> = <span style="color: #000000; font-weight: bold;">false</span>; <span style="color: #808080; font-style: italic;">/* Variable booleana en la cual guardaremos el valor de true si existe la base de datos y false en caso contrario */</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">var</span> queryStatement:SQLStatement = <span style="color: #000000; font-weight: bold;">new</span> SQLStatement<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Creamos una variable de tipo SQLStatement en la cual estableceremos los queries y parámetros de nuestras consultas */</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Para crear las sentencias de SQL, necesitamos de un objeto de la clase <strong>SQLStatement</strong>, a este objeto lo llamamos <em>queryStatement</em>.</p>
<p>La función <strong>abreConexion </strong>(que mostraremos a continuación) será llamada desde la aplicación principal, es decir desde el archivo <em>Sistema_Clientes.mxml</em> (recuerda que al crear un nuevo proyecto, Flex Builder construye automáticamente un archivo MXML con el nombre del proyecto y el cual es el punto de partida de nuestra aplicación). Esta función se encargará de verificar si existe la base de datos la cual la pasamos como parámetro del constructor de la clase <strong>File</strong>.  Si no existiera la base de datos la aplicación se encargará de crearla. En caso contrario, se establecería la conexión con la base de datos.  El nombre de nuestra base de datos será <strong>clientesDB.sqlite</strong>, presta atención a la primera línea de nuestra función:</p>
<div class="igBar"><span id="lactionscript-90"><a href="#" onclick="javascript:showPlainTxt('actionscript-90'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-90">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> abreConexion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Asignamos a nuestra variable database el archivo de nuestra base de datos */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; database = <span style="color: #000000; font-weight: bold;">new</span> File<span style="color: #66cc66;">&#40;</span>File.<span style="color: #006600;">applicationStorageDirectory</span>.<span style="color: #006600;">nativePath</span> + <span style="color: #ff0000;">"<span style="color: #000099; font-weight: bold;">\d</span>atabase<span style="color: #000099; font-weight: bold;">\c</span>lientesDB.sqlite"</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Inicializamos nuestra variable conexion */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion = <span style="color: #000000; font-weight: bold;">new</span> SQLConnection<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Creamos el listener que será llamado cuando se abra la conexión a la base de datos */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conexion.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SQLEvent.<span style="color: #006600;">OPEN</span>, dbAbrirConexion<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Creamos el listener que será llamado cuando exista algún error en la conexión a la bd */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">conexion.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>SQLErrorEvent.<span style="color: #0066CC;">ERROR</span>, dbErrorConexion<span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">queryStatement.<span style="color: #006600;">sqlConnection</span> = conexion; <span style="color: #808080; font-style: italic;">/* Le asignamos a su propiedad sqlConnection la variable conexion que creamos al inicio del archivo&nbsp; */</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>!database.<span style="color: #006600;">exists</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">// Comprobamos si existe o no la base de datos</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; existeBD = <span style="color: #000000; font-weight: bold;">false</span>; <span style="color: #808080; font-style: italic;">// No existe la bd, por lo tanto le asignamos a existeBD el valor de falso</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; conexion.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span>database<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Abrimos la conexión a la bd&nbsp; &nbsp; &nbsp; &nbsp; </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; conexion.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span>database<span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Abrimos la conexión a la bd</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span>&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Observa que al constructor de la clase <strong>File </strong>le estamos pasando como parámetro el URL de donde estará almacenada nuestra base de datos. Para construir este URL estamos usando la propiedad <strong>applicationStorageDirectory</strong>, la cual hace referencia al directorio privado donde se encuentra la aplicación. Además, estamos usando la propiedad <strong>nativePath </strong>la cual nos regresa la ruta completa de acuerdo al sistema operativo donde se encuentra el sistema. A grandes rasgos, esta línea crea un directorio con el nombre de la aplicación (en este caso el directorio se llama <strong>Sistema_Clientes</strong>) dentro de la carpeta de Application Data (Datos de programa). Esta carpeta es donde los programas que tenemos instalados guardan información o las preferencias del usuario de la computadora. En Windows Vista, el directorio donde está almacenada la base de datos es C:\Users\Nombre_Usuario\AppData\Roaming\Sistema_Clientes. En Windows XP, el directorio es: C:\Documents and Settings\Nombre_Usuario\Datos de programa\Sistema_Clientes.</p>
<p>Al hacer la llamada a la función <strong>open</strong>, la función <strong>dbAbrirConexion </strong>será llamada en caso de que no exista error; en caso contrario la función <strong>dbErrorConexion </strong>será llamada. El código de estas funciones se muestra a continuación:</p>
<div class="igBar"><span id="lactionscript-91"><a href="#" onclick="javascript:showPlainTxt('actionscript-91'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-91">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dbAbrirConexion<span style="color: #66cc66;">&#40;</span>event:SQLEvent<span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>&nbsp;&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>!existeBD<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #808080; font-style: italic;">/* Si no existe la base de datos, llamamos a la función createTBLCliente */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; createTBLCliente<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> dbErrorConexion<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"No se pudo conectar a la base de datos"</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">/* Mostramos un mensaje de error*/</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Nuestra base de datos estará conformada por solamente una tabla (sólo para fines del ejercicio, ya que no es común que una base de datos esté formada por sólo una tabla). Nuestra tabla se llama <strong>cliente </strong>y sus elementos son los siguientes:</p>
<div align="center"><div id="attachment_272" class="wp-caption aligncenter" style="width: 390px"><a href="http://www.codigometropoli.com/wp-content/uploads/2008/08/proy1image2.jpg"><img class="size-full wp-image-272" title="proy1image2" src="http://www.codigometropoli.com/wp-content/uploads/2008/08/proy1image2.jpg" alt="Imagen 2" width="380" height="226" /></a><p class="wp-caption-text">Imagen 2</p></div></div>
<p>De la imagen anterior podemos determinar que el query para crear esta tabla es:</p>
<div class="igBar"><span id="lsql-92"><a href="#" onclick="javascript:showPlainTxt('sql-92'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-92">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">`cliente`</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">`id`</span> INTEGER <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span>&nbsp; <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>, <span style="color: #ff0000;">`nombre`</span> TEXT, <span style="color: #ff0000;">`direccion`</span> TEXT, <span style="color: #ff0000;">`telefono`</span> TEXT, <span style="color: #ff0000;">`email`</span> TEXT<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Este query lo usaremos en la función <strong>createTBLCliente</strong>, el cual es llamado desde <strong>dbAbrirConexion</strong>.</p>
<div class="igBar"><span id="lactionscript-93"><a href="#" onclick="javascript:showPlainTxt('actionscript-93'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-93">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> createTBLCliente<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">clearParameters</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> sql:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"CREATE TABLE `cliente` "</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; sql += <span style="color: #ff0000;">"(`id` INTEGER PRIMARY KEY&nbsp; NOT NULL, `nombre` TEXT, `direccion` TEXT "</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; sql += <span style="color: #ff0000;">", `telefono` TEXT, `email` TEXT)"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #0066CC;">text</span> = sql;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; insertDefaultData<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:SQLError<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error al insertar el registro: "</span> + <span style="color: #0066CC;">error</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Para crear las sentencias de SQL, necesitamos de un objeto de la clase <strong>SQLStatement</strong>, a este objeto lo llamamos <em>queryStatement </em>y lo declaramos al inicio del programa. Para asegurarnos de que no tengamos parámetros asignados a este SQLStatement, usamos la función <strong>clearParameters</strong>, de no hacer esto el programa generará un error indicándonos que la cantidad de parámetros establecidos en el query no concuerda con los parámetros del <strong>SQLStatement</strong>. Posteriormente declaramos una variable <em>sql </em>de tipo <em>String</em> que contiene el query de crear la tabla de cliente.<br />
La propiedad <strong>text </strong>de la clase <strong>SQLStatement </strong>nos permite asignarle la sentencia SQL, por lo que le asignamos la variable <em>sql</em>.</p>
<p>Para poder "cachar" cualquier error que ocurra al ejecutar la sentencia, colocamos la llamada a la función <strong>execute </strong>dentro del bloque <strong>try</strong>. Cualquier error que ocurra será detectado y administrador en el bloque <strong>catch</strong>. En caso de que no exista ningún error al llamar a la función <strong>execute</strong>, llamaremos a la función <em>insertDefaultData </em>para insertar algunos registros por default.</p>
<p>A continuación pego el código de la función <em>insertDefaultData:</em></p>
<div class="igBar"><span id="lactionscript-94"><a href="#" onclick="javascript:showPlainTxt('actionscript-94'); return false;">Texto Plano</a></span></div>
<div class="syntax_hilite"><span class="langName">Actionscript:</span>
<div id="actionscript-94">
<div class="actionscript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0066CC;">private</span> <span style="color: #000000; font-weight: bold;">function</span> insertDefaultData<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">clearParameters</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">var</span> sql:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">"INSERT INTO `cliente` (nombre, direccion, telefono, email) VALUES (:nombre, :direccion, :telefono, :email)"</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":nombre"</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">'Ernesto Trujillo'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":direccion"</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">'Avenida Importante #33'</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":telefono"</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">'55667788'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #006600;">parameters</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">":email"</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #ff0000;">'etrujillo@email.com'</span>;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; queryStatement.<span style="color: #0066CC;">text</span> = sql;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; queryStatement.<span style="color: #006600;">execute</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0066CC;">catch</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">error</span>:SQLError<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Alert.<span style="color: #0066CC;">show</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"Error al crear la tabla cliente: "</span> + <span style="color: #0066CC;">error</span>.<span style="color: #0066CC;">toString</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;&nbsp;&nbsp;</div>
</li>
<li style="font-weight: bold;color:#0B1558;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#2C442A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Este código es similar al de la función <em>createTBLCliente </em>en cuanto a la creación de la variable del <strong>SQLStatement</strong>, la creación del query y su asignación a la propiedad <strong>text</strong>. Sin embargo, presta atención en la forma en cómo se le pasan los valores al query; esto es usando dos puntos seguidos de un nombre cualquiera que quieras asignarle. Posteriormente debes establecer el valor de estos parámetros usando la propiedad <strong>parameters </strong>la cual recibe un arreglo asociativo con los valores del parámetro especificado.</p>
<p>Como recomendación y para que te asegures de que tu base de datos, la tabla y el registro fueron creados, puedes bajar el complemento para Firefox llamado <a href="https://addons.mozilla.org/es-ES/firefox/addon/5817" target="_blank"><strong>SQLite Manager</strong></a>, el cual es un pequeño y simple administrador de bases  SQLite.</p>
<div align="center" style="margin-top:0px"><script type="text/javascript"><!--
      google_ad_client = "pub-5808310808246221";
      /* 250x250, Posts */
      google_ad_slot = "8254875600";
      google_ad_width = 250;
      google_ad_height = 250;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></div>
<div style="margin-top:40px; margin-bottom:30px;"><strong>Enlaces recomendados:</strong><br />
<br />
» <a href="http://livedocs.adobe.com/flex/3/html/help.html?content=SQL_01.html" target="_blank">Working with local SQL databases</a><br />
» <a href="http://livedocs.adobe.com/flex/3/langref/index.html" target="_blank">Adobe® Flex® 3 Language Reference</a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.codigometropoli.com/sistema-de-clientes-parte-i/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
	</channel>
</rss>
