Cristobal
Me la puedes enviar
acuellar@lostajiboshotel.com
Muchas Gracias
csincuir wrote:Gracias CM, gracias por tus comentarios.
Los datos se estaban enviando correctamente, el problema era cabalmente la version de la TCalex que estaba utilizando, pero ya Cristobal amablemente me envió las fuentes corregidas de la TCalex y ya todo esta funcionando correctamente.
Gracias a todos por su ayuda con sus comentarios y ejemplo, que me ha servido grandemente para entender esta clase.
Saludos cordiales.
Carlos.
Vista Mensual
Vista Semanal
Vista Diaria
#include "fivewin.ch"
#include "calendar.ch"
#include "calex.ch"
#include "tselex.ch"
#include "ord.ch"
#include "tdolphin.ch"
#include "Report.ch"
MEMVAR oApp
//----------------------------------------------------------------------------//
STATIC oCalex, oBrw, oQryBrw, cVentana, oDlgBrw, nFilter, nSeekWild, oSelec
FUNCTION Agenda()
LOCAL oWnd, oExBar, oDtPick, oPanelExplorer, oPanelCalex, oPanel, oPanel1, oPanel2, hHand, oGet := ARRAY(10),;
oBot := ARRAY(5), nOption:=5, dDate := DATE()
DEFINE WINDOW oWnd MDICHILD OF oApp:oWnd TITLE "Agenda " + oApp:usuanom ICON oApp:oIco
*** Paneles
oPanelExplorer = TPanel():New( 0, 0, oWnd:nHeight, 280, oWnd )
oPanelCalex = TPanel():New( 0, 281, oWnd:nHeight, oWnd:nWidth, oWnd )
oExBar := TExplorerBar():New( 0, 0, 250, 300, oPanelExplorer )
oPanel := oExBar:AddPanel( "Seleccionar Fecha", ".\bitmaps\CALENDAR2.bmp", 255 )
oPanel:AddLink( "Ver Dia" , { || oCalex:SetDayView() , SetDatas() }, ".\bitmaps\CALENDAR.bmp" )
oPanel:AddLink( "Ver Semana" , { || oCalex:SetWeekView(), SetDatas() }, ".\bitmaps\CALENDAR.bmp" )
oPanel:AddLink( "Ver mes" , { || oCalex:SetMonthView(),SetDatas() }, ".\bitmaps\CALENDAR.bmp" )
oPanel:AddLink( "Agregar cita" , { || Cita("A",oCalex:oView) }, ".\bitmaps\additem.bmp" )
oPanel:AddLink( "Modificar cita" , { || Cita("M",oCalex:oView),SetDatas() }, ".\bitmaps\edit.bmp" )
oPanel:AddLink( "Eliminar cita " , { || Cita("B",oCalex:oView) }, ".\bitmaps\delete.bmp" )
oPanel:AddLink( "Imprimir Citas" , { || Imprime(oCalex:dDate) }, ".\bitmaps\printer.bmp" )
oPanel:bMMoved := {|| oDlgBrw:Hide(), oCalex:Show(), oPanelCalex:oClient := oCalex}
oPanelExplorer:oClient = oExBar
// Calendario
DEFINE CALEX oCalex OF oPanelCalex FIRST_DATE 0
/*@170, 15 CALENDAR oDtPick VAR oCalex:dDateSelected OF oPanel PIXEL;
SIZE 220, 157*/
//Mes
DEFINE MONTH VIEW OF oCalex ACTIVATE;
START HOUR 7 ;
END HOUR 20;
ON SELECT VIEW SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),oDtPick:Refresh(), SetDatas()) ;
ON SELECT DAY SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),oDtPick:Refresh(), SetDatas()) ;
ON SELECT WEEK SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),oDtPick:Refresh(), SetDatas()) ;
ON NEXT SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),oDtPick:Refresh(), SetDatas()) ;
ON PREV SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),oDtPick:Refresh(), SetDatas())
//Dia
DEFINE DAY VIEW OF oCalex ;
INTERVAL 30 ;
START HOUR 7 ;
END HOUR 20;
ON SELECT VIEW SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),SetDatas()) ;
ON NEXT SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),SetDatas());
ON PREV SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),SetDatas())
//Semana
DEFINE WEEK VIEW OF oCalex ;
INTERVAL 30 ;
START HOUR 7 ;
END HOUR 20 ;
ON SELECT VIEW SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),SetDatas()) ;
ON NEXT SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),SetDatas());
ON PREV SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),SetDatas())
// Calendario en el panel. Lo pono aca porque debe estar inicializado oCalex
/*oDtPick:bChange = { | o | ChangeDate( o ) }
oCalex:bLClicked = { | nRow,nCol | oDtPick:SetDate( oCalex:oView:dDateSelected )}
oCalex:bLClicked = { | nRow,nCol | oDtPick:SetDate( ;
oCalex:oView:GetDateFromPos(oCalex:oMonthView:GetPosition( nRow, nCol )[1],oCalex:oMonthView:GetPosition( nRow, nCol )[2]))}
*/
@180, 15 SAY "Intervalo (En minutos):" PIXEL OF oPanel TRANSPARENT
@257, 15 SAY "Rango horario:" PIXEL OF oPanel TRANSPARENT
@200, 15 SELEX oSelec VAR nOption OF oPanel PIXEL SIZE 200, 45;
ITEMS "5", "10", "15", "20", "30", "60" ;
GRADIENT OUTTRACK { { 1/2, nRGB( 219, 230, 244 ), nRGB( 207-50, 221-25, 255 ) }, ;
{ 1/2, nRGB( 201-50, 217-25, 255 ), nRGB( 231, 242, 255 ) } };
LINECOLORS nRGB( 237, 242, 248 ), nRGB( 141, 178, 227 );
COLORTEXT CLR_BLACK, CLR_GREEN ;
ACTION (oCalex:oView:SetInterval( Val( oSelec:aOptions[ nOption ])) , oCalex:Refresh() )
@255,100 GET oGet[2] VAR oCalex:oView:nStartHour PICTURE "99" SIZE 30,20 PIXEL OF oPanel RIGHT ;
VALID( oCalex:oView:nStartHour>=0 .AND. oCalex:oView:nStartHour <= (oCalex:oView:nEndHour - 1 ))
@255,170 GET oGet[3] VAR oCalex:oView:nEndHour PICTURE "99" SIZE 30,20 PIXEL OF oPanel RIGHT ;
VALID( oCalex:oView:nEndHour>=(oCalex:oView:nStartHour + 1) .and. oCalex:oView:nEndHour <= 24)
oPanelCalex:oClient = oCalex
oCalex:bLDblClick := {|nRow, nCol, nKeyFlags| MostrarInfo(nRow,nCol) }
/*
oCalex:bLDblClick := {|nRow, nCol, nKeyFlags| IF(oCalex:oView:oCalex:oCalInfoSelected==nil,.f.,;
MsgInfo("Inicio cita: " + STR(oCalex:oView:oCalex:oCalInfoSelected:nStart) + CHR(10) +;
"Fin cita: "+ STR(oCalex:oView:oCalex:oCalInfoSelected:nEnd) + CHR(10) +;
"Del dia: " + DTOC(oCalex:oView:oCalex:oCalInfoSelected:dStart) + CHR(10)+;
"Motivo: " + oCalex:oView:oCalex:oCalInfoSelected:cSubject + CHR(10)+;
"Estado: " + IF(!oCalex:oView:oCalex:oCalInfoSelected:lAplicado,"Hecha","Pendiente") + CHR(10)+;
"ID Cita: " + STR(oCalex:oView:oCalex:oCalInfoSelected:nIdx),"Info"))}
*/
ACTIVATE WINDOW oWnd ON RESIZE (oPanelExplorer:Move( , , , oWnd:nHeight ),;
oPanelCalex:Move ( , , oWnd:nWidth - oPanelExplorer:nRight, oWnd:nHeight - 60 ));
ON INIT (oWnd:SetSize(oApp:oWnd:oWndclient:nWidth, oApp:oWnd:oWndclient:nHeight),oWnd:Move(0,0))
return nil
*** Mostrar Info
STATIC FUNCTION MostrarInfo(nRow,nCol)
LOCAL oCI
IF nRow < 50 .or. nCol < 50
RETURN nil
ENDIF
IF oCalex:IsKindOf( "TDAYVIEW" )
oCI := oCalex:oDayView:oCalex:oCalInfoSelected
ELSE
oCI := oCalex:oWeekView:oCalex:oCalInfoSelected
ENDIF
IF ! (oCI == nil )
MsgInfo("Inicio cita: " + STR(oCI:nStart) + CHR(10) +;
"Fin cita: "+ STR(oCI:nEnd) + CHR(10) +;
"Del dia: " + DTOC(oCI:dStart) + CHR(10)+;
"Motivo: " + oCI:cSubject + CHR(10)+;
"Estado: " + IF(!oCI:lAplicado,"Hecha","Pendiente") + CHR(10)+;
"ID Cita: " + STR(oCI:nIdx),"Info")
ENDIF
RETURN nil
*********************************
** Poner citas en agenda
STATIC FUNCTION SetDatas()
LOCAL i, j, dAnt, oQry, cColor
oCalex:Reset()
cColor := { { 1, nRGB( 145, 0, 204 ), nRGB( 145, 0, 053 ) } }
oQry := oApp:oServer:Query("SELECT * FROM citas WHERE fecha >= " + ClipValue2Sql(oCalex:oMonthView:GetDateFromPos( 1, 1 )) + " AND "+;
"fecha <= " + ClipValue2Sql(oCalex:oMonthView:GetDateFromPos( 5, 7 )) + ;
" AND usuario = "+ClipValue2Sql(oApp:usuario)+ " ORDER BY fecha,hora,id ")
oQry:GoTop()
do while !oQry:Eof()
oCalex:LoadDates( VAL(STRTRAN(oQry:hora,":","")), VAL(STRTRAN(oQry:horafin,":","")), ;
oQry:fecha, oQry:fecha, ALLTRIM(oQry:motivo), ALLTRIM(oQry:motivo) + "-", oQry:id,.T.,!oQry:estado)
oQry:Skip()
enddo
oCalex:Refresh()
RETURN nil
*******************************************************************************
** Citas
STATIC FUNCTION Cita(cTipo, oV)
LOCAL cText, oV1, lRta, oQry
IF oCalex:oView:IsKindOf( "TMONTHVIEW" )
MsgStop("Agregar, modificar y eliminar en vista dia o mes","Error")
RETURN nil
ENDIF
IF oV:oCalex:oCalInfoSelected == NIL .and. cTipo$"MB"
MsgStop("No hay datos en ese horario para " + IF(cTipo="M","modificar","Eliminar"),"Error")
RETURN nil
ENDIF
DO CASE
CASE cTipo$"AM"
oV1 := oV:oCalex:oCalInfoSelected
oQry := oApp:oServer:Query("SELECT * FROM citas " + IF(ctipo="A","LIMIT 0","WHERE id="+ ClipValue2Sql(oV1:nIdx)))
IF Formu1(oQry,cTipo="A",oV1)
SetDatas()
oV:BuildDates()
ENDIF
CASE cTipo = "B"
oV1 := oV:oCalex:oCalInfoSelected
cText := "Inicio cita:" + STR(oV1:nStart) + CHR(10) +;
"Fin cita:" + STR(oV1:nEnd) + CHR(10) +;
"Del dia:" + DTOC(oV1:dStart) + CHR(10)+;
"Motivo:" + oV1:cSubject + CHR(10)+;
"ID Cita:" + STR(oV1:nIdx)
IF MsgNoYes(cText,"Seguro de eliminar?")
oApp:oServer:Execute("DELETE FROM citas WHERE id=" + ClipValue2Sql(oV1:nIdx))
oCalex:DelCalInfo()
ENDIF
ENDCASE
RETURN nil
************************************************
** Formulario de altas y modificaciones de citas
STATIC FUNCTION Formu1 (oQry,lAlta,oV)
LOCAL oGet := ARRAY(20), oBot := ARRAY(2), oForm, lRta := .f., aCor, base, oFont, oError, nHora, nHoraFin,;
mhasta, mcada, lRepite := .f., i, aDias := ARRAY(7)
IF !lAlta .and. oQry:nRecCount = 0
MsgStop("La cita fue borrada","Error")
oCalex:Refresh()
RETURN .t.
ENDIF
afill(aDias, .f.)
IF lAlta
base := oQry:GetBlankRow()
base:id := oApp:oServer:GetAutoIncrement("citas")
base:usuario := oApp:usuario
IF oCalex:oView:nLastRow == nil
nHora := oCalex:oView:nStartHour * 100
nHoraFin := oCalex:oView:nStartHour * 100
ELSE
nHora := oCalex:oView:GetTimeFromRow( oCalex:oView:nLastRow )
nHorafin := oCalex:oView:GetTimeFromRow( oCalex:oView:nLastRow+1 )
ENDIF
base:hora := LEFT(STRTRAN(STR(nhora ,4)," ","0"),2)+":" +RIGHT(STR(nhora,4),2)
base:horafin := LEFT(STRTRAN(STR(nhorafin,4)," ","0"),2)+":" +RIGHT(STR(nhorafin,4),2)
base:fecha := oCalex:oView:dDateSelected
mhasta := base:fecha
mcada := 7
ELSE
base := oQry:GetRowObj()
oQry:lAppend := .f.
ENDIF
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-11.5
DO WHILE .T.
DEFINE DIALOG oForm TITLE IF(lAlta,"Alta","Modificacion") + " de Citas";
FROM 05,15 TO IF(lAlta,30,25),90 FONT oFont
@ 07, 05 SAY "Id:" OF oForm PIXEL SIZE 60,20 RIGHT
@ 22, 05 SAY "Hora Inciio:" OF oForm PIXEL SIZE 60,20 RIGHT
@ 37, 05 SAY "Hora Final:" OF oForm PIXEL SIZE 60,16 RIGHT
@ 52, 05 SAY "Fecha Cita:" OF oForm PIXEL SIZE 60,16 RIGHT
@ 67, 05 SAY "Motivo:" OF oForm PIXEL SIZE 60,16 RIGHT
IF lAlta
@127, 70 SAY "Repetir cada " OF oForm PIXEL SIZE 55,16 RIGHT
@127,150 SAY "dias" OF oForm PIXEL SIZE 20,16
@142, 70 SAY "Hasta el dia:" OF oForm PIXEL SIZE 55,16 RIGHT
ENDIF
@ 05, 70 GET oGet[1] VAR base:id OF oForm PICTURE "9999999" PIXEL RIGHT WHEN(.F.)
@ 20, 70 GET oGet[2] VAR base:hora OF oForm PIXEL RIGHT PICTURE "99:99" WHEN(!lAlta)
@ 35, 70 GET oGet[3] VAR base:horafin OF oForm PIXEL RIGHT PICTURE "99:99" WHEN(!lAlta)
@ 50, 70 GET oGet[4] VAR base:fecha OF oForm PIXEL CENTER
@ 65, 70 GET oGet[5] VAR base:motivo OF oForm PIXEL CUEBANNER "Escriba el motivo de la cita"
@ 80, 70 CHECKBOX oGet[7] VAR base:estado PROMPT "Esta cita esta cumplida" SIZE 100,13 OF oForm PIXEL
@ 95, 70 CHECKBOX oGet[8] VAR base:alerta PROMPT "Emitir alerta cuando llegue la hora" SIZE 100,13 OF oForm PIXEL
IF lAlta
@ 110, 05 CHECKBOX oGet[9] VAR lRepite PROMPT "Repetir esta tarea" SIZE 100,13 OF oForm PIXEL
@ 125, 05 RADIO oGet[12] VAR i PROMPT "Cada","Los dias" OF oForm PIXEL SIZE 30, 12 WHEN(lRepite)
@ 125,130 GET oGet[10] VAR mcada PICTURE "999" OF oForm PIXEL VALID mcada > 0 WHEN(lRepite .AND. i=1)
@ 140,130 GET oGet[11] VAR mhasta OF oForm PIXEL CENTER VALID mhasta > base:fecha WHEN(lRepite)
@ 155, 02 CHECKBOX oGet[13] VAR aDias[1] PROMPT "Domingo" OF oForm PIXEL SIZE 30,12 WHEN(lRepite .AND. i=2)
@ 155, 40 CHECKBOX oGet[14] VAR aDias[2] PROMPT "Lunes" OF oForm PIXEL SIZE 25,12 WHEN(lRepite .AND. i=2)
@ 155, 80 CHECKBOX oGet[15] VAR aDias[3] PROMPT "Martes" OF oForm PIXEL SIZE 25,12 WHEN(lRepite .AND. i=2)
@ 155,120 CHECKBOX oGet[16] VAR aDias[4] PROMPT "Miercoles" OF oForm PIXEL SIZE 30,12 WHEN(lRepite .AND. i=2)
@ 155,160 CHECKBOX oGet[17] VAR aDias[5] PROMPT "Jueves" OF oForm PIXEL SIZE 25,12 WHEN(lRepite .AND. i=2)
@ 155,200 CHECKBOX oGet[18] VAR aDias[6] PROMPT "Viernes" OF oForm PIXEL SIZE 25,12 WHEN(lRepite .AND. i=2)
@ 155,240 CHECKBOX oGet[19] VAR aDias[7] PROMPT "Sabados" OF oForm PIXEL SIZE 30,12 WHEN(lRepite .AND. i=2)
ENDIF
@ 170,40 BUTTON oBot[1] PROMPT "&Grabar" OF oForm SIZE 30,10 ;
ACTION ((lRta := .t.), oForm:End() ) PIXEL
@ 170,90 BUTTON oBot[2] PROMPT "&Cancelar" OF oForm SIZE 30,10 ;
ACTION ((lRta := .f.), oForm:End() ) PIXEL CANCEL
ACTIVATE DIALOG oForm CENTER
IF !lRta
RELEASE oFont
RETURN .f.
ENDIF
IF lAlta
oQry:GetBlankRow()
ENDIF
oQry:oRow := base
TRY
oApp:oServer:BeginTransaction()
oQry:Save()
IF lAlta .and. lRepite
IF i = 1
FOR i := base:fecha+mcada TO mhasta STEP mcada
oApp:oServer:Execute("INSERT INTO citas (fecha,hora,horafin,motivo,estado,alerta,usuario) VALUES ("+;
ClipValue2Sql(i)+","+;
ClipValue2Sql(base:hora)+","+;
ClipValue2Sql(base:horafin)+","+;
ClipValue2Sql(base:motivo)+","+;
ClipValue2Sql(base:estado)+","+;
ClipValue2Sql(base:alerta)+","+;
ClipValue2Sql(base:usuario)+")")
NEXT i
ELSE
FOR i := base:fecha+1 TO mhasta
IF aDias[DOW(i)]
oApp:oServer:Execute("INSERT INTO citas (fecha,hora,horafin,motivo,estado,alerta,usuario) VALUES ("+;
ClipValue2Sql(i)+","+;
ClipValue2Sql(base:hora)+","+;
ClipValue2Sql(base:horafin)+","+;
ClipValue2Sql(base:motivo)+","+;
ClipValue2Sql(base:estado)+","+;
ClipValue2Sql(base:alerta)+","+;
ClipValue2Sql(base:usuario)+")")
ENDIF
NEXT i
ENDIF
ENDIF
oQry:Refresh()
oApp:oServer:CommitTransaction()
CATCH oError
ValidaError(oError)
LOOP
END TRY
EXIT
ENDDO
RELEASE oFont
RETURN .t.
STATIC FUNCTION ChangeDate( oDatePick )
oCalex:oView:SetDate( oDatePick:GetDate() )
if oCalex:oView:IsKindOf( "TMONTHVIEW" )
oCalex:SetMonthView()
elseif oCalex:oView:IsKindOf( "TWEEKVIEW" )
oCalex:SetWeekView()
else
oCalex:SetDayView()
endif
*oDatePick:Refresh()
RETURN NIL
****** Imprimir Dia
STATIC FUNCTION Imprime(dFecha)
LOCAL oRep, oFont1, oFont2, acor, oDlg1, oGet1, oGet2, oGet3, ;
oBot1, oBot2, mrta := .f., mdesde := dFecha, mhasta := dFecha, oQryRep, mestado := 1
// Defino los distintos tipos de letra
DEFINE FONT oFont1 NAME "ARIAL" SIZE 0,-10
DEFINE FONT oFont2 NAME "ARIAL" SIZE 0,-10 BOLD
DEFINE DIALOG oDlg1 TITLE "Reporte de Citas" FROM 03,15 TO 13,70 ;
OF oApp:oWnd
@ 07, 05 SAY "Estado:" OF oDlg1 PIXEL SIZE 50,12 RIGHT
@ 22, 05 SAY "Desde Fecha:" OF oDlg1 PIXEL SIZE 50,12 RIGHT
@ 37, 05 SAY "Hasta Fecha:" OF oDlg1 PIXEL SIZE 50,12 RIGHT
@ 05, 60 COMBOBOX oGet1 VAR mestado OF oDlg1 SIZE 60,12 PIXEL ITEMS {"Todas","Solo pendientes","Solo Realizadas"}
@ 20, 60 GET oGet2 VAR mdesde OF oDlg1 PIXEL
@ 35, 60 GET oGet3 VAR mhasta OF oDlg1 PIXEL VALID(mhasta >= mdesde)
@ 50,40 BUTTON oBot1 PROMPT "&Imprimir" OF oDlg1 SIZE 30,10 ;
ACTION ((mrta := .t.), oDlg1:End() ) PIXEL
@ 50,90 BUTTON oBot2 PROMPT "&Cancelar" OF oDlg1 SIZE 30,10 ;
ACTION ((mrta := .f.), oDlg1:End() ) PIXEL
ACTIVATE DIALOG oDlg1 CENTER
IF !mrta
RETURN nil
ENDIF
mestado := IF(mestado=1," TRUE ",IF(mestado=3," estado = TRUE "," estado = FALSE"))
oQryRep := oApp:oServer:Query("SELECT * FROM citas WHERE "+mestado+" AND "+;
"fecha >= "+ClipValue2Sql(mdesde)+" AND fecha <= "+ClipValue2Sql(mhasta) + " ORDER BY fecha,hora,id")
IF oQryRep:nRecCount = 0
MsgStop("Sin datos para listar en ese rango","Error")
RELEASE oFont1
RELEASE oFont1
RETURN nil
ENDIF
REPORT oRep TITLE "Citas de " + ALLTRIM(oApp:usuanom) + ;
" del " + DTOC(mdesde) + " al " + DTOC(mhasta) ;
FONT oFont1,oFont2 HEADER OemToAnsi(oApp:nomb_emp) CENTER ;
FOOTER "Hoja:" + STR(oRep:npage,3) ,"Fecha:"+DTOC(DATE()) CENTER;
PREVIEW CAPTION "Citas"
COLUMN TITLE "Id" DATA oQryRep:id SIZE 07 FONT 1
COLUMN TITLE "Fecha" DATA oQryRep:fecha SIZE 08 FONT 2
COLUMN TITLE "Desde" DATA oQryRep:hora SIZE 05 FONT 1
COLUMN TITLE "Hasta" DATA oQryRep:horafin SIZE 05 FONT 1
COLUMN TITLE "Motivo" DATA oQryRep:motivo SIZE 20 FONT 1
COLUMN TITLE "Alarma" DATA IF(oQryRep:alerta,"SI","NO") SIZE 05 FONT 1
COLUMN TITLE "Estado" DATA IF(oQryRep:estado,"REALIZADA ","PENDIENTE") SIZE 10 FONT 1
COLUMN TITLE "Obser." DATA REPLICATE("_",20) SIZE 15 FONT 1
// Digo que el titulo lo escriba con al letra 2
oRep:oTitle:aFont[1] := {|| 2 }
oRep:oTitle:aFont[1] := {|| 2 }
oRep:bInit := {|| oQryRep:GoTop() }
oRep:bSkip := {|| oQryRep:Skip() }
END REPORT
ACTIVATE REPORT oRep WHILE !oQryRep:EOF() ON INIT CursorArrow() ON STARTPAGE oRep:SayBitmap(.1,.1,"LOGO.BMP",.5,.5)
oQryRep:End()
RELEASE oFont1, oFont2
RETURN nil
CREATE TABLE `citas` (
`id_cita` INT(11) NOT NULL AUTO_INCREMENT,
`usuario` VARCHAR(10) NOT NULL DEFAULT '',
`fecha` DATE NULL DEFAULT NULL,
`hora` VARCHAR(5) NOT NULL DEFAULT '',
`horafin` VARCHAR(5) NOT NULL DEFAULT '',
`motivo` VARCHAR(120) NOT NULL DEFAULT '',
`estado` CHAR(1) NOT NULL DEFAULT 'P',
PRIMARY KEY (`id_cita`),
INDEX `idx_citas01` (`fecha`, `usuario`)
);
csincuir wrote:Hola Jose Luis.
Te copio el ejemplo que me envio "cmsoft", que trabaja con MySQL utilizando la TDolphin.
Yo utilizo la Eagle1, pero el concepto es el mismo, de correr los scripts SQL como se muestra en el ejemplo:
- Code: Select all Expand view
#include "fivewin.ch"
#include "calendar.ch"
#include "calex.ch"
#include "tselex.ch"
#include "ord.ch"
#include "tdolphin.ch"
#include "Report.ch"
MEMVAR oApp
//----------------------------------------------------------------------------//
STATIC oCalex, oBrw, oQryBrw, cVentana, oDlgBrw, nFilter, nSeekWild, oSelec
FUNCTION Agenda()
LOCAL oWnd, oExBar, oDtPick, oPanelExplorer, oPanelCalex, oPanel, oPanel1, oPanel2, hHand, oGet := ARRAY(10),;
oBot := ARRAY(5), nOption:=5, dDate := DATE()
DEFINE WINDOW oWnd MDICHILD OF oApp:oWnd TITLE "Agenda " + oApp:usuanom ICON oApp:oIco
*** Paneles
oPanelExplorer = TPanel():New( 0, 0, oWnd:nHeight, 280, oWnd )
oPanelCalex = TPanel():New( 0, 281, oWnd:nHeight, oWnd:nWidth, oWnd )
oExBar := TExplorerBar():New( 0, 0, 250, 300, oPanelExplorer )
oPanel := oExBar:AddPanel( "Seleccionar Fecha", ".\bitmaps\CALENDAR2.bmp", 255 )
oPanel:AddLink( "Ver Dia" , { || oCalex:SetDayView() , SetDatas() }, ".\bitmaps\CALENDAR.bmp" )
oPanel:AddLink( "Ver Semana" , { || oCalex:SetWeekView(), SetDatas() }, ".\bitmaps\CALENDAR.bmp" )
oPanel:AddLink( "Ver mes" , { || oCalex:SetMonthView(),SetDatas() }, ".\bitmaps\CALENDAR.bmp" )
oPanel:AddLink( "Agregar cita" , { || Cita("A",oCalex:oView) }, ".\bitmaps\additem.bmp" )
oPanel:AddLink( "Modificar cita" , { || Cita("M",oCalex:oView),SetDatas() }, ".\bitmaps\edit.bmp" )
oPanel:AddLink( "Eliminar cita " , { || Cita("B",oCalex:oView) }, ".\bitmaps\delete.bmp" )
oPanel:AddLink( "Imprimir Citas" , { || Imprime(oCalex:dDate) }, ".\bitmaps\printer.bmp" )
oPanel:bMMoved := {|| oDlgBrw:Hide(), oCalex:Show(), oPanelCalex:oClient := oCalex}
oPanelExplorer:oClient = oExBar
// Calendario
DEFINE CALEX oCalex OF oPanelCalex FIRST_DATE 0
/*@170, 15 CALENDAR oDtPick VAR oCalex:dDateSelected OF oPanel PIXEL;
SIZE 220, 157*/
//Mes
DEFINE MONTH VIEW OF oCalex ACTIVATE;
START HOUR 7 ;
END HOUR 20;
ON SELECT VIEW SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),oDtPick:Refresh(), SetDatas()) ;
ON SELECT DAY SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),oDtPick:Refresh(), SetDatas()) ;
ON SELECT WEEK SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),oDtPick:Refresh(), SetDatas()) ;
ON NEXT SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),oDtPick:Refresh(), SetDatas()) ;
ON PREV SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),oDtPick:Refresh(), SetDatas())
//Dia
DEFINE DAY VIEW OF oCalex ;
INTERVAL 30 ;
START HOUR 7 ;
END HOUR 20;
ON SELECT VIEW SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),SetDatas()) ;
ON NEXT SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),SetDatas());
ON PREV SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),SetDatas())
//Semana
DEFINE WEEK VIEW OF oCalex ;
INTERVAL 30 ;
START HOUR 7 ;
END HOUR 20 ;
ON SELECT VIEW SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),SetDatas()) ;
ON NEXT SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),SetDatas());
ON PREV SetDatas() ;//( oDtPick:SetDate( oCalex:dDateSelected ),SetDatas())
// Calendario en el panel. Lo pono aca porque debe estar inicializado oCalex
/*oDtPick:bChange = { | o | ChangeDate( o ) }
oCalex:bLClicked = { | nRow,nCol | oDtPick:SetDate( oCalex:oView:dDateSelected )}
oCalex:bLClicked = { | nRow,nCol | oDtPick:SetDate( ;
oCalex:oView:GetDateFromPos(oCalex:oMonthView:GetPosition( nRow, nCol )[1],oCalex:oMonthView:GetPosition( nRow, nCol )[2]))}
*/
@180, 15 SAY "Intervalo (En minutos):" PIXEL OF oPanel TRANSPARENT
@257, 15 SAY "Rango horario:" PIXEL OF oPanel TRANSPARENT
@200, 15 SELEX oSelec VAR nOption OF oPanel PIXEL SIZE 200, 45;
ITEMS "5", "10", "15", "20", "30", "60" ;
GRADIENT OUTTRACK { { 1/2, nRGB( 219, 230, 244 ), nRGB( 207-50, 221-25, 255 ) }, ;
{ 1/2, nRGB( 201-50, 217-25, 255 ), nRGB( 231, 242, 255 ) } };
LINECOLORS nRGB( 237, 242, 248 ), nRGB( 141, 178, 227 );
COLORTEXT CLR_BLACK, CLR_GREEN ;
ACTION (oCalex:oView:SetInterval( Val( oSelec:aOptions[ nOption ])) , oCalex:Refresh() )
@255,100 GET oGet[2] VAR oCalex:oView:nStartHour PICTURE "99" SIZE 30,20 PIXEL OF oPanel RIGHT ;
VALID( oCalex:oView:nStartHour>=0 .AND. oCalex:oView:nStartHour <= (oCalex:oView:nEndHour - 1 ))
@255,170 GET oGet[3] VAR oCalex:oView:nEndHour PICTURE "99" SIZE 30,20 PIXEL OF oPanel RIGHT ;
VALID( oCalex:oView:nEndHour>=(oCalex:oView:nStartHour + 1) .and. oCalex:oView:nEndHour <= 24)
oPanelCalex:oClient = oCalex
oCalex:bLDblClick := {|nRow, nCol, nKeyFlags| MostrarInfo(nRow,nCol) }
/*
oCalex:bLDblClick := {|nRow, nCol, nKeyFlags| IF(oCalex:oView:oCalex:oCalInfoSelected==nil,.f.,;
MsgInfo("Inicio cita: " + STR(oCalex:oView:oCalex:oCalInfoSelected:nStart) + CHR(10) +;
"Fin cita: "+ STR(oCalex:oView:oCalex:oCalInfoSelected:nEnd) + CHR(10) +;
"Del dia: " + DTOC(oCalex:oView:oCalex:oCalInfoSelected:dStart) + CHR(10)+;
"Motivo: " + oCalex:oView:oCalex:oCalInfoSelected:cSubject + CHR(10)+;
"Estado: " + IF(!oCalex:oView:oCalex:oCalInfoSelected:lAplicado,"Hecha","Pendiente") + CHR(10)+;
"ID Cita: " + STR(oCalex:oView:oCalex:oCalInfoSelected:nIdx),"Info"))}
*/
ACTIVATE WINDOW oWnd ON RESIZE (oPanelExplorer:Move( , , , oWnd:nHeight ),;
oPanelCalex:Move ( , , oWnd:nWidth - oPanelExplorer:nRight, oWnd:nHeight - 60 ));
ON INIT (oWnd:SetSize(oApp:oWnd:oWndclient:nWidth, oApp:oWnd:oWndclient:nHeight),oWnd:Move(0,0))
return nil
*** Mostrar Info
STATIC FUNCTION MostrarInfo(nRow,nCol)
LOCAL oCI
IF nRow < 50 .or. nCol < 50
RETURN nil
ENDIF
IF oCalex:IsKindOf( "TDAYVIEW" )
oCI := oCalex:oDayView:oCalex:oCalInfoSelected
ELSE
oCI := oCalex:oWeekView:oCalex:oCalInfoSelected
ENDIF
IF ! (oCI == nil )
MsgInfo("Inicio cita: " + STR(oCI:nStart) + CHR(10) +;
"Fin cita: "+ STR(oCI:nEnd) + CHR(10) +;
"Del dia: " + DTOC(oCI:dStart) + CHR(10)+;
"Motivo: " + oCI:cSubject + CHR(10)+;
"Estado: " + IF(!oCI:lAplicado,"Hecha","Pendiente") + CHR(10)+;
"ID Cita: " + STR(oCI:nIdx),"Info")
ENDIF
RETURN nil
*********************************
** Poner citas en agenda
STATIC FUNCTION SetDatas()
LOCAL i, j, dAnt, oQry, cColor
oCalex:Reset()
cColor := { { 1, nRGB( 145, 0, 204 ), nRGB( 145, 0, 053 ) } }
oQry := oApp:oServer:Query("SELECT * FROM citas WHERE fecha >= " + ClipValue2Sql(oCalex:oMonthView:GetDateFromPos( 1, 1 )) + " AND "+;
"fecha <= " + ClipValue2Sql(oCalex:oMonthView:GetDateFromPos( 5, 7 )) + ;
" AND usuario = "+ClipValue2Sql(oApp:usuario)+ " ORDER BY fecha,hora,id ")
oQry:GoTop()
do while !oQry:Eof()
oCalex:LoadDates( VAL(STRTRAN(oQry:hora,":","")), VAL(STRTRAN(oQry:horafin,":","")), ;
oQry:fecha, oQry:fecha, ALLTRIM(oQry:motivo), ALLTRIM(oQry:motivo) + "-", oQry:id,.T.,!oQry:estado)
oQry:Skip()
enddo
oCalex:Refresh()
RETURN nil
*******************************************************************************
** Citas
STATIC FUNCTION Cita(cTipo, oV)
LOCAL cText, oV1, lRta, oQry
IF oCalex:oView:IsKindOf( "TMONTHVIEW" )
MsgStop("Agregar, modificar y eliminar en vista dia o mes","Error")
RETURN nil
ENDIF
IF oV:oCalex:oCalInfoSelected == NIL .and. cTipo$"MB"
MsgStop("No hay datos en ese horario para " + IF(cTipo="M","modificar","Eliminar"),"Error")
RETURN nil
ENDIF
DO CASE
CASE cTipo$"AM"
oV1 := oV:oCalex:oCalInfoSelected
oQry := oApp:oServer:Query("SELECT * FROM citas " + IF(ctipo="A","LIMIT 0","WHERE id="+ ClipValue2Sql(oV1:nIdx)))
IF Formu1(oQry,cTipo="A",oV1)
SetDatas()
oV:BuildDates()
ENDIF
CASE cTipo = "B"
oV1 := oV:oCalex:oCalInfoSelected
cText := "Inicio cita:" + STR(oV1:nStart) + CHR(10) +;
"Fin cita:" + STR(oV1:nEnd) + CHR(10) +;
"Del dia:" + DTOC(oV1:dStart) + CHR(10)+;
"Motivo:" + oV1:cSubject + CHR(10)+;
"ID Cita:" + STR(oV1:nIdx)
IF MsgNoYes(cText,"Seguro de eliminar?")
oApp:oServer:Execute("DELETE FROM citas WHERE id=" + ClipValue2Sql(oV1:nIdx))
oCalex:DelCalInfo()
ENDIF
ENDCASE
RETURN nil
************************************************
** Formulario de altas y modificaciones de citas
STATIC FUNCTION Formu1 (oQry,lAlta,oV)
LOCAL oGet := ARRAY(20), oBot := ARRAY(2), oForm, lRta := .f., aCor, base, oFont, oError, nHora, nHoraFin,;
mhasta, mcada, lRepite := .f., i, aDias := ARRAY(7)
IF !lAlta .and. oQry:nRecCount = 0
MsgStop("La cita fue borrada","Error")
oCalex:Refresh()
RETURN .t.
ENDIF
afill(aDias, .f.)
IF lAlta
base := oQry:GetBlankRow()
base:id := oApp:oServer:GetAutoIncrement("citas")
base:usuario := oApp:usuario
IF oCalex:oView:nLastRow == nil
nHora := oCalex:oView:nStartHour * 100
nHoraFin := oCalex:oView:nStartHour * 100
ELSE
nHora := oCalex:oView:GetTimeFromRow( oCalex:oView:nLastRow )
nHorafin := oCalex:oView:GetTimeFromRow( oCalex:oView:nLastRow+1 )
ENDIF
base:hora := LEFT(STRTRAN(STR(nhora ,4)," ","0"),2)+":" +RIGHT(STR(nhora,4),2)
base:horafin := LEFT(STRTRAN(STR(nhorafin,4)," ","0"),2)+":" +RIGHT(STR(nhorafin,4),2)
base:fecha := oCalex:oView:dDateSelected
mhasta := base:fecha
mcada := 7
ELSE
base := oQry:GetRowObj()
oQry:lAppend := .f.
ENDIF
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-11.5
DO WHILE .T.
DEFINE DIALOG oForm TITLE IF(lAlta,"Alta","Modificacion") + " de Citas";
FROM 05,15 TO IF(lAlta,30,25),90 FONT oFont
@ 07, 05 SAY "Id:" OF oForm PIXEL SIZE 60,20 RIGHT
@ 22, 05 SAY "Hora Inciio:" OF oForm PIXEL SIZE 60,20 RIGHT
@ 37, 05 SAY "Hora Final:" OF oForm PIXEL SIZE 60,16 RIGHT
@ 52, 05 SAY "Fecha Cita:" OF oForm PIXEL SIZE 60,16 RIGHT
@ 67, 05 SAY "Motivo:" OF oForm PIXEL SIZE 60,16 RIGHT
IF lAlta
@127, 70 SAY "Repetir cada " OF oForm PIXEL SIZE 55,16 RIGHT
@127,150 SAY "dias" OF oForm PIXEL SIZE 20,16
@142, 70 SAY "Hasta el dia:" OF oForm PIXEL SIZE 55,16 RIGHT
ENDIF
@ 05, 70 GET oGet[1] VAR base:id OF oForm PICTURE "9999999" PIXEL RIGHT WHEN(.F.)
@ 20, 70 GET oGet[2] VAR base:hora OF oForm PIXEL RIGHT PICTURE "99:99" WHEN(!lAlta)
@ 35, 70 GET oGet[3] VAR base:horafin OF oForm PIXEL RIGHT PICTURE "99:99" WHEN(!lAlta)
@ 50, 70 GET oGet[4] VAR base:fecha OF oForm PIXEL CENTER
@ 65, 70 GET oGet[5] VAR base:motivo OF oForm PIXEL CUEBANNER "Escriba el motivo de la cita"
@ 80, 70 CHECKBOX oGet[7] VAR base:estado PROMPT "Esta cita esta cumplida" SIZE 100,13 OF oForm PIXEL
@ 95, 70 CHECKBOX oGet[8] VAR base:alerta PROMPT "Emitir alerta cuando llegue la hora" SIZE 100,13 OF oForm PIXEL
IF lAlta
@ 110, 05 CHECKBOX oGet[9] VAR lRepite PROMPT "Repetir esta tarea" SIZE 100,13 OF oForm PIXEL
@ 125, 05 RADIO oGet[12] VAR i PROMPT "Cada","Los dias" OF oForm PIXEL SIZE 30, 12 WHEN(lRepite)
@ 125,130 GET oGet[10] VAR mcada PICTURE "999" OF oForm PIXEL VALID mcada > 0 WHEN(lRepite .AND. i=1)
@ 140,130 GET oGet[11] VAR mhasta OF oForm PIXEL CENTER VALID mhasta > base:fecha WHEN(lRepite)
@ 155, 02 CHECKBOX oGet[13] VAR aDias[1] PROMPT "Domingo" OF oForm PIXEL SIZE 30,12 WHEN(lRepite .AND. i=2)
@ 155, 40 CHECKBOX oGet[14] VAR aDias[2] PROMPT "Lunes" OF oForm PIXEL SIZE 25,12 WHEN(lRepite .AND. i=2)
@ 155, 80 CHECKBOX oGet[15] VAR aDias[3] PROMPT "Martes" OF oForm PIXEL SIZE 25,12 WHEN(lRepite .AND. i=2)
@ 155,120 CHECKBOX oGet[16] VAR aDias[4] PROMPT "Miercoles" OF oForm PIXEL SIZE 30,12 WHEN(lRepite .AND. i=2)
@ 155,160 CHECKBOX oGet[17] VAR aDias[5] PROMPT "Jueves" OF oForm PIXEL SIZE 25,12 WHEN(lRepite .AND. i=2)
@ 155,200 CHECKBOX oGet[18] VAR aDias[6] PROMPT "Viernes" OF oForm PIXEL SIZE 25,12 WHEN(lRepite .AND. i=2)
@ 155,240 CHECKBOX oGet[19] VAR aDias[7] PROMPT "Sabados" OF oForm PIXEL SIZE 30,12 WHEN(lRepite .AND. i=2)
ENDIF
@ 170,40 BUTTON oBot[1] PROMPT "&Grabar" OF oForm SIZE 30,10 ;
ACTION ((lRta := .t.), oForm:End() ) PIXEL
@ 170,90 BUTTON oBot[2] PROMPT "&Cancelar" OF oForm SIZE 30,10 ;
ACTION ((lRta := .f.), oForm:End() ) PIXEL CANCEL
ACTIVATE DIALOG oForm CENTER
IF !lRta
RELEASE oFont
RETURN .f.
ENDIF
IF lAlta
oQry:GetBlankRow()
ENDIF
oQry:oRow := base
TRY
oApp:oServer:BeginTransaction()
oQry:Save()
IF lAlta .and. lRepite
IF i = 1
FOR i := base:fecha+mcada TO mhasta STEP mcada
oApp:oServer:Execute("INSERT INTO citas (fecha,hora,horafin,motivo,estado,alerta,usuario) VALUES ("+;
ClipValue2Sql(i)+","+;
ClipValue2Sql(base:hora)+","+;
ClipValue2Sql(base:horafin)+","+;
ClipValue2Sql(base:motivo)+","+;
ClipValue2Sql(base:estado)+","+;
ClipValue2Sql(base:alerta)+","+;
ClipValue2Sql(base:usuario)+")")
NEXT i
ELSE
FOR i := base:fecha+1 TO mhasta
IF aDias[DOW(i)]
oApp:oServer:Execute("INSERT INTO citas (fecha,hora,horafin,motivo,estado,alerta,usuario) VALUES ("+;
ClipValue2Sql(i)+","+;
ClipValue2Sql(base:hora)+","+;
ClipValue2Sql(base:horafin)+","+;
ClipValue2Sql(base:motivo)+","+;
ClipValue2Sql(base:estado)+","+;
ClipValue2Sql(base:alerta)+","+;
ClipValue2Sql(base:usuario)+")")
ENDIF
NEXT i
ENDIF
ENDIF
oQry:Refresh()
oApp:oServer:CommitTransaction()
CATCH oError
ValidaError(oError)
LOOP
END TRY
EXIT
ENDDO
RELEASE oFont
RETURN .t.
STATIC FUNCTION ChangeDate( oDatePick )
oCalex:oView:SetDate( oDatePick:GetDate() )
if oCalex:oView:IsKindOf( "TMONTHVIEW" )
oCalex:SetMonthView()
elseif oCalex:oView:IsKindOf( "TWEEKVIEW" )
oCalex:SetWeekView()
else
oCalex:SetDayView()
endif
*oDatePick:Refresh()
RETURN NIL
****** Imprimir Dia
STATIC FUNCTION Imprime(dFecha)
LOCAL oRep, oFont1, oFont2, acor, oDlg1, oGet1, oGet2, oGet3, ;
oBot1, oBot2, mrta := .f., mdesde := dFecha, mhasta := dFecha, oQryRep, mestado := 1
// Defino los distintos tipos de letra
DEFINE FONT oFont1 NAME "ARIAL" SIZE 0,-10
DEFINE FONT oFont2 NAME "ARIAL" SIZE 0,-10 BOLD
DEFINE DIALOG oDlg1 TITLE "Reporte de Citas" FROM 03,15 TO 13,70 ;
OF oApp:oWnd
@ 07, 05 SAY "Estado:" OF oDlg1 PIXEL SIZE 50,12 RIGHT
@ 22, 05 SAY "Desde Fecha:" OF oDlg1 PIXEL SIZE 50,12 RIGHT
@ 37, 05 SAY "Hasta Fecha:" OF oDlg1 PIXEL SIZE 50,12 RIGHT
@ 05, 60 COMBOBOX oGet1 VAR mestado OF oDlg1 SIZE 60,12 PIXEL ITEMS {"Todas","Solo pendientes","Solo Realizadas"}
@ 20, 60 GET oGet2 VAR mdesde OF oDlg1 PIXEL
@ 35, 60 GET oGet3 VAR mhasta OF oDlg1 PIXEL VALID(mhasta >= mdesde)
@ 50,40 BUTTON oBot1 PROMPT "&Imprimir" OF oDlg1 SIZE 30,10 ;
ACTION ((mrta := .t.), oDlg1:End() ) PIXEL
@ 50,90 BUTTON oBot2 PROMPT "&Cancelar" OF oDlg1 SIZE 30,10 ;
ACTION ((mrta := .f.), oDlg1:End() ) PIXEL
ACTIVATE DIALOG oDlg1 CENTER
IF !mrta
RETURN nil
ENDIF
mestado := IF(mestado=1," TRUE ",IF(mestado=3," estado = TRUE "," estado = FALSE"))
oQryRep := oApp:oServer:Query("SELECT * FROM citas WHERE "+mestado+" AND "+;
"fecha >= "+ClipValue2Sql(mdesde)+" AND fecha <= "+ClipValue2Sql(mhasta) + " ORDER BY fecha,hora,id")
IF oQryRep:nRecCount = 0
MsgStop("Sin datos para listar en ese rango","Error")
RELEASE oFont1
RELEASE oFont1
RETURN nil
ENDIF
REPORT oRep TITLE "Citas de " + ALLTRIM(oApp:usuanom) + ;
" del " + DTOC(mdesde) + " al " + DTOC(mhasta) ;
FONT oFont1,oFont2 HEADER OemToAnsi(oApp:nomb_emp) CENTER ;
FOOTER "Hoja:" + STR(oRep:npage,3) ,"Fecha:"+DTOC(DATE()) CENTER;
PREVIEW CAPTION "Citas"
COLUMN TITLE "Id" DATA oQryRep:id SIZE 07 FONT 1
COLUMN TITLE "Fecha" DATA oQryRep:fecha SIZE 08 FONT 2
COLUMN TITLE "Desde" DATA oQryRep:hora SIZE 05 FONT 1
COLUMN TITLE "Hasta" DATA oQryRep:horafin SIZE 05 FONT 1
COLUMN TITLE "Motivo" DATA oQryRep:motivo SIZE 20 FONT 1
COLUMN TITLE "Alarma" DATA IF(oQryRep:alerta,"SI","NO") SIZE 05 FONT 1
COLUMN TITLE "Estado" DATA IF(oQryRep:estado,"REALIZADA ","PENDIENTE") SIZE 10 FONT 1
COLUMN TITLE "Obser." DATA REPLICATE("_",20) SIZE 15 FONT 1
// Digo que el titulo lo escriba con al letra 2
oRep:oTitle:aFont[1] := {|| 2 }
oRep:oTitle:aFont[1] := {|| 2 }
oRep:bInit := {|| oQryRep:GoTop() }
oRep:bSkip := {|| oQryRep:Skip() }
END REPORT
ACTIVATE REPORT oRep WHILE !oQryRep:EOF() ON INIT CursorArrow() ON STARTPAGE oRep:SayBitmap(.1,.1,"LOGO.BMP",.5,.5)
oQryRep:End()
RELEASE oFont1, oFont2
RETURN nil
Seria solo de crear la tabla de "citas" dentro de tu base de datos de MySQL.
Te envio el script de creacion que utilice para trabajar el ejemplo que me enviara "cmsoft":
- Code: Select all Expand view
CREATE TABLE `citas` (
`id_cita` INT(11) NOT NULL AUTO_INCREMENT,
`usuario` VARCHAR(10) NOT NULL DEFAULT '',
`fecha` DATE NULL DEFAULT NULL,
`hora` VARCHAR(5) NOT NULL DEFAULT '',
`horafin` VARCHAR(5) NOT NULL DEFAULT '',
`motivo` VARCHAR(120) NOT NULL DEFAULT '',
`estado` CHAR(1) NOT NULL DEFAULT 'P',
PRIMARY KEY (`id_cita`),
INDEX `idx_citas01` (`fecha`, `usuario`)
);
Saludos cordiales.
Carlos.
********************************************
** Alertas
FUNCTION Alertas(lPrimerVez)
LOCAL oQry, oDlg, oSay, oBot, aNueva, i,j, cVentana, oFont, oBrw1
DEFAULT lPrimerVez := .f.
cVentana := PROCNAME()
IF ASCAN(oApp:aVentanas,cVentana) > 0
RETURN nil
ENDIF
oQry := oApp:oServer:Query("SELECT * FROM in_citas WHERE alerta = TRUE AND estado = FALSE AND usuario = " +ClipValue2Sql(oApp:usuario)+ ;
" AND fecha " + IF(lPrimerVez,"<" + ClipValue2Sql(DATE()),;
"= " + ClipValue2Sql(DATE()) + " AND hora <= " + ClipValue2Sql(LEFT(TIME(),5))) )
IF oQry:nRecCount > 0
AADD(oApp:aVentanas,cVentana)
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-13.5
DEFINE DIALOG oDlg TITLE "Alertas " + IF(lPrimerVez," pendientes de dias anteriores"," para el dia " + DTOC(DATE())) + " para usuario " + oApp:usuanom;
FROM 09,15 TO 28,135 OF oApp:oWnd
oDlg:lHelpIcon := .f.
//Reproduzco un sonido que esta guardado en el archivo ringin.wav
SndPlaySound("ringin.wav",1)
@ 01,001 BITMAP FILE "BITMAPS\ALERT.PNG" SIZE 65,140 ADJUST PIXEL OF oDlg NOBORDER
@ 01,080 XBROWSE oBrw1 DATASOURCE oQry SIZE 325,140 OF oDlg PIXEL ;
COLUMNS "id","fecha","hora","horafin","motivo","estado","alerta";
HEADERS "id","Fecha","Hora","Hasta","Motivo","Hecha?","Alerta?";
SIZES 65,65,45,45,250,55,55
PintaBrw(oBrw1,7)
*oBrw1:aCols[6]:bStrData := { || If( oQry:estado, " ","Sin Hacer" ) }
oBrw1:aCols[ 6 ]:bEditValue := { || oQry:estado = .T. }
*oBrw1:aCols[7]:bStrData := { || If( oQry:alerta, "Con Alerta"," " ) }
oBrw1:aCols[ 7 ]:bEditValue := { || oQry:alerta = .T. }
oBrw1:aCols[6]:SetCheck(,.t.)
oBrw1:aCols[7]:SetCheck(,.t.)
oBrw1:nFreeze := 7
oBrw1:CreateFromCode()
@01,408 GROUP TO 140,468 PIXEL OF oDlg
@10,423 BUTTON oBot PROMPT "&Salir" OF oDlg SIZE 30,10 ACTION oDlg:End() PIXEL
@25,423 BUTTON oBot PROMPT "&Silenciar" OF oDlg SIZE 30,10 ;
ACTION IF(MsgNoYes("Seguro de sacar alerta?","Atencion"),(oQry:alerta:=.f.,oQry:Save(),oBrw1:Refresh()),.t.) PIXEL
@40,423 BUTTON oBot PROMPT "&Realizada" OF oDlg SIZE 30,10 ;
ACTION IF(MsgNoYes("Confirma como realizada esta tarea?","Atencion"),(oQry:estado:=.t.,oQry:Save(),oBrw1:Refresh()),.t.) PIXEL
@55,423 BUTTON oBot PROMPT "&Mover" OF oDlg SIZE 30,10 ;
ACTION IF(Mover(oQry,oDlg),oBrw1:Refresh(),.t.) PIXEL
// Activo el dialog
ACTIVATE DIALOG oDlg CENTER ON INIT DlgOnTop( .t.,oDlg:hWnd )
RELEASE oFont
ENDIF
RETURN nil
STATIC FUNCTION Mover(oQry,oDlg)
LOCAL lRta := .f., oForm, oBot := ARRAY(2), oGet := ARRAY(8), aCor, base, aVar := ARRAY(3), oError
base := oQry:GetRowObj()
aVar[1] := base:fecha
aVar[2] := base:hora
aVar[3] := base:horafin
DO WHILE .T.
DEFINE DIALOG oForm TITLE "Mover Cita" FROM 05,15 TO 18,60 OF oDlg
@ 07, 05 SAY "Tarea:" OF oForm PIXEL SIZE 40,12 RIGHT
@ 22, 05 SAY "Dia:" OF oForm PIXEL SIZE 40,12 RIGHT
@ 37, 05 SAY "Hora:" OF oForm PIXEL SIZE 40,12 RIGHT
@ 52, 05 SAY "Mover a Dia:" OF oForm PIXEL SIZE 40,12 RIGHT
@ 67, 05 SAY "Hora:" OF oForm PIXEL SIZE 40,12 RIGHT
@ 05, 50 GET oGet[01] VAR base:motivo OF oForm PIXEL WHEN(.F.)
@ 20, 50 GET oGet[02] VAR aVar[1] OF oForm PIXEL WHEN(.F.)
@ 35, 50 GET oGet[03] VAR aVar[2] OF oForm PIXEL WHEN(.f.)
@ 35, 90 GET oGet[04] VAR aVar[3] OF oForm PIXEL WHEN(.f.)
@ 50, 50 GET oGet[05] VAR base:fecha OF oForm PIXEL
@ 65, 50 GET oGet[06] VAR base:hora OF oForm PIXEL PICTURE "99:99"
@ 65, 90 GET oGet[07] VAR base:horafin OF oForm PIXEL PICTURE "99:99"
@ 80,50 BUTTON oBot[1] PROMPT "&Grabar" OF oForm SIZE 30,10 ;
ACTION ((lRta := .t.), oForm:End() ) PIXEL
@ 80,100 BUTTON oBot[2] PROMPT "&Cancelar" OF oForm SIZE 30,10 ;
ACTION ((lRta := .f.), oForm:End() ) PIXEL CANCEL
ACTIVATE DIALOG oForm CENTER ON INIT oGet[2]:SetFocus()
IF !lRta
RETURN nil
ENDIF
oQry:oRow := base
TRY
oApp:oServer:BeginTransaction()
oQry:Save()
oQry:Refresh()
oApp:oServer:CommitTransaction()
CATCH oError
Msginfo("Error al grabar")
LOOP
END TRY
EXIT
ENDDO
RETURN lrta
***********************************
function DlgOnTop( lState, hWnd )
local nRet := 0
DEFAULT hWnd := GetActiveWindow()
if !lState
nRet = AcpOnTop( hWnd, -2, 0, 0, 0, 0, 3 )
else
nRet = AcpOnTop( hWnd, -1, 0, 0, 0, 0, 3 )
endif
return nRet
dll32 static function AcpOnTop( hWnd AS LONG, hWndInsertAfter AS LONG, x AS LONG, y AS LONG, cx AS LONG, cy AS LONG, wFlags AS LONG ) ;
AS LONG PASCAL FROM "SetWindowPos" LIB "User32.dll"
cmsoft wrote:Hola Jose Luis:
Te agrego el código que utilizo para los recordatorios, que se lanza desde la aplicación principal con un timer. Mantiene la estructura del programa que le copie a Carlos.
Tiene un parametro de si es la primera vez que se lanza, que es para que te muestre todas las citas incumplidas anteriores a la fecha del dia, sino solo te muestra las citas pendientes del dia de la fecha
La cita se puede mover, silenciar o dar por cumplida.
Espero que te sea de utilidad
- Code: Select all Expand view
********************************************
** Alertas
FUNCTION Alertas(lPrimerVez)
LOCAL oQry, oDlg, oSay, oBot, aNueva, i,j, cVentana, oFont, oBrw1
DEFAULT lPrimerVez := .f.
cVentana := PROCNAME()
IF ASCAN(oApp:aVentanas,cVentana) > 0
RETURN nil
ENDIF
oQry := oApp:oServer:Query("SELECT * FROM in_citas WHERE alerta = TRUE AND estado = FALSE AND usuario = " +ClipValue2Sql(oApp:usuario)+ ;
" AND fecha " + IF(lPrimerVez,"<" + ClipValue2Sql(DATE()),;
"= " + ClipValue2Sql(DATE()) + " AND hora <= " + ClipValue2Sql(LEFT(TIME(),5))) )
IF oQry:nRecCount > 0
AADD(oApp:aVentanas,cVentana)
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-13.5
DEFINE DIALOG oDlg TITLE "Alertas " + IF(lPrimerVez," pendientes de dias anteriores"," para el dia " + DTOC(DATE())) + " para usuario " + oApp:usuanom;
FROM 09,15 TO 28,135 OF oApp:oWnd
oDlg:lHelpIcon := .f.
//Reproduzco un sonido que esta guardado en el archivo ringin.wav
SndPlaySound("ringin.wav",1)
@ 01,001 BITMAP FILE "BITMAPS\ALERT.PNG" SIZE 65,140 ADJUST PIXEL OF oDlg NOBORDER
@ 01,080 XBROWSE oBrw1 DATASOURCE oQry SIZE 325,140 OF oDlg PIXEL ;
COLUMNS "id","fecha","hora","horafin","motivo","estado","alerta";
HEADERS "id","Fecha","Hora","Hasta","Motivo","Hecha?","Alerta?";
SIZES 65,65,45,45,250,55,55
PintaBrw(oBrw1,7)
*oBrw1:aCols[6]:bStrData := { || If( oQry:estado, " ","Sin Hacer" ) }
oBrw1:aCols[ 6 ]:bEditValue := { || oQry:estado = .T. }
*oBrw1:aCols[7]:bStrData := { || If( oQry:alerta, "Con Alerta"," " ) }
oBrw1:aCols[ 7 ]:bEditValue := { || oQry:alerta = .T. }
oBrw1:aCols[6]:SetCheck(,.t.)
oBrw1:aCols[7]:SetCheck(,.t.)
oBrw1:nFreeze := 7
oBrw1:CreateFromCode()
@01,408 GROUP TO 140,468 PIXEL OF oDlg
@10,423 BUTTON oBot PROMPT "&Salir" OF oDlg SIZE 30,10 ACTION oDlg:End() PIXEL
@25,423 BUTTON oBot PROMPT "&Silenciar" OF oDlg SIZE 30,10 ;
ACTION IF(MsgNoYes("Seguro de sacar alerta?","Atencion"),(oQry:alerta:=.f.,oQry:Save(),oBrw1:Refresh()),.t.) PIXEL
@40,423 BUTTON oBot PROMPT "&Realizada" OF oDlg SIZE 30,10 ;
ACTION IF(MsgNoYes("Confirma como realizada esta tarea?","Atencion"),(oQry:estado:=.t.,oQry:Save(),oBrw1:Refresh()),.t.) PIXEL
@55,423 BUTTON oBot PROMPT "&Mover" OF oDlg SIZE 30,10 ;
ACTION IF(Mover(oQry,oDlg),oBrw1:Refresh(),.t.) PIXEL
// Activo el dialog
ACTIVATE DIALOG oDlg CENTER ON INIT DlgOnTop( .t.,oDlg:hWnd )
RELEASE oFont
ENDIF
RETURN nil
STATIC FUNCTION Mover(oQry,oDlg)
LOCAL lRta := .f., oForm, oBot := ARRAY(2), oGet := ARRAY(8), aCor, base, aVar := ARRAY(3), oError
base := oQry:GetRowObj()
aVar[1] := base:fecha
aVar[2] := base:hora
aVar[3] := base:horafin
DO WHILE .T.
DEFINE DIALOG oForm TITLE "Mover Cita" FROM 05,15 TO 18,60 OF oDlg
@ 07, 05 SAY "Tarea:" OF oForm PIXEL SIZE 40,12 RIGHT
@ 22, 05 SAY "Dia:" OF oForm PIXEL SIZE 40,12 RIGHT
@ 37, 05 SAY "Hora:" OF oForm PIXEL SIZE 40,12 RIGHT
@ 52, 05 SAY "Mover a Dia:" OF oForm PIXEL SIZE 40,12 RIGHT
@ 67, 05 SAY "Hora:" OF oForm PIXEL SIZE 40,12 RIGHT
@ 05, 50 GET oGet[01] VAR base:motivo OF oForm PIXEL WHEN(.F.)
@ 20, 50 GET oGet[02] VAR aVar[1] OF oForm PIXEL WHEN(.F.)
@ 35, 50 GET oGet[03] VAR aVar[2] OF oForm PIXEL WHEN(.f.)
@ 35, 90 GET oGet[04] VAR aVar[3] OF oForm PIXEL WHEN(.f.)
@ 50, 50 GET oGet[05] VAR base:fecha OF oForm PIXEL
@ 65, 50 GET oGet[06] VAR base:hora OF oForm PIXEL PICTURE "99:99"
@ 65, 90 GET oGet[07] VAR base:horafin OF oForm PIXEL PICTURE "99:99"
@ 80,50 BUTTON oBot[1] PROMPT "&Grabar" OF oForm SIZE 30,10 ;
ACTION ((lRta := .t.), oForm:End() ) PIXEL
@ 80,100 BUTTON oBot[2] PROMPT "&Cancelar" OF oForm SIZE 30,10 ;
ACTION ((lRta := .f.), oForm:End() ) PIXEL CANCEL
ACTIVATE DIALOG oForm CENTER ON INIT oGet[2]:SetFocus()
IF !lRta
RETURN nil
ENDIF
oQry:oRow := base
TRY
oApp:oServer:BeginTransaction()
oQry:Save()
oQry:Refresh()
oApp:oServer:CommitTransaction()
CATCH oError
Msginfo("Error al grabar")
LOOP
END TRY
EXIT
ENDDO
RETURN lrta
***********************************
function DlgOnTop( lState, hWnd )
local nRet := 0
DEFAULT hWnd := GetActiveWindow()
if !lState
nRet = AcpOnTop( hWnd, -2, 0, 0, 0, 0, 3 )
else
nRet = AcpOnTop( hWnd, -1, 0, 0, 0, 0, 3 )
endif
return nRet
dll32 static function AcpOnTop( hWnd AS LONG, hWndInsertAfter AS LONG, x AS LONG, y AS LONG, cx AS LONG, cy AS LONG, wFlags AS LONG ) ;
AS LONG PASCAL FROM "SetWindowPos" LIB "User32.dll"
cnavarro wrote:No problem
Cristobal, saludos, puedes enviar la clase hacia mi correo jnavas@datapronet.com
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: Google [Bot] and 71 guests