/*
*
* 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
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
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';"
oRsHdr := FW_OpenRecordSet(oApp:oCon,"SELECT " +;
"* " +;
"FROM " +;
"HdrVts " +; <<=============
"WHERE " +;
"HDR_FDV = '" + DtoS(dHoy) + "' " +;
"ORDER BY " +;
"HDR_FOL",adLockOptimistic,adOpenDynamic,0)
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()
oRsHdr:Fields("HDR_HDV"):Value := Time() <==========
#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
xBrowse oRsHdrFASTEDIT
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
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.
#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
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
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 79 guests