Really, this should be it, for the passing income.
[capital-apms-progress.git] / vwr / sel / b-selmtr.w
blob0c80b5e1bece1c85307f1724cbb5148f046dc207
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
2 &ANALYZE-RESUME
3 /* Connected Databases
4 ttpl PROGRESS
5 */
6 &Scoped-define WINDOW-NAME CURRENT-WINDOW
7 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS B-table-Win
8 /*------------------------------------------------------------------------
9 File:
10 Description:
11 ------------------------------------------------------------------------*/
13 CREATE WIDGET-POOL.
15 /* *************************** Definitions ************************** */
17 DEF VAR gap-1 AS CHAR NO-UNDO FORMAT "X" LABEL "".
19 DEF VAR property-code AS CHAR NO-UNDO.
21 /* _UIB-CODE-BLOCK-END */
22 &ANALYZE-RESUME
25 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
27 /* ******************** Preprocessor Definitions ******************** */
29 &Scoped-define PROCEDURE-TYPE SmartBrowser
31 &Scoped-define ADM-SUPPORTED-LINKS Record-Source,Record-Target,TableIO-Target
33 /* Name of first Frame and/or Browse and/or first Query */
34 &Scoped-define FRAME-NAME F-Main
35 &Scoped-define BROWSE-NAME br_table
37 /* Internal Tables (found by Frame, Query & Browse Queries) */
38 &Scoped-define INTERNAL-TABLES SupplyMeter
40 /* Define KEY-PHRASE in case it is used by any query. */
41 &Scoped-define KEY-PHRASE TRUE
43 /* Definitions for BROWSE br_table */
44 &Scoped-define FIELDS-IN-QUERY-br_table SupplyMeter.PropertyCode ~
45 SupplyMeter.MeterCode SupplyMeter.Level SupplyMeter.Description ~
46 SupplyMeter.EntityType SupplyMeter.EntityCode SupplyMeter.AccountCode ~
47 SupplyMeter.Multiplier SupplyMeter.ElectricityUnitRate
48 &Scoped-define ENABLED-FIELDS-IN-QUERY-br_table SupplyMeter.PropertyCode ~
49 SupplyMeter.MeterCode SupplyMeter.Level SupplyMeter.Description ~
50 SupplyMeter.EntityType SupplyMeter.EntityCode SupplyMeter.AccountCode ~
51 SupplyMeter.Multiplier SupplyMeter.ElectricityUnitRate
52 &Scoped-define FIELD-PAIRS-IN-QUERY-br_table~
53 ~{&FP1}PropertyCode ~{&FP2}PropertyCode ~{&FP3}~
54 ~{&FP1}MeterCode ~{&FP2}MeterCode ~{&FP3}~
55 ~{&FP1}Level ~{&FP2}Level ~{&FP3}~
56 ~{&FP1}Description ~{&FP2}Description ~{&FP3}~
57 ~{&FP1}EntityType ~{&FP2}EntityType ~{&FP3}~
58 ~{&FP1}EntityCode ~{&FP2}EntityCode ~{&FP3}~
59 ~{&FP1}AccountCode ~{&FP2}AccountCode ~{&FP3}~
60 ~{&FP1}Multiplier ~{&FP2}Multiplier ~{&FP3}~
61 ~{&FP1}ElectricityUnitRate ~{&FP2}ElectricityUnitRate ~{&FP3}
62 &Scoped-define ENABLED-TABLES-IN-QUERY-br_table SupplyMeter
63 &Scoped-define FIRST-ENABLED-TABLE-IN-QUERY-br_table SupplyMeter
64 &Scoped-define OPEN-QUERY-br_table OPEN QUERY br_table FOR EACH SupplyMeter WHERE ~{&KEY-PHRASE} NO-LOCK ~
65 ~{&SORTBY-PHRASE}.
66 &Scoped-define TABLES-IN-QUERY-br_table SupplyMeter
67 &Scoped-define FIRST-TABLE-IN-QUERY-br_table SupplyMeter
70 /* Definitions for FRAME F-Main */
72 /* Standard List Definitions */
73 &Scoped-Define ENABLED-OBJECTS br_table
75 /* Custom List Definitions */
76 /* List-1,List-2,List-3,List-4,List-5,List-6 */
78 /* _UIB-PREPROCESSOR-BLOCK-END */
79 &ANALYZE-RESUME
82 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Foreign Keys" B-table-Win _INLINE
83 /* Actions: ? adm/support/keyedit.w ? ? ? */
84 /* STRUCTURED-DATA
85 <KEY-OBJECT>
86 &BROWSE-NAME
87 </KEY-OBJECT>
88 <FOREIGN-KEYS>
89 PropertyCode|y|y|TTPL.SupplyMeter.PropertyCode
90 MeterCode||y|TTPL.SupplyMeter.MeterCode
91 </FOREIGN-KEYS>
92 <EXECUTING-CODE>
93 **************************
94 * Set attributes related to FOREIGN KEYS
96 RUN set-attribute-list (
97 'Keys-Accepted = "PropertyCode",
98 Keys-Supplied = "PropertyCode,MeterCode"':U).
100 /* Tell the ADM to use the OPEN-QUERY-CASES. */
101 &Scoped-define OPEN-QUERY-CASES RUN dispatch ('open-query-cases':U).
102 /**************************
103 </EXECUTING-CODE> */
104 /* _UIB-CODE-BLOCK-END */
105 &ANALYZE-RESUME
107 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _XFTR "Advanced Query Options" B-table-Win _INLINE
108 /* Actions: ? adm/support/advqedit.w ? ? ? */
109 /* STRUCTURED-DATA
110 <KEY-OBJECT>
111 &BROWSE-NAME
112 </KEY-OBJECT>
113 <SORTBY-OPTIONS>
114 </SORTBY-OPTIONS>
115 <SORTBY-RUN-CODE>
116 ************************
117 * Set attributes related to SORTBY-OPTIONS */
118 RUN set-attribute-list (
119 'SortBy-Options = ""':U).
120 /************************
121 </SORTBY-RUN-CODE>
122 <FILTER-ATTRIBUTES>
123 </FILTER-ATTRIBUTES> */
125 /* _UIB-CODE-BLOCK-END */
126 &ANALYZE-RESUME
129 /* *********************** Control Definitions ********************** */
132 /* Definitions of the field level widgets */
133 /* Query definitions */
134 &ANALYZE-SUSPEND
135 DEFINE QUERY br_table FOR
136 SupplyMeter SCROLLING.
137 &ANALYZE-RESUME
139 /* Browse definitions */
140 DEFINE BROWSE br_table
141 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS br_table B-table-Win _STRUCTURED
142 QUERY br_table NO-LOCK DISPLAY
143 SupplyMeter.PropertyCode
144 SupplyMeter.MeterCode COLUMN-LABEL "Meter" FORMAT "X(5)"
145 SupplyMeter.Level
146 SupplyMeter.Description FORMAT "X(60)"
147 SupplyMeter.EntityType
148 SupplyMeter.EntityCode
149 SupplyMeter.AccountCode
150 SupplyMeter.Multiplier
151 SupplyMeter.ElectricityUnitRate
152 ENABLE
153 SupplyMeter.PropertyCode
154 SupplyMeter.MeterCode
155 SupplyMeter.Level
156 SupplyMeter.Description
157 SupplyMeter.EntityType
158 SupplyMeter.EntityCode
159 SupplyMeter.AccountCode
160 SupplyMeter.Multiplier
161 SupplyMeter.ElectricityUnitRate
162 /* _UIB-CODE-BLOCK-END */
163 &ANALYZE-RESUME
164 WITH NO-ASSIGN NO-ROW-MARKERS SEPARATORS SIZE 93.43 BY 19
165 BGCOLOR 15 .
168 /* ************************ Frame Definitions *********************** */
170 DEFINE FRAME F-Main
171 br_table AT ROW 1 COL 1
172 WITH 1 DOWN NO-BOX KEEP-TAB-ORDER OVERLAY
173 SIDE-LABELS NO-UNDERLINE THREE-D
174 AT COL 1 ROW 1 SCROLLABLE
175 FGCOLOR 0 .
178 /* *********************** Procedure Settings ************************ */
180 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
181 /* Settings for THIS-PROCEDURE
182 Type: SmartBrowser
183 Allow: Basic,Browse
184 Frames: 1
185 Add Fields to: EXTERNAL-TABLES
186 Other Settings: PERSISTENT-ONLY COMPILE
189 /* This procedure should always be RUN PERSISTENT. Report the error, */
190 /* then cleanup and return. */
191 IF NOT THIS-PROCEDURE:PERSISTENT THEN DO:
192 MESSAGE "{&FILE-NAME} should only be RUN PERSISTENT."
193 VIEW-AS ALERT-BOX ERROR BUTTONS OK.
194 RETURN.
195 END.
197 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
199 /* ************************* Create Window ************************** */
201 &ANALYZE-SUSPEND _CREATE-WINDOW
202 /* DESIGN Window definition (used by the UIB)
203 CREATE WINDOW B-table-Win ASSIGN
204 HEIGHT = 19
205 WIDTH = 96.29.
206 /* END WINDOW DEFINITION */
208 &ANALYZE-RESUME
211 /* *************** Runtime Attributes and UIB Settings ************** */
213 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
214 /* SETTINGS FOR WINDOW B-table-Win
215 NOT-VISIBLE,,RUN-PERSISTENT */
216 /* SETTINGS FOR FRAME F-Main
217 NOT-VISIBLE Size-to-Fit */
218 /* BROWSE-TAB br_table 1 F-Main */
219 ASSIGN
220 FRAME F-Main:SCROLLABLE = FALSE
221 FRAME F-Main:HIDDEN = TRUE.
223 /* _RUN-TIME-ATTRIBUTES-END */
224 &ANALYZE-RESUME
227 /* Setting information for Queries and Browse Widgets fields */
229 &ANALYZE-SUSPEND _QUERY-BLOCK BROWSE br_table
230 /* Query rebuild information for BROWSE br_table
231 _TblList = "TTPL.SupplyMeter"
232 _Options = "NO-LOCK KEY-PHRASE SORTBY-PHRASE"
233 _FldNameList[1] > TTPL.SupplyMeter.PropertyCode
234 "SupplyMeter.PropertyCode" ? ? "integer" ? ? ? ? ? ? yes ?
235 _FldNameList[2] > TTPL.SupplyMeter.MeterCode
236 "SupplyMeter.MeterCode" "Meter" "X(5)" "character" ? ? ? ? ? ? yes ?
237 _FldNameList[3] > TTPL.SupplyMeter.Level
238 "SupplyMeter.Level" ? ? "integer" ? ? ? ? ? ? yes ?
239 _FldNameList[4] > TTPL.SupplyMeter.Description
240 "SupplyMeter.Description" ? "X(60)" "character" ? ? ? ? ? ? yes ?
241 _FldNameList[5] > TTPL.SupplyMeter.EntityType
242 "SupplyMeter.EntityType" ? ? "character" ? ? ? ? ? ? yes ?
243 _FldNameList[6] > TTPL.SupplyMeter.EntityCode
244 "SupplyMeter.EntityCode" ? ? "integer" ? ? ? ? ? ? yes ?
245 _FldNameList[7] > TTPL.SupplyMeter.AccountCode
246 "SupplyMeter.AccountCode" ? ? "decimal" ? ? ? ? ? ? yes ?
247 _FldNameList[8] > TTPL.SupplyMeter.Multiplier
248 "SupplyMeter.Multiplier" ? ? "decimal" ? ? ? ? ? ? yes ?
249 _FldNameList[9] > TTPL.SupplyMeter.ElectricityUnitRate
250 "SupplyMeter.ElectricityUnitRate" ? ? "decimal" ? ? ? ? ? ? yes ?
251 _Query is NOT OPENED
252 */ /* BROWSE br_table */
253 &ANALYZE-RESUME
255 &ANALYZE-SUSPEND _QUERY-BLOCK FRAME F-Main
256 /* Query rebuild information for FRAME F-Main
257 _Options = "NO-LOCK"
258 _Query is NOT OPENED
259 */ /* FRAME F-Main */
260 &ANALYZE-RESUME
265 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB B-table-Win
266 /* ************************* Included-Libraries *********************** */
268 {src/adm/method/browser.i}
269 {inc/method/m-selvwr.i}
271 /* _UIB-CODE-BLOCK-END */
272 &ANALYZE-RESUME
277 /* ************************ Control Triggers ************************ */
279 &Scoped-define BROWSE-NAME br_table
280 &Scoped-define SELF-NAME br_table
281 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
282 ON ROW-ENTRY OF br_table IN FRAME F-Main
284 /* This code displays initial values for newly added or copied rows. */
285 {src/adm/template/brsentry.i}
286 END.
288 /* _UIB-CODE-BLOCK-END */
289 &ANALYZE-RESUME
292 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
293 ON ROW-LEAVE OF br_table IN FRAME F-Main
295 /* Do not disable this code or no updates will take place except
296 by pressing the Save button on an Update SmartPanel. */
297 {src/adm/template/brsleave.i}
298 END.
300 /* _UIB-CODE-BLOCK-END */
301 &ANALYZE-RESUME
304 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_table B-table-Win
305 ON VALUE-CHANGED OF br_table IN FRAME F-Main
307 /* This ADM trigger code must be preserved in order to notify other
308 objects when the browser's current row changes. */
309 {src/adm/template/brschnge.i}
311 END.
313 /* _UIB-CODE-BLOCK-END */
314 &ANALYZE-RESUME
317 &UNDEFINE SELF-NAME
319 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK B-table-Win
322 /* *************************** Main Block *************************** */
324 /* _UIB-CODE-BLOCK-END */
325 &ANALYZE-RESUME
328 /* ********************** Internal Procedures *********************** */
330 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-open-query-cases B-table-Win adm/support/_adm-opn.p
331 PROCEDURE adm-open-query-cases :
332 /*------------------------------------------------------------------------------
333 Purpose: Opens different cases of the query based on attributes
334 such as the 'Key-Name', or 'SortBy-Case'
335 Parameters: <none>
336 ------------------------------------------------------------------------------*/
337 DEF VAR key-value AS CHAR NO-UNDO.
339 /* Look up the current key-value. */
340 RUN get-attribute ('Key-Value':U).
341 key-value = RETURN-VALUE.
343 /* Find the current record using the current Key-Name. */
344 RUN get-attribute ('Key-Name':U).
345 CASE RETURN-VALUE:
346 WHEN 'PropertyCode':U THEN DO:
347 &Scope KEY-PHRASE SupplyMeter.PropertyCode eq INTEGER(key-value)
348 {&OPEN-QUERY-{&BROWSE-NAME}}
349 END. /* PropertyCode */
350 OTHERWISE DO:
351 &Scope KEY-PHRASE TRUE
352 {&OPEN-QUERY-{&BROWSE-NAME}}
353 END. /* OTHERWISE...*/
354 END CASE.
356 END PROCEDURE.
358 /* _UIB-CODE-BLOCK-END */
359 &ANALYZE-RESUME
362 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available B-table-Win _ADM-ROW-AVAILABLE
363 PROCEDURE adm-row-available :
364 /*------------------------------------------------------------------------------
365 Purpose: Dispatched to this procedure when the Record-
366 Source has a new row available. This procedure
367 tries to get the new row (or foriegn keys) from
368 the Record-Source and process it.
369 Parameters: <none>
370 ------------------------------------------------------------------------------*/
372 /* Define variables needed by this internal procedure. */
373 {src/adm/template/row-head.i}
375 /* Process the newly available records (i.e. display fields,
376 open queries, and/or pass records on to any RECORD-TARGETS). */
377 {src/adm/template/row-end.i}
379 END PROCEDURE.
381 /* _UIB-CODE-BLOCK-END */
382 &ANALYZE-RESUME
385 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI B-table-Win _DEFAULT-DISABLE
386 PROCEDURE disable_UI :
387 /*------------------------------------------------------------------------------
388 Purpose: DISABLE the User Interface
389 Parameters: <none>
390 Notes: Here we clean-up the user-interface by deleting
391 dynamic widgets we have created and/or hide
392 frames. This procedure is usually called when
393 we are ready to "clean-up" after running.
394 ------------------------------------------------------------------------------*/
395 /* Hide all frames. */
396 HIDE FRAME F-Main.
397 IF THIS-PROCEDURE:PERSISTENT THEN DELETE PROCEDURE THIS-PROCEDURE.
398 END PROCEDURE.
400 /* _UIB-CODE-BLOCK-END */
401 &ANALYZE-RESUME
404 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE inst-add-link B-table-Win
405 PROCEDURE inst-add-link :
406 /*------------------------------------------------------------------------------
407 Purpose: add a record source link
408 ------------------------------------------------------------------------------*/
409 DEF INPUT PARAMETER src-hdl AS HANDLE NO-UNDO.
410 DEF INPUT PARAMETER lnk-type AS CHAR NO-UNDO.
411 DEF INPUT PARAMETER dst-hdl AS HANDLE NO-UNDO.
413 RUN add-link IN adm-broker-hdl ( src-hdl, lnk-type, dst-hdl ).
415 END PROCEDURE.
417 /* _UIB-CODE-BLOCK-END */
418 &ANALYZE-RESUME
421 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE local-open-query-cases B-table-Win
422 PROCEDURE local-open-query-cases :
423 /*------------------------------------------------------------------------------
424 Purpose: Override standard ADM method
425 Notes:
426 ------------------------------------------------------------------------------*/
428 /* Code placed here will execute PRIOR to standard behavior. */
429 RUN get-attribute( "Source-Viewer":U ).
430 RUN send-key IN WIDGET-HANDLE(RETURN-VALUE) ( "PropertyCode":U, OUTPUT property-code ).
431 RUN set-attribute-list( "Key-Value = " + property-code ).
433 /* Dispatch standard ADM method. */
434 RUN dispatch IN THIS-PROCEDURE ( INPUT 'open-query-cases':U ) .
436 /* Code placed here will execute AFTER standard behavior. */
438 END PROCEDURE.
440 /* _UIB-CODE-BLOCK-END */
441 &ANALYZE-RESUME
444 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-key B-table-Win adm/support/_key-snd.p
445 PROCEDURE send-key :
446 /*------------------------------------------------------------------------------
447 Purpose: Sends a requested KEY value back to the calling
448 SmartObject.
449 Parameters: <see adm/template/sndkytop.i>
450 ------------------------------------------------------------------------------*/
452 /* Define variables needed by this internal procedure. */
453 {src/adm/template/sndkytop.i}
455 /* Return the key value associated with each key case. */
456 {src/adm/template/sndkycas.i "PropertyCode" "SupplyMeter" "PropertyCode"}
457 {src/adm/template/sndkycas.i "MeterCode" "SupplyMeter" "MeterCode"}
459 /* Close the CASE statement and end the procedure. */
460 {src/adm/template/sndkyend.i}
462 END PROCEDURE.
464 /* _UIB-CODE-BLOCK-END */
465 &ANALYZE-RESUME
468 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records B-table-Win _ADM-SEND-RECORDS
469 PROCEDURE send-records :
470 /*------------------------------------------------------------------------------
471 Purpose: Send record ROWID's for all tables used by
472 this file.
473 Parameters: see template/snd-head.i
474 ------------------------------------------------------------------------------*/
476 /* Define variables needed by this internal procedure. */
477 {src/adm/template/snd-head.i}
479 /* For each requested table, put it's ROWID in the output list. */
480 {src/adm/template/snd-list.i "SupplyMeter"}
482 /* Deal with any unexpected table requests before closing. */
483 {src/adm/template/snd-end.i}
485 END PROCEDURE.
487 /* _UIB-CODE-BLOCK-END */
488 &ANALYZE-RESUME
491 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed B-table-Win
492 PROCEDURE state-changed :
493 /* -----------------------------------------------------------
494 Purpose:
495 Parameters: <none>
496 Notes:
497 -------------------------------------------------------------*/
498 DEFINE INPUT PARAMETER p-issuer-hdl AS HANDLE NO-UNDO.
499 DEFINE INPUT PARAMETER p-state AS CHARACTER NO-UNDO.
501 CASE p-state:
502 /* Object instance CASEs can go here to replace standard behavior
503 or add new cases. */
504 {src/adm/template/bstates.i}
505 END CASE.
506 END PROCEDURE.
508 /* _UIB-CODE-BLOCK-END */
509 &ANALYZE-RESUME