#include "fivewin.ch"
#include "xbrowse.ch"
// #include "colores.ch"
#define METRO_EXCEL1 RGB( 33,115, 70 )
#define METRO_WORD1 RGB( 43, 87,154 )
STATIC aWnd, oBrw, oQry, oWnd
PROCEDURE Personal
LOCAL cMsg, oIco, oWait, oCols, aCols
LOCAL oFont, oBold, eFont, oServer, xWind
hb_gcAll( .F. ) // limpiamos la memoria
WaitOn( "Espere un momento por favor...", @oWait )
// SysRefresh() ???
IF !CheckConect()
WaitOff( @oWait )
MsgStop( "Falla de conexion al servidor, reintente !!!", "STOP" )
RETURN
ENDIF
cMsg := "SELECT p.*,CONCAT(apellido_p,' ',apellido_m,' ',nombres) AS nombresx FROM personal p ORDER BY nombresx"
oQry := oServer:RowSet( cMsg )
IF oWnd:nWidth <= 850
xWind := 830
ELSE
xWind := 830
ENDIF
aCols := { ;
{ "id", "ID", NIL, 60, AL_LEFT }, ;
{ "codigo", "CODIGO", NIL, 80, AL_LEFT }, ;
{ "nombresx", "APELLIDOS Y NOPMBRES", NIL, 200, AL_LEFT }, ;
{ "cargo", "PUESTO", NIL, 100, AL_LEFT }, ;
{ "horario_1", "INGRESO", NIL, 80, AL_LEFT }, ;
{ "horario_2", "SALIDA", NIL, 80, AL_LEFT }, ;
{ "horario_3", "INICIO", NIL, 80, AL_LEFT }, ;
{ "horario_4", "FINAL", NIL, 80, AL_LEFT };
}
DEFINE ICON oIco FILE ".\img\user.ico"
DEFINE FONT oFont NAME "Segoe UI" SIZE 0, - 10
DEFINE FONT oBold NAME 'Segoe UI' SIZE 0, - 12 BOLD
DEFINE FONT eFont NAME 'Lucida Console' SIZE 0, - 12
DEFINE WINDOW aWnd FROM 0, 0 TO oWnd:nHeight - 225, xWind PIXEL MDICHILD ;
OF oWnd TITLE "MANTENIMIENTO DE PERSONAL" ICON oIco ;
COLOR CLR_BLACK, RGB( 250, 250, 250 ) ;
STYLE nOr( WS_CAPTION, WS_VISIBLE, WS_SYSMENU ) // , WS_POPUP
@0, 0 XBROWSE oBrw OF aWnd DATASOURCE oQry COLUMNS aCols ;
LINES CELL FASTEDIT PIXEL
WITH OBJECT oBrw
:bClrRowFocus := oBrw:bClrSelFocus
:nRowHeight := 25
:nHeaderLines := 4
:nHeaderHeight := 60
:oHeaderFonts := oFont
:nFooterHeight := 20
:nFooterLines := 2
:oFooterFonts := eFont
:nFreeze := 3
:nStretchCol := 3
:lAllowColHiding := .F.
:lAllowColSwapping := .F.
:lDisplayZeros := .F.
:lRecordSelector := .F.
:lHScroll := .F.
:l2007 := .F.
:lFooter := .T.
:lDrawBorder := .T.
:lAllowColReGroup := .T.
:lColDividerComplete := .T.
:SetGroupHeader( 'Jornada', 5, 6, oFont )
:SetGroupHeader( 'Refrigerio', 7, 8, oFont )
:bClrHeader := { || { nRGB( 000, 000, 000 ), METRO_EXCEL1 } }
:bClrSel := { || { CLR_BLACK, CLR_HGRAY } }
:bClrStd := { || IF( oBrw:KeyNo() % 2 == 0, { CLR_BLACK, RGB( 198, 255, 198 ) }, { CLR_BLACK, RGB( 232, 255, 232 ) } ) }
:bClrFooter := { || { CLR_WHITE, METRO_WORD1 } }
:bClrEdits := { || { CLR_BLACK, CLR_YELLOW } }
END
AEval( oBrw:aCols, {| o | o:nHeadStrAlign := AL_CENTER, o:oDataFont := oFont } )
oBrw:CreateFromCode()
aWnd:oClient := oBrw
BrwBtnBar() // FUNCIONA CORRECTO?
WaitOff( @oWait ) // Muestre esto, pls;
ACTIVATE WINDOW aWnd MAXIMIZED ;
ON INIT( oBrw:SetFocus() )
hb_gcAll( .T. ) // limpiamos la memoria
RETURN
STATIC PROCEDURE BrwbtnBar() // FUNCIONA BIEN?
LOCAL oBar, oBtn, oBold
DEFINE BUTTONBAR oBar OF oBrw:oWnd SIZE 75, 75 3D HEIGHT 96 2015
DEFINE BUTTON OF oBar FILE ".\img\new.bmp" TOP PROMPT "&Nuevo" ;
GROUP LABEL "MANTENIMIENTO" COLORS CLR_BLACK, CLR_HRED ;
TOOLTIP { "Crear nuevo personal", "Mantenimiento" } ;
ACTION AddReg( .T. )
DEFINE BUTTON OF oBar FILE ".\img\edit.bmp" TOP PROMPT "&Editar" ;
TOOLTIP { "Editar los datos del personal", "Mantenimiento" } ;
ACTION AddReg( .F. )
DEFINE BUTTON OF oBar FILE ".\img\no.bmp" TOP PROMPT "&Borrar" ;
TOOLTIP { "Eliminar el registro del personal", "Mantenimiento" } ;
ACTION DelReg()
DEFINE BUTTON OF oBar FILE ".\img\exit.bmp" PROMPT "&Salir" ;
ACTION ( oQry:End(), aWnd:End(), aWnd := NIL ) ;
TOOLTIP { "Cerrar Ventana", "Mantenimiento" } BTNRIGHT FLAT
AEval( oBar:aControls, {| oBtn | oBtn:bColorMap := {| o | If( o:lMOver, { CLR_BLACK, CLR_HRED }, NIL ) } } )
//ATUNCAR.prg(137) Warning W0006 Procedure returns value
RETURN( oBar )
STATIC PROCEDURE AddReg( modo )
LOCAL oDlg, oGet[ 10 ], oWait, cMsg, oServer
LOCAL cGet[ 10 ]
LOCAL lRet := .F.
IF modo // inc // .T.
cGet[ 01 ] := Space( 11 )
cGet[ 02 ] := Space( 20 )
cGet[ 03 ] := Space( 30 )
cGet[ 04 ] := Space( 30 )
cGet[ 05 ] := Space( 90 )
cGet[ 06 ] := Space( 50 )
cGet[ 07 ] := Space( 10 )
cGet[ 08 ] := Space( 10 )
cGet[ 09 ] := Space( 10 )
cGet[ 10 ] := Space( 10 )
ELSE // alt // .F.
cGet[ 01 ] := oQry:codigo
cGet[ 02 ] := oQry:nombres
cGet[ 03 ] := oQry:apellido_p
cGet[ 04 ] := oQry:apellido_m
cGet[ 05 ] := oQry:direccion
cGet[ 06 ] := oQry:cargo
cGet[ 07 ] := oQry:horario_1
cGet[ 08 ] := oQry:horario_2
cGet[ 09 ] := oQry:horario_3
cGet[ 10 ] := oQry:horario_4
ENDIF
DEFINE DIALOG oDlg RESOURCE "personal"
REDEFINE GET oGet[ 01 ] VAR cGet[ 01 ] ID 100 OF oDlg UPDATE ;
VALID GetCodigo( cGet[ 01 ], modo )
REDEFINE GET oGet[ 02 ] VAR cGet[ 02 ] ID 101 OF oDlg PICTURE "@!" UPDATE
REDEFINE GET oGet[ 03 ] VAR cGet[ 03 ] ID 102 OF oDlg PICTURE "@!" UPDATE
REDEFINE GET oGet[ 04 ] VAR cGet[ 04 ] ID 103 OF oDlg PICTURE "@!" UPDATE
REDEFINE GET oGet[ 05 ] VAR cGet[ 05 ] ID 104 OF oDlg UPDATE
REDEFINE GET oGet[ 06 ] VAR cGet[ 06 ] ID 105 OF oDlg UPDATE
REDEFINE GET oGet[ 07 ] VAR cGet[ 07 ] ID 106 OF oDlg PICTURE "99:99:99" UPDATE
REDEFINE GET oGet[ 08 ] VAR cGet[ 08 ] ID 107 OF oDlg PICTURE "99:99:99" UPDATE
REDEFINE GET oGet[ 09 ] VAR cGet[ 09 ] ID 108 OF oDlg PICTURE "99:99:99" UPDATE
REDEFINE GET oGet[ 10 ] VAR cGet[ 10 ] ID 109 OF oDlg PICTURE "99:99:99" UPDATE
REDEFINE BUTTON ID 200 OF oDlg ACTION ( lRet := .T., oDlg:End() )
REDEFINE BUTTON ID 201 OF oDlg ACTION ( lRet := .F., oDlg:End() ) CANCEL
ACTIVATE DIALOG oDlg CENTERED
IF lRet
IF CheckConect()
WaitOn( "Espere, un momento por favor...", @oWait ) // ???
IF modo
cMsg := "INSERT INTO personal SET "
ELSE
cMsg := "UPDATE personal SET "
ENDIF
cMsg += "codigo = " + ClipValue2Sql( cGet[ 01 ] )
cMsg += ",nombres = " + ClipValue2Sql( cGet[ 02 ] )
cMsg += ",apellido_p = " + ClipValue2Sql( cGet[ 03 ] )
cMsg += ",apellido_m = " + ClipValue2Sql( cGet[ 04 ] )
cMsg += ",direccion = " + ClipValue2Sql( cGet[ 05 ] )
cMsg += ",cargo = " + ClipValue2Sql( cGet[ 06 ] )
cMsg += ",horario_1 = " + ClipValue2Sql( cGet[ 07 ] )
cMsg += ",horario_2 = " + ClipValue2Sql( cGet[ 08 ] )
cMsg += ",horario_3 = " + ClipValue2Sql( cGet[ 09 ] )
cMsg += ",horario_4 = " + ClipValue2Sql( cGet[ 10 ] )
IF !modo
cMsg += " WHERE id=" + ClipValue2Sql( oQry:id ) // ???
ENDIF
oServer:Execute( cMsg )
IF modo
oQry:ReQuery()
ELSE
oQry:ReSync()
ENDIF
oBrw:Refresh()
WaitOff( @oWait ) // ????
ELSE
MsgStop( "Verifique su conexion al servidor....", "Stop" )
ENDIF
ENDIF
RETURN
STATIC PROCEDURE DelReg
LOCAL cMsg
IF MsgYesNo( "Desea Eliminar este registro ? ", "Confirme" )
IF CheckConect()
cMsg := "DELETE FROM personal WHERE id=" + ClipValue2Sql( oQry:id )
oQry:Execute( cMsg )
oQry:ReQuery()
oBrw:Refresh()
ENDIF
ENDIF
RETURN
STATIC FUNCTION GetCodigo( cCodigo, modo )
LOCAL cMsg, cQry, oServer
LOCAL lRet := .T.
IF CheckConect()
cMsg := "SELECT * FROM personal WHERE codigo=" + ClipValue2Sql( cCodigo )
IF !modo
cMsg += " AND id != " + ClipValue2Sql( oQry:id )
ENDIF
cQry := oServer:Query( cMsg )
IF cQry:LastRec() > 0
lRet := .F.
MsgStop( "Codigo ingresado ya existe !!!", "Stop" )
ENDIF
cQry:End()
ENDIF
RETURN( lRet )
/*
Error: Unresolved external '_HB_FUN_WAITON'
Error: Unresolved external '_HB_FUN_CHECKCONECT'
Error: Unresolved external '_HB_FUN_WAITOFF'
Error: Unresolved external '_HB_FUN_CLIPVALUE2SQL'
*/
// FIN / END
MSGRUN( "Guardando datos", "Usuario un momento por favor", {|| GuardaDatos() } )
#include "FiveWin.ch"
function Main()
local oWnd, oDlg
DEFINE WINDOW oWnd
@ 2, 2 BUTTON "Test" ACTION ( oDlg := Test(), SysWait( 5 ), oDlg:End() ) SIZE 80, 20
ACTIVATE WINDOW oWnd
return nil
function Test()
local oDlg
DEFINE DIALOG oDlg
ACTIVATE DIALOG oDlg NOWAIT
return oDlg
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: Google [Bot] and 11 guests