

select fecha, hinicia, htermina ;
from eventos ;
where fecha = _fecha ;
and ( _horaFin>hInicia or _horaIni<hTermina or ;
BETWEEN(_horaIni, hInicia, hTermina) and BETWEEN(_horaFin, hInicia, hTermina)) ;
into cursor EventoRegistrado
IF RECCOUNT()>0
SELECT EventoRegistrado
BROWSE
ELSE
WAIT window "todo ok"
ENDIF select fecha, hinicia, htermina ;
from eventos ;
where fecha = _fecha ;
and (hInicia > _horaIni and hTermina > _horaFin or ;
hInicia < _horaIni and hTermina < _horaFin or ;
_horaIni between(hInicia, hTermina) and _horaFin between(hInicia, hTermina) or ;
hInicia >= _horaIni and hTermina <= _horaFin or ;
hInicia between(_horaIni, _horaFin) and hTermina between(_horaIni, _horaFin));LOCAL _fecha as Date, _horaIni as Integer, _horaFin as Integer
_fecha = Thisform.Fecha
_horaIni = Thisform.txthoraIni.Value
_horaFin = Thisform.txthoraFin.Value
Local lcSelect
Text To m.lcSelect Textmerge Noshow Pretext 15
Select fecha
, hinicia
, htermina
From eventos
Where fecha = <<_fecha>>
And ( (hinicia > <<_horaIni>> And htermina > <<_horaFin>>)
Or (hinicia < <<_horaIni>> And htermina < <<_horaFin>>)
Or (<<_horaIni>> Between hinicia And htermina And <<_horaFin>> Between hinicia And htermina)
Or (hinicia >= <<_horaIni>> And htermina <= <<_horaFin>>)
)
Into Cursor EventoRegistrado
Endtext
Execscript(m.lcSelect)
If Reccount() > 0
Select EventoRegistrado
Browse
Else
Wait Window "todo ok"
ENDIF<<_fecha>>
Where fecha = <<_fecha>>
And ( (hinicia > <<_horaIni>> And htermina > <<_horaFin>>)
Where fecha = ?_fecha
And ( (hinicia > ?_horaIni And htermina > ?_horaFin)
y así sucesivamente
numericos
<<_fecha>>
PRIVATE _fecha as Date, _horaIni as Integer, _horaFin as Integer
_fecha = Thisform.Fecha
_horaIni = Thisform.txthoraIni.Value
_horaFin = Thisform.txthoraFin.Value
Local lcSelect
Text To m.lcSelect Textmerge Noshow Pretext 15
Select fecha
, hinicia
, htermina
From eventos
Where fecha = ?_fecha
And ( (hinicia > ?_horaIni And htermina > ?_horaFin)
Or (hinicia > ?_horaIni And htermina < ?_horaFin)
Or (?_horaIni Between hinicia And htermina And ?_horaFin Between hinicia And htermina)
Or (hinicia >= ?_horaIni And htermina <= ?_horaFin)
)
Into Cursor EventoRegistrado
Endtext
Execscript(m.lcSelect)
If Reccount() > 0
Select EventoRegistrado
Browse
Else
Wait Window "todo ok"
ENDIF
Local lcSelect
Text To m.lcSelect Textmerge Noshow Pretext 15
Select num, fecha
, hinicia
, htermina
From eventos
Where fecha = ?_fecha
And ( (?_horaIni < hInicia And ?_horaFin < hTermina)
Or (?_horaIni > hInicia And ?_horaFin > hTermina)
Or (?_horaIni Between hinicia And htermina And ?_horaFin Between hinicia And htermina) )
Or (?_horaIni < hInicia And ?_horaFin > hTermina)
Into Cursor EventoRegistrado
Endtext
Execscript(m.lcSelect)
If Reccount() > 0
Select EventoRegistrado
LOCAL _id as Integer
MESSAGEBOX("Ya existe un Evento agendado en esta fecha y horario",0+64,"Agenda ocupada por evento")
DO FORM formas\mostrarEvento1 WITH _fecha, _horaIni, _horaFin
ELSE
MESSAGEBOX("Fecha y horario libre para agendar",0+64,"Agendar Evento")
ENDIF Where fecha = ?_fecha
And ( (?_horaIni < hInicia And ?_horaFin < hTermina)
Or (?_horaIni > hInicia And ?_horaFin > hTermina)
Or (?_horaIni Between hinicia And htermina And ?_horaFin Between hinicia And htermina) )
Or (?_horaIni < hInicia And ?_horaFin > hTermina)
Into Cursor EventoRegistrado
Where fecha = ?_fecha
And ( (?_horaIni < hInicia And ?_horaFin < hTermina)
Or (?_horaIni > hInicia And ?_horaFin > hTermina)
Or (?_horaIni Between hinicia And htermina And ?_horaFin Between hinicia And htermina)
Or (?_horaIni <= hInicia And ?_horaFin >= hTermina)
)
Into Cursor EventoRegistrado
LPARAMETERS _fecha, _horaInicia, _horaTermina
PRIVATE _fecha1 as Date, _horaIni1 as Integer, _horaFin1 as Integer
_fecha1 = _fecha
_horaIni1 = _horaInicia
_horaFin1 = _horaTermina
Local lcSelect
Text To m.lcSelect Textmerge Noshow Pretext 15
Select SUBSTR(ALLTRIM(STR(hinicia)),1,2)+':'+SUBSTR(ALLTRIM(STR(hinicia)),3,2) as hInicia
, SUBSTR(ALLTRIM(STR(hTermina)),1,2)+':'+SUBSTR(ALLTRIM(STR(hTermina)),3,2) as hTermina
, fecha
, num
From eventos
Where fecha = ?_fecha1
And ( (?_horaIni1 < hInicia And ?_horaFin1 < hTermina)
Or (?_horaIni1 > hInicia And ?_horaFin1 > hTermina)
Or (?_horaIni1 Between hinicia And htermina And ?_horaFin1 Between hinicia And htermina) )
Or (?_horaIni1 < hInicia And ?_horaFin1 > hTermina)
Into Cursor cEventos
Endtext
Execscript(m.lcSelect) No hay necesidad de transformar los datos numéricos de las horas, para rellenar con ceros a la izquierda e insertar el ":" se usan las propiedades de las columnas Format = "RL" e InputMask = 99:99
Fíjate en el formulario Agenda_3 del proyecto que te envié.
LPARAMETERS _fecha, _horaInicia, _horaTermina
PRIVATE _fecha1 as Date, _horaIni1 as Integer, _horaFin1 as Integer
_fecha1 = _fecha
_horaIni1 = _horaInicia
_horaFin1 = _horaTermina
Local lcSelect
Text To m.lcSelect Textmerge Noshow Pretext 15
Select hinicia
, hTermina
, fecha
, num
From eventos
Where fecha = ?_fecha1
And ( (?_horaIni1 < hInicia And ?_horaFin1 < hTermina)
Or (?_horaIni1 > hInicia And ?_horaFin1 > hTermina)
Or (?_horaIni1 Between hinicia And htermina And ?_horaFin1 Between hinicia And htermina) )
Or (?_horaIni1 <= hInicia And ?_horaFin1 >= hTermina)
Into Cursor cEventos
Endtext
Execscript(m.lcSelect)

--
Blog de la Comunidad Visual FoxPro en Español http://comunidadvfp.blogspot.com
---
Has recibido este mensaje porque estás suscrito al grupo "Comunidad de Visual Foxpro en Español" de Grupos de Google.
Para cancelar la suscripción a este grupo y dejar de recibir sus mensajes, envía un correo electrónico a publicesvfoxp...@googlegroups.com.
Para ver este debate, visita https://groups.google.com/d/msgid/publicesvfoxpro/9a06b82d-dd8e-48f1-be49-622388f38183n%40googlegroups.com.
