-
Notifications
You must be signed in to change notification settings - Fork 1
/
Vuelos.lua
128 lines (95 loc) · 3.78 KB
/
Vuelos.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
---------------------------------
-- Vuelos.lua
-- Hernán Cano Martínez
-- Ene-2018
---------------------------------
package.cpath = "?.dll;?53.dll;lua533/?.dll;lua533/?53.dll;" -- [in Windows]
require ( "iuplua" )
-- ***************************************************************************
function MessageBox ( pTit, pCad )
if (pCad) then
return iup.Message( pTit or '', pCad or '' )
else
return iup.Message( pCad or '', pTit or '' )
end
end
-- ***************************************************************************
-- los controles que usaremos en nuestro formulario
cmbC = iup.list { value=1 , expand='NO', floating='NO', rastersize ="150", cx="030", cy="000", font ="Courier New, 10", NC='10', ACTIVE='YES', ALIGNMENT='ACENTER', " sólo de ida ", " ida y regreso ", dropdown="Yes" --[[, valuechanged_cb = cmbC_valuechanged_cb]] }
txt1 = iup.text { value="", expand='NO', floating='NO', rastersize ="150", cx="030", cy="050", font ="Courier New, 10", NC='10', ACTIVE='YES', ALIGNMENT='ACENTER' }
txt2 = iup.text { value="", expand='NO', floating='NO', rastersize ="150", cx="030", cy="100", font ="Courier New, 10", NC='10', ACTIVE='No' , ALIGNMENT='ACENTER' }
txt1.Value = os.date("%Y.%m.%d")
txt2.Value = os.date("%Y.%m.%d")
btnB = iup.button { title = "Reservar", expand='NO', floating='NO', rastersize ="155x35", cx="030", cy="150", font ="Segoe IU, 9", TIP='Haga click para reservar' }
-- ***************************************************************************
function ValidDates()
if (tonumber(cmbC.Value) == 2) then -- ida y regreso
if (txt2.Value >= txt1.Value) then
-- MessageBox( 'es mayor txt2' )
btnB.ACTIVE = 'YES'
else
btnB.ACTIVE = 'NO'
-- MessageBox( 'es mayor txt1' )
end
end
-- MessageBox(btnB.ACTIVE )
end
---- ***************************************************************************
-- el Contenedor de controles
vArea = iup.cbox{ expand='NO', floating='NO', size = "250x300",
cmbC, txt1, txt2, btnB,
nil
}
-- El formulario
frmVuelos = iup.dialog{ expand='NO', floating='NO',
vArea,
title = "Reserva de Vuelos",
size = "150x150"
}
-- ********************************** Callbacks *****************************************
function btnB:action()
-- MessageBox ( cmbC.Value )
-- iup.Message('Usted ha reservado un vuelo de ida para la fecha '..txt1.Value,'hcano')
if tonumber(cmbC.Value) == 1 then -- sólo de ida
MessageBox('Usted ha reservado un vuelo de ida para la fecha '..txt1.Value)
end
if tonumber(cmbC.Value) == 2 then -- ida y regreso
MessageBox('Usted ha reservado un vuelo de ida y vuelta, donde la ida es en '..txt1.Value..' y la vuelta para '..txt2.Value)
end
-- MessageBox ( 'txt2.active '..txt2.active )
-- Exits the main loop
-- return iup.CLOSE
-- return iup.DEFAULT
end
function txtC_action(t, new_value)
if new_value and tonumber(new_value) then
local nNum = tonumber(new_value)
txtF.value = nNum * (9/5) + 32
end
end
function cmbC.valuechanged_cb(self)
local value = self.value
-- MessageBox ( value )
if tonumber(value) == 1 then -- sólo de ida
txt2.active='NO'
end
if tonumber(value) == 2 then -- ida y regreso
txt2.active='YES'
end
-- iup.SetAttribute(iup.GetDialog(self), "TOOLSTYLE", value)
end
function txt1:killfocus_cb() --(t, new_value)
ValidDates()
end
function txt2:killfocus_cb() --(t, new_value)
ValidDates()
end
--------------------------------------------
-- Ahora sí: mostremos el formulario
frmVuelos:showxy(iup.CENTER,iup.CENTER)
-- to be able to run this script inside another context
-- if (iup.MainLoopLevel()==0) then
if (not iup.MainLoopLevel or iup.MainLoopLevel()==0) then
iup.MainLoop()
end
----------------------------------------------