Picture para campo Time() (Resuelto)

Picture para campo Time() (Resuelto)

Postby Armando » Tue Mar 08, 2022 7:47 pm

Saludos al foro:

Amigos, tengo una tabla con un campo TIME() cuyo contenido es 13:45:00, necesito
mostrar este campo en un XBrowse pero la columna se muestra en blanco, asumo
que debe llevar un picture pero no atino a encontrar cual debe ser, algún hilo?

Saludos
Last edited by Armando on Sat Mar 12, 2022 4:47 pm, edited 1 time in total.
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
User avatar
Armando
 
Posts: 3230
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Picture para campo Time()

Postby karinha » Tue Mar 08, 2022 9:55 pm

Code: Select all  Expand view  RUN

/*
*
* XbRowEd.Prg
*
* Using oBrw:CurrentRow() object for popup edits
*
*/



#include 'fivewin.ch'
#include 'adodef.ch'  // in \fwh\include folder
#include 'ord.ch'
#include 'xbrowse.ch'

REQUEST DBFCDX

function Main()

   local oBrw, oDlg, uData
   local oFont

   SET EXCLUSIVE OFF
   SET DELETED ON
   SET OPTIMIZE ON

   SetGetColorFocus()

   uData    := OpenData()

   DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
   DEFINE DIALOG oDlg SIZE 640,460 PIXEL TITLE 'XBrowse Row Edit' ;
      FONT oFont

   @ 10,10 XBROWSE oBrw SIZE -10,-30 PIXEL OF oDlg ;
      COLUMNS 'First', 'City', 'Age', 'Salary', "hora" ;
      PICTURES nil, nil, '999', '99,999,999.99', "99:99:99" ;
      OBJECT uData ;
      AUTOSORT CELL LINES NOBORDER ;
      ON DBLCLICK RowEdit( oBrw:CurrentRow() )

   WITH OBJECT oBrw
      :nStretchCol  := STRETCHCOL_WIDEST
      :CreateFromCode()
   END

   @ 210, 10 BUTTON 'Edit'  SIZE 40,14 PIXEL OF oDlg ACTION RowEdit( oBrw:CurrentRow() )
   @ 210,270 BUTTON 'Close' SIZE 40,14 PIXEL OF oDlg ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   CloseData( uData )

return nil

static function RowEdit( oRow )

   LOCAL oDlg

   DEFINE DIALOG oDlg SIZE 300,200 PIXEL TITLE 'Edit Customer' ;
      FONT oRow:oBrw:oFont

   @  10, 10 SAY 'First' SIZE 40,10 PIXEL OF oDlg RIGHT
   @  10, 60 GET oRow:First SIZE 80,12 PIXEL OF oDlg UPDATE ;
            VALID ( oDlg:AEvalWhen(), .t. )

   @  25, 10 SAY 'City' SIZE 40,10 PIXEL OF oDlg RIGHT
   @  25, 60 GET oRow:City SIZE 80,12 PIXEL OF oDlg UPDATE ;
            VALID ( oDlg:AEvalWhen(), .t. )

   @  40, 10 SAY 'Age' SIZE 40,10 PIXEL OF oDlg RIGHT
   @  40, 60 GET oRow:Age ;
      SIZE oRow:oBrw:Age:nWidth / 2,12 PIXEL OF oDlg UPDATE ;
      PICTURE oRow:oBrw:Age:cEditPicture RIGHT ;
      VALID ( oDlg:AEvalWhen(), .t. )

   @  55, 10 SAY 'Salary' SIZE 40,10 PIXEL OF oDlg RIGHT
   @  55, 60 GET oRow:Salary ;
      SIZE oRow:oBrw:Salary:nWidth / 2,12 PIXEL OF oDlg UPDATE ;
      PICTURE oRow:oBrw:Salary:cEditPicture RIGHT ;
      VALID ( oDlg:AEvalWhen(), .t. )

   @  80, 10 BUTTON 'Undo'  SIZE 30,12 PIXEL OF oDlg ;
      WHEN oRow:Modified() ACTION ( oRow:Undo(), oDlg:Update() )

   @  80, 78 BUTTON 'Save'  SIZE 30,12 PIXEL OF oDlg ;
      WHEN oRow:Modified() ACTION ( oRow:Save(), oDlg:AEvalWhen() )

   @  80,110 BUTTON 'Close' SIZE 30,12 PIXEL OF oDlg ACTION oDlg:End()

   ACTIVATE DIALOG oDlg CENTERED NOMODAL

return nil

// ----  DATA OPEN AND CLOSE FUNCTIONS ---- //

