Ejemplo de xBrowse (Solucionado, thanks Mr. Rao)
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Ejemplo de xBrowse
Sorry for the mistake.
Please change :aCol[ as :aCols[
I edited my posting and corrected it now.
Please change :aCol[ as :aCols[
I edited my posting and corrected it now.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Ejemplo de xBrowse
Mr. Rao:
Great!, now it works fine.
Thank you so much
Now you can have a beer, I'll pay it
BTW, I need columns 5 and 6 with date format, how can I do it?
With best regards
Great!, now it works fine.
Thank you so much
Now you can have a beer, I'll pay it

BTW, I need columns 5 and 6 with date format, how can I do it?
With best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Ejemplo de xBrowse
Your original code contained these functionsArmando wrote: BTW, I need columns 5 and 6 with date format, how can I do it?
Code: Select all
Date2Txt(DameFecha(oRsCxc:Fields("CARFEC"):Value))
1) How is the date stored in CARFEC and CARVTO fields?
2) What is the function "DameFecha(...)" ?
3) What is the function "Date2Txt(...)" ?
Anyway please try:
Code: Select all
COLUMNS "CARCAR", "CARCLI", "CLINOM", "DameFecha(CARFEC)", "DameFecha(CARVTO)", "CARIMP" ;
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Ejemplo de xBrowse
Mr. Rao:
CARFEC and CARVTO fields are stored in numeric format and
here is the source code for DameFecha() function
And this is the Date2Txt()
Best regards
CARFEC and CARVTO fields are stored in numeric format and
here is the source code for DameFecha() function
Code: Select all
[color=#FF0000]// Converts a numeric type field to date type[/color]
STATIC FUNCTION DameFecha(nFecha)
LOCAL dFecha
LOCAL cFecha := STR(nFecha,08,0)
dFecha := CTOD(LEFT(cFecha,2) + "/" + SUBSTR(cFecha,3,2) + "/" + SUBSTR(cFecha,5,4))
RETURN(dFecha)
Code: Select all
//
Converts a date type field to a character string formatted as date
Sample 29/06/2018 to 29/Jun/2018
/*
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
° Funcion: Date2Txt()
Argumentos: 8
Argumento 1: La fecha a convertir variable tipo fecha
Argumento 2: Tipo de nombre del día 1=Corto, 2=Largo Ejem: 1=Sáb, 2=Sábado
Argumento 3: Tipo de nombre del mes 1=Corto, 2=Largo Ejem: 1=Ene, 2=Enero
Argumento 4: Tipo de año 1=2 dígitos, 2=4 dígitos Ejem: 1=99, 2=1999
Argumento 5: Separador entre el día de la semana y la fecha
Argumento 6: Separador entre dia y mes
Argumento 7: Separador entre mes y año
Argumento 8: Variable lógica para decidir si el día debe ir precedido de cero
cuando el valor el menor a 10. Ejem: 1 aparecerá 01
Copyright: (2011) Por SOI, s.a. de c.v.
Desarrolló: Ing. Armando Estrada Bucio
°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
*/
#INCLUDE "FiveWin.ch"
FUNCTION Date2Txt(dFecha,nTipdia,nTipMes,nTipAmo,cSepDia,cSepDM,cSepMA,lZeros)
LOCAL aNomMesC := {"Ene", "Feb", "Mzo", "Abr", "May", ;
"Jun", "Jul", "Ago", "Sep", "Oct", ;
"Nov", "Dic"}
LOCAL aNomMes := {"Enero", "Febrero", "Marzo", "Abril", "Mayo", ;
"Junio", "Julio", "Agosto", "Septiembre", "Octubre", ;
"Noviembre", "Diciembre"}
LOCAL aNomDia := {"Domingo", "Lunes", "Martes", "Míercoles", ;
"Jueves", "Viernes", "Sábado"}
LOCAL La_Fecha := ""
DEFAULT lZeros := (.T.)
// DEFAULT dFecha := DATE()
// DEFAULT nTipDia := 0
// DEFAULT nTipMes := 1
// DEFAULT nTipAmo := 2
// DEFAULT cSepDia := SPACE(1)
// DEFAULT cSepDM := "/"
// DEFAULT cSepMA := "/"
IF EMPTY(dFecha)
dFecha := DATE()
ENDIF
IF EMPTY(nTipDia)
nTipDia := 0
ENDIF
IF EMPTY(nTipMes)
nTipMes := 1
ENDIF
IF EMPTY(nTipAmo)
nTipAmo := 2
ENDIF
IF cSepDia == NIL
cSepDia := SPACE(1)
ENDIF
IF cSepDM == NIL
cSepDM := "/"
ENDIF
IF cSepMA == NIL
cSepMA := "/"
ENDIF
DO CASE
CASE nTipdia == 1
La_Fecha:= LEFT(aNomDia[DOW(dFecha)], 3) + cSepDia
CASE nTipdia == 2
La_Fecha:= aNomDia[DOW(dFecha)] + cSepDia
ENDCASE
IF lZeros
La_Fecha:= La_Fecha + STRZERO(DAY(dFecha), 2, 0)
ELSE
La_Fecha:= La_Fecha + STR(DAY(dFecha), 2, 0)
ENDIF
DO CASE
CASE nTipMes == 1
La_Fecha:= La_Fecha + cSepDM + LEFT(aNomMesC[MONTH(dFecha)], 3)
CASE nTipMes == 2
La_Fecha:= La_Fecha + cSepDM + aNomMes[MONTH(dFecha)]
ENDCASE
DO CASE
CASE nTipAmo == 1
La_Fecha:= La_Fecha + cSepMA + RIGHT(STR(YEAR(dFecha), 4, 0), 2)
CASE nTipAmo == 2
La_Fecha:= La_Fecha + cSepMA + STR(YEAR(dFecha), 4, 0)
ENDCASE
RETURN (La_Fecha)
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Ejemplo de xBrowse
Please first convert
STATIC FUNCTION Date2Txt
AS
FUNCTION Date2Txt
After that use the columns statement like this
STATIC FUNCTION Date2Txt
AS
FUNCTION Date2Txt
After that use the columns statement like this
Code: Select all
COLUMNS "CARCAR", "CARCLI", "CLINOM", "Date2Txt( DameFecha(CARFEC) )", "Date2Txt( DameFecha(CARVTO) )", "CARIMP" ;
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Ejemplo de xBrowse
I provided an immediate solution to you in my post above.
But please read this also.
When you are using a wonderful RDBMS like MySql there is no need to use external functions.
It is better to store date values in date type fields as dates than as character values like "ddmmyyyy".
Anyway, keeping your present structure as it is, you can read formatted dates directly from the MySql server like this:
But please read this also.
When you are using a wonderful RDBMS like MySql there is no need to use external functions.
It is better to store date values in date type fields as dates than as character values like "ddmmyyyy".
Anyway, keeping your present structure as it is, you can read formatted dates directly from the MySql server like this:
Code: Select all
// AT THE BEGINNING OF THE PROGRAM
REQUEST HB_LANG_ESWIN
REQUEST HB_CODEPAGE_ESWIN
HB_CDPSELECT("ESWIN")
HB_LangSelect( "ESWIN" )
// SOON AFTER OPENING THE CONNECTION
oCn:Execute( "SET lc_time_names = 'es_ES'" )
// READING DATA FROM TABLE
cSql := "SELECT DATE_FORMAT( STR_TO_DATE( CARFEC, '%d%m%Y' ), '%W %D %M %Y' ) AS CARFEC FROM <yourtablename>"
oRs := FW_OpenRecordSet( oCn, cSql )
XBROWSER oRs
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Ejemplo de xBrowse
Mr. Rao:
"When you are using a wonderful RDBMS like MySql there is no need to use external functions.
It is better to store date values in date type fields as dates than as character values like "ddmmyyyy"."
Yes, you are right but the database is not mine, I'am Reading the database from an other application.
With your first suggestion
the columns in xbrowse shows the string
shows the following error
With best regards
"When you are using a wonderful RDBMS like MySql there is no need to use external functions.
It is better to store date values in date type fields as dates than as character values like "ddmmyyyy"."
Yes, you are right but the database is not mine, I'am Reading the database from an other application.
With your first suggestion
Code: Select all
REDEFINE XBROWSE oBrw ID 201 OF oDlg;
DATASOURCE oRsCxc ;
COLUMNS "CARCAR", "CARCLI", "CLINOM", "Date2Txt(DameFecha(CARFEC))", "Date2Txt(DameFecha(CARVTO))", "CARIMP" ;
HEADERS "Factura", "Cliente", "Nombre o Razón Social", "Emisión", "Vencimiento", "Saldo" ;
COLSIZES 60,60,300,85,85,90 ;
FOOTERS
WITH OBJECT oBrw
:l2007 := (.F.)
:lHScroll := (.F.)
:nMarqueeStyle := MARQSTYLE_HIGHLROWMS
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:nRowDividerStyle := LINESTYLE_LIGHTGRAY
:nStretchCol := STRETCHCOL_WIDEST
:nHeaderHeight := 25
:nRowHeight := 22
:nFooterHeight := 25
:bClrHeader := { || {CLR_WHITE,CLR_BLACK} }
:bClrFooter := { || {CLR_WHITE,CLR_BLACK} }
:bClrSel := { || IF( oBrw:KeyNo % oApp:nRowsInt == 0 ,{ CLR_BLACK, oApp:nRowParClr },{ CLR_BLACK, oApp:nRowNonClr }) }
:bClrSelFocus := { || {oApp:nFClrFocus,oApp:nBClrFocus} }
:bClrStd := { || IF( oBrw:KeyNo % oApp:nRowsInt == 0 ,{ CLR_BLACK, oApp:nRowParClr },{ CLR_BLACK, oApp:nRowNonClr }) }
:nRecSelColor := oApp:nRowParClr
:lDisplayZeros := (.F.)
END
WITH OBJECT oBrw
:aCols[ 5]:bFooter := { || Len( oBrw:aSelected ) }
WITH OBJECT :aCols[ 6]
:nFooterType := AGGR_SUM
:bSumCondition := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
END
:bOnMultiSelect := { || oBrw:MakeTotals() }
:bChange := { || IF( LEN( oBrw:aSelected ) <= 1, ;
( oBrw:oCol(6):nTotal := oBrw:oCol(6):Value,;
oBrw:oCol(6):RefreshFooter() ),NIL ) }
:MakeTotals()
END
- "Date2Txt( DameFecha(CARFEC) )", "Date2Txt( DameFecha(CARVTO) )"
Code: Select all
REQUEST HB_LANG_ESWIN
REQUEST HB_CODEPAGE_ESWIN
FUNCTION AppPag()
LOCAL oDlg
LOCAL oIcono
LOCAL oFont,oFont1
LOCAL oBrush
LOCAL oBrw
LOCAL aCol := ARRAY(10)
LOCAL aGets := ARRAY(25)
LOCAL aSays := ARRAY(01)
LOCAL oAceptar
LOCAL oCancelar
SET CENTURY ON
SET DATE TO FRENCH
SET DELETED ON
SET OPTIMIZE ON
SETBALLOON(.T.)
HB_CDPSELECT("ESWIN")
HB_LangSelect( "ESWIN" )
……
…..
STATIC FUNCTION Conecta()
LOCAL oError
TRY
oApp:oCon := TOleAuto( ) :new( "adodb.connection" )
CATCH oError
MsgStop( "No se ha podido crear la conexión al servidor !")
RETURN( .F. )
END
oApp:oCon:ConnectionString := "Provider=IBMDA400;Data Source=AS400;User Id=Armando;Password=soidito"
oApp:oCon:CommandTimeout := 1800 // 30 Minutos * 60 segundos
oApp:oCon:ConnectionTimeout := 300 // 5 Minutos * 60 segundos
TRY
oApp:oCon:Open()
CATCH oError
MsgInfo( "No se pudo lograr la conexión al servidor, REVISE LA CONEXION DE SU RED O LA CONEXION A INTERNET !",oApp:cAplicacion)
RETURN(.F.)
END
// SOON AFTER OPENING THE CONNECTION
oApp:oCon:Execute( "SET lc_time_names = 'es_ES'" )
RETURN(.T.)
- Application
===========
Path and name: C:\AppPag\AppPag.Exe (32 bits)
Size: 3,925,504 bytes
Compiler version: Harbour 3.2.0dev (r1801051438)
FiveWin version: FWH 17.11
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.1, Build 7601 Service Pack 1
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 30/06/2018, 09:13:56
Error description: (DOS Error -2147352567) WINOLE/1007 SQL0104: Símbolo LC_TIME_NAMES no válido. Símbolos válidos: :.
Causa . . . . . : Se ha detectado un error de sintaxis en el símbolo LC_TIME_NAMES. El símbolo LC_TIME_NAMES no es un símbolo válido. Una lista parcial de símbolos válidos es :. Esta lista presupone que la sentencia es correcta hasta el símbolo. El error puede estar anteriormente en la sentencia, pero la sintaxis de la sentencia aparece como válida hasta este punto. Recuperación . : Efectúe una o más de las siguientes acciones y vuelva a intentar la petición: -- Verifique la sentencia SQL en el área del símbolo LC_TIME_NAMES. Corrija la sentencia. El error podría ser la omisión de una coma o comillas; podría tratarse de una palabra con errores ortográficos, o podría estar relacionado con el orden de las cláusulas. -- Si el símbolo de error es <FIN DE SENTENCIA>, corrija la sentencia SQL porque no finaliza con una cláusula válida. (0x80004005): IBMDA400 Command
Args:
[ 1] = C SET lc_time_names = 'es_ES'
Stack Calls
===========
Called from: => TOLEAUTO:EXECUTE( 0 )
Called from: Source\AppPag.Prg => CONECTA( 1499 )
Called from: Source\AppPag.Prg => APPPAG( 73 )
With best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: Ejemplo de xBrowse
For this to properly work, Date2Txt() should not be a "STATIC" FUNCTION.the columns in xbrowse shows the string
"Date2Txt( DameFecha(CARFEC) )", "Date2Txt( DameFecha(CARVTO) )"
Please make it a normal FUNCTION
FUNCTION Date2Txt(...
Not
STATIC FUNCTION Date2Txt(
Alternatively, we can also use
{ || Date2Txt( DameFecha( oRsCxc:Fields("CARFEC"):Value ) ) }, ...
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Ejemplo de xBrowse
Mr. Rao:
I made not static the DameFecha() function instead Date2Txt() function and
now everything is fine.
I have an other questions, I'll open an other post.
I am vey gratefuly.
With best regards
I made not static the DameFecha() function instead Date2Txt() function and
now everything is fine.
I have an other questions, I'll open an other post.
I am vey gratefuly.
With best regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero