Project

General

Profile

hotel_gui_spreadsheet.20240719a.diff

Hynek Cihlar, 07/19/2024 01:54 PM

Download (14 KB)

View differences:

new/abl/guests-frame.w 2024-07-19 16:40:26 +0000
243 243
         SIZE 125.2 BY 15.38
244 244
         FONT 8 WIDGET-ID 100.
245 245

  
246
&if defined(FWD-VERSION) &then
247
DEF MENU staysMenu MENU-ITEM sheetMenuItem LABEL "Open in Spreadsheet...".
248
ASSIGN staysBrowse:POPUP-MENU = MENU staysMenu:HANDLE.
249
&endif         
246 250

  
247 251
/* *********************** Procedure Settings ************************ */
248 252

  
......
488 492
/* _UIB-CODE-BLOCK-END */
489 493
&ANALYZE-RESUME
490 494

  
495
&if defined(FWD-VERSION) &then
496
ON CHOOSE OF MENU-ITEM sheetMenuItem
497
DO:
498
  RUN export-as-spreadsheet.
499
END.
500
&endif
491 501

  
492 502
&Scoped-define SELF-NAME filterRoom
493 503
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL filterRoom fFrameWin
......
879 889
/* _UIB-CODE-BLOCK-END */
880 890
&ANALYZE-RESUME
881 891

  
892
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE export-as-spreadsheet fFrameWin 
893
PROCEDURE export-as-spreadsheet :
894
/*------------------------------------------------------------------------------
895
  Purpose:     
896
  Parameters:  <none>
897
  Notes:       
898
------------------------------------------------------------------------------*/
899
  DEFINE TEMP-TABLE person field roomNum AS INTEGER
900
                           field fullName AS CHAR
901
                           field nGuests AS INTEGER
902
                           field chkIn as DATE
903
                           field chkOut as DATE
904
                           field duration as INTEGER
905
                           field roomType as CHAR
906
                           field roomPrice as INTEGER FORMAT ">>>,>>>,>>9".
907
  
908
  DEFINE QUERY staysBrowseRpt FOR stay, room, room-type, guest SCROLLING.
909
  OPEN QUERY staysBrowseRpt FOR EACH stay, EACH room of stay,
910
     EACH room-type OF room, EACH guest OF stay NO-LOCK.
911
     
912
  GET FIRST staysBrowseRpt.
913
  
914
  DO WHILE AVAILABLE stay:
915
     CREATE person. assign roomNum = stay.room-num
916
                           fullName = guest.first-name + " " + guest.last-name
917
                           nGuests = stay.num-guests
918
                           chkIn = stay.start-date
919
                           chkOut = stay.end-date
920
                           duration = stay.end-date - stay.start-date
921
                           roomType = room-type.description
922
                           roomPrice = stay.price.
923
     GET NEXT staysBrowseRpt.
924
  END.
925

  
926
  RUN guests-spreadsheet.w (INPUT TABLE person).
927
 END.
928
/* _UIB-CODE-BLOCK-END */
929
&ANALYZE-RESUME
930

  
882 931
PROCEDURE printFile EXTERNAL "xPrint.dll" PERSISTENT :
883 932
    DEF INPUT PARAMETER A AS CHAR.
884 933
    END.
new/abl/guests-spreadsheet.w 2024-07-19 09:15:43 +0000
1
&ANALYZE-SUSPEND _VERSION-NUMBER AB_v10r12 GUI ADM2
2
&ANALYZE-RESUME
3
&Scoped-define WINDOW-NAME wWin
4
{adecomm/appserv.i}
5
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS wWin 
6
/*------------------------------------------------------------------------
7

  
8
  File: 
9

  
10
  Description: from cntnrwin.w - ADM SmartWindow Template
11

  
12
  Input Parameters:
13
      <none>
14

  
15
  Output Parameters:
16
      <none>
17

  
18
  History: New V9 Version - January 15, 1998
19
          
20
------------------------------------------------------------------------*/
21
/*          This .W file was created with the Progress AB.              */
22
/*----------------------------------------------------------------------*/
23

  
24
/* Create an unnamed pool to store all the widgets created 
25
     by this procedure. This is a good default which assures
26
     that this procedure's triggers and internal procedures 
27
     will execute in this procedure's storage, and that proper
28
     cleanup will occur on deletion of the procedure. */
