FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Problemas con una búsqueda.
Posts: 212
Joined: Wed Apr 07, 2021 03:56 PM
Problemas con una búsqueda.
Posted: Sun Jun 16, 2024 04:36 AM

Buenas noches.

Adaptando el MSGDATE a mis necesidades me topo con este problema.

Agregue una dbf de FERIADOS cuyo indice es dtoc(fecha) (tambien prove con dtos(fecha)) con el objeto de mostrar en otro color los dias feriados.

lo hago de esta forma:

....

     ATail( oDlg:aControls ):nClrText = if(nCol=1,CLR_HRED, ;

                                                  If( dWork == Date(), CLR_YELLOW,;

                                                  If( dWork == dDate, CLR_HBLUE, If( Month( dWork ) == nMonth,;

                                                     if( feriados->(DbSeek(DToC(ATail( oDlg:aControls ):Cargo)),.f.), CLR_BROWN,CLR_BLACK ), CLR_CYAN ) ) ) )

...

y no logro cambiar el color del dia que esta en la base FERIADOS.

probe poniendo esta linea:

 if( dtoc(ATail( oDlg:aControls ):Cargo) == '17/06/2024', CLR_BROWN,CLR_BLACK ), CLR_CYAN ) ) ) )

y asi si me muestra en otro color dicha fecha que tambien esta en la base. se entiende ?

que concepto tengo equivocado que no logro el objetivo?

Muchas gracias!!!!

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Problemas con una búsqueda.
Posted: Sun Jun 16, 2024 05:30 AM

Estimado José,

Puedes proporcionar el código completo de tu MsgDate() modificado ? gracias

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 212
Joined: Wed Apr 07, 2021 03:56 PM
Re: Problemas con una búsqueda.
Posted: Sun Jun 16, 2024 06:31 AM
Hola Antonio!!!

Gracias x tu tiempo.



aqui va el codigo que comence a modificar.



// FiveWin MsgDate() function sample



#include "FiveWin.ch"



Static oWnd



FUNCTION Main()



SET 3DLOOK ON

SET EPOCH TO 1950

SET CENTURY ON

SET DATE FORMAT TO "DD/MM/YYYY"







DEFINE WINDOW oWnd FROM 1, 1 TO 12, 32 TITLE "TEST" MENU MakeMenu()



ACTIVATE WINDOW oWnd



RETURN( NIL )



Function MakeMenu()

Local oMenu



MENU oMenu

MENUITEM '&Menu'

MENU

MENUITEM "&1 MsgDate (Use DATE())" ACTION MsgInfo(MsgDate(DATE()), "Date Returned")

MENUITEM "&2 MsgDate (Use 03/25/97)" ACTION MsgInfo(MsgDate(TToD("03/25/97", "MM/DD/YY")), "Date Returned")

MENUITEM "&3 MsgDate (Use 2002/11/24)" ACTION MsgInfo(MsgDate(TToD("2002/11/24", "YYYY/MM/DD")), "Date Returned")

ENDMENU

ENDMENU

Return (oMenu)



//----------------------------------------------------------------------------//

function MsgDate( dDate, cPrompt, oGet )

local oDlg, oFont, oCursor, dSelect, dWork

local nRow, nCol, nMonth, nYear

local aMonths := {'Enero ',;

'Febrero ',;

'Marzo ',;

'Abril ',;

'Mayo ',;

'Junio ',;

'Julio ',;

'Agosto ',;

'Septiembre',;

'Octubre ',;

'Noviembre ',;

'Diciembre '}

local aDays := {"Dom","Lun","Mar","Mie","Jue","Vie","Sab"}

local nLin := 0

local nColu := 0







DEFAULT dDate := Date(), cPrompt := "Seleccione Una Fecha"

//FOR nMonth = 1 to 12

// AADD( aMonths, cMonth(TToD( "01/" + padl( nMonth, 2 ) + "/98", "DD/MM/YY" )))

//NEXT nMonth



use feriados index feriado1 new







cLongDate := dDateToString( dDate )

cLongFecha := verfecha( dDate )

cCYear := str(year(dDate), 4)

nYear := Year( dDate )

nMonth := Month( dDate )

dSelect := dDate

