1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12 GUI
6 &Scoped-define WINDOW-NAME CURRENT-WINDOW
7 &Scoped-define FRAME-NAME D-Dialog
8 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS D-Dialog
9 /*------------------------------------------------------------------------
13 Description
: Edit alternate company names
16 Person Code and Main Company
24 ------------------------------------------------------------------------*/
28 /* *************************** Definitions
************************** */
30 /* Parameters Definitions
--- */
31 DEF INPUT PARAMETER person-code
AS INT NO-UNDO.
32 DEF INPUT PARAMETER person-default
AS CHAR NO-UNDO.
33 DEF INPUT PARAMETER alternate-type
AS CHAR NO-UNDO.
35 /* Local Variable Definitions
--- */
37 FIND Person
WHERE Person.PersonCode
= person-code
39 IF NOT AVAILABLE(Person
) THEN DO:
40 MESSAGE "No person record available for" person-code
41 VIEW-AS ALERT-BOX ERROR.
44 /* _UIB-CODE-BLOCK-END
*/
48 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
50 /* ******************** Preprocessor Definitions
******************** */
52 &Scoped-define PROCEDURE-TYPE SmartDialog
54 &Scoped-define ADM-CONTAINER DIALOG-BOX
56 /* Name of first Frame and
/or Browse and
/or first Query
*/
57 &Scoped-define FRAME-NAME D-Dialog
58 &Scoped-define BROWSE-NAME br_Details
61 &Scoped-define EXTERNAL-TABLES Person
62 &Scoped-define FIRST-EXTERNAL-TABLE Person
65 /* Need to scope the external tables to this procedure
*/
66 DEFINE QUERY external_tables
FOR Person.
67 /* Internal Tables
(found by Frame
, Query
& Browse Queries) */
68 &Scoped-define INTERNAL-TABLES PersonDetail
70 /* Definitions for
BROWSE br_Details
*/
71 &Scoped-define FIELDS-IN-QUERY-br_Details PersonDetail.ContactType PersonDetail.DataValue
72 &Scoped-define ENABLED-FIELDS-IN-QUERY-br_Details PersonDetail.ContactType ~
73 PersonDetail.DataValue
74 &Scoped-define FIELD-PAIRS-IN-QUERY-br_Details~
75 ~
{&FP1}ContactType ~{&FP2}ContactType ~{&FP3}~
76 ~
{&FP1}DataValue ~{&FP2}DataValue ~{&FP3}
77 &Scoped-define ENABLED-TABLES-IN-QUERY-br_Details PersonDetail
78 &Scoped-define FIRST-ENABLED-TABLE-IN-QUERY-br_Details PersonDetail
79 &Scoped-define SELF-NAME br_Details
80 &Scoped-define OPEN-QUERY-br_Details OPEN QUERY {&SELF-NAME} FOR EACH PersonDetail OF Person WHERE PersonDetail.PersonDetailType = "ALT" AND PersonDetail.SupplementaryType = alternate-type NO-LOCK.
81 &Scoped-define TABLES-IN-QUERY-br_Details PersonDetail
82 &Scoped-define FIRST-TABLE-IN-QUERY-br_Details PersonDetail
85 /* Definitions for
DIALOG-BOX D-Dialog
*/
86 &Scoped-define OPEN-BROWSERS-IN-QUERY-D-Dialog ~
87 ~
{&OPEN-QUERY-br_Details}
89 /* Standard List Definitions
*/
90 &Scoped-Define ENABLED-OBJECTS RECT-2 br_Details btn_add btn_remove Btn_OK ~
92 &Scoped-Define DISPLAYED-OBJECTS default-value
94 /* Custom List Definitions
*/
95 /* List-1
,List-2
,List-3
,List-4
,List-5
,List-6
*/
97 /* _UIB-PREPROCESSOR-BLOCK-END
*/
102 /* *********************** Control Definitions
********************** */
104 /* Define a dialog box
*/
106 /* Definitions of the field level widgets
*/
107 DEFINE BUTTON btn_add
111 DEFINE BUTTON Btn_Cancel
AUTO-END-KEY
116 DEFINE BUTTON Btn_OK
AUTO-GO DEFAULT
121 DEFINE BUTTON btn_remove
125 DEFINE VARIABLE default-value
AS CHARACTER FORMAT "X(80)"
130 DEFINE RECTANGLE RECT-2
131 EDGE-PIXELS 2 GRAPHIC-EDGE NO-FILL
134 /* Query definitions
*/
136 DEFINE QUERY br_Details
FOR
137 PersonDetail
SCROLLING.
140 /* Browse definitions
*/
141 DEFINE BROWSE br_Details
142 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _DISPLAY-FIELDS br_Details D-Dialog _FREEFORM
143 QUERY br_Details
DISPLAY
144 PersonDetail.ContactType
FORMAT "X(6)" WIDTH 6
145 PersonDetail.DataValue
COLUMN-LABEL "Company" FORMAT "X(50)" WIDTH 41
147 PersonDetail.ContactType
148 PersonDetail.DataValue
149 /* _UIB-CODE-BLOCK-END
*/
151 WITH NO-ROW-MARKERS SIZE 50.86 BY 7.5
155 /* ************************ Frame Definitions
*********************** */
157 DEFINE FRAME D-Dialog
158 default-value
AT ROW 1.3 COL 6.43 COLON-ALIGNED
159 br_Details
AT ROW 3.6 COL 1.57
160 btn_add
AT ROW 11.2 COL 31.57
161 btn_remove
AT ROW 11.2 COL 42.14
162 Btn_OK
AT ROW 12.5 COL 1
163 Btn_Cancel
AT ROW 12.5 COL 10.14
164 "Enter the contact types and the overrides which apply." VIEW-AS TEXT
165 SIZE 49.43 BY .8 AT ROW 2.6 COL 2.14
166 RECT-2
AT ROW 1 COL 1
167 SPACE(0.13) SKIP(1.59)
168 WITH VIEW-AS DIALOG-BOX KEEP-TAB-ORDER
169 SIDE-LABELS NO-UNDERLINE THREE-D SCROLLABLE
171 TITLE "Address Details"
172 DEFAULT-BUTTON Btn_OK
CANCEL-BUTTON Btn_Cancel.
175 /* *********************** Procedure Settings
************************ */
177 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
178 /* Settings for
THIS-PROCEDURE
180 External Tables
: TTPL.Person
181 Allow
: Basic
,Browse
,DB-Fields
,Query
,Smart
182 Other Settings
: COMPILE
184 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
187 /* *************** Runtime Attributes and UIB Settings
************** */
189 &ANALYZE-SUSPEND _RUN-TIME-ATTRIBUTES
190 /* SETTINGS
FOR DIALOG-BOX D-Dialog
192 /* BROWSE-TAB br_Details default-value D-Dialog
*/
194 FRAME D-Dialog
:SCROLLABLE = FALSE
195 FRAME D-Dialog
:HIDDEN = TRUE.
197 /* SETTINGS
FOR FILL-IN default-value
IN FRAME D-Dialog
199 /* _RUN-TIME-ATTRIBUTES-END
*/
203 /* Setting information for Queries and Browse Widgets fields
*/
205 &ANALYZE-SUSPEND _QUERY-BLOCK BROWSE br_Details
206 /* Query rebuild information for
BROWSE br_Details
208 OPEN QUERY {&SELF-NAME} FOR EACH PersonDetail OF Person
209 WHERE PersonDetail.PersonDetailType
= "ALT"
210 AND PersonDetail.SupplementaryType
= alternate-type
NO-LOCK.
212 _Where
[1] = "PersonDetail.PersonDetailType = ""ALT""
213 AND PersonDetail.SupplementaryType = alternate-type"
215 */ /* BROWSE br_Details
*/
218 &ANALYZE-SUSPEND _QUERY-BLOCK DIALOG-BOX D-Dialog
219 /* Query rebuild information for
DIALOG-BOX D-Dialog
220 _Options
= "SHARE-LOCK"
222 */ /* DIALOG-BOX D-Dialog
*/
228 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB D-Dialog
229 /* ************************* Included-Libraries
*********************** */
231 {src
/adm
/method
/containr.i
}
233 /* _UIB-CODE-BLOCK-END
*/
239 /* ************************ Control Triggers
************************ */
241 &Scoped-define SELF-NAME D-Dialog
242 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL D-Dialog D-Dialog
243 ON WINDOW-CLOSE
OF FRAME D-Dialog
/* Address Details
*/
245 /* Add Trigger to equate WINDOW-CLOSE to END-ERROR.
*/
246 APPLY "END-ERROR":U
TO SELF.
249 /* _UIB-CODE-BLOCK-END
*/
253 &Scoped-define BROWSE-NAME br_Details
254 &Scoped-define SELF-NAME br_Details
255 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br_Details D-Dialog
256 ON VALUE-CHANGED
OF br_Details
IN FRAME D-Dialog
/* Browse
1 */
258 RUN display-alternate.
261 /* _UIB-CODE-BLOCK-END
*/
265 &Scoped-define SELF-NAME btn_add
266 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_add D-Dialog
267 ON CHOOSE OF btn_add
IN FRAME D-Dialog
/* Add
*/
272 /* _UIB-CODE-BLOCK-END
*/
276 &Scoped-define SELF-NAME btn_remove
277 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL btn_remove D-Dialog
278 ON CHOOSE OF btn_remove
IN FRAME D-Dialog
/* Remove
*/
280 RUN remove-alternate.
283 /* _UIB-CODE-BLOCK-END
*/
289 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK D-Dialog
292 /* *************************** Main Block
*************************** */
293 default-value
= person-default.
294 DataValue
:LABEL IN BROWSE {&BROWSE-NAME} = alternate-type.
296 ON LEAVE OF PersonDetail.ContactType
IN BROWSE {&BROWSE-NAME} DO:
297 RUN assign-alternate.
300 ON LEAVE OF PersonDetail.DataValue
IN BROWSE {&BROWSE-NAME} DO:
301 RUN assign-alternate.
305 RUN display-alternate.
307 {src
/adm
/template
/dialogmn.i
}
309 /* _UIB-CODE-BLOCK-END
*/
313 /* ********************** Internal Procedures
*********************** */
315 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE add-alternate D-Dialog
316 PROCEDURE add-alternate
:
317 /*------------------------------------------------------------------------------
319 ------------------------------------------------------------------------------*/
321 DO WITH FRAME {&FRAME-NAME}:
323 DEF VAR reposition-row
AS INT NO-UNDO.
324 DEF VAR reposition-rowid
AS ROWID NO-UNDO.
326 IF NUM-RESULTS( "{&BROWSE-NAME}" ) = 0 OR NUM-RESULTS( "{&BROWSE-NAME}" ) = ?
THEN DO:
330 IF AVAILABLE PersonDetail
THEN RUN assign-alternate.
333 PersonDetail.PersonCode
= person-code.
334 PersonDetail.PersonDetailType
= "ALT".
335 PersonDetail.SupplementaryType
= alternate-type.
337 reposition-rowid
= ROWID( PersonDetail
).
339 reposition-row
= {&BROWSE-NAME}:GET-REPOSITIONED-ROW().
340 reposition-row
= INT( {&BROWSE-NAME}:HEIGHT-CHARS ) - 1.
341 OPEN QUERY {&BROWSE-NAME} FOR EACH PersonDetail.
342 IF {&BROWSE-NAME}:SET-REPOSITIONED-ROW( reposition-row, "CONDITIONAL" ) THEN.
343 REPOSITION {&BROWSE-NAME} TO ROWID reposition-rowid.
345 RUN display-alternate.
346 RUN assign-alternate.
347 APPLY '
ENTRY'
:U
TO PersonDetail.ContactType
IN BROWSE {&BROWSE-NAME}.
353 /* _UIB-CODE-BLOCK-END
*/
357 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-create-objects D-Dialog _ADM-CREATE-OBJECTS
358 PROCEDURE adm-create-objects
:
359 /*------------------------------------------------------------------------------
360 Purpose
: Create handles for all SmartObjects used in this procedure.
361 After SmartObjects are initialized
, then SmartLinks are added.
363 ------------------------------------------------------------------------------*/
367 /* _UIB-CODE-BLOCK-END
*/
371 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE adm-row-available D-Dialog _ADM-ROW-AVAILABLE
372 PROCEDURE adm-row-available
:
373 /*------------------------------------------------------------------------------
374 Purpose
: Dispatched to this procedure when the Record-
375 Source has a new row available. This procedure
376 tries to get the new row
(or foriegn keys
) from
377 the Record-Source and process it.
379 ------------------------------------------------------------------------------*/
381 /* Define variables needed by this internal procedure.
*/
382 {src
/adm
/template
/row-head.i
}
384 /* Create a list of all the tables that we need to get.
*/
385 {src
/adm
/template
/row-list.i
"Person"}
387 /* Get the record
ROWID's from the RECORD-SOURCE.
*/
388 {src
/adm
/template
/row-get.i
}
390 /* FIND each record specified by the RECORD-SOURCE.
*/
391 {src
/adm
/template
/row-find.i
"Person"}
393 /* Process the newly available records
(i.e. display fields
,
394 open queries
, and
/or pass records on to any RECORD-TARGETS
).
*/
395 {src
/adm
/template
/row-end.i
}
399 /* _UIB-CODE-BLOCK-END
*/
403 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE assign-alternate D-Dialog
404 PROCEDURE assign-alternate
:
405 /*------------------------------------------------------------------------------
407 ------------------------------------------------------------------------------*/
409 IF AVAILABLE PersonDetail
THEN DO:
410 FIND CURRENT PersonDetail
EXCLUSIVE-LOCK.
411 ASSIGN BROWSE {&BROWSE-NAME}
412 PersonDetail.DataValue
413 PersonDetail.ContactType .
415 PersonDetail.PersonCode
= person-code.
416 PersonDetail.PersonDetailType
= "ALT".
417 PersonDetail.SupplementaryType
= alternate-type.
418 FIND CURRENT PersonDetail
NO-LOCK.
422 /* _UIB-CODE-BLOCK-END
*/
426 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE close-alt-query D-Dialog
427 PROCEDURE close-alt-query
:
428 /*------------------------------------------------------------------------------
432 ------------------------------------------------------------------------------*/
434 CLOSE QUERY {&BROWSE-NAME}.
438 /* _UIB-CODE-BLOCK-END
*/
442 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE disable_UI D-Dialog _DEFAULT-DISABLE
443 PROCEDURE disable_UI
:
444 /*------------------------------------------------------------------------------
445 Purpose
: DISABLE the User Interface
447 Notes
: Here we clean-up the user-interface by deleting
448 dynamic widgets we have created and
/or hide
449 frames. This procedure is usually called when
450 we are ready to
"clean-up" after running.
451 ------------------------------------------------------------------------------*/
452 /* Hide all frames.
*/
456 /* _UIB-CODE-BLOCK-END
*/
460 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE display-alternate D-Dialog
461 PROCEDURE display-alternate
:
462 /*------------------------------------------------------------------------------
464 ------------------------------------------------------------------------------*/
466 IF AVAILABLE PersonDetail
THEN DO:
467 DISPLAY {&FIELDS-IN-QUERY-{&BROWSE-NAME}} WITH BROWSE {&BROWSE-NAME}.
469 RUN sensitise-buttons.
473 /* _UIB-CODE-BLOCK-END
*/
477 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE enable_UI D-Dialog _DEFAULT-ENABLE
478 PROCEDURE enable_UI
:
479 /*------------------------------------------------------------------------------
480 Purpose
: ENABLE the User Interface
482 Notes
: Here we display
/view
/enable the widgets in the
483 user-interface. In addition
, OPEN all queries
484 associated with each
FRAME and
BROWSE.
485 These statements here are based on the
"Other
486 Settings" section of the widget Property Sheets.
487 ------------------------------------------------------------------------------*/
488 DISPLAY default-value
490 ENABLE RECT-2 br_Details btn_add btn_remove Btn_OK Btn_Cancel
493 {&OPEN-BROWSERS-IN-QUERY-D-Dialog}
496 /* _UIB-CODE-BLOCK-END
*/
500 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE open-alt-query D-Dialog
501 PROCEDURE open-alt-query
:
502 /*------------------------------------------------------------------------------
504 ------------------------------------------------------------------------------*/
506 DO WITH FRAME {&FRAME-NAME}:
507 {&OPEN-QUERY-{&BROWSE-NAME}}
508 RUN display-alternate.
513 /* _UIB-CODE-BLOCK-END
*/
517 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE remove-alternate D-Dialog
518 PROCEDURE remove-alternate
:
519 /*------------------------------------------------------------------------------
523 ------------------------------------------------------------------------------*/
525 DO WITH FRAME {&FRAME-NAME}:
527 IF NUM-RESULTS( "{&BROWSE-NAME}" ) = 0 OR NUM-RESULTS( "{&BROWSE-NAME}" ) = ?
THEN RETURN.
529 IF {&BROWSE-NAME}:SELECT-FOCUSED-ROW() AND
530 {&BROWSE-NAME}:FETCH-SELECTED-ROW(1) THEN
532 GET CURRENT {&BROWSE-NAME}.
534 IF {&BROWSE-NAME}:DELETE-CURRENT-ROW() THEN.
537 IF NUM-RESULTS( "{&BROWSE-NAME}" ) = ?
OR
538 NUM-RESULTS( "{&BROWSE-NAME}" ) = 0 THEN
541 RUN sensitise-buttons.
545 IF {&BROWSE-NAME}:FETCH-SELECTED-ROW(1) THEN RUN display-alternate.
551 /* _UIB-CODE-BLOCK-END
*/
555 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE send-records D-Dialog _ADM-SEND-RECORDS
556 PROCEDURE send-records
:
557 /*------------------------------------------------------------------------------
558 Purpose
: Send record
ROWID's for all tables used by
560 Parameters
: see template
/snd-head.i
561 ------------------------------------------------------------------------------*/
563 /* Define variables needed by this internal procedure.
*/
564 {src
/adm
/template
/snd-head.i
}
566 /* For each requested table
, put it's
ROWID in the output list.
*/
567 {src
/adm
/template
/snd-list.i
"Person"}
568 {src
/adm
/template
/snd-list.i
"PersonDetail"}
570 /* Deal with any unexpected table requests before closing.
*/
571 {src
/adm
/template
/snd-end.i
}
575 /* _UIB-CODE-BLOCK-END
*/
579 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE sensitise-buttons D-Dialog
580 PROCEDURE sensitise-buttons
:
581 /*------------------------------------------------------------------------------
583 ------------------------------------------------------------------------------*/
585 DO WITH FRAME {&FRAME-NAME}:
586 btn_remove
:SENSITIVE = AVAILABLE PersonDetail.
591 /* _UIB-CODE-BLOCK-END
*/
595 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE state-changed D-Dialog
596 PROCEDURE state-changed
:
597 /* -----------------------------------------------------------
601 -------------------------------------------------------------*/
602 DEFINE INPUT PARAMETER p-issuer-hdl
AS HANDLE NO-UNDO.
603 DEFINE INPUT PARAMETER p-state
AS CHARACTER NO-UNDO.
606 /* _UIB-CODE-BLOCK-END
*/