#include "fivewin.ch"
#include "adodef.ch"
static oCn
function Main()
local oWnd, oBar
FWNumFormat( "A", .t. )
SET DATE FORMAT TO "dd/mm/yyyy"
CursorWait()
oCn := FW_OpenAdoConnection( { "MYSQL","208.91.198.197:3306", "fwhdemo", "gnraofwh", "Bharat@1950" }, .t. )
DEFINE WINDOW oWnd MDI
DEFINE BUTTONBAR oBar OF oWnd SIZE 45,45 2007
DEFINE BUTTON OF oBar PROMPT "TEST" CENTER ACTION Test()
oWnd:oWndClient:bPainted := {||oWnd:oWndClient:DrawImage( "c:\fwh\bitmaps\logo.bmp", "BR" )}
ACTIVATE WINDOW oWnd
return nil
static function Test()
local oDlg, oWndChild
local oBar, oMsgBar, oBrw
local oRsHdr
CreateTable()
oRsHdr := OpenTable()
DEFINE DIALOG oDlg SIZE 700,400 PIXEL TRUEPIXEL
DEFINE BUTTONBAR oBar OF oDlg SIZE 56,42 2007
DEFINE BUTTON OF oBar PROMPT "Add" CENTER ACTION InsertMovs( oBrw )
DEFINE BUTTON OF oBar PROMPT "Zap" CENTER ACTION ( ;
oCn:Execute( "TRUNCATE TABLE `HdrVda`" ), ;
oRsHdr:ReQuery(), oBrw:Refresh(), oBrw:SetFocus() )
DEFINE BUTTON OF oBar PROMPT "Close" CENTER ACTION oWndChild:End()
@ oBar:nHeight, 0 XBROWSE oBrw SIZE 0,-30 PIXEL OF oDlg ;
DATASOURCE oRsHdr ;
COLUMNS "HDR_FOL","HDR_FDM","HDR_REF",;
"IF( HDR_EOS == 1, 'Entrada', 'Salida' )",;
"IF( HDR_EOS == 1, HDR_TOU, 0.00 )",;
"IF( HDR_EOS == 1, HDR_TOC, 0.00 )",;
"IF( HDR_EOS == 2, HDR_TOU, 0.00 )",;
"IF( HDR_EOS == 2, HDR_TOC, 0.00 )",;
"[SUC_NOM]","HDR_CAN";
HEADERS "Folio","Fecha","Referencia","Tipo","Unidades","Costos","Unidades","Costos","Sucursal","Can";
LINES NOBORDER
WITH OBJECT oBrw
:bGotFocus := { || oRsHdr:Requery(), oBrw:Refresh() }
//
:CreateFromCode()
END
oDlg:oClient := oBrw
oDlg:bPostEnd := { || oRsHdr:Close() }
ACTIVATE DIALOG oDlg AS MDICHILD SETUP ( ;
oWndChild := oWnd, ;
oMsgBar := TMsgBar():New( oWnd,,,,,,,,,,.t. ) )
return nil
STATIC FUNCTION CreateTable()
LOCAL cCmdSql := NIL
// oApp:oCon:Execute("USE Test")
cCmdSql := "CREATE TABLE IF NOT EXISTS HdrVda (" +;
"HDR_FOL INTEGER(03) NOT NULL AUTO_INCREMENT COMMENT 'Folio'," +;
"HDR_EOS DECIMAL(01,0) NOT NULL DEFAULT 0 COMMENT 'E=Entrada y S=Salida'," +;
"HDR_SUC DECIMAL(03,0) NULL COMMENT 'Número de sucursal'," +;
"HDR_FDM DATE NOT NULL DEFAULT '0000-00-00' COMMENT 'Fecha del movimiento'," +;
"HDR_REF VARCHAR(15) NOT NULL DEFAULT '' COMMENT 'Referencia'," +;
"HDR_TOU DECIMAL(05,0) NOT NULL DEFAULT 0 COMMENT 'Total de unidades'," +;
"HDR_TOC DECIMAL(11,2) NOT NULL DEFAULT 0.00 COMMENT 'Total de costos'," +;
"HDR_CAN BIT NOT NULL DEFAULT 0 COMMENT 'Cancelado ?'," +;
"HDR_MOT VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'Motivo de la cancelación'," +;
"PRIMARY KEY(HDR_FOL))" +;
"ENGINE = InnoDB COMMENT 'Encabezado de vales de almacén';"
oCn:Execute(cCmdSql)
RETURN(.T.)
STATIC FUNCTION OpenTable()
local oRsHdr
/*
oRsHdr := FW_OpenRecordSet( oCn,"SELECT " +;
"*," +;
"SUC_NOM " +;
"FROM " +;
"HdrVda " +;
"LEFT JOIN " +;
"Sucursales " +;
"ON " +;
"HDR_SUC = Sucursales.SUC_NUM",adLockOptimistic,adOpenDynamic,0)
*/
oRsHdr := FW_OpenRecordSet( oCn, "HdrVda" )
IF oRsHdr == nil
MsgStop("I can't open the table HDRVDA !",)
FW_ShowAdoError( oCn )
RETURN nil
ENDIF
IF oRsHdr:BOF() .AND. oRsHdr:EOF()
ELSE
oRsHdr:MoveFirst()
ENDIF
RETURN oRsHdr
STATIC FUNCTION InsertMovs(oBrw)
oBrw:oRs:AddNew( { "HDR_EOS", "HDR_FDM", "HDR_TOU", "HDR_TOC" }, ;
{ 1, Date(), 10, 175.25 } )
oBrw:oRs:AddNew( { "HDR_EOS", "HDR_SUC", "HDR_FDM", "HDR_REF", "HDR_TOU", "HDR_TOC" }, ;
{ 2, 1, Date(), "F_254", 150, 15000.00 } )
oBrw:oRs:ReQuery()
oBrw:Refresh()
oBrw:SetFocus()
RETURN(.T.)
#include "fivewin.ch"
#include "adodef.ch"
static oCn
function Main()
local oWnd, oBar
FWNumFormat( "A", .t. )
SET DATE FORMAT TO "dd/mm/yyyy"
CursorWait()
oCn := FW_OpenAdoConnection( { "MYSQL","208.91.198.197:3306", "fwhdemo", "gnraofwh", "Bharat@1950" }, .t. )
DEFINE WINDOW oWnd MDI
DEFINE BUTTONBAR oBar OF oWnd SIZE 45,45 2007
DEFINE BUTTON OF oBar PROMPT "TEST" CENTER ACTION Test()
oWnd:oWndClient:bPainted := {||oWnd:oWndClient:DrawImage( "c:\fwh\bitmaps\logo.bmp", "BR" )}
ACTIVATE WINDOW oWnd
return nil
static function Test()
local oDlg, oWndChild
local oBar, oMsgBar, oBrw
local oRsHdr
CreateTable()
oRsHdr := OpenTable()
DEFINE DIALOG oDlg SIZE 700,400 PIXEL TRUEPIXEL
DEFINE BUTTONBAR oBar OF oDlg SIZE 56,42 2007
DEFINE BUTTON OF oBar PROMPT "Add" CENTER ACTION InsertMovs( oBrw )
DEFINE BUTTON OF oBar PROMPT "Zap" CENTER ACTION ( ;
oCn:Execute( "TRUNCATE TABLE `HdrVda`" ), ;
oRsHdr:ReQuery(), oBrw:Refresh(), oBrw:SetFocus() )
DEFINE BUTTON OF oBar PROMPT "Close" CENTER ACTION oWndChild:End()
@ oBar:nHeight, 0 XBROWSE oBrw SIZE 0,-30 PIXEL OF oDlg ;
DATASOURCE oRsHdr ;
COLUMNS "HDR_FOL","HDR_FDM","HDR_REF",;
"IF( HDR_EOS == 1, 'Entrada', 'Salida' )",;
"IF( HDR_EOS == 1, HDR_TOU, 0.00 )",;
"IF( HDR_EOS == 1, HDR_TOC, 0.00 )",;
"IF( HDR_EOS == 2, HDR_TOU, 0.00 )",;
"IF( HDR_EOS == 2, HDR_TOC, 0.00 )",;
"[SUC_NOM]","HDR_CAN";
HEADERS "Folio","Fecha","Referencia","Tipo","Unidades","Costos","Unidades","Costos","Sucursal","Can";
LINES NOBORDER
WITH OBJECT oBrw
:bGotFocus := { || oRsHdr:Requery(), oBrw:Refresh() }
//
:CreateFromCode()
END
oDlg:oClient := oBrw
oDlg:bPostEnd := { || oRsHdr:Close() }
ACTIVATE DIALOG oDlg AS MDICHILD SETUP ( ;
oWndChild := oWnd, ;
oMsgBar := TMsgBar():New( oWnd,,,,,,,,,,.t. ) )
return nil
STATIC FUNCTION CreateTable()
LOCAL cCmdSql := NIL
local c
// oApp:oCon:Execute("USE Test")
cCmdSql := "CREATE TABLE IF NOT EXISTS HdrVda (" +;
"HDR_FOL INTEGER(03) NOT NULL AUTO_INCREMENT COMMENT 'Folio'," +;
"HDR_EOS DECIMAL(01,0) NOT NULL DEFAULT 0 COMMENT 'E=Entrada y S=Salida'," +;
"HDR_SUC DECIMAL(03,0) NULL COMMENT 'Número de sucursal'," +;
"HDR_FDM DATE NOT NULL DEFAULT '0000-00-00' COMMENT 'Fecha del movimiento'," +;
"HDR_REF VARCHAR(15) NOT NULL DEFAULT '' COMMENT 'Referencia'," +;
"HDR_TOU DECIMAL(05,0) NOT NULL DEFAULT 0 COMMENT 'Total de unidades'," +;
"HDR_TOC DECIMAL(11,2) NOT NULL DEFAULT 0.00 COMMENT 'Total de costos'," +;
"HDR_CAN BIT NOT NULL DEFAULT 0 COMMENT 'Cancelado ?'," +;
"HDR_MOT VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'Motivo de la cancelación'," +;
"PRIMARY KEY(HDR_FOL))" +;
"ENGINE = InnoDB COMMENT 'Encabezado de vales de almacén';"
oCn:Execute(cCmdSql)
if !FW_AdoTableExists( "Sucursales" )
FWAdoCreateTable( "Sucursales", {{ "SUC_NOM","C",10,0}}, oCn, "SUC_NUM" )
for each c in { "One", "Two", "Three" }
oCn:Execute( "INSERT INTO Sucursales ( SUC_NOM ) VALUES ('" + c + "')" )
next
endif
RETURN(.T.)
STATIC FUNCTION OpenTable()
local oRsHdr
/*
oRsHdr := FW_OpenRecordSet( oCn,"SELECT " +;
"*," +;
"SUC_NOM " +;
"FROM " +;
"HdrVda " +;
"LEFT JOIN " +;
"Sucursales " +;
"ON " +;
"HDR_SUC = Sucursales.SUC_NUM",adLockOptimistic,adOpenDynamic,0)
*/
oRsHdr := FW_OpenRecordSet( oCn, ;
"SELECT *,S.SUC_NOM FROM HdrVda H LEFT JOIN Sucursales S ON H.HDR_SUC = S.SUC_NUM ORDER BY HDR_FOL" )
IF oRsHdr == nil
MsgStop("I can't open the table HDRVDA !",)
FW_ShowAdoError( oCn )
RETURN nil
ENDIF
IF oRsHdr:BOF() .AND. oRsHdr:EOF()
ELSE
oRsHdr:MoveFirst()
ENDIF
RETURN oRsHdr
STATIC FUNCTION InsertMovs(oBrw)
oBrw:oRs:AddNew( { "HDR_EOS", "HDR_FDM", "HDR_TOU", "HDR_TOC" }, ;
{ 1, Date(), 10, 175.25 } )
oBrw:oRs:AddNew( { "HDR_EOS", "HDR_SUC", "HDR_FDM", "HDR_REF", "HDR_TOU", "HDR_TOC" }, ;
{ 2, 1, Date(), "F_254", 150, 15000.00 } )
oBrw:oRs:ReQuery()
oBrw:Refresh()
oBrw:SetFocus()
RETURN(.T.)
oCn := FW_OpenAdoConnection( { "MYSQL","localhost", "SiaJAEM", "root", "91502127" }, .t. )
oCn := FW_OpenAdoConnection( { "MYSQL","208.91.198.197:3306", "fwhdemo", "gnraofwh", "Bharat@1950" }, .t. )
I got the error
by the way, if I remove the LEFT JOIN code, there is no error at all.
cCmdSql := "CREATE TABLE IF NOT EXISTS Sucursales (" +;
"SUC_NUM TINYINT NOT NULL AUTO_INCREMENT COMMENT 'Número de sucursal'," +;
"SUC_NOM VARCHAR(40) NOT NULL DEFAULT '' COMMENT 'Nombre o Razón Social'," +;
"SUC_IAT VARCHAR(05) NOT NULL DEFAULT '' COMMENT 'Código IATA'," +;
"SUC_CAL VARCHAR(60) NOT NULL DEFAULT '' COMMENT 'Domicilio'," +;
"SUC_NUE VARCHAR(20) NOT NULL DEFAULT '' COMMENT 'Número exterior'," +;
"SUC_NUI VARCHAR(20) NOT NULL DEFAULT '' COMMENT 'Número interior'," +;
"SUC_COL VARCHAR(60) NOT NULL DEFAULT '' COMMENT 'Colonia'," +;
"SUC_COP VARCHAR(05) NOT NULL DEFAULT '' COMMENT 'Código postal'," +;
"SUC_CIU VARCHAR(25) NOT NULL DEFAULT '' COMMENT 'Población'," +;
"SUC_MUN VARCHAR(30) NOT NULL DEFAULT '' COMMENT 'Delegación o municipio'," +;
"SUC_EST VARCHAR(25) NOT NULL DEFAULT '' COMMENT 'Entidad federativa'," +;
"SUC_TEL VARCHAR(25) NOT NULL DEFAULT '' COMMENT 'Teléfono'," +;
"SUC_EMA VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'e-mail'," +;
"PRIMARY KEY(SUC_NUM))" +;
"ENGINE = InnoDB COMMENT 'Sucursales';"
CREATE TABLE `Sucursales` (
`SUC_NUM` int(11) NOT NULL AUTO_INCREMENT,
`SUC_NOM` varchar(10) DEFAULT NULL,
PRIMARY KEY (`SUC_NUM`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
"209.250.245.152","fwh","fwhuser","FiveTech@2022"
#include "fivewin.ch"
#include "adodef.ch"
static oCn
function Main()
local oWnd, oBar
FWNumFormat( "A", .t. )
SET DATE FORMAT TO "dd/mm/yyyy"
CursorWait()
oCn := FW_OpenAdoConnection( { "MYSQL","209.250.245.152","fwh","fwhuser","FiveTech@2022" }, .t. )
// oCn := FW_OpenAdoConnection( { "MYSQL","208.91.198.197:3306", "fwhdemo", "gnraofwh", "Bharat@1950" }, .t. )
// oCn := FW_OpenAdoConnection( { "MYSQL","localhost", "SiaJAEM", "root", "91502127" }, .t. )
DEFINE WINDOW oWnd MDI
DEFINE BUTTONBAR oBar OF oWnd SIZE 45,45 2007
DEFINE BUTTON OF oBar PROMPT "TEST" CENTER ACTION Test()
oWnd:oWndClient:bPainted := {||oWnd:oWndClient:DrawImage( "c:\fwh\bitmaps\logo.bmp", "BR" )}
ACTIVATE WINDOW oWnd
return nil
static function Test()
local oDlg, oWndChild
local oBar, oMsgBar, oBrw
local oRsHdr
CreateTable()
oRsHdr := OpenTable()
DEFINE DIALOG oDlg SIZE 700,400 PIXEL TRUEPIXEL
DEFINE BUTTONBAR oBar OF oDlg SIZE 56,42 2007
DEFINE BUTTON OF oBar PROMPT "Add" CENTER ACTION InsertMovs( oBrw )
DEFINE BUTTON OF oBar PROMPT "Zap" CENTER ACTION ( ;
oCn:Execute( "TRUNCATE TABLE `HdrVda`" ), ;
oRsHdr:ReQuery(), oBrw:Refresh(), oBrw:SetFocus() )
DEFINE BUTTON OF oBar PROMPT "Close" CENTER ACTION oWndChild:End()
@ oBar:nHeight, 0 XBROWSE oBrw SIZE 0,-30 PIXEL OF oDlg ;
DATASOURCE oRsHdr ;
COLUMNS "HDR_FOL","HDR_FDM","HDR_REF",;
"IF( HDR_EOS == 1, 'Entrada', 'Salida' )",;
"IF( HDR_EOS == 1, HDR_TOU, 0.00 )",;
"IF( HDR_EOS == 1, HDR_TOC, 0.00 )",;
"IF( HDR_EOS == 2, HDR_TOU, 0.00 )",;
"IF( HDR_EOS == 2, HDR_TOC, 0.00 )",;
"[SUC_NOM]","HDR_CAN";
HEADERS "Folio","Fecha","Referencia","Tipo","Unidades","Costos","Unidades","Costos","Sucursal","Can";
LINES NOBORDER
WITH OBJECT oBrw
:bGotFocus := { || oRsHdr:Requery(), oBrw:Refresh() }
//
:CreateFromCode()
END
oDlg:oClient := oBrw
oDlg:bPostEnd := { || oRsHdr:Close() }
ACTIVATE DIALOG oDlg AS MDICHILD SETUP ( ;
oWndChild := oWnd, ;
oMsgBar := TMsgBar():New( oWnd,,,,,,,,,,.t. ) )
return nil
STATIC FUNCTION CreateTable()
LOCAL cCmdSql := NIL
local c
// oApp:oCon:Execute("USE Test")
cCmdSql := "CREATE TABLE IF NOT EXISTS HdrVda (" +;
"HDR_FOL INTEGER(03) NOT NULL AUTO_INCREMENT COMMENT 'Folio'," +;
"HDR_EOS DECIMAL(01,0) NOT NULL DEFAULT 0 COMMENT 'E=Entrada y S=Salida'," +;
"HDR_SUC DECIMAL(03,0) NULL COMMENT 'Número de sucursal'," +;
"HDR_FDM DATE NULL COMMENT 'Fecha del movimiento'," +;
"HDR_REF VARCHAR(15) NOT NULL DEFAULT '' COMMENT 'Referencia'," +;
"HDR_TOU DECIMAL(05,0) NOT NULL DEFAULT 0 COMMENT 'Total de unidades'," +;
"HDR_TOC DECIMAL(11,2) NOT NULL DEFAULT 0.00 COMMENT 'Total de costos'," +;
"HDR_CAN BIT NOT NULL DEFAULT 0 COMMENT 'Cancelado ?'," +;
"HDR_MOT VARCHAR(50) NOT NULL DEFAULT '' COMMENT 'Motivo de la cancelación'," +;
"PRIMARY KEY(HDR_FOL))" +;
"ENGINE = InnoDB COMMENT 'Encabezado de vales de almacén';"
// "HDR_FDM DATE NOT NULL DEFAULT '0000-00-00' COMMENT 'Fecha del movimiento'," +;
oCn:Execute(cCmdSql)
if !FW_AdoTableExists( "Sucursales" )
FWAdoCreateTable( "Sucursales", {{ "SUC_NOM","C",10,0}}, oCn, "SUC_NUM" )
for each c in { "One", "Two", "Three" }
oCn:Execute( "INSERT INTO Sucursales ( SUC_NOM ) VALUES ('" + c + "')" )
next
endif
RETURN(.T.)
STATIC FUNCTION OpenTable()
local oRsHdr
oRsHdr := FW_OpenRecordSet( oCn, ;
"SELECT *,S.SUC_NOM FROM HdrVda H LEFT JOIN Sucursales S ON H.HDR_SUC = S.SUC_NUM ORDER BY HDR_FOL" )
//// "SELECT * FROM HdrVda ORDER BY HDR_FOL"
IF oRsHdr == nil
MsgStop("I can't open the table HDRVDA !",)
FW_ShowAdoError( oCn )
RETURN nil
ENDIF
IF oRsHdr:BOF() .AND. oRsHdr:EOF()
ELSE
oRsHdr:MoveFirst()
ENDIF
RETURN oRsHdr
STATIC FUNCTION InsertMovs(oBrw)
oBrw:oRs:AddNew( { "HDR_EOS", "HDR_FDM", "HDR_TOU", "HDR_TOC" }, ;
{ 1, Date(), 10, 175.25 } )
oBrw:oRs:AddNew( { "HDR_EOS", "HDR_SUC", "HDR_FDM", "HDR_REF", "HDR_TOU", "HDR_TOC" }, ;
{ 2, 1, Date(), "F_254", 150, 15000.00 } )
oBrw:oRs:ReQuery()
oBrw:Refresh()
oBrw:SetFocus()
RETURN(.T.)
"SELECT *,S.SUC_NOM FROM HdrVda H LEFT JOIN Sucursales S ON H.HDR_SUC = S.SUC_NUM ORDER BY HDR_FOL"
"SELECT H.*,S.SUC_NOM FROM HdrVda H LEFT JOIN Sucursales S ON H.HDR_SUC = S.SUC_NUM ORDER BY HDR_FOL"
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 58 guests