dWork := TToD( "01/" + padl( nMonth, 2 ) + "/" + ;

right( cCYear, 2), "DD/MM/YY" )

while DoW( dWork ) > 1

dWork --

enddo



DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -14

DEFINE FONT oFont2 NAME "Ms Sans Serif" SIZE 0, -18

DEFINE FONT oFont3 NAME "Courier New" SIZE 0, -18 BOLD

DEFINE FONT oFont4 NAME "ARIAL BLACK" SIZE 0, -22 BOLD



DEFINE DIALOG oDlg SIZE 400, 340 TITLE cPrompt FONT oFont // -> 6 Semanas



@ 0.2, .75 COMBOBOX nMonth ITEMS aMonths SIZE 60,100 OF oDlg FONT oFont2;

ON CHANGE MoveCalendar(oDlg, 1, nMonth )

@ 3.1, 86 BTNBMP PROMPT "-" SIZE 12, 12 ACTION ( MoveCalendar(oDlg, 3 ))

@ 3.4, 150 BTNBMP PROMPT "+" SIZE 12, 12 ACTION ( MoveCalendar(oDlg, 4 ))



@ 0.3, 12.3 GET nYear SIZE 40, 12 OF oDlg FONT oFont2

ATail( oDlg:aControls ):Cargo = "YEAR"



@ 1.1, 5 SAY cLongFecha COLOR CLR_HBLUE FONT oFont2

ATail( oDlg:aControls ):Cargo = "DATE"



@ 2, 3 SAY "DOM" COLOR CLR_HRED FONT oFont3

@ 2, 7 SAY "LUN" COLOR CLR_HGREEN FONT oFont3

@ 2, 11 SAY "MAR" COLOR CLR_HRED FONT oFont3

@ 2, 15.3 SAY "MIE" COLOR CLR_HRED FONT oFont3

@ 2, 19.5 SAY "JUE" COLOR CLR_HRED FONT oFont3

@ 2, 23.5 SAY "VIE" COLOR CLR_HRED FONT oFont3

@ 2, 27.8 SAY "SAB" COLOR CLR_HRED FONT oFont3



for nRow = 2 to 7

do case

case nRow=2

nLin := 42

case nRow=3

nLin := 62

case nRow=4

nLin := 82

case nRow=5

nLin := 102

case nRow=6

nLin := 122

case nRow=7

nLin := 142

endcase

for nCol = 1 to 7

do case

case nCol=1

nColu := 15

case nCol=2

nColu := 40

case nCol=3

nColu := 65

case nCol=4

nColu := 90

case nCol=5

nColu := 115

case nCol=6

nColu := 140

case nCol=7

nColu := 165

endcase



@ nLin, nColu BTNBMP ;

PROMPT Str( Day( dWork ), 2 ) SIZE 20, 20 NOBORDER FONT oFont4 ; //size 12,12

ACTION ( oDlg:Cargo := ::Cargo, oDlg:End( IDOK ) )



ATail( oDlg:aControls ):Cargo = dWork

ATail( oDlg:aControls ):nClrText = if(nCol=1,CLR_HRED, ;

If( dWork == Date(), CLR_YELLOW,;

If( dWork == dDate, CLR_HBLUE, If( Month( dWork ) == nMonth,;

if( feriados->(DbSeek(DToC(ATail( oDlg:aControls ):Cargo)),.f.), CLR_BROWN,CLR_BLACK ), CLR_CYAN ) ) ) )



// esto anda if( dtoc(ATail( oDlg:aControls ):Cargo) == '17/06/2024', CLR_BROWN,CLR_BLACK ), CLR_CYAN ) ) ) )





// if( feriados->(DbSeek(DToS(ATail( oDlg:aControls ):Cargo))), CLR_BROWN,CLR_BLACK ), CLR_CYAN ) ) ) )







if ATail( oDlg:aControls ):Cargo == dDate

ATail( oDlg:aControls ):lPressed = .t.

ATail( oDlg:aControls ):cToolTip = "Selección"

elseif ATail( oDlg:aControls ):Cargo == Date()

ATail( oDlg:aControls ):cToolTip = "Hoy"

else

ATail( oDlg:aControls ):cToolTip = DToC(ATail( oDlg:aControls ):Cargo)

