Module ORDERENT.VW

     1//********************************************************************************
     2// ORDERENT
     3//
     4// Author              :
     5// Originally created  : 01/07/99
     6// Last Update         : 01/07/99
     7//
     8//********************************************************************************
     9
    10Use ALLENTRY
    11Use CONFIRM
    12Use BatchDD.pkg
    13Set Class_Colors to U_TEXT_WINDOW 0 0
    14
    15// Data Set Class Inclusions
    16
    17Use CUSTOMER.DD
    18Use SALESP.DD
    19Use VENDOR.DD
    20Use INVT.DD
    21Use ORDERHEA.DD
    22Use ORDERDTL.DD
    23
    24
    25Activate_View Activate_ORDERENT For ORDERENT_View
    26
    27Object ORDERENT_View is an Entry_View_Client No_Image ;
    28        Action_Bar (Main_Menu(self))
    29
    30    Function Confirm_Delete_Order Returns Integer
    31        Function_Return (confirm(self,"Delete Entire Order?"))
    32    End_Function
    33
    34    Function Confirm_Save_Order Returns Integer
    35        Function_Return (confirm(self,"Save Entire Order?"))
    36    End_Function
    37
    38    Set Verify_Save_MSG       to GET_Confirm_Save_Order
    39    Set Verify_Delete_MSG     to GET_Confirm_Delete_Order
    40    Set Verify_Data_Loss_MSG  to GET_Data_loss_Confirmation
    41    Set Verify_Exit_MSG       to GET_Exit_loss_Confirmation
    42
    43    Object CUSTOMER_DD is a CUSTOMER_DataDictionary
    44    End_Object // CUSTOMER_DD
    45
    46    Object SALESP_DD is a SALESP_DataDictionary
    47    End_Object // SALESP_DD
    48
    49    Object VENDOR_DD is a VENDOR_DataDictionary
    50    End_Object // VENDOR_DD
    51
    52    Object INVT_DD is a INVT_DataDictionary
    53        Set DDO_Server to (VENDOR_DD(self))
    54    End_Object // INVT_DD
    55
    56    Object ORDERHEA_DD is a ORDERHEA_DataDictionary
    57        Set DDO_Server to (CUSTOMER_DD(self))
    58        Set DDO_Server to (SALESP_DD(self))
    59    End_Object // ORDERHEA_DD
    60
    61    Object ORDERDTL_DD is a ORDERDTL_DataDictionary
    62        Set DDO_Server to (INVT_DD(self))
    63        Set DDO_Server to (ORDERHEA_DD(self))
    64        Set Constrain_file to ORDERHEA.File_Number
    65    End_Object // ORDERDTL_DD
    66
    67    Set Server  to (OrderHea_DD(self))
    68    Set Main_DD to (OrderHea_DD(self))
    69
    70/Order_EF_Image
    71┌────────────────────────────────────────────────────────────────────────────┐
    72│  Order Number: _____.  Customer Number: _____.    Order Date: __/__/____   │
    73│                                                                            │
    74│ Customer Name: ______________________________                              │
    75│        Street: ______________________________     Ordered By: ____________ │
    76│   City/St/Zip: ______________  __  __________   Sales Person: ____         │
    77│                                                                            │
    78│         Terms: ____________                         Ship Via: ____________ │
    79├────────────────────────────────────────────────────────────────────────────┤
    80│Item Id    Description                 Unit Price     Price  Qty     Total  │
    81├──────────┬──────────────────────────────┬───────┬─────────┬────┬───────────┤
    82/Dtl_TBL_Image
    83│__________│______________________________│____.__│______.__│___.│______.__  │
    84│__________│______________________________│____.__│______.__│___.│______.__  │
    85│__________│______________________________│____.__│______.__│___.│______.__  │
    86│__________│______________________________│____.__│______.__│___.│______.__  │
    87│__________│______________________________│____.__│______.__│___.│______.__  │
    88│__________│______________________________│____.__│______.__│___.│______.__  │
    89├──────────┴──────────────────────────────┴───────┴─────────┴────┴───────────┤
    90/Ordtotal_EF_Image
    91│ Alt+D=Duplicate Order                               Order Total:_______.__ │
    92└────────────────────────────────────────────────────────────────────────────┘
    93/*
    94
    95    Object Order_EF is an Entry_Form Order_EF_Image
    96       Set Location to 2 1 Relative
    97
    98        On_key kADD_MODE send append_a_row
    99
   100        Item_List
   101            Entry_Item ORDERHEA.ORDER_NUMBER
   102            Entry_Name_Item CustNum## CUSTOMER.CUSTOMER_NUMBER {iValidate=Get_Validate_Auto_Prompt}
   103            Entry_Item ORDERHEA.ORDER_DATE
   104            Entry_Item CUSTOMER.NAME             {DisplayOnly}
   105            Entry_Item CUSTOMER.ADDRESS
   106            Entry_Item ORDERHEA.ORDERED_BY
   107            Entry_Item CUSTOMER.CITY
   108            Entry_Item CUSTOMER.STATE
   109            Entry_Item CUSTOMER.ZIP
   110            Entry_Item SALESP.ID                 {iValidate=Get_Validate_Auto_Prompt}
   111            Entry_Item ORDERHEA.TERMS            {iValidate=Get_Validate_Auto_Prompt}
   112            Entry_Item ORDERHEA.SHIP_VIA         {iValidate=Get_Validate_Auto_Prompt}
   113        End_Item_List
   114
   115        //  Set passed item to Display_only (or not) based on passed state.
   116        //  Display_only is acheived by setting two item properties:
   117        //  noput and noenter.
   118        Procedure Set Item_Options_DisplayOnly Integer Itm# Integer State
   119          Set Item_Option Item Itm# noput   to State
   120          Set Item_Option Item Itm# NoEnter to State
   121        End_Procedure
   122
   123        // If order record exists, disallow entry in customer windows.
   124        Procedure Refresh Integer mode
   125          Integer Srvr# Crnt
   126          Get Server to Srvr#                 // get the DataDictionary
   127          Get Current_Record of Srvr# to Crnt // get record in DataDictionary
   128          // Set displayonly to true if Crnt is non-zero
   129          Set Item_Options_DisplayOnly Item CustNum## to Crnt
   130          Forward Send Refresh mode          // do normal refrsh
   131          // don't leave us sitting on a displayonly window
   132          If (Crnt AND Current_Item(self)=CustNum##) Send Next
   133        End_Procedure
   134
   135        Function Allow_Child_Entry Returns Integer
   136          Integer Obj# Srvr# SaveMsg Changed Rec reply
   137          Get Server to Srvr#
   138          Get Current_Record of Srvr# to Rec // if 0, its a new record
   139          Get Should_Save to Changed // if true, changes exist, save is needed
   140
   141          // unchanged new record...don't allow
   142          // unchanged old record...ok
   143          If not Changed Begin
   144             If Rec eq 0 Begin // a new unchanged record...not allowed
   145                Error 300 'You must First Create & Save Main Order Header'
   146                Function_Return 1
   147             End
   148             Else ;
   149                Function_Return 0 // an old unchanged record, allowed.
   150          End
   151
   152          // If a new record we will confirm the save. Old records we can save
   153          // without a confirm.
   154          If Rec eq 0 Begin // new record
   155             Get confirmation "Save New Order and enter Detail?" to reply
   156             if reply ne 0 Function_return 1 // confirmation failed
   157          end
   158
   159          // If here we have either a new or old record which needs saving.
   160          // Go ahead and save it without any further confirmations.
   161          Get Verify_Save_MSG to SaveMsg             // the old confirmation
   162          Set Verify_Save_MSG to GET_No_Confirmation // disable confirmation
   163          Send Request_Save_no_Clear                 // save it
   164          Set Verify_Save_MSG to SaveMsg             // restore old confirm
   165
   166          // Did the save succeed? If it did not we want to return a
   167          // non-zero value. If should_save is still true then for some
   168          // reason the save failed.
   169          Get Should_Save to Changed
   170          Function_Return Changed
   171        End_Function
   172
   173        Procedure Append_a_Row     // Again...think like a keyboard
   174          Integer Dtl Rval
   175          Register_object Dtl_Table
   176//          Move (Dtl_table(self)) to Dtl // detail object ID
   177          Move Dtl_table to Dtl // detail object ID
   178          Get Msg_Activate of Dtl to Rval         // attempt to activate it.
   179          If rVal eq 0 Send Append_a_row to Dtl   // If allowed, jump to end
   180        End_Procedure                             // of table.
   181
   182    End_Object  // Order_EF
   183
   184    Object Dtl_TBL is a Table Dtl_TBL_Image
   185        Set Server to (ORDERDTL_DD(self))
   186        Set Ordering to index.1
   187        Set Location to 13 1 Relative
   188        Set wrap_state               to TRUE     // keeps NEXT within table
   189        Set child_table_state        to TRUE     // DAF - Saves when exit object
   190        Set Auto_Regenerate_state to false       // table is always in order.
   191
   192        on_key kADD_MODE send append_a_row  // shift+f10 adds to end
   193
   194        // Define Default Confirmation Messages
   195        Set Verify_Save_MSG             to GET_Save_Confirmation
   196        Set Verify_Delete_MSG           to GET_Line_Delete_Confirmation
   197
   198        Begin_Row
   199            Entry_Item INVT.ITEM_ID
   200            Entry_Item INVT.DESCRIPTION
   201            Entry_Item INVT.UNIT_PRICE
   202            Entry_Item ORDERDTL.PRICE
   203            Entry_Item ORDERDTL.QTY_ORDERED
   204            Entry_Item ORDERDTL.EXTENDED_PRICE
   205        End_Row
   206
   207        Function Child_Entering
   208            Integer rVal
   209            //Get Allow_Child_Entry of (Order_ef(self))to rVal
   210            Get Allow_Child_Entry of Order_ef to rVal
   211            Function_Return rVal
   212        End_Function
   213
   214        Set Verify_Delete_MSG to GET_Delete_Confirmation
   215        Set Verify_Save_MSG   to GET_No_Confirmation
   216
   217        procedure Append_a_Row    // Q: how would a keyboard do this?
   218            Send End_Of_Data        // A: Go to end of table and
   219            Send Down               //    down 1 line to empty line
   220        End_Procedure
   221
   222
   223    End_Object  // Dtl_TBL
   224
   225    Object Ordtotal_EF is an Entry_Form Ordtotal_EF_Image
   226        Set Location to 20 1 Relative
   227        Item_List
   228            Entry_Item OrderHea.Order_Total
   229        End_Item_List
   230    End_Object  // Ordtotal_EF
   231
   232    #include DupBPO.pkg
   233
   234    Procedure DuplicateOrder
   235       integer iRec hDD
   236       Get server to hDD
   237       Get Current_record of hDD to iRec
   238       If iRec Begin
   239           Get DoDuplicateOrder of DuplicateOrder iRec to iRec
   240           If iRec Begin
   241               Move iRec to OrderHea.Recnum
   242               Send Find of hDD EQ 0
   243            End
   244        End
   245    end_procedure
   246
   247    on_key Key_Alt+Key_D Send DuplicateOrder
   248
   249
   250End_Object // ORDERENT_View
   251