Loading images from the DB


For loading images from which we save its path into the DB, we create into our collection an invisible field of type PATH text, and a button field that we call AP_IMAGE.

<prop name="IMAGEN" group="1" type="T" size="255" visible="7" title="Invisible" fieldsize="10" />
<button name="MAP_IMAGEN" group="1" caption=" " locked="true" locking="true" visible="true" labelwidth="20" img="##FLD_IMAGEN##" bgcolor="#FFFFFF" text-bgcolor-disabled="#FFFFFF" />



This one will be collection from which we get the data, and the image path to be able to visualize them into our Entry collection.

    <coll name="Peliculas" notab="true" title="Peliculas" fontsize="8" sql="SELECT t1.ID,t1.IDCOMUNIDAD,t1.IDPROVINCIA,t1.IDLOCALIDAD,
		t1.IDGENERO,t1.IDDIRECTOR,t1.IDCLASIFICACION,t1.TITULO,t1.OPCION,
		t1.IMAGENFOTO,t1.IMAGENRUTA,t1.SINOPSIS,t1.AÑO,t2.NOMBRE AS MAP_COMUNIDAD,
		t3.NOMBRE AS MAP_PROVINCIA,t4.NOMBRE AS MAP_LOCALIDAD,t6.NOMBRE AS MAP_DIRECTOR,t5.NOMBRE AS MAP_GENERO,t7.NOMBRE AS MAP_CLASIFICACION,t1.DISPONIBLE
			 FROM ((((((##PREF##Peliculas t1 LEFT OUTER JOIN ##PREF##Comunidades t2 ON t1.IDCOMUNIDAD=t2.ID)
			 LEFT OUTER JOIN ##PREF##Provincias t3 ON t1.IDPROVINCIA=t3.ID)
			 LEFT OUTER JOIN ##PREF##Localidades t4 ON t1.IDLOCALIDAD=t4.ID)
			 LEFT OUTER JOIN ##PREF##Generos t5 ON t1.IDGENERO=t5.ID)
			 LEFT OUTER JOIN ##PREF##Directores t6 ON t1.IDDIRECTOR=t6.ID)
			 LEFT OUTER JOIN ##PREF##Clasificacion t7 ON t1.IDCLASIFICACION=t7.ID)" objname="Peliculas" updateobj="Peliculas" filter="" sort="" progid="ASData.CASBasicDataObj">
      <group name="General" id="1" />
      <!-- ENLACE CON LA COLECION PROVINCIAS POR LA ID PARA OBTENER EL NOMBRE DE LA PROVINCIAS-->
      <prop name="IDCOMUNIDAD" group="1" type="N" visible="0" fieldsize="10" size="10" mapcol="Comunidades" mapfld="ID" />
      <prop name="IDPROVINCIA" group="1" type="N" visible="0" fieldsize="10" size="10" mapcol="Provincias" mapfld="ID" filter="IDCOMUNIDAD=##FLD_IDCOMUNIDAD##" />
      <prop name="IDLOCALIDAD" group="1" type="N" visible="0" fieldsize="10" size="10" mapcol="Localidades" mapfld="ID" filter="IDPROVINCIA=##FLD_IDPROVINCIA##" />
      <prop name="IDGENERO" group="1" type="N" visible="0" title="Genero" fieldsize="10" size="10" mapcol="Generos" mapfld="ID" />
      <prop name="IDDIRECTOR" group="1" type="N" visible="0" title="Director" fieldsize="10" size="10" mapcol="Directores" mapfld="ID" />
      <prop name="IDCLASIFICACION" group="1" type="N" visible="0" title="Clasificacion" fieldsize="10" size="10" mapcol="Clasificacion" mapfld="ID" />
      <!-- GRUPO 1 -->
      <prop name="TITULO" group="1" type="T" visible="3" title="Titulo" fieldsize="10" size="30" />
      <prop name="OPCION" group="1" type="N" vidible="1" title="Opcion" fieldsize="10" size="10" onchange="refresh" visible="" />
      <prop name="MAP_IMAGEN" group="1" type="NC" visible="1" title="Imagen del movil" fieldsize="10" size="10" onchange="refresh" />
      <prop name="MAP_FHOTO" group="1" type="NC" visible="1" title="Imagen por foto" fieldsize="10" size="10" newline="false" onchange="refresh" />
      <prop name="IMAGENFOTO" group="1" type="PH" visible="1" title="Foto" fieldsize="10" size="255" disablevisible="OPCION=0 or OPCION=1" onchange="refresh" />
      <prop name="IMAGENRUTA" group="1" type="IMG" visible="1" title="Imagen" labelwidth="0" fieldsize="10" size="255" disablevisible="OPCION=0 or OPCION=2" onchange="refresh" />
      <prop name="MAP_RUTA" group="1" type="AT" visible="1" title="Ruta" fieldsize="10" size="255" disablevisible="OPCION=0 or OPCION=2" onchange="refresh" />
      <prop name="SINOPSIS" group="1" type="T" visible="1" title="Sinopsis" fieldsize="10" size="100" lines="5" />
      <prop name="AÑO" group="1" type="T" visible="3" title="Año De Estreno" fieldsize="10" size="10" onchange="refresh" />
      <prop name="MAP_COMUNIDAD" group="1" type="T" visible="1" title="Comunidad" fieldsize="10" size="25" linkedto="IDCOMUNIDAD" linkedfield="NOMBRE" onchange="refresh" />
      <prop name="MAP_PROVINCIA" group="1" type="T" visible="1" title="Provincia" fieldsize="10" size="30" linkedto="IDPROVINCIA" disableedit="IDCOMUNIDAD=0" linkedfield="NOMBRE" onchange="refresh" />
      <prop name="MAP_LOCALIDAD" group="1" type="T" visible="1" title="Localidad" fieldsize="10" size="10" linkedto="IDLOCALIDAD" disableedit="IDPROVINCIA=0" linkedfield="NOMBRE" onchange="refresh" />
      <prop name="MAP_DIRECTOR" group="1" type="T" visible="1" title="Director" fieldsize="10" size="10" linkedto="IDDIRECTOR" linkedfield="NOMBRE" onchange="refresh" />
      <prop name="MAP_GENERO" group="1" type="T" visible="3" title="Genero" fieldsize="10" size="10" linkedto="IDGENERO" linkedfield="NOMBRE" onchange="refresh" />
      <prop name="MAP_CLASIFICACION" group="1" type="T" visible="1" title="Clasificacion" fieldsize="10" size="10" linkedto="IDCLASIFICACION" linkedfield="NOMBRE" onchange="refresh" />
      <prop name="DISPONIBLE" group="1" type="NC" visible="3" title="Disponible" fieldsize="10" size="1" />
      </coll>


Creation of the Entry Collection


This collection will be like a catalog, where we visualize as if it were a video store the different available films:

 <coll name="Entrada" title="Entrada" fontsize="8" sql="SELECT t1.ID
			 FROM ##PREF##Entrada t1" objname="Entrada" updateobj="Entrada" filter="" sort="" progid="ASData.CASBasicDataObj" notab="true">
      <group name="Pelis" id="1" />
      <frame name="General" align="center" width="100%" height="50%" />
      <frame name="ImagenPelis" frame="General" width="100%" height="100%" />
      <frame name="Cargando" align="center" width="100%" height="20%" />
      <frame name="Carga" frame="Cargando" width="100%" height="100%" />
      <prop name="MAP_TITULO" type="T" visible="1" title="Titulo" group="1" fieldsize="10" size="15" />
      <prop name="MAP_IMAGEN" type="IMG" frame="ImagenPelis" labelwidth="0" visible="1" group="1" fieldsize="10" size="255" ximg="##FLD_MAP_IMAGEN##"/>
      <prop name="MAP_BOTON_ANT" type="B" visible="1" lmargin="4" title="ATRAS" group="1" labelwidth="9" fieldsize="10" size="15" method="ExecuteNode (ANTERIOR)" disableedit="MAP_BUTOM_ACTIVATE=0" />
      <prop name="MAP_BOTON_SIG" type="B" visible="1" title="SIGUIENTE" group="1" labelwidth="9" fieldsize="15" size="15" method="ExecuteNode (SIGUIENTE)" newline="false" disableedit="MAP_BUTOM_ACTIVATE=1" />
      <prop name="MAP_BOTON" type="B" visible="1" lmargin="10" title="Alquilar" group="1" labelwidth="9" fieldsize="10" size="15" method="ExecuteNode (click)" />
      <prop name="MAP_BANDERA" type="N" visible="0" title="BANDERA" group="1" fieldsize="10" size="15" />
      <prop name="MAP_BUTOM_ACTIVATE" type="N" visible="0" title="visible" group="1" fieldsize="10" size="15" />
      <prop name="MAP_CARGA" type="IMG" visible="1" title="visible" group="1" labelwidth="0" fieldsize="10" size="15" path="##APP##\icons\cargando.gif" />
      <create>
        <action name="runscript">
          <script language="VBScript"> 
          		RecogerDatosColeccionSiguiente
           </script>
        </action>
        <action name="setval" field="MAP_BUTOM_ACTIVATE" value="0" />
      </create>
      <click>
        <action name="runscript">
          <script language="VBScript">
          		Dim dato 'pb1
				LlamarColeccion("Peliculas")
				'dato=pb1.This.contents.("TITULO")Obtener un campo de una coleccion
				'Appdata.FailWithMessage -11822,dato
           </script>
        </action>
      </click>
      <SIGUIENTE>
        <action name="runscript">
          <script language="VBScript">
          		RecogerDatosColeccionSiguiente
           </script>
        </action>
      </SIGUIENTE>
      <ANTERIOR>
        <action name="runscript">
          <script language="VBScript">
          		RecogerDatosColeccionAtras
           </script>
        </action>
      </ANTERIOR>
    </coll>




In this function we will browse the database of the films collection, upwardly sorted, with the ID condition smaller that it was, and it will take the first log that is, if no log is taken it means that there is no more.


function RecogerDatosColeccionAtras()
	Dim i,col,sFilter
	set col=appData.GetCollection("Peliculas")
	col.sort="t1.ID DESC"
	i=this("MAP_BANDERA")
	sFilter="t1.ID<"+i
	col.filter=sFilter
	col.startBrowse
	if not col.currentItem is nothing then
		AsignarDatos(col.currentItem)
		col.movenext
		if col.currentItem is nothing then
			this("MAP_BUTOM_ACTIVATE")=0		
		else
			this("MAP_BUTOM_ACTIVATE")=2
		end if
	end if
	col.endBrowse
end function



This function will be same than the previous one, but upwardly sorted.

function RecogerDatosColeccionSiguiente()
	Dim i,col,sFilter
	set col=appData.GetCollection("Peliculas")
	col.sort="t1.ID ASC"
	i=this("MAP_BANDERA")
	sFilter="t1.ID>"+i
	col.filter=sFilter
	col.startBrowse
	if not col.currentItem is nothing then
		AsignarDatos(col.currentItem)
		col.movenext
		if col.currentItem is nothing then
			this("MAP_BUTOM_ACTIVATE")=1
		else
			this("MAP_BUTOM_ACTIVATE")=2
		end if
	end if
	col.endBrowse
end function



With this function we will take the data we want from the taken log.

function AsignarDatos(obj)
	this("MAP_ID")=obj("ID")
	this("MAP_TITULO")=obj("TITULO")
	this("MAP_BANDERA")=obj("ID")
	if obj("IMAGENFOTO")="" then
		this("MAP_IMAGEN")=obj("IMAGENRUTA")
	else
		this("MAP_IMAGEN")=obj("IMAGENFOTO")
	end if
end function