static function OpenData

   local uData, nDataType

   nDataType   := Max( 1, Alert( 'DataType', { 'DBFCDX', 'TDataBase', 'ADO' } ) )

   if nDataType > 2
      uData := OpenADO()
   else
      USE CUSTOMER NEW ALIAS CUST SHARED VIA 'DBFCDX'
      DATABASE uData

      if nDataType == 1
         uData := 'CUST'
      endif

   endif

return uData

static function OpenADO

   local oCn, oRs, cPath := HB_CURDRIVE() + ':' + CURDIR()

   oCn      := TOleAuto():New( '
ADODB.Connection' )
   WITH OBJECT oCn
      :ConnectionString := '
Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=' + cPath
      :CursorLocation   := adUseClient
      :Open()
   END

   oRs      := TOleAuto():New( '
ADODB.RecordSet' )
   WITH OBJECT oRs
      :ActiveConnection := oCn
      :Source           := '
CUSTOMER'
      :LockType         := adLockOptimistic
      :Open()
   END

return oRs

static function CloseData( uData )

   local oCn

   if ValType( uData ) == '
O'
      if Upper( uData:ClassName ) = '
TOLEAUTO'
         oCn   := uData:ActiveConnection
         uData:Close()
         oCn:Close()
      else
         uData:Close()
      endif
   else
      CLOSE DATA
   endif

return nil


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Picture para campo Time()

Postby Armando » Tue Mar 08, 2022 10:04 pm

Karinha:

Gracias por la respuesta, pero no no me funciona con el picture "99:99:99",
olvide mencionar que uso MySql, tal vez por eso.

Saludos
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
User avatar
Armando
 
Posts: 3230
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Picture para campo Time()

Postby karinha » Tue Mar 08, 2022 10:22 pm

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Picture para campo Time()

Postby nageswaragunupudi » Fri Mar 11, 2022 4:18 pm

Armando wrote:Saludos al foro:

Amigos, tengo una tabla con un campo TIME() cuyo contenido es 13:45:00, necesito
mostrar este campo en un XBrowse pero la columna se muestra en blanco, asumo
que debe llevar un picture pero no atino a encontrar cual debe ser, algún hilo?

Saludos


Is the field type "TIME" in MySql?
Are you using ADO or FWH built-in mysql library?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10654
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Picture para campo Time()

Postby Armando » Fri Mar 11, 2022 5:06 pm

Mr. Rao:

Tanks in advance.

I'm using ADO and yes, the field is a Time field, this is my code

Code: Select all  Expand view  RUN

   cCmdSql := "CREATE TABLE IF NOT EXISTS HdrVts (" +;
                  "HDR_FOL DECIMAL(07,0)      NOT NULL    DEFAULT 0            COMMENT 'Número de folio'," +;
                  "HDR_FDV DATE               NOT NULL    DEFAULT '0000-00-00' COMMENT 'Fecha de venta'," +;
                  "HDR_HDV TIME               NOT NULL    DEFAULT '00:00:00'   COMMENT 'Hora de venta'," +;   <========= This is the time field
                  "HDR_CTD DECIMAL(03,0)      NOT NULL    DEFAULT 0            COMMENT 'Cantidad total'," +;
                  "HDR_IMP DECIMAL(09,2)      NOT NULL    DEFAULT 0.00         COMMENT 'Importe total'," +;
                  "HDR_USU VARCHAR(20)        NOT NULL    DEFAULT ''           COMMENT 'Nombre del usuario'," +;
                  "HDR_CAN BIT                NOT NULL    DEFAULT 0            COMMENT 'Cancelada ?'," +;
                  "HDR_MOT TINYTEXT           NOT NULL                         COMMENT 'Motivo de la cancelación'," +;
                  "PRIMARY KEY(HDR_FOL))" +;
                  "ENGINE = InnoDB                                             COMMENT 'Encabezado de vales de venta';"
 


And I open the table as:

Code: Select all  Expand view  RUN
  oRsHdr := FW_OpenRecordSet(oApp:oCon,"SELECT " +;
                                          "* " +;
                                         "FROM " +;
                                          "HdrVts " +;                  <<=============
                                       "WHERE " +;
                                          "HDR_FDV = '" + DtoS(dHoy) + "' " +;
                                       "ORDER BY " +;
                                          "HDR_FOL",adLockOptimistic,adOpenDynamic,0)
 


And this my code to save datas

Code: Select all  Expand view  RUN

      oRsHdr:AddNew()
      oRsHdr:Fields("HDR_FOL"):Value := oHdr:FOL
      oRsHdr:Fields("HDR_FDV"):Value := Date()
      oRsHdr:Fields("HDR_HDV"):Value := Time()           <==========
      oRsHdr:Fields("HDR_CTD"):Value := oBrx:aCols[01]:nCount //Total
      oRsHdr:Fields("HDR_IMP"):Value := oBrx:aCols[04]:nTotal
      oRsHdr:Fields("HDR_USU"):Value := oApp:cUsuario
      oRsHdr:Fields("HDR_CAN"):Value := oHdr:CAN
      oRsHdr:Fields("HDR_MOT"):Value := oHdr:MOT
      oRsHdr:UpDate()
 


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
User avatar
Armando
 
Posts: 3230
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Picture para campo Time()

Postby nageswaragunupudi » Fri Mar 11, 2022 7:17 pm

oRsHdr:Fields("HDR_HDV"):Value := Time() <==========

This is working for me.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10654
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Picture para campo Time()

Postby Armando » Fri Mar 11, 2022 7:24 pm

Mr. Rao:

Yes, the problem is that I can't show that field in a xBrowse, I don't know what PICTURE should I use

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
User avatar
Armando
 
Posts: 3230
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Picture para campo Time()

Postby nageswaragunupudi » Sat Mar 12, 2022 2:38 am

Here, xbrowse displays the time field value.
Please try this test program.
This program connects to our cloud server and you can also connect.
Code: Select all  Expand view  RUN
#include "fivewin.ch"
#include "adodef.ch"

function Main()

   local oCn, oRs, cSql

   oCn   := FW_OpenAdoConnection( { "MYSQL", "208.91.198.197:3306", "fwhdemo", "gnraofwh", "Bharat@1950" }, .t. )

   if FW_AdoTableExists( "timefield", oCn )
      oCn:Execute( "DROP TABLE `timefield`" )
   endif

TEXT INTO cSql
CREATE TABLE `timefield` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `FNAME` varchar(10) DEFAULT NULL,
  `FTIME` time DEFAULT NULL,
  PRIMARY KEY (`id`)
)
ENDTEXT

   oCn:Execute( cSql )

   oRs   := FW_OpenRecordSet( oCn, "timefield" )

   oRs:AddNew()
   oRs:Fields( "FNAME" ):Value := "MON"
   oRs:Fields( "FTIME" ):Value := TIME()
   oRs:Update()

   oRs:AddNew( { "FNAME", "FTIME" }, { "TUE", "13:25:45" } )

   XBROWSER oRs FASTEDIT

   oRs:Close()
   oCn:Close()

return nil
 


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10654
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Picture para campo Time()

Postby Armando » Sat Mar 12, 2022 3:08 am

Mr. Rao:

Using this code

Code: Select all  Expand view  RUN

xBrowse oRsHdrFASTEDIT
 


Everything is ok, but I don't use that code I use this one

Code: Select all  Expand view  RUN

            REDEFINE XBROWSE oBrw ID 200 OF oDlg;
                DATASOURCE oRsHdr;
                COLUMNS "HDR_FOL","HDR_CTD","HDR_IMP","HDR_CAN","HDR_MOT","HDR_HDV";
                HEADERS "Folio","Cantidad","Importe","Can","Motivo de la cancelación","Hora";
                COLSIZES 50,60,90,40,250,80;
                PICTURES "@Z 9999999","@Z 999","@Z 999,999.99",NIL,NIL,NIL;
                JUSTIFY {AL_RIGHT,AL_RIGHT,AL_RIGHT,AL_CENTER,AL_LEFT,AL_LEFT};
                FOOTERS AUTOSORT BACKGROUND oApp:cBrush
 


And here is the image, please look the "Hora" column, the field "HDR_HDV" has "20:05:01" value

Image

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
User avatar
Armando
 
Posts: 3230
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Picture para campo Time()

Postby nageswaragunupudi » Sat Mar 12, 2022 5:08 am

First, please try with a simpler code:
Code: Select all  Expand view  RUN

            FWNumFormat( "A", .t. )

            REDEFINE XBROWSE oBrw ID 200 OF oDlg;
                DATASOURCE oRsHdr;
                COLUMNS "HDR_FOL","HDR_CTD","HDR_IMP","HDR_CAN","HDR_MOT","HDR_HDV";
                HEADERS "Folio","Cantidad","Importe","Can","Motivo de la cancelación","Hora";
                FOOTERS AUTOSORT

            oBrw:lDisplayZeros := .f.
// do not assign any cDataType to any column.
// to start with do not assign any colors or other attribs to oBrw
// just keep the code to the minimum.
 

There seems to be only one record.
May be the value is NULL.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10654
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Picture para campo Time()

Postby nageswaragunupudi » Sat Mar 12, 2022 7:19 am

Code: Select all  Expand view  RUN
#include "fivewin.ch"

function Main()

   local oCn, oRs, cSql
   local oDlg, oBrw, oFont

   FWNumFormat( "A", .t. )

   oCn   := FW_OpenAdoConnection( { "MYSQL", "208.91.198.197:3306", "fwhdemo", "gnraofwh", "Bharat@1950" }, .t. )
   ? "Connected"

   if FW_AdoTableExists( "HdrVts", oCn )
      oCn:Execute( "DROP TABLE `HdrVts`" )
   endif

   cSql := "CREATE TABLE IF NOT EXISTS HdrVts (" +;
           "HDR_FOL DECIMAL(07,0)      NOT NULL    DEFAULT 0            COMMENT 'Número de folio'," +;
           "HDR_FDV DATE               NOT NULL    DEFAULT '0000-00-00' COMMENT 'Fecha de venta'," +;
           "HDR_HDV TIME               NOT NULL    DEFAULT '00:00:00'   COMMENT 'Hora de venta'," +;
           "HDR_CTD DECIMAL(03,0)      NOT NULL    DEFAULT 0            COMMENT 'Cantidad total'," +;
           "HDR_IMP DECIMAL(09,2)      NOT NULL    DEFAULT 0.00         COMMENT 'Importe total'," +;
           "HDR_USU VARCHAR(20)        NOT NULL    DEFAULT ''           COMMENT 'Nombre del usuario'," +;
           "HDR_CAN BIT                NOT NULL    DEFAULT 0            COMMENT 'Cancelada ?'," +;
           "HDR_MOT TINYTEXT           DEFAULT NULL                     COMMENT 'Motivo de la cancelación'," +;
           "PRIMARY KEY(HDR_FOL))" +;
           "ENGINE = InnoDB"

   oCn:Execute( cSql )

   oRs   := FW_OpenRecordSet( oCn, "SELECT * FROM HdrVts WHERE HDR_FDV =" + ;
            FW_ValToSQL( Date() ) + "ORDER BY HDR_FOL" )

   oRs:AddNew()
   oRs:Fields("HDR_FOL"):Value := 1
   oRs:Fields("HDR_FDV"):Value := Date()
   oRs:Fields("HDR_HDV"):Value := Time()
   oRs:Fields("HDR_CTD"):Value := 20
   oRs:Fields("HDR_IMP"):Value := 2000
   oRs:Fields("HDR_USU"):Value := "USER"
   oRs:Fields("HDR_CAN"):Value := .t.
   oRs:Fields("HDR_MOT"):Value := "MOT"
   oRs:Update()


//   XBROWSER oRs FASTEDIT

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE 750,400 PIXEL TRUEPIXEL FONT oFont
   @ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
      DATASOURCE oRS;
      COLUMNS "HDR_FOL","HDR_CTD","HDR_IMP","HDR_CAN","HDR_MOT","HDR_HDV";
      HEADERS "Folio","Cantidad","Importe","Can","Motivo de la cancelación","Hora";
      FOOTERS AUTOSORT CELL LINES NOBORDER

   oBrw:lDisplayZeros := .f.
   oBrw:nEditTypes    := EDIT_GET
   oBrw:aCols[ 4 ]:SetCheck()

   oBrw:CreateFromCode()

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

   oRs:Close()
   oCn:Close()

return nil
 


Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10654
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Picture para campo Time()

Postby Armando » Sat Mar 12, 2022 7:31 am

Mr. Rao:

I'm afraid there is no solution, following your advice the problem continues, the table now has 3 records.

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
User avatar
Armando
 
Posts: 3230
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: Picture para campo Time()

Postby nageswaragunupudi » Sat Mar 12, 2022 9:01 am

Armando wrote:Mr. Rao:

I'm afraid there is no solution, following your advice the problem continues, the table now has 3 records.

Best regards

Why?
I shown that with your data structures and your code, it is working fine on our cloud server.
You can run the program I posted above.

Please first build the program I posted and run it.
It SHOULD work.

PS: Your where clause is wrong. Please see my where clause
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10654
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Picture para campo Time() (Resuelto)

Postby Armando » Sat Mar 12, 2022 4:49 pm

Mr. Rao and friends:

with Mr Rao code the problem is solved. As usually!

Thank you very much Mr. Rao.

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
User avatar
Armando
 
Posts: 3230
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 18 guests