endif



dWork++

next

next



oDlg:Cargo := dDate

ACTIVATE DIALOG oDlg CENTERED

dSelect := oDlg:Cargo



if oGet != NIL

oGet:VarPut( If( oDlg:nResult == IDOK, dSelect, dDate ) )

oGet:Refresh()

endif

CLOSE FERIADOS

return If( oDlg:nResult == IDOK, dSelect, ctod('//') )

//return If( oDlg:nResult == IDOK, dSelect, dDate )



//-----------------------------------------------------------------------//



static function MoveCalendar( oDlg, nMode, nVar)

local dSelect := oDlg:Cargo

local n

local nFirstButton := 0

local nLastButton := 0

local nDate := 0

local nSkip := 0

local nPDate := 0

local nPYear := 0

local nDay, nMonth, nYear

local dWork

local nDays := 0



for n := 1 TO Len( oDlg:aControls )

if oDlg:aControls[ n ]:ClassName() == "TBTNBMP"

nFirstButton := If( nFirstButton == 0, If(nSkip<2, 0, n), nFirstButton )

nLastButton := n

nSkip++

oDlg:aControls[ n ]:lPressed := .F.

endif

if ValType( oDlg:aControls[ n ]:Cargo ) == "C"

if oDlg:aControls[ n ]:Cargo == "DATE"

nPDate := n

endif

if oDlg:aControls[ n ]:Cargo == "YEAR"

nPYear := n

endif

endif

next n



nDay := Day( dSelect )

nMonth := Month( dSelect )

nYear := Year( dSelect )



do case

case nMode == 1

nMonth := nVar

case nMode == 3

nYear --

case nMode == 4

nYear ++

endcase



dSelect := TToD( padl( nDay, 2) + "/" + ;

padl( nMonth, 2 ) + "/" + ;

right(padl( nYear, 4 ), 2), "DD/MM/YY" )

cLongDate := dDateToString( dSelect )

clongfecha := verfecha( dselect )

oDlg:aControls[ nPDate ]:cMsg := cLongDate

oDlg:aControls[ nPYear ]:VarPut( nYear)



dWork := TToD( "01/" + padl( nMonth, 2 ) + "/" + right(padl( nYear, 4 ), 2), "DD/MM/YY" )

while DoW( dWork ) > 1

dWork --

enddo



for n := nFirstButton TO nLastButton

oDlg:aControls[ n ]:SetText( Str( Day( dWork ), 2 ) )



oDlg:aControls[ n ]:Cargo = dWork

oDlg:aControls[ n ]:nClrText = If( dWork == Date(), CLR_HRED,;

If( dWork == dSelect, CLR_HBLUE, If( Month( dWork ) == nMonth,;

CLR_BLACK, CLR_CYAN ) ) )



oDlg:aControls[ n ]:cToolTip = DToC(dWork)

if dWork == dSelect

oDlg:aControls[ n ]:lPressed = .T.

oDlg:aControls[ n ]:cToolTip = "Selected"

endif

dWork++

next n



for n := 1 TO Len( oDlg:aControls )

oDlg:aControls[ n ]:Refresh()

next n

oDlg:Cargo := dSelect

return nil



//-----------------------------------------------------------------------//

static function dDateToString( dDate )

return cDow( dDate) + " " + cMonth( dDate ) + " " + Str( Day ( dDate), 2) +;

", " + Str( Year( dDate), 4)



//-----------------------------------------------------------------------//

static function TToD(cDate, cFormat)

LOCAL cDay, cMonth, cYear, cLYear

LOCAL RetDate

LOCAL cClipFormat := UPPER(SET(4))

LOCAL nEPOCH := SET(5)



IF VALTYPE(cFormat) != "C"

cFormat := "MM/DD/YY"

ENDIF

IF EMPTY(cDate)

RetDate := CTOD("")

ELSE

IF ("YYYY" $ cFormat)

cLYear := PADR( VAL( SUBSTR(cDate, AT("YYYY", cFormat), 4 )), 4, "0")

cYear := PADL( VAL( RIGHT(cLYear, 2)), 2, "0")

ELSEIF ("YY" $ cFormat)