29

  
30
DEFINE TEMP-TABLE person field roomNum AS INTEGER
31
field fullName AS CHAR
32
field nGuests AS INTEGER
33
field chkIn as DATE
34
field chkOut as DATE
35
field duration as INTEGER
36
field roomType as CHAR
37
field roomPrice as INTEGER FORMAT ">>>,>>>,>>9".
38

  
39
DEFINE INPUT PARAMETER TABLE FOR person.
40

  
41
CREATE WIDGET-POOL.
42

  
43
/* ***************************  Definitions  ************************** */
44

  
45
/* Parameters Definitions ---                                           */
46

  
47
/* Local Variable Definitions ---                                       */
48

  
49
DEFINE VAR CtrlFrame AS HANDLE.
50
DEFINE VAR chCtrlFrame AS COM-HANDLE.
51

  
52
{src/adm2/widgetprto.i}
53

  
54
/* _UIB-CODE-BLOCK-END */
55
&ANALYZE-RESUME
56

  
57

  
58
&ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK 
59

  
60
/* ********************  Preprocessor Definitions  ******************** */
61

  
62
&Scoped-define PROCEDURE-TYPE SmartWindow
63
&Scoped-define DB-AWARE no
64

  
65
&Scoped-define ADM-CONTAINER WINDOW
66

  
67
&Scoped-define ADM-SUPPORTED-LINKS Data-Target,Data-Source,Page-Target,Update-Source,Update-Target,Filter-target,Filter-Source
68

  
69
/* Name of designated FRAME-NAME and/or first browse and/or first query */
70
&Scoped-define FRAME-NAME fMain
71

  
72
/* Custom List Definitions                                              */
73
/* List-1,List-2,List-3,List-4,List-5,List-6                            */
74

  
75
/* _UIB-PREPROCESSOR-BLOCK-END */
76
&ANALYZE-RESUME
77

  
78

  
79

  
80
/* ***********************  Control Definitions  ********************** */
81

  
82
/* Define the widget handle for the window                              */
83
DEFINE VAR wWin AS WIDGET-HANDLE NO-UNDO.
84

  
85
def sub-menu smFile
86
  menu-item miOpen label "&Open...".
87

  
88
define menu m menubar.
89
  sub-menu smFile label "File".
90

  
91
/* ************************  Frame Definitions  *********************** */
92

  
93
DEFINE FRAME fMain
94
    WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY 
95
         SIDE-LABELS NO-UNDERLINE THREE-D 
96
         AT COL 1 ROW 1
97
         SIZE 185.8 BY 29.48 WIDGET-ID 100.
98

  
99
/* *********************** Procedure Settings ************************ */
100

  
101
&ANALYZE-SUSPEND _PROCEDURE-SETTINGS
102
/* Settings for THIS-PROCEDURE
103
   Type: SmartWindow
104
   Allow: Basic,Browse,DB-Fields,Query,Smart,Window
105
   Container Links: Data-Target,Data-Source,Page-Target,Update-Source,Update-Target,Filter-target,Filter-Source
106
   Other Settings: APPSERVER
107
 */
108
&ANALYZE-RESUME _END-PROCEDURE-SETTINGS
109

  
110
/* *************************  Create Window  ************************** */
111

  
112
&ANALYZE-SUSPEND _CREATE-WINDOW
113
IF SESSION:DISPLAY-TYPE = "GUI":U THEN
114
  CREATE WINDOW wWin ASSIGN
115
         HIDDEN             = YES
116
         TITLE              = "Guests"
117
         HEIGHT             = 29.48
118
         WIDTH              = 185.8
119
         RESIZE             = yes
120
         SCROLL-BARS        = no
121
         STATUS-AREA        = no
122
         BGCOLOR            = ?
123
         FGCOLOR            = ?
124
         THREE-D            = yes
125
         MESSAGE-AREA       = no
126
         SENSITIVE          = yes
127
         MENUBAR            = menu m:handle.
