home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-05-19 | 52.6 KB | 1,288 lines |
-
- USE UI
- SET APPLICATION_NAME to "PES"
- // *********************************************************************
- // System: PES (Personal Expense System) *
- // Program: PES.FRM *
- // Author: Doug Goldner 7/9/90 *
- // Purpose: Personal Expense System master program. Allows modification*
- // of all files and creation of new expense entries. *
- // *********************************************************************
- /Title
- ______________________________________________________________________________
- /action_bar
- ______ ____ ____ ____
- /Record_Exit_Pull_Down
- ┌──────────────────────────────────┐
- │ ______________________________ │
- │ ______________________________ │
- │ ______________________________ │
- │ ______________________________ │
- │ ______________________________ │
- │ ______________________________ │
- │ ______________________________ │
- │ ______________________________ │
- │ ______________________________ │
- │ ______________________________ │
- │ ______________________________ │
- │ ______________________________ │
- ├──────────────────────────────────┤
- │ ______________________________ │
- └──────────────────────────────────┘
- /view_pull_down
- ┌──────────────────────┐
- │ ___________________ │
- │ ___________________ │
- │ ___________________ │
- │ ___________________ │
- │ ___________________ │
- │ ___________________ │
- └──────────────────────┘
- /edit_pull_down
- ┌────────────────────┐
- │ _________________ │
- │ _________________ │
- └────────────────────┘
- /Choose_Event
- ┌────────────────────────────────────┐
- │ Choose an Event │
- │ │
- │ ____________ ____________________ │
- │ ____________ ____________________ │
- │ ____________ ____________________ │
- │ ____________ ____________________ │
- │ ____________ ____________________ │
- └────────────────────────────────────┘
- /Choose_Person
- ┌──────────────────────────────────────────────────────┐
- │ Choose a Person │
- │ │
- │ ________ ____________________ ____________________ │
- │ ________ ____________________ ____________________ │
- │ ________ ____________________ ____________________ │
- │ ________ ____________________ ____________________ │
- │ ________ ____________________ ____________________ │
- └──────────────────────────────────────────────────────┘
- /Choose_Tran_Typ
- ┌───────────────────────────┐
- │ Choose a Transaction Type │
- │ │
- │ ____________________ │
- │ ____________________ │
- │ ____________________ │
- │ ____________________ │
- └───────────────────────────┘
- /Choose_Payment_Type
- ┌───────────────────────────┐
- │ Choose a Payment Type │
- │ │
- │ ____________________ │
- │ ____________________ │
- │ ____________________ │
- │ ____________________ │
- └───────────────────────────┘
- /Transact_Screen
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ Transaction Edit │
- │ Assignment Identifier │
- │ Person Unique ID . . . ________ │
- │ Name . . . . . . . . ____________________ , ____________________ │
- │ │
- │ Event Unique ID . . . ________ │
- │ Event Name . . . . . ____________________ __/__/__ thru __/__/__ │
- │ │
- │ Cash Advanced . . . . $______.__ Cash Spent . . $______.__ │
- │ Credit Spent . . . . $______.__ Total Spent . $______.__ │
- │ ┌────────────────────────── Transaction Details ─────────────────────────┐ │
- │ │ Date Type Amount Payment Receipt? │ │
- │ │ __/__/__ _______________ $____.__ ________ _ │ │
- │ │ __/__/__ _______________ $____.__ ________ _ │ │
- │ │ __/__/__ _______________ $____.__ ________ _ │ │
- │ └────────────────────────────────────────────────────────────────────────┘ │
- │ Comments: │
- │ │
- │ │
- └────────────────────────────────────────────────────────────────────────────┘
- /Verify_Image
- ╔══════════════════════════════╗
- ║ ____________________________ ║
- ║ ┌──────────────────────────┐ ║
- ║ │ <__> <______> │ ║
- ║ └──────────────────────────┘ ║
- ╚══════════════════════════════╝
- /about
- ╔═════════════════════════════════════════════════════╗
- ║_____________________________________________________║
- ║─────────────────────────────────────────────────────║
- ║ ║
- ║ P E S ║
- ║ ║
- ║ Version 1.00b ║
- ║ Written by Doug Goldner ║
- ║ ║
- ║ Copyright 1987-1992 Data Access Corporation ║
- ║ Miami FL, USA - All rights reserved ║
- ║ ║
- ║ Memory: __________ Bytes ║
- ║ ║
- ║ <__> ║
- ╚═════════════════════════════════════════════════════╝
- /*
- //*************************************************************************
- //************************ Initialization Routines ************************
- //*************************************************************************
-
- // Open the files that we are using in this program
-
- open Assign
- open Person
- open Event
- open Tran_Typ
- open Transact
-
-
- //**************************************************************************
- //************************* Package Inclusions *****************************
- //**************************************************************************
-
- // Tell the DataFlex compiler which packages we are using. The UI package
- // is a special case of the USE command which tells DataFlex to include the
- // UI initialization code from FMAC.
-
- Use UI
- Use Data_Set
- Use Menu
- Use Sellist
- Use Text_win
- Use Table
- Use EntryFrm
- Use PickList
- Use Enterr
-
- // Define our help system object. It is named Help and is of type Help_System
- // (the standard help class). No other information is required since the
- // Help System package defines the image and all associated properties of
- // the object.
-
- Use Help
- set Filename_Prefix of Help_Object to "PES"
-
- // Break our main image down into a sub image and a main image. We
- // defined them as one big image and broke them down with the
- // Sub_Page command so that our positioning would be easier to code.
-
- Sub_Page Transact_Entry FROM Transact_Screen RECTANGULAR 12 5 3
- Sub_Page Transact_Header FROM Transact_Screen 1 2 3 4 5 6 7 8 9 10 11
- Sub_Page Ok_Cancel_Prompt FROM Verify_Image 2 3
-
-
- //**************************************************************************
- //************************* Object Definitions *****************************
- //**************************************************************************
-
- // The Verify_It object is a generic object used to pop-up a verification
- // object. The function VALIDATE_OK is used to set the verification
- // message and returns a MSG_OK if the user chooses OK. It is used
- // like this:
- // If (Validate_Ok(Verify_It.obj,"Delete Confirmation")) eq MSG_OK ...
-
-
- object Verify_It is a CLIENT Verify_Image
-
- set LOCATION to 7 25 ABSOLUTE
- set CENTER_STATE of current_object item 0 to TRUE
-
- // Define this object (and its children) as a separate, popped up
- // object with an entirely different scope. This will automatically
- // turn off the mouse when in this object (you cannot click on other
- // objects) and it will not send the Exit and Entry messages when this
- // object is activated.
-
- set SCOPE_STATE to TRUE
- set POPUP_STATE to TRUE
-
- object Ask_Ok is a button Ok_Cancel_Prompt
-
- item_list
- On_Item "OK" SEND Ok
- On_Item "CANCEL" SEND Cancel
- end_item_list
-
- End_Object // Ask_Ok
-
- function Validate_Ok string Description returns integer
- local integer Return_Val
- set VALUE of Verify_It item 0 to Description
- ui_accept Verify_It object to Return_Val
- function_return Return_Val
- end_function
-
- End_Object // Verify_It
-
- // The global function verify_a_delete returns a 1 if the delete is
- // aborted, or a 0 if it is confirmed.
-
- function verify_a_delete returns integer
- if (Validate_Ok(Verify_It.obj,"Delete Confirmation")) ne MSG_OK ;
- function_Return 1
- end_function
-
-
-
- // We kept the Trace Object included in the example so that you can see
- // how it is used. To invoke the trace object, press the Shift-F10 keys
- // while running the program.
-
- use traceobj
-
- // We need to register all objects which we refer to prior to their appearance
- // in the source code.
-
- register_object Choose_Event
- register_object Choose_Person
- register_object Assign_Data_Set
- register_object Event_Client
- register_object Person_Entry
- register_object Tran_Typ_Entry
- register_object Choose_Tran_Typ
- register_object Choose_Payment_Type
- register_object Assignment_Entry
-
- //**************************************************************************
- //************************* Our Action Bar Object **************************
- //**************************************************************************
-
-
- // Here, we create our action bar using the Create_Menu command defined
- // in the Menu package.
-
- Create_Menu action_bar LOCATION 1 0 ABSOLUTE
-
- SET ACTION_BAR_KEYS_MSG TO MAIN_MENU_KEYS
-
- // recde_Pd.inc is a section of code which defines the RECORD
- // action bar item (with EXIT as the last choice).
- // It saves us from having to insert all of the
- // On_Item commands for the RECORD pull down in every program
- // that uses it. Look at the file Recde_Pd.Inc to see what code
- // is invoked by its use.
-
- #include RECDE_PD.INC
-
- On_Item 'View' begin_pull_down View_pull_down
- On_Item "Transactions..." send activate_scope to ;
- (Assign_Data_Set(desktop))
- On_Item "Events..." send activate_scope to ;
- (Event_Client(Desktop))
- On_Item "People..." send activate_scope to ;
- (Person_Entry(Desktop))
- On_Item "Assignments..." send activate_scope to ;
- (Assignment_Entry(Desktop))
- On_Item "Transaction Types..." send activate_scope to ;
- (Tran_Typ_Entry(Desktop))
- On_Item "Expense Report..." send Show_Expense_Report to ;
- desktop
- End_Pull_Down
-
- On_Item 'Edit' begin_pull_down Edit_Pull_Down
- on_item "Prompt F4" send prompt
- on_item "Zoom Alt+F6" send zoom
- End_Pull_Down
-
- #include helpa_pd.inc
-
- End_Menu // Action_Bar
-
- PROCEDURE MAIN_MENU_KEYS FOR DESKTOP INTEGER ACT_OBJ
- ON_KEY KEY_ALT+KEY_R SEND ACTIVATE_PULL_DOWN TO (Record_PULL_DOWN(ACT_OBJ)) PRIVATE
- ON_KEY KEY_ALT+KEY_V SEND ACTIVATE_PULL_DOWN TO (VIEW_PULL_DOWN(ACT_OBJ)) PRIVATE
- ON_KEY KEY_ALT+KEY_E SEND ACTIVATE_PULL_DOWN TO (Edit_PULL_DOWN(ACT_OBJ)) PRIVATE
- ON_KEY KEY_ALT+KEY_H SEND ACTIVATE_PULL_DOWN TO (HELP_PULL_DOWN(ACT_OBJ)) PRIVATE
- END_PROCEDURE
-
- // Define our Data sets. Since multiple data entry objects can use the
- // same data set, it is generally a good idea to define the data sets
- // at the beginning of your program so that all data entry objects
- // can refer to the same set of data sets.
-
- Object Event_Data_Set is a Data_Set NO_IMAGE Main_File ;
- EVENT
- End_Object // Event_Data_Set
-
- Object Person_Data_Set is a Data_Set NO_IMAGE Main_File ;
- PERSON
- End_Object // Person_Data_Set
-
- Object Tran_Typ_Data_Set is a Data_Set NO_IMAGE Main_File ;
- TRAN_TYP
- End_Object // Tran_Typ_Data_Set
-
-
- // Data sets can also be defined as parents of data entry objects. You
- // would do this to visually enforce data set relationships.
-
- // Define the Data Set that oversees creation/modification of the assigment
- // file. The name of the Data Set is Assign_Data_Set and it uses
- // an image named Transact_Screen.
- // The Entry_Form of the Data Set is for finding
- // Assignment/Person/Event records and the Table is for editing/creating
- // individual Transactions.
-
- // The updating component lists other data sets which this data set updates.
- // Normally, a data set UPDATEs all data sets which are parents of the
- // main file for the data set. In this case, ASSIGN relates to Event and
- // Person so the data set for ASSIGN UPDATEs the Event and Person data sets.
- // Notice, because Event_Data_Set and Person_Data_Set are forward referenced,
- // we need to refer to them using their "access methods." That is why we
- // use (Event_Data_Set(Desktop)) instead of just Event_Data_Set.obj
- // The ACTION_BAR component lists the Action Bar object to switch to when
- // the switch to action bar key is pressed.
-
- Object Assign_Data_Set is a DATA_SET Transact_Screen ;
- ACTION_BAR Action_Bar.obj RING;
- MAIN_FILE Assign;
- UPDATING;
- (Event_Data_Set(desktop));
- (Person_Data_Set(Desktop))
-
- set LOCATION to 2 0 ABSOLUTE
- set VERIFY_DELETE_MSG to GET_VERIFY_A_DELETE
-
-
- // Define the Transact_Header Entry_Form. This object is the UI
- // component that allows the user to communicate with the Data Set.
- // Because it appears nested within our data set, it assumes that its
- // data set is its parent. See below for examples of UI objects which
- // communicate with data sets which are not their parents.
-
- Object Transact_Header is an ENTRY_FORM Transact_Header
-
- // Override the FIND keys to perform SUPERFINDs
-
- on_key kFind SEND SuperFind
- on_key kFind_Next SEND SuperFind_Next
- on_key kFind_Previous SEND SuperFind_Previous
-
- // Here, we list the individual fields to enter data into
- // including any entry options we want placed on the field
- // (within {} )
-
- Item_List
-
- // The following is a list of which fields we want displayed
- // and will allow the user to see. The entry options are
- // enclosed in curly braces to the right of the Entry_Item
- // lines.
-
- Entry_Item Person.Id ;
- {AUTOFIND, CAPSLOCK, iPROMPT=(Choose_Person(desktop))}
- Entry_Item Person.Last {DISPLAYONLY}
- Entry_Item Person.First {DISPLAYONLY}
- Entry_Item Event.Id ;
- {CAPSLOCK, AUTOFIND, FINDREQ,iPROMPT=(Choose_Event(desktop))}
- Entry_Item Event.Name {DISPLAYONLY}
- Entry_Item Event.Start {DISPLAYONLY}
- Entry_Item Event.End {DISPLAYONLY}
-
- // The following Entry_Item are display only and show
- // calculated totals from the assignment file. This data is
- // updated in the Backout and Update procedures.
-
- Entry_Item Assign.Cash_Adv {DISPLAYONLY}
- Entry_Item Assign.Cash_Spent {DISPLAYONLY}
- Entry_Item Assign.Credit_Spent {DISPLAYONLY}
- Entry_Item (Assign.Cash_Spent + Assign.Credit_Spent)
-
- End_Item_List
-
- End_Object // Transact_Header
-
-
- // We need to define another Data Set for our virtual table
- // since we are dealing with another file (Transact).
- // Since we have nested this Data Set within our ASSIGN data set,
- // we do not need to use the UPDATING clause since nesting of
- // data sets implies an UPDATING.
-
- Object Transact_Entry_Header is a Data_Set Transact_Entry RING;
- MAIN_FILE Transact ;
- updating tran_typ_data_set.obj
-
- set VERIFY_DELETE_MSG to GET_VERIFY_A_DELETE
-
- // Here, we define our Virtual Table object that will allow the
- // user to enter/edit multiple expense items at once. It is
- // called Transact_Entry. It talks to the Transact_Entry_Header
- // data set since it is nested as a child of that data set.
- // The RING option tells the Table to create a closed focus list.
- // The NEXT and PREVIOUS keys will rotate within the table
- // (perhaps wrapping at top and bottom).
-
- Object Transact_Entry is a Table Transact_Entry by index.1
-
- // Force the Switch and Switch_Back key to exit the
- // table and go back into the entry_form or down into
- // the edit object.
- on_key KSWITCH send SWITCH_NEXT_GROUP
- on_key KSWITCH_BACK send SWITCH_PRIOR_GROUP
-
- // We want our Scroll Bar to be at a different location than
- // the default so we create it (by making it visible) and then
- // change its location.
-
- set SCROLL_BAR_VISIBLE_STATE to TRUE
- set LOCATION of (ScrollBar(current_object)) to 13 62 RELATIVE
-
- // Below, we define a prototype row. We list all of the
- // entries that the row needs to have along with appropriate
- // entry options.
-
- Begin_Row
-
- Entry_Item Transact.Date
- Entry_Item Tran_Typ.Type_Code ;
- {CAPSLOCK, AUTOFIND, FINDREQ, ;
- iPROMPT=(Choose_Tran_Typ(Desktop))}
- Entry_Item Transact.Amount {AUTOCLEAR}
- Entry_Item Transact.Payment_Typ ;
- {CAPSLOCK,IVALIDATE=Get_Validate_Pay_Typ, ;
- iPROMPT=(Choose_Payment_Type(Desktop))}
- Entry_Item Transact.Receipt {CAPSLOCK, CHECK="YN "}
-
- End_Row
-
- // Override the Help_Name function to return a help
- // name unique for each item in our table. The return
- // will be the old help name followed by the current
- // column number.
-
- function Help_Name returns string
- local string temp_name
- local integer temp_item
- forward get Help_Name to temp_name
- get current_item to temp_item
-
- // Determine our column number by subtracting the
- // first item in our row from the curret item in the
- // row.
-
- move (temp_item - base_item(current_object)) to temp_item
- function_return (temp_name + "." + string(temp_item))
- End_Function // Help_Name
- procedure Request_Delete
- forward send Request_Delete
- // After we're done updating data in the assignment file,
- // we need to tell the data entry object (Transact_Header)
- // to redisplay the changed values.
- send Entry_Display to (Transact_Header(Current_Object)) 0 0
- end_procedure
-
- procedure save_Row
- forward send save_Row
- // After we're done updating data in the assignment file,
- // we need to tell the data entry object (Transact_Header)
- // to redisplay the changed values.
- send Entry_Display to (Transact_Header(Current_Object)) 0 0
- end_procedure
-
- // Define our validation function for the Pay Type field.
- // If this function returns a 1, the user is not allowed to
- // progress past this field, otherwise, the user can.
-
- function Validate_Pay_Typ integer Item_Number returns integer
-
- local integer fine
- local string Temp_Value
-
- // What we are doing is making sure that the user has
- // entered the name of a credit card that the user has
- // set up in his person file.
-
- move 0 to fine
- get value of current_object item Item_Number to Temp_Value
- if Temp_Value ne "CASH" begin
- if Person.Card_1 ne '' if Person.Card_1 eq Temp_Value ;
- move 1 to fine
- if Person.Card_2 ne '' if Person.Card_2 eq Temp_Value ;
- move 1 to fine
- if Person.Card_3 ne '' if Person.Card_3 eq Temp_Value ;
- move 1 to fine
-
- // If we haven't found a match (between the card the
- // user typed in and the user's record in the person
- // file) declare an error and cause the validation
- // to fail (by function_return 1).
-
- if fine eq 0 begin
- error 201 'Invalid Payment Type (press PROMPT)'
- function_return 1
- end
- end
- end_function
-
- End_Object // Transact_Entry
-
- // This procedure is called when we edit or delete an
- // existing record. It decrements the ASSIGN file with
- // the values from the TRANSACT file.
-
- procedure Backout
- if Transact.Payment_Typ eq "CASH" ;
- move (Assign.Cash_Spent - Transact.Amount) to ;
- Assign.Cash_Spent
- else move (Assign.Credit_Spent - Transact.Amount) to ;
- Assign.Credit_Spent
- end_procedure
-
- // This procedure is called when we save a record (either a
- // new or existing record). It increments the ASSIGN file
- // with the values from the TRANSACT file.
-
- procedure Update
- if Transact.Payment_Typ eq "CASH" ;
- move (Assign.Cash_Spent + Transact.Amount) to ;
- Assign.Cash_Spent
- else move (Assign.Credit_Spent + Transact.Amount) to ;
- Assign.Credit_Spent
- end_procedure
-
- End_Object // Transact_Entry_Header
-
- // Define the Text_Window object used in our Entry Form for
- // the ASSIGN comment field.
- // The Text_Window object also talks to the Assign
- // Data Set. The FOR clause tells the Text_Window what field
- // it is for.
-
- Object Edit_Event_Comment is a Text_Window FOR Assign.Comments
-
- set LOCATION to 18 2 RELATIVE
- set SIZE to 2 72
-
- End_Object // Edit_Event_Comment
-
- End_Object // Assign_Data_Set
-
-
- //**************************************************************************
- //**************** Images and objects for editing the EVENT file ***********
- //**************************************************************************
-
- /Event_Entry
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ Event Edit │
- │ │
- │ Unique ID . . . ________ │
- │ Event Name . . . ____________________ │
- │ Start Date . . . __/__/__ │
- │ End Date . . . . __/__/__ │
- │ │
- │ Comments │
- │ │
- │ │
- │ │
- │ │
- │ │
- │ │
- │ │
- │ │
- │ <_______> <__________> │
- │ │
- └────────────────────────────────────────────────────────────────────────────┘
- /event_client
- /*
- // Define our sub_page for our button object.
-
- Sub_Page Event_Buttons FROM Event_Entry 5 6
-
- object Event_Client is an Entry_Client Event_Client RING
- // Define the Event_Entry Entry_Form. This is the UI Component that
- // talks to the Event data set (Event_Data_Set). Note the USING clause
- // which tells the entry_form who its data set is.
- // The ACTION_BAR clause tells the UI object what action bar to switch to
- // when the user presses the switch to action bar key.
-
- Object Event_Entry is an Entry_Form Event_Entry ACTION_BAR Action_Bar.obj ;
- USING Event_Data_Set.obj
-
- set LOCATION to 3 0 ABSOLUTE
-
- procedure switch_back
- end_procedure
-
- // Here, we list the individual fields to enter data into including any
- // entry options we want placed on the field (within {} )
-
- Item_List
-
- Entry_Item Event.Id {AUTOFIND, CAPSLOCK}
- Entry_Item Event.Name
- Entry_Item Event.Start
- Entry_Item Event.End
-
- End_Item_List
-
-
- // Define the Text_Window object used in our Entry Form for the Event
- // comment field.
- // The Text_Window object also talks to the Event Data Set (see the
- // USING clause). The FOR clause tells the Text_Window what field
- // it is for.
-
- Object Edit_Event_Comment is a Text_Window USING Event_Data_Set.obj ;
- FOR Event.Comment
-
- set LOCATION to 10 2 RELATIVE
- set SIZE to 6 73
-
- procedure switch
- end_procedure
-
- End_Object // Edit_Event_Comment
-
- // Define the button object used in our Entry Form (we pop up our
- // buttons at the bottom of the screen to allow a mouse user to "click"
- // on a function rather than having to press a key and to act as a quick
- // key reference for a keyboard user). The object is named Event_Buttons
- // and defaults to using an image of the same name.
-
- Object Event_Buttons is a Button
-
- // We don't want the user to be able to rotate down to the button
- // area so we change the Focus_Mode of the object to Pointer_Only.
- // This makes sure that the button object cannot take the focus,
- // however, it CAN still be clicked on and WILL send the appropriate
- // message, it just won't RETAIN the focus.
-
- set FOCUS_MODE to POINTER_ONLY
-
- Item_List
-
- // Perform help if the first button is clicked
- On_Item "F1=Help" send Help
-
- // Exit this client if the second button is clicked.
- On_Item "ESC=Cancel" send Request_Cancel
-
- End_Item_List
-
- End_Object // Event_Buttons
-
- End_Object // Event_Entry
- End_Object
-
- // The Choose_Event object is a selection list. It is called by any
- // UI component which wants to invoke a pop-up list of events from
- // the Event file. This program uses it when the user presses the
- // PROMPT key while looking up an assignment or entering new assignments
- // Because it uses the Event file, its USING clause specifies the
- // Event_Data_Set.
-
- Object Choose_Event is a Selection_List Choose_Event POP_UP RING USING ;
- Event_Data_Set.obj by index.1
-
- set LOCATION to 8 17 ABSOLUTE
- // We set the SCOPE_STATE to true whenever an object is a different
- // entity (a different set of related objects etc.). In previous
- // objects, we didn't need to do this since we invoked those objects
- // with the ACTIVATE_SCOPE message from the action bar. The
- // ACTIVATE_SCOPE message automatically sets the SCOPE_STATE of the
- // object it activates.
-
- set SCOPE_STATE to TRUE
-
- Begin_Row
-
- Entry_Item Event.Id
- Entry_Item Event.Name
-
- End_Row
-
- End_Object // Choose_Event
-
- // The Choose_Person object is a selection list. It is called by any
- // UI component which wants to invoke a pop-up list of people from
- // the Person file. This program uses it when the user presses the
- // PROMPT key while looking up an assignment or entering new assignments.
- // Because it uses the Person file, its USING clause specifies the
- // Person_Data_Set.
-
- Object Choose_Person is a Selection_List Choose_Person POP_UP RING USING ;
- Person_Data_Set.obj by index.1
-
- set LOCATION to 8 11 ABSOLUTE
- set SCOPE_STATE to TRUE
-
- Begin_Row
-
- Entry_Item Person.Id
- Entry_Item Person.First
- Entry_Item Person.Last
-
- End_Row
-
- End_Object // Choose_Person
-
-
- //**************************************************************************
- //************ The images and objects for editing the PERSON file **********
- //**************************************************************************
-
- /Choose_Card
- ╔═══════════════════════════╗
- ║ Choose a credit card type ║
- ║ ║
- ║ ____________ ║
- ║ ____________ ║
- ║ ____________ ║
- ║ ____________ ║
- ╚═══════════════════════════╝
- /Person_Entry
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ Person Edit │
- │ Personal Information │
- │ │
- │ Person Unique ID . . . ________ │
- │ Name . . . . . . . . ____________________ , ____________________ │
- │ (Last) (First) │
- │ Department . . . . . ____________________ │
- │ Title . . . . . . . ____________________ │
- │ │
- │ Credit Card Information │
- │ │
- │ 1) Card Name . . . . . ________ Number . . . ____________________ │
- │ 2) Card Name . . . . . ________ Number . . . ____________________ │
- │ 3) Card Name . . . . . ________ Number . . . ____________________ │
- │ │
- │ │
- │ <_______> <__________> │
- └────────────────────────────────────────────────────────────────────────────┘
- /*
-
- // Break our main image down into 2 sub images. We defined them as one
- // big image and broke them down with the Sub_Page command so that our
- // positioning would be easier to code.
-
- Sub_Page Person_Buttons FROM Person_Entry 12 13
-
-
- // The Person_Entry object is the UI object that allows us
- // to edit/enter Person records. It uses the PERSON file so its
- // data set is Person_Data_Set (See the USING clause).
-
- Object Person_Entry is an Entry_Form Person_Entry ACTION_BAR Action_Bar.obj;
- USING Person_Data_Set
-
- set LOCATION to 4 0 ABSOLUTE
-
- procedure switch
- end_procedure
-
- procedure switch_back
- end_procedure
-
- // While in our Person_Entry object, we want to be able to pop-up a
- // list of valid credit cards when the user presses the PROMPT key
- // while in a credit card name field. The Choose_Card object is a
- // selection list and will pop-up a list of credit cards.
-
- Object Choose_Card is a Pick_List Choose_Card STATIC RADIO
-
- set SCOPE_STATE to TRUE
- set POPUP_STATE to TRUE
- set LOCATION to 1 3 ITEM_RELATIVE
- set EXPORT_ITEM_STATE to TRUE
-
- // Auto_Select mode means that as the user uses the mouse or arrows
- // to move through the list, the current item becomes selected. In
- // a single select list, the space bar or a double click from the
- // mouse is needed to select an item.
-
- set SELECT_MODE to AUTO_SELECT
-
- // Define our choices. Note that the first letter is capitalized to
- // allow for first letter selection (press a 'D' and the selection
- // rotates to Diners)
-
- item_list
- on_item "AMEX" send NONE
- on_item "DINERS" send NONE
- on_item "MASTERCD" send NONE
- on_item "VISA" send NONE
- end_item_list
-
- End_Object // Choose_Card
-
- // Here, we list the individual fields to enter data into including any
- // entry options we want placed on the field (within {} )
-
- Item_List
-
- Entry_Item Person.Id {AUTOFIND, CAPSLOCK}
- Entry_Item Person.Last
- Entry_Item Person.First
- Entry_Item Person.Dept
- Entry_Item Person.Title
-
-
- Entry_Item Person.Card_1 {IVALIDATE=Get_Validate_Card_Name,CAPSLOCK, ;
- iPROMPT=(Choose_Card(Person_Entry.obj))}
- Entry_Item Person.Cnum_1 {CAPSLOCK}
- Entry_Item Person.Card_2 {IVALIDATE=Get_Validate_Card_Name,CAPSLOCK, ;
- iPROMPT=(Choose_Card(Person_Entry.obj))}
- Entry_Item Person.Cnum_2 {CAPSLOCK}
- Entry_Item Person.Card_3 {IVALIDATE=Get_Validate_Card_Name,CAPSLOCK, ;
- iPROMPT=(Choose_Card(Person_Entry.obj))}
- Entry_Item Person.Cnum_3 {CAPSLOCK}
-
- End_Item_List
-
- // This procedure is called to validate each card name field.
- // It checks the value in the field with the values in the
- // Choose_Card object and aborts the save if the value in the
- // field is incorrect.
-
- function Validate_Card_Name integer Item_Number returns integer
-
- local string Item_Value
- local integer start
-
- // The algorithm used to validate a card is to compare the
- // card name that the user has typed in with the Choose_Card
- // object. We use the Item_Matching message to see if there is
- // an item matching what the user has entered, in the Choose_Card
- // object (which lists all possible cards). This way, if we add new
- // card types in Choose_Card, our validation routine automatically
- // changes to reflect the new cards.
- // If the validation fails, we function_return a 1.
-
- move 0 to start
- get VALUE of current_object ITEM Item_Number to Item_Value
- if Item_Value ne '' begin
- get Item_Matching of (Choose_Card(current_object)) ;
- Item_Value Start
-
- // If Item_Matching returns a -1, it didn't find a match. This
- // means that we declare an error and fail the validation.
-
- if Start eq -1 begin
- error 202 'Invalid card, press PROMPT'
- function_return 1
- end
- end
-
- end_function // Validate_Card_Name
-
- // Define the button object used in our Entry Form.
-
- Object Person_Buttons is a Button
-
- // We don't want the user to be able to rotate down to the
- // button area so we change the Focus_Mode of the object to
- // Pointer_Only. This makes sure that the button object
- // cannot take the focus, however, it CAN still be clicked
- // on and WILL send the appropriate message, it just won't
- // RETAIN the focus.
-
- set FOCUS_MODE to POINTER_ONLY
-
- Item_List
-
- // Perform help if the first button is clicked
- On_Item "F1=Help" send Help
-
- // Exit this panel when if the second button is clicked.
- On_Item "ESC=Cancel" send Request_Cancel
-
- End_Item_List
-
- End_Object // Person_Buttons
-
- End_Object // Person_Entry
-
-
-
- //**************************************************************************
- //****** The images and objects for editing the TRAN_TYP FILE file**********
- //**************************************************************************
-
- /Tran_Typ
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ Transaction Type Edit │
- │ │
- │ Transaction Type . . . ______________ │
- │ │
- │ │
- │ │
- │ <_______> <__________> │
- │ │
- └────────────────────────────────────────────────────────────────────────────┘
- /*
-
-
- // Break our main image down into 2 sub images. We defined them as one
- // big image and broke them down with the Sub_Page command so that our
- // positioning would be easier to code.
-
- Sub_Page Tran_Typ_Buttons FROM Tran_Typ 2 3
-
-
- Object Tran_Typ_Entry is an Entry_Form Tran_Typ ACTION_BAR Action_Bar.obj;
- USING Tran_Typ_Data_Set.obj
-
- set LOCATION to 5 0 ABSOLUTE
-
- procedure switch
- end_procedure
-
- procedure switch_back
- end_procedure
-
- // Here, we list the individual fields to enter data into including any
- // entry options we want placed on the field (within {} )
-
- Item_List
-
- Entry_Item Tran_Typ.Type_Code {AUTOFIND, CAPSLOCK}
-
- End_Item_List
-
- // Define the button object used in our Entry Form (we pop up our buttons
- // at the bottom of the screen to allow a mouse user to "click" on a
- // function rather than having to press a key and to act as a quick key
- // reference for a keyboard user). The object is named Tran_Typ_Buttons
- // and defaults to using an image of the same name.
-
- Object Tran_Typ_Buttons is a Button
-
- // We don't want the user to be able to rotate down to the button
- // area so we change the Focus_Mode of the object to Pointer_Only.
- // This makes sure that the button object cannot take the focus,
- // however, it CAN still be clicked on and WILL send the appropriate
- // message, it just won't RETAIN the focus.
-
- set FOCUS_MODE to POINTER_ONLY
-
- Item_List
-
- // Perform help if the first button is clicked
- On_Item "F1=Help" send Help
-
- // Exit this panel when if the second button is clicked.
- On_Item "ESC=Cancel" send Request_Cancel
-
- End_Item_List
-
- End_Object // Tran_Typ_Buttons
-
- End_Object // Tran_Typ_Entry
-
-
- // The Choose_Tran_Typ object is a selection list. It is called by any
- // UI component which wants to invoke a pop-up list of Transaction Types
- // from the Person file. This program uses it when the user presses the
- // PROMPT key while creating a transaction.
- // Because it uses the Tran_Typ file, its USING clause specifies the
- // Tran_Typ_Data_Set.
-
- Object Choose_Tran_Typ is a Selection_List Choose_Tran_Typ POP_UP RING;
- USING Tran_Typ_Data_Set.obj ;
- BY Index.1
-
- set LOCATION to 8 11 ABSOLUTE
- set SCOPE_STATE to TRUE
-
- Begin_Row
-
- Entry_Item Tran_Typ.Type_Code
-
- End_Row
-
- End_Object // Choose_Tran_Typ
-
-
-
- //**************************************************************************
- //****** The images and objects for editing the ASSIGN FILE file ***********
- //**************************************************************************
-
- /Assignment_Entry
- ┌────────────────────────────────────────────────────────────────────────────┐
- │ Assignment Edit │
- │ Assignment Identifier │
- │ │
- │ Person Unique ID . . . ________ │
- │ Name . . . . . . . . ____________________ , ____________________ │
- │ │
- │ Event Unique ID . . . ________ │
- │ Event Name . . . . . ____________________ │
- │ │
- │ Assignment Details │
- │ │
- │ Cash Advanced . . . . $______.__ │
- │ Cash Spent . . . . . $______.__ │
- │ Credit Spent . . . . . $______.__ │
- │ Date Settled . . . . . __/__/__ │
- │ │
- │ Comments │
- │ │
- │ │
- └────────────────────────────────────────────────────────────────────────────┘
- /*
-
- Object Assignment_Entry is an Entry_Form Assignment_Entry ACTION_BAR ;
- Action_Bar.obj USING Assign_Data_Set.obj
-
-
- set LOCATION to 2 0 ABSOLUTE
-
- procedure switch_back
- end_procedure
-
- // Here, we list the individual fields to enter data into including any
- // entry options we want placed on the field (within {} )
-
- Item_List
-
- // The following Entry_Items are from the Person File. We are using
- // this information as lookup only.
-
- Entry_Item Person.Id {AUTOFIND, CAPSLOCK, ;
- iPROMPT=Choose_Person.obj}
- Entry_Item Person.Last {NOPUT}
- Entry_Item Person.First {FINDREQ, NOPUT}
-
- // The following Entry_Items are from the Event File. We are using
- // this information as lookup only.
-
- Entry_Item Event.Id {CAPSLOCK, AUTOFIND, ;
- iPROMPT=Choose_Event.obj}
- Entry_Item Event.Name {FINDREQ, NOPUT}
-
- // The following Entry_Items are from the Assign file. We are
- // WRITING to these fields.
-
- Entry_Item Assign.Cash_Adv
- Entry_Item Assign.Cash_Spent
- Entry_Item Assign.Credit_Spent
- Entry_Item Assign.Date_Settled
-
- End_Item_List
-
- // Allow this object to have file level help. By changing the
- // help name returned when the user is in different entry_items
- // for different files, we create a different help name for
- // those items. We can then create different help text for those
- // help names and give the user file level help.
-
- Function Help_Name returns string
- local string temp_name
- local string temp_filename
- local integer temp_file
- forward get Help_Name to temp_name
- get data_file to temp_file
- if temp_file eq event.file_number move "EVENT" to temp_filename
- if temp_file eq person.file_number move "PERSON" to temp_filename
- if temp_file eq assign.file_number function_return temp_name
- function_return (temp_name + "." + temp_filename)
- End_Function // Help_Name
-
- // Define the Assign_Comments object. This object is an edit object
- // displayed on the screen that shows the Assign.Comments field for
- // the current assignment.
-
-
- Object Edit_Assign_Comment is a Text_Window FOR Assign.Comments
-
- set LOCATION to 18 2 RELATIVE
- set SIZE to 2 72
-
-
- procedure switch
- end_procedure
-
- End_Object // Edit_Assign_Comment
-
- End_Object // Assignment_Entry
-
-
- //**************************************************************************
- //******************* Miscellaneous Global Objects *************************
- //**************************************************************************
-
-
- // While in our Transact_Entry object, we want to be able to pop-up a
- // list of valid payment types when the user presses the PROMPT key
- // while in the payment field. The Choose_Payment_Type object is a
- // pick list and will pop-up a list of payment types valid for
- // this user (using the Person file).
-
- Object Choose_Payment_Type is a Pick_List Choose_Payment_Type RADIO
-
- set SCOPE_STATE to TRUE
- set POPUP_STATE to TRUE
- set LOCATION to 8 3 ABSOLUTE
-
- procedure deactivating
- send delete_data
- end_procedure
-
- // Auto_Select mode means that as the user uses the mouse or arrows
- // to move through the list, the current item becomes selected. In
- // a single select list, the space bar or a double click from the
- // mouse is needed to select an item.
-
- set SELECT_MODE to AUTO_SELECT
-
- procedure fill_list
- // When we activate this pop-up, add only valid payment types
- // for this user (start with CASH unconditionally).
-
- send add_item MSG_NONE "CASH"
- if Person.Card_1 ne '' send Add_Item MSG_NONE Person.Card_1
- if Person.Card_2 ne '' send Add_Item MSG_NONE Person.Card_2
- if Person.Card_3 ne '' send Add_Item MSG_NONE Person.Card_3
- end_procedure
-
- End_Object // Choose_Payment_Type
-
-
-
- // The ABOUT object is popped-up from the action bar help pull down when
- // the user requests information about the program. The object is
- // actually a button with a special override of item_change which keeps
- // the user from changing to any item other than item 2 (the OK)
- // button.
-
- Object about is a button
-
- set LOCATION to 5 11 absolute
- set BLOCK_MOUSE_STATE to true
- set SCOPE_STATE to true
- set AUTO_TOP_ITEM_STATE to false
-
- Item_List
-
- On_Item 'DataFlex Personal Expense System' send none
- set CENTER_STATE to TRUE
-
- On_Item '' send NONE
- On_Item 'OK' send STOP_UI
-
- End_Item_List
-
- set CURRENT_ITEM to 2
-
- // The item_change procedure overrides the standard item_change
- // procedure. It's intention is to insure that the user cannot
- // rotate onto any item other than item 2 (the OK button).
-
- procedure item_change integer i_from integer i_to returns integer
- procedure_return 2
- end_procedure
-
- // The activating procedure fills in item 1 of ABOUT with the
- // current available memory.
-
- procedure activating
- local integer mem
- memory mem
- set VALUE item 1 to mem
- end_procedure
-
- End_Object // About
-
- // Title is our title bar. It appears at the top of our images and is
- // not able to receive the focus.
-
- Object Title is a Title
-
- set CENTER_STATE item 0 to TRUE
- set VALUE item 0 to "Per$onal Expen$e Sy$tem"
- set ATTACH_PARENT_STATE to TRUE
- set FOCUS_MODE to NONFOCUSABLE
-
- End_Object // Title
-
- //**************************************************************************
- //************************* Global Procedures *****************************
- //**************************************************************************
-
-
- // Here, we define a global procedure Show_Expense_Report. This message
- // is sent by the action bar when the user chooses to print a report.
- // In this procedure, we chain wait to the report (EXPENSE), passing it
- // parameters about which expense report to generate. When we return, we
- // send the refresh_screen message to restore the screen.
-
- procedure Show_Expense_Report
- local string report_string
-
- move "Expense " to report_string
- append report_string assign.person ' ' assign.event ' ' event.start;
- ' ' event.end ' ' 'test.fil'
- chain wait report_string
- send refresh_screen
- end_procedure
-
-
- // Here we define a global procedure, show_about which is called when we
- // want to pop-up the ABOUT object (which shows us information about the
- // program).
-
- procedure About for Desktop
- ui_accept about to windowindex
- end_procedure
-
- Item_Group
- Dependent_Item (Transact_Header(Assign_Data_Set.obj)) 0
- Dependent_Item Person_Entry 0
- End_Item_Group
-
- Item_Group
- Dependent_Item (Transact_Header(Assign_Data_Set.obj)) 1
- Dependent_Item Person_Entry 1
- End_Item_Group
-
- Item_Group
- Dependent_Item (Transact_Header(Assign_Data_Set.obj)) 2
- Dependent_Item Person_Entry 2
- End_Item_Group
-
- Item_Group
- Dependent_Item (Transact_Header(Assign_Data_Set.obj)) 3
- Dependent_Item (Event_Entry(Event_Client.obj)) 0
- End_Item_Group
-
- Item_Group
- Dependent_Item (Transact_Header(Assign_Data_Set.obj)) 4
- Dependent_Item (Event_Entry(Event_Client.obj)) 1
- End_Item_Group
-
- Item_Group
- Dependent_Item (Transact_Header(Assign_Data_Set.obj)) 5
- Dependent_Item (Event_Entry(Event_Client.obj)) 2
- End_Item_Group
-
- Item_Group
- Dependent_Item (Transact_Header(Assign_Data_Set.obj)) 6
- Dependent_Item (Event_Entry(Event_Client.obj)) 3
- End_Item_Group
-
- //**************************************************************************
- //*********** End of object definitons and start of main program ***********
- //**************************************************************************
-
- // Put our Title object on the screen
-
- send add_focus to Title (parent(Title.obj))
-
- // Start the User Interface system and give the focus to Transact_Screen
-
- start_ui Action_Bar
-
- // After the last object has been deactivated, we return here.
-
- clearscreen
- abort
-