cYear := PADL( VAL( SUBSTR(cDate, AT("YY", cFormat), 2 )), 2, "0")

IF VAL("19" + cYear) > nEPOCH

cLYear := "19" + cYear

ELSE

cLYear := "20" + cYear

ENDIF

ENDIF

IF ("MM" $ cFormat)

cMonth := PADL( ALLTRIM( SUBSTR(cDate, AT("MM", cFormat), 2 )), 2, "0")

ENDIF

IF ("DD" $ cFormat)

cDay := PADL( ALLTRIM( SUBSTR(cDate, AT("DD", cFormat), 2 )), 2, "0")

ENDIF



IF ("YYYY" $ cClipFormat)

cClipFormat := LEFT(cClipFormat, AT("YYYY", cClipFormat) - 1 ) + cLYear + SUBSTR(cClipFormat, AT("YYYY", cClipFormat) + 4 )

ELSEIF ("YY" $ cClipFormat)

cClipFormat := LEFT(cClipFormat, AT("YY", cClipFormat) - 1 ) + cYear + SUBSTR(cClipFormat, AT("YY", cClipFormat) + 2 )

ENDIF

IF ("MM" $ cClipFormat)

cClipFormat := LEFT(cClipFormat, AT("MM", cClipFormat) - 1 ) + cMonth + SUBSTR(cClipFormat, AT("MM", cClipFormat) + 2 )

ENDIF

IF ("DD" $ cClipFormat)

cClipFormat := LEFT(cClipFormat, AT("DD", cClipFormat) - 1 ) + cDay + SUBSTR(cClipFormat, AT("DD", cClipFormat) + 2 )

ENDIF

RetDate := CTOD(cClipFormat)

ENDIF

return (RetDate)

//-----------------------------------------------------------------------//

static function verfecha( dDate )

return dialet( DOW(dDate)) + ", " + Str( Day ( dDate), 2)+ " de "+;

meslet( month(dDate) ) + " de " + Str( Year( dDate), 4)



*------------------------------------------------------------------------------------

*------------------------------------------------------------------------

// Funci¢n MesLet( <nMes> )

// Objeto: Obtiene el Mes en letras correspondiente a <nMes>

// Return: <cMes>

// Nota: Si <nMes> no es v lido devuelve el mes de la fecha actual



function MesLet(mes,_Minus)

local meses:={'ENERO','FEBRERO','MARZO','ABRIL','MAYO','JUNIO','JULIO','AGOSTO','SETIEMBRE','OCTUBRE','NOVIEMBRE','DICIEMBRE'}

Local Meses2:={" Enero "," Febrero "," Marzo "," Abril "," Mayo "," Junio "," Julio "," Agosto ","Setiembre"," Octubre ","Noviembre","Diciembre"}

return if(_Minus==.t., meses2[if(mes=nil,month(date()) ,mes)] , meses[if(mes=nil,month(date()) ,mes)])



*--------------------------------------------------------------------------

function DiaLet(_Dia)

local que_dia:={'Domingo','Lunes','Martes','Miércoles','Jueves' ,'Viernes','Sábado'}

return Que_Dia[if(_dia=nil,day(date()),_dia)]

*--------------------------------------------------------------------------
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Problemas con una búsqueda.
Posted: Sun Jun 16, 2024 03:56 PM

Hacer que FERIADOS.DBF esté disponible para descargar.

Gracias. Tks.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 212
Joined: Wed Apr 07, 2021 03:56 PM
Re: Problemas con una búsqueda.
Posted: Sun Jun 16, 2024 04:43 PM

Solucionado!!!!

asi quedo:

     ATail( oDlg:aControls ):nClrText = if(nCol=1,CLR_HRED, ;

                                                  If( dWork == Date(), CLR_YELLOW,;

                                                  If( dWork == dDate, CLR_HBLUE, If( Month( dWork ) == nMonth,;

                                                     if( feriados-&gt;(DbSeek(ATail( oDlg:aControls ):Cargo)), CLR_BROWN,CLR_BLACK ), CLR_CYAN ) ) ) )

Gracias por sus tiempos.

Joao: La base FERIADOS es de 3 campos, fecha, mensaje, motivo.

Continue the discussion