128
ELSE {&WINDOW-NAME} = CURRENT-WINDOW.
129
/* END WINDOW DEFINITION                                                */
130
&ANALYZE-RESUME
131
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "SmartWindowCues" wWin _INLINE
132
/* Actions: adecomm/_so-cue.w ? adecomm/_so-cued.p ? adecomm/_so-cuew.p */
133
/* SmartWindow,ab,49271
134
Destroy on next read */
135
/* _UIB-CODE-BLOCK-END */
136
&ANALYZE-RESUME
137

  
138

  
139
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB wWin 
140
/* ************************* Included-Libraries *********************** */
141

  
142
{src/adm2/containr.i}
143

  
144
/* _UIB-CODE-BLOCK-END */
145
&ANALYZE-RESUME
146

  
147

  
148

  
149

  
150
/* ***********  Runtime Attributes and AppBuilder Settings  *********** */
151

  
152
&ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
153
/* SETTINGS FOR WINDOW wWin
154
  VISIBLE,,RUN-PERSISTENT                                               */
155
/* SETTINGS FOR FRAME fMain
156
   FRAME-NAME                                                           */
157
IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(wWin)
158
THEN wWin:HIDDEN = yes.
159

  
160
/* _RUN-TIME-ATTRIBUTES-END */
161
&ANALYZE-RESUME
162

  
163
 
164

  
165

  
166

  
167
/* ************************  Control Triggers  ************************ */
168

  
169
&Scoped-define SELF-NAME wWin
170
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wWin wWin
171
ON END-ERROR OF wWin /* <insert SmartWindow title> */
172
OR ENDKEY OF {&WINDOW-NAME} ANYWHERE DO:
173
  /* This case occurs when the user presses the "Esc" key.
174
     In a persistently run window, just ignore this.  If we did not, the
175
     application would exit. */
176
  IF THIS-PROCEDURE:PERSISTENT THEN RETURN NO-APPLY.
177
END.
178

  
179
/* _UIB-CODE-BLOCK-END */
180
&ANALYZE-RESUME
181

  
182

  
183
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wWin wWin
184
ON WINDOW-CLOSE OF wWin /* <insert SmartWindow title> */
185
DO:
186
  /* This ADM code must be left here in order for the SmartWindow
187
     and its descendents to terminate properly on exit. */
188
  APPLY "CLOSE":U TO THIS-PROCEDURE.
189
  RETURN NO-APPLY.
190
END.
191

  
192
/* _UIB-CODE-BLOCK-END */
193
&ANALYZE-RESUME
194

  
195
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wWin wWin
196
ON WINDOW-RESIZED OF wWin /* <insert SmartWindow title> */
197
DO:
198
  frame fMain:width = wWin:width.
199
  frame fMain:height = wWin:height.
200
  CtrlFrame:width = frame fMain:width.
201
  CtrlFrame:height = frame fMain:height .
202
END.
203

  
204
/* _UIB-CODE-BLOCK-END */
205
&ANALYZE-RESUME
206

  
207
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL wWin wWin
208
on choose of menu-item miOpen do:
209
  DEF VAR fName as CHAR.
210
  SYSTEM-DIALOG GET-FILE fName AT-WEB-BROWSER UPLOAD.
211
  if fName <> ? and length(fName) > 0 then chCtrlFrame:F1Book:read(fName, 0).
212
end.
213

  
214
/* _UIB-CODE-BLOCK-END */
215
&ANALYZE-RESUME
216

  
217

  
218
&UNDEFINE SELF-NAME
219

  
220
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK wWin 
221

  
222

  
223
/* ***************************  Main Block  *************************** */
224

  
225
/* Include custom  Main Block code for SmartWindows. */
226
{src/adm2/windowmn.i}
227

  
228
/* _UIB-CODE-BLOCK-END */
229
&ANALYZE-RESUME
230

  
231

  
232
/* **********************  Internal Procedures  *********************** */
233

  
234
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-create-objects wWin  _ADM-CREATE-OBJECTS
235
PROCEDURE adm-create-objects :
236
/*------------------------------------------------------------------------------
237
  Purpose:     Create handles for all SmartObjects used in this procedure.
238
               After SmartObjects are initialized, then SmartLinks are added.
239
  Parameters:  <none>
240
------------------------------------------------------------------------------*/
241

  
242
END PROCEDURE.
243

  
244
/* _UIB-CODE-BLOCK-END */
245
&ANALYZE-RESUME
246

  
247
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI wWin  _DEFAULT-DISABLE
248
PROCEDURE disable_UI :
249
/*------------------------------------------------------------------------------
250
  Purpose:     DISABLE the User Interface
251
  Parameters:  <none>
252
  Notes:       Here we clean-up the user-interface by deleting
253
               dynamic widgets we have created and/or hide 
254
               frames.  This procedure is usually called when
255
               we are ready to "clean-up" after running.
256
------------------------------------------------------------------------------*/
257
  delete widget CtrlFrame.
