by Manuel Valdenebro » Mon Oct 09, 2006 8:13 pm
Raymundo,
El tema es un poco mas complicado. Se trata de actualizar (refrescar) un browse compuestos por bitmap, al cambiar la información. Todo funciona bien, para al pulsar el botón CALENDA (te lo señalo en rojo), el programa actualiza bien la base de datos (treservas), pero despues no refleja ese cambio en el browse, a pesar del refresh y del Updated. Gracias a tu idea, con oLbx:aHeaders:=aDia, conseguí actualizar las cabeceras, pero no logro actualizar los campos. Por eso te decia si puedo utilizar otra matriz. Este es el código:
FUNCTION RESERVAS ()
local oLbx, oDlg, oFont, oBmp, oBtn := ARRAY(10), ;
aDia := ARRAY (33), n, ofecha1, oSay1, lOk := .f.,;
dFecha1 := DATE()
local aBit := { LOADBitmap( GetResources(), "bverde" ), ;
LoadBitmap( GetResources(), "brojo" ), ;
LoadBitmap( GetResources(), "bCeles" ), ;
LoadBitmap( GetResources(), "bamari" ) }
FIELD CON_INM
aDia := C_RESERDIA( aDia, dFecha1 ) // calcula cabeceras listbox
DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, -14 BOLD
ABRE ("RESERVA", "RESERVA", "RESERVA" )
ORDSETFOCUS("CON_INM")
ABRE ( "inqui", "inqui", "inqui" )
ORDSETFOCUS("CON_INM")
ABRE ("fincas", "fincas", "fincas" )
SET RELA TO CON_INM INTO inqui
// calcula la informacion del listbox
MSGRUN (" ", "Cuadro Reservas.", ;
{ | oDlg | C_RESERVA ( oDlg, dFecha1, .t. ) } )
SELE tReserva
DBGOTOP()
DEFINE DIALOG oDlg ;
TITLE "Cuadro de Reservas" ;
FROM 5, 2 TO 32, 99
@ 0.1, 11.0 SAY oSay1 VAR dFecha1 SIZE 80, 8 UPDATE
@ 0.1, 20.0 SAY "Ocupado" SIZE 24,8
@ 0.25,18.5 BITMAP oBmp OF oDlg RESOURCE "brojo" NOBORDER ;
SIZE 8,8
@ 0.1, 31.0 SAY "Libre" SIZE 15,8
@ 0.25, 25.5 BITMAP oBmp OF oDlg RESOURCE "bverde" NOBORDER ;
SIZE 8,8
@ 0.1, 40.0 SAY "Entrada" SIZE 20,8
@ 0.25, 33.0 BITMAP oBmp OF oDlg RESOURCE "bamari" NOBORDER ;
SIZE 8,8
@ 0.1, 50.0 SAY "Salida" SIZE 15,8
@ 0.25, 40.0 BITMAP oBmp OF oDlg RESOURCE "bCeles" NOBORDER ;
SIZE 8,8
@ 1,1 LISTBOX oLbx ;
FIELDS tReserva->FINCA , ;
Num2Str(tReserva->DORM,1,0), ;
aBit[Max(1,treserva->D01+1)], ;
aBit[Max(1,treserva->D02+1)], ;
aBit[Max(1,treserva->D03+1)], ;
aBit[Max(1,treserva->D04+1)], ;
aBit[Max(1,treserva->D05+1)], ;
aBit[Max(1,treserva->D06+1)], ;
aBit[Max(1,treserva->D07+1)], ;
aBit[Max(1,treserva->D08+1)], ;
aBit[Max(1,treserva->D09+1)], ;
aBit[Max(1,treserva->D10+1)], ;
aBit[Max(1,treserva->D11+1)], ;
aBit[Max(1,treserva->D12+1)], ;
aBit[Max(1,treserva->D13+1)], ;
aBit[Max(1,treserva->D14+1)], ;
aBit[Max(1,treserva->D15+1)], ;
aBit[Max(1,treserva->D16+1)], ;
aBit[Max(1,treserva->D17+1)], ;
aBit[Max(1,treserva->D18+1)], ;
aBit[Max(1,treserva->D19+1)], ;
aBit[Max(1,treserva->D20+1)], ;
aBit[Max(1,treserva->D21+1)], ;
aBit[Max(1,treserva->D22+1)], ;
aBit[Max(1,treserva->D23+1)], ;
aBit[Max(1,treserva->D24+1)], ;
aBit[Max(1,treserva->D25+1)], ;
aBit[Max(1,treserva->D26+1)], ;
aBit[Max(1,treserva->D27+1)], ;
aBit[Max(1,treserva->D28+1)], ;
aBit[Max(1,treserva->D29+1)], ;
aBit[Max(1,treserva->D30+1)], ;
aBit[Max(1,treserva->D31+1)] ;
FIELDSIZES 95, 15, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, ;
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, ;
20, 20, 20, 20, 20, 20 ;
SIZE 366,138 FONT oFont OF oDlg UPDATE;
ON DBLCLICK ( FINCAS( "Reserva", tReserva->CON_INM) , ;
C_RESERVA (oDlg, dFecha1, .f.), oDlg:REFRESH() )
oLbx:nClrPane:={|| IIF((oLbx:cAlias)->(OrdKeyNo())% 2==0,CELE,GRIS)}
oLbx:nClrForeHead := AZUL // gracias Raymundo
oLbx:bKeyDown:={|nK| IIF ( nK != VK_RETURN, , (FINCAS( "Reserva", tReserva->CON_INM) , oDlg:End()))}
oLbx:aHeaders:=aDia
**
@ 165,198 BUTTONBMP oBtn[4] OF oDlg ;
SIZE 42,16 PIXEL ;
ACTION ( dFecha1 := CALENDAR(dFecha1), ;
aDia := C_RESERDIA( aDia, dFecha1 ), ;
C_RESERVA (oDlg, dFecha1, .f., .t. ), ;
oLbx:REFRESH(), oDlg:UPDATED() ) ;
MESSAGE " Ver calendario." ;
PROMPT SPACE(3) + "&Calenda" ;
BITMAP "calendar1" TEXTRIGHT
@ 165,258 BUTTONBMP oBtn[6] OF oDlg ;
SIZE 42,16 PIXEL ;
ACTION Fayuda( cChmFich, "reservas.htm#cuadro") ;
MESSAGE " Ayuda" ;
PROMPT SPACE(5) + "a&Yuda" ;
BITMAP "Ayuda" TEXTRIGHT
@ 165,318 BUTTONBMP oBtn[7] OF oDlg ;
SIZE 42,16 PIXEL ;
ACTION (oDlg:End()) ;
MESSAGE " Salir de esta ventana" ;
PROMPT SPACE(4) + "&Salir" ;
BITMAP "salir1" TEXTRIGHT
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT (oDlg:lHelpIcon:=.f., ;
PonBarra(oDlg, " Cuadro de reservas.",.f.) )
CLOSE tReserva
CLOSE fincas
CLOSE reserva
RETURN nil
///////////////////////////////////////////////
/// calculo de la cabecera listbox
///////////////////////////////////////////////
STATIC FUNCTION C_RESERDIA( aDia, dFecha )
local n := 3 // , aDia := ARRAY (31)
aDia[1] := "Fincas"
aDia[2] := "D"
WHILE n <= 33
aDia[n] := Str( DAY (dFecha), 2, 0 )
n++
dFecha++
ENDD
RETURN aDia
///////////////////////////////////////////////
/// calculo del Cuadro de Reservas (planin)
///////////////////////////////////////////////
STATIC FUNCTION C_RESERVA( oDlg, dFecha1, lOpcion, lCalendar)
local N, dF, dFecha2 := (dFecha1 + 31), aDbf := {}, nRec1 := 0
Default lCalendar := .f.
if lOpcion // inicio o cambio de dia
//
// primero, vamos a preparar un fichero temporal
//
AADD(aDbf,{"CON_INM" ,"N", 6, 0}) // control inmueble
AADD(aDbf,{"FINCA" ,"C", 10, 0}) // direccion del inmueble
AADD(aDbf,{"DORM" ,"N", 1, 0}) // numero dormitorios
AADD(aDbf,{"D01" ,"N", 1, 0})
AADD(aDbf,{"D02" ,"N", 1, 0})
AADD(aDbf,{"D03" ,"N", 1, 0})
AADD(aDbf,{"D04" ,"N", 1, 0})
AADD(aDbf,{"D05" ,"N", 1, 0})
AADD(aDbf,{"D06" ,"N", 1, 0})
AADD(aDbf,{"D07" ,"N", 1, 0})
AADD(aDbf,{"D08" ,"N", 1, 0})
AADD(aDbf,{"D09" ,"N", 1, 0})
AADD(aDbf,{"D10" ,"N", 1, 0})
AADD(aDbf,{"D11" ,"N", 1, 0})
AADD(aDbf,{"D12" ,"N", 1, 0})
AADD(aDbf,{"D13" ,"N", 1, 0})
AADD(aDbf,{"D14" ,"N", 1, 0})
AADD(aDbf,{"D15" ,"N", 1, 0})
AADD(aDbf,{"D16" ,"N", 1, 0})
AADD(aDbf,{"D17" ,"N", 1, 0})
AADD(aDbf,{"D18" ,"N", 1, 0})
AADD(aDbf,{"D19" ,"N", 1, 0})
AADD(aDbf,{"D20" ,"N", 1, 0})
AADD(aDbf,{"D21" ,"N", 1, 0})
AADD(aDbf,{"D22" ,"N", 1, 0})
AADD(aDbf,{"D23" ,"N", 1, 0})
AADD(aDbf,{"D24" ,"N", 1, 0})
AADD(aDbf,{"D25" ,"N", 1, 0})
AADD(aDbf,{"D26" ,"N", 1, 0})
AADD(aDbf,{"D27" ,"N", 1, 0})
AADD(aDbf,{"D28" ,"N", 1, 0})
AADD(aDbf,{"D29" ,"N", 1, 0})
AADD(aDbf,{"D30" ,"N", 1, 0})
AADD(aDbf,{"D31" ,"N", 1, 0})
DBCREATE( cDirEsta + "TRESERVA.DBF", aDbf, "DBFCDX")
USE (cDirEsta + "TRESERVA") NEW
ENDI
IF lCalendar
SELE tReserva
DBGOTOP()
ENDI
SELE fincas // indice por nombres
while !eof()
nRec1++
// refresca msgrun
oDlg:cMsg := "Alta recibo "+ LTrim( Str( nRec1 ) )
oDlg:Refresh()
SysRefresh()
SELE tReserva
IF lOpcion // alta
ALTA_R(5)
tReserva->CON_INM := fincas->CON_INM
ELSE
BLOQ_R(5)
ENDI
tReserva->DORM := fincas->DORMITORIO
tReserva->FINCA := fincas->NOMBRE
// fincas ocupadas
IF fincas->INQUILIN > 0
dF := dFecha1
N := 4
WHILE dF <= dFecha2
IF dF < inqui->VTO // hasta el dia antes del vto
IF dF = inqui->FINI
tReserva->(FIELDPUT(n, 3))
ELSEIF dF > inqui->FINI
tReserva->(FIELDPUT(n, 1))
ENDI
ELSEIF dF = inqui->VTO
tReserva->(FIELDPUT(n, 2))
ENDI
n++
dF++
IF dF > inqui->VTO
EXIT
ENDI
ENDD
ENDI
// anota las reservas
SELE reserva
ORDSETFOCUS("CON_INM") // control inmuebles
DBSEEK(fincas->CON_INM)
IF FOUND()
WHILE reserva->CON_INM = fincas->CON_INM
IF reserva->FENTRA <= dFecha2 .and. reserva->FSALE >= dFecha1
dF := dFecha1
N := 4
WHILE dF <= dFecha2
IF dF >= reserva->FENTRA .and. dF < reserva->FSALE
IF dF = reserva->FENTRA
tReserva->(FIELDPUT(n, 3))
ELSE
tReserva->(FIELDPUT(n, 1))
ENDI
ELSEIF dF = reserva->FSALE
tReserva->(FIELDPUT(n, 2))
ENDI
n++
dF++
IF dF > reserva->FSALE
EXIT
ENDI
ENDD
ENDI
SELE reserva
DBSKIP()
ENDD
ENDI
SELE tReserva
UNLOCK
IF lOpcion .or. lCalendar
SELE fincas
DBSKIP()
ELSE
EXIT
ENDI
ENDD
RETURN nil
Un saludo
Manuel