258

  
259
  /* Delete the WINDOW we created */
260
  IF SESSION:DISPLAY-TYPE = "GUI":U AND VALID-HANDLE(wWin)
261
  THEN DELETE WIDGET wWin.
262
  IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
263
END PROCEDURE.
264

  
265
/* _UIB-CODE-BLOCK-END */
266
&ANALYZE-RESUME
267

  
268
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI wWin  _DEFAULT-ENABLE
269
PROCEDURE enable_UI :
270
/*------------------------------------------------------------------------------
271
  Purpose:     ENABLE the User Interface
272
  Parameters:  <none>
273
  Notes:       Here we display/view/enable the widgets in the
274
               user-interface.  In addition, OPEN all queries
275
               associated with each FRAME and BROWSE.
276
               These statements here are based on the "Other 
277
               Settings" section of the widget Property Sheets.
278
------------------------------------------------------------------------------*/
279

  
280
  create control-frame CtrlFrame assign
281
    frame           = frame fmain:handle
282
    row             = 1
283
    column          = 1
284
    height          = frame fmain:height - 1
285
    width           = frame fmain:width
286
    tab-stop        = no
287
    hidden          = yes
288
    sensitive       = yes.
289
  
290
  CtrlFrame:name = "sheet".
291
  chCtrlFrame = CtrlFrame:com-handle.
292
  chCtrlFrame:F1Book:LoadControls("", "spreadsheet":U).
293
  
294
  chCtrlFrame:F1Book:ShowEditBar = true.
295
  chCtrlFrame:F1Book:ShowTabs = true.
296
  chCtrlFrame:F1Book:ShowToolBar = true.
297

  
298
  VIEW FRAME fMain IN WINDOW wWin.
299
  ENABLE ALL WITH FRAME fMain.
300

  
301
  {&OPEN-BROWSERS-IN-QUERY-fMain}
302
  VIEW wWin.
303

  
304
  /* load data in the spreadsheet */
305
  chCtrlFrame:F1Book:Read("res/guests.xlsx", 0).
306
  DEF VAR row AS INT INIT 2.
307
  FOR EACH person:
308
    chCtrlFrame:F1Book:TextRC(row, 1) = person.fullName.
309
    chCtrlFrame:F1Book:TextRC(row, 2) = person.chkIn.
310
    chCtrlFrame:F1Book:TextRC(row, 3) = person.chkOut.
311
    chCtrlFrame:F1Book:TextRC(row, 4) = person.duration.
312
    chCtrlFrame:F1Book:TextRC(row, 5) = person.nGuests.
313
    chCtrlFrame:F1Book:TextRC(row, 6) = person.roomNum.
314
    chCtrlFrame:F1Book:TextRC(row, 7) = person.roomPrice.
315
    chCtrlFrame:F1Book:TextRC(row, 8) = person.roomType.
316
    row = row + 1.
317
  END.
318
END PROCEDURE.
319

  
320
/* _UIB-CODE-BLOCK-END */
321
&ANALYZE-RESUME
322

  
323
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE exitObject wWin 
324
PROCEDURE exitObject :
325
/*------------------------------------------------------------------------------
326
  Purpose:  Window-specific override of this procedure which destroys 
327
            its contents and itself.
328
    Notes:  
329
------------------------------------------------------------------------------*/
330

  
331
  APPLY "CLOSE":U TO THIS-PROCEDURE.
332
  RETURN.
333

  
334
END PROCEDURE.
335

  
336
/* _UIB-CODE-BLOCK-END */
337
&ANALYZE-RESUME
338

  
new/abl/guests-spreadsheet.w.ext-hints 2024-07-17 12:16:23 +0000
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
<extension>
3
   <ocx com-handle="chCtrlFrame:F1Book" target-widget="Spreadsheet" target-handle="hSheet" control-frame="CtrlFrame" control-frame-handle="chCtrlFrame"/>
